Пример #1
0
 def parse_nodes(self, nodes):
     vms = list()
     for element in nodes:
         node = element.attributes
         resource = Resource()
         sliver = Sliver()
         if node.has_key('client_id'):
             resource.set_id(node.get('client_id').value)
         if node.has_key('interfaces'):
             pass #Implement when needed    
         if node.has_key('component_manager_id'):
             resource.set_component_manager_id(node.get('component_manager_id').value)
             
         if node.has_key('component_manager_name'):
             resource.set_component_manager_name(node.get('component_manager_name').value)
             
         if node.has_key('component_id'):
             resource.set_component_id(node.get('component_id').value)
             
         if node.has_key('component_name'):
             resource.set_component_id(node.get('component_name').value)
             
         if node.has_key('services'):
             pass #Implement when needed
       
         slivers = element.getElementsByTagName("sliver_type")
         for sliver_elem in slivers:
             sliver = Sliver()
             attrs = sliver_elem.attributes
             if attrs.has_key('name'):
                 sliver.set_name(attrs.get('name').value)
             
             # AIST 201508
             # obtain disk image URN
             disk_image_urn = ""
             disk_image_urn_default = "XXX_DEFAULT_DISK_IMAGE_URN"
             disk_images = sliver_elem.getElementsByTagName("disk_image")
             if(disk_images == None or len(disk_images) == 0):
                 ParserManager.logger.debug("cannot find <disk_image> tag, use default")
                 disk_image_urn = disk_image_urn_default
             else:
                 elem_attrs = disk_images[0].attributes
                 if elem_attrs.has_key('name'):
                     disk_image_urn = elem_attrs.get('name').value
                 else:
                     ParserManager.logger.debug("cannot find name attr in <disk_image> tag, use default")
                     disk_image_urn = disk_image_urn_default
                     
             ParserManager.logger.debug("disk_image_urn = " + disk_image_urn)
             resource.set_disk_image(disk_image_urn)
             sliver.set_resource(resource)
             resource.set_sliver(sliver)
         
         vms.append(resource)
     return vms
Пример #2
0
 def parse_nodes(self, nodes):
     vms = list()
     for element in nodes:
         node = element.attributes
         resource = Resource()
         sliver = Sliver()
         if node.has_key('client_id'):
             resource.set_id(node.get('client_id').value)
         if node.has_key('interfaces'):
             pass #Implement when needed    
         if node.has_key('component_manager_id'):
             resource.set_component_manager_id(node.get('component_manager_id').value)
             
         if node.has_key('component_manager_name'):
             resource.set_component_manager_name(node.get('component_manager_name').value)
             
         if node.has_key('component_id'):
             resource.set_component_id(node.get('component_id').value)
             
         if node.has_key('component_name'):
             resource.set_component_id(node.get('component_name').value)
             
         if node.has_key('services'):
             pass #Implement when needed
       
         slivers = element.getElementsByTagName("sliver_type")
         for sliver_elem in slivers:
             sliver = Sliver()
             attrs = sliver_elem.attributes
             if attrs.has_key('name'):
                 sliver.set_name(attrs.get('name').value)
                 
             sliver.set_resource(resource)
             resource.set_sliver(sliver)
         
         vms.append(resource)
     return vms