def load_from_xml(self, xml): self.xml_node = xml self.name_set(xml.prop('name')) self.uuid = xml.prop('uuid') if not os.access(self.disk, os.R_OK): print 'warning: assembly %s does not have a disk(%s).' % ( self.name, self.disk) self.rf = resource.ResourceFactory(xml)
def resource_remove(self, rsc_name): ''' resource_remove <resource name> <assembly_name> ''' if self.rf == None: self.rf = resource.ResourceFactory(self.xml_node) self.rf.delete(rsc_name) self.save()
def resource_add(self, rsc_name, rsc_type): ''' resource_add <resource name> <resource template> <assembly_name> ''' if self.rf == None: self.rf = resource.ResourceFactory(self.xml_node) r = self.rf.get(rsc_name) r.name = rsc_name r.type = rsc_type r.save() self.save()
def resource_factory_setup(self): if self.rf == None: if self.xml_node is None: self.save() self.rf = resource.ResourceFactory(self.xml_node)
def resources_get(self): if self.rf == None: self.rf = resource.ResourceFactory(self.xml_node) return self.rf.all_get()