コード例 #1
0
    def save(self, context):
        """In addition to save the pf, it should also save the
        vfs associated with this pf
        """
        # To ensure the saving type is PF
        if self.type != 'pf':
            raise exception.InvalidDeployType()

        for exist_vf in self.virtual_function_list:
            exist_vf.save(context)
        super(PhysicalFunction, self).save(context)
コード例 #2
0
ファイル: deployable.py プロジェクト: opnfv/cran
 def add_attribute(self, attribute):
     """add a attribute object to the attribute_list.
     If the attribute already exists, it will update the value,
     otherwise, the vf will be appended to the list.
     """
     if not isinstance(attribute, Attribute):
         raise exception.InvalidDeployType()
     for exist_attr in self.attributes_list:
         if base.obj_equal_prims(vf, exist_attr):
             LOG.warning("The attribute already exists.")
             return None
コード例 #3
0
 def add_vf(self, vf):
     """add a vf object to the virtual_function_list.
     If the vf already exists, it will ignore,
     otherwise, the vf will be appended to the list
     """
     if not isinstance(vf, VirtualFunction) or vf.type != 'vf':
         raise exception.InvalidDeployType()
     for exist_vf in self.virtual_function_list:
         if base.obj_equal_prims(vf, exist_vf):
             LOG.warning("The vf already exists")
             return None
     vf.parent_uuid = self.uuid
     vf.root_uuid = self.root_uuid
     vf_copy = copy.deepcopy(vf)
     self.virtual_function_list.append(vf_copy)
コード例 #4
0
 def create(self, context):
     # To ensure the creating type is PF
     if self.type != 'pf':
         raise exception.InvalidDeployType()
     super(PhysicalFunction, self).create(context)
コード例 #5
0
 def save(self, context):
     # To ensure the saving type is VF
     if self.type != 'vf':
         raise exception.InvalidDeployType()
     super(VirtualFunction, self).save(context)