コード例 #1
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
コード例 #2
0
ファイル: deployable.py プロジェクト: tobyxdd/cyborg
    def delete_attribute(self, context, attribute):
        """remove an attribute from the attributes_list
        if the attribute does not exist, ignore it
        """

        idx = 0
        for exist_attribute in self.attributes_list:
            if base.obj_equal_prims(attribute, exist_attribute):
                removed_attribute = self.attributes_list.pop(idx)
                removed_attribute.destroy(context)
                return
            idx = idx + 1
        LOG.warning("The removing attribute does not exist!")
コード例 #3
0
ファイル: deployable.py プロジェクト: yongfengdu/cyborg
    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
        """

        for exist_attr in self.attributes_list:
            if base.obj_equal_prims(attribute, exist_attr):
                LOG.warning("The attribute already exists")
                return None
        attribute.deployable_id = self.id
        attribute_copy = copy.deepcopy(attribute)
        self.attributes_list.append(attribute_copy)
コード例 #4
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)