Beispiel #1
0
def make_counter_from_instance(instance, name, type, unit, volume):
    return counter.Counter(
        name=name,
        type=type,
        unit=unit,
        volume=volume,
        user_id=instance.user_id,
        project_id=instance.tenant_id,
        resource_id=instance.id,
        timestamp=timeutils.isotime(),
        resource_metadata=compute_instance.get_metadata_from_object(instance),
    )
Beispiel #2
0
def make_counter_from_instance(instance, name, type, unit, volume):
    return counter.Counter(
        name=name,
        type=type,
        unit=unit,
        volume=volume,
        user_id=instance.user_id,
        project_id=instance.tenant_id,
        resource_id=instance.id,
        timestamp=timeutils.isotime(),
        resource_metadata=compute_instance.get_metadata_from_object(instance),
    )
 def test_metadata(self):
     md = instance.get_metadata_from_object(self.instance)
     iprops = self.INSTANCE_PROPERTIES
     for name in md.keys():
         actual = md[name]
         print 'checking', name, actual
         if name == 'name':
             assert actual == iprops['OS-EXT-SRV-ATTR:instance_name']
         elif name == 'host':
             assert actual == iprops['hostId']
         elif name == 'display_name':
             assert actual == iprops['name']
         elif name == 'instance_type':
             assert actual == iprops['flavor']['id']
         elif name == 'image_ref':
             assert actual == iprops['image']['id']
         elif name == 'image_ref_url':
             assert actual == iprops['image']['links'][0]['href']
         else:
             assert actual == iprops[name]
 def test_metadata(self):
     md = instance.get_metadata_from_object(self.instance)
     iprops = self.INSTANCE_PROPERTIES
     for name in md.keys():
         actual = md[name]
         print 'checking', name, actual
         if name == 'name':
             assert actual == iprops['OS-EXT-SRV-ATTR:instance_name']
         elif name == 'host':
             assert actual == iprops['hostId']
         elif name == 'display_name':
             assert actual == iprops['name']
         elif name == 'instance_type':
             assert actual == iprops['flavor']['id']
         elif name == 'image_ref':
             assert actual == iprops['image']['id']
         elif name == 'image_ref_url':
             assert actual == iprops['image']['links'][0]['href']
         else:
             assert actual == iprops[name]
Beispiel #5
0
 def test_metadata(self):
     md = instance.get_metadata_from_object(self.instance)
     iprops = self.INSTANCE_PROPERTIES
     for name in md.keys():
         actual = md[name]
         print 'checking', name, actual
         if name == 'name':
             assert actual == iprops['OS-EXT-SRV-ATTR:instance_name']
         elif name == 'host':
             assert actual == iprops['hostId']
         elif name == 'display_name':
             assert actual == iprops['name']
         elif name == 'instance_type':
             assert actual == iprops['flavor']['id']
         elif name == 'image_ref':
             assert actual == iprops['image']['id']
         elif name == 'image_ref_url':
             assert actual == iprops['image']['links'][0]['href']
         elif name == 'user_metadata':
             expected = iprops['metadata']['metering.autoscale.group'][:256]
             self.assertEqual(actual['autoscale_group'], expected)
             self.assertEqual(len(actual), 1)
         else:
             assert actual == iprops[name]
 def test_metadata_empty_image(self):
     self.INSTANCE_PROPERTIES['image'] = ''
     self.instance = FauxInstance(**self.INSTANCE_PROPERTIES)
     md = instance.get_metadata_from_object(self.instance)
     self.assertEqual(md['image_ref'], None)
     self.assertEqual(md['image_ref_url'], None)
 def test_metadata_empty_image(self):
     self.INSTANCE_PROPERTIES['image'] = ''
     self.instance = FauxInstance(**self.INSTANCE_PROPERTIES)
     md = instance.get_metadata_from_object(self.instance)
     self.assertEqual(md['image_ref'], None)
     self.assertEqual(md['image_ref_url'], None)