Beispiel #1
0
 def create(self, context, deployable_id):
     """Convert driver-side Attribute into Attribute Object so as to
     store in DB."""
     attr_obj = Attribute()
     attr_obj.deployable_id = deployable_id
     attr_obj.set_key_value_pair(self.key, self.value)
     attr_obj.create(context)
Beispiel #2
0
    def add_attribute(self, context, key, value):
        """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 key == exist_attr.key:
                LOG.warning("The attribute already exists")
                if value != exist_attr.value:
                    exist_attr.value = value
                    exist_attr.save(context)
                return None
        # The attribute does not exist yet. Create it.
        attr_vals = {'deployable_id': self.id, 'key': key, 'value': value}
        attr = Attribute(context, **attr_vals)
        attr.create(context)
        self.attributes_list.append(attr)