+
+ def set_profile_sriov_provider_network_type(self, profile, network, type):
+ """
+ Set SR-IOV provider network type
+
+ Arguments:
+ The profile name
+ The SR-IOV network name
+ The type of SR-IOV network
+
+ Raises:
+ ConfigError in-case of an error
+ """
+ self._validate_network_is_sriov_provider_network(profile, network)
+
+ if not isinstance(type, basestring):
+ raise configerror.ConfigError(
+ 'Profile %s has invalid SR-IOV provider network type for the network %s: %s' %
+ (profile, network, type))
+
+ self.config[self.ROOT][profile]['sriov_provider_networks'][network]['type'] = type
+
+ def is_sriov_network_trusted(self, profile, network):
+ """
+ Is SR-IOV provider network trusted (VF parameter)
+
+ Arguments:
+ The profile name
+ The SR-IOV network name
+
+ Returns:
+ True if VFs should be configured as trusted in this network
+
+ Raises:
+ ConfigError in-case of an error
+ """
+ self._validate_network_is_sriov_provider_network(profile, network)
+
+ return self.config[self.ROOT][profile]['sriov_provider_networks'][network].get('trusted') is True
+
+ def is_sriov_network_type_caas(self, profile, network):
+ """
+ Is SR-IOV network type caas
+
+ Arguments:
+ The profile name
+ The SR-IOV network name
+
+ Returns:
+ True if SR-IOV network is for CaaS
+
+ Raises:
+ ConfigError in-case of an error
+ """
+ self._validate_network_is_sriov_provider_network(profile, network)
+
+ return self.config[self.ROOT][profile]['sriov_provider_networks'][network].get('type') == 'caas'
+
+ def _validate_network_is_sriov_provider_network(self, profile, network):
+ if network not in self.get_profile_sriov_provider_networks(profile):
+ raise configerror.ConfigError(
+ 'Profile %s has no SR-IOV provider network %s' %
+ (profile, network))
+
+ def get_profile(self, name):
+ """
+ Get the network profile data
+
+ Arguments:
+ The profile name
+
+ Returns:
+ A dict of network profile data
+
+ """
+ self.is_valid_profile(name)
+ return self.config[self.ROOT][name]
+
+ def dump(self):
+ """ Dump all network profiles data. """
+
+ self.validate_root()
+ return self.config[self.ROOT]
+
+ def add_profile(self, name, profile):
+ """ Add network profile.
+
+ Parameters
+ ----------
+ name : str, profile name.
+ profile : dict, profile data
+
+ """
+ if name in self.config[self.ROOT]:
+ raise configerror.ConfigError('Profile %s already exists' % name)
+
+ data = {}
+ data[name] = profile
+ self.config[self.ROOT].update(data)
+
+ def delete_profile(self, name):
+ """ Delete network profile.
+
+ Parameters
+ ----------
+ name : str, profile name.
+
+ """
+ self.is_valid_profile(name)
+ self.config[self.ROOT].pop(name)