Exemple #1
0
 def setUp(self):
     self.utils = XMLUtils()
     self.ipProfile = IpProfile()
     self.ip_profile_list = []
     self.ipProfile.set_ipAddress('10.10.0.0')
     self.ipProfile.set_hostname('LOCALHOST')
     self.ipProfile.set_ipType("IPV4")
     self.ip_profile_list.append(self.ipProfile)
Exemple #2
0
 def testVmHostPayloadGenerator(self):
     metadata = \
         event_metadata.get_EventMetaData(
             event_metadata.EVENT_TYPE_HOST_ADDED)
     obj = VmHost()
     obj.name = 'TestVmHost'
     ipProfile = IpProfile()
     ipProfile.ipAddress = '10.10.10.1'
     obj.add_ipAddresses(ipProfile)
     payload = payload_generator.generate_payload(metadata, obj)
     self.assertEquals(payload['entity_type'], obj.__class__.__name__)
     self.assertEquals(payload['name'], obj.name)
     self.assertEquals(payload['ipAddresses'], ipProfile.ipAddress)
 def testVmHostPayloadGenerator(self):
     metadata = \
         event_metadata.get_EventMetaData(
             event_metadata.EVENT_TYPE_HOST_ADDED)
     obj = VmHost()
     obj.name = 'TestVmHost'
     ipProfile = IpProfile()
     ipProfile.ipAddress = '10.10.10.1'
     obj.add_ipAddresses(ipProfile)
     payload = payload_generator.generate_payload(metadata, obj)
     self.assertEquals(payload['entity_type'],
                       obj.__class__.__name__)
     self.assertEquals(payload['name'], obj.name)
     self.assertEquals(payload['ipAddresses'],
                       ipProfile.ipAddress)
Exemple #4
0
 def setUp(self):
     self.utils = XMLUtils()
     self.ipProfile = IpProfile()
     self.ip_profile_list = []
     self.ipProfile.set_ipAddress('10.10.0.0')
     self.ipProfile.set_hostname('LOCALHOST')
     self.ipProfile.set_ipType("IPV4")
     self.ip_profile_list.append(self.ipProfile)
 def testVmHostPayload_with_storage_size(self):
     self.flags(instances_path="/var/lib/nova/instances")
     metadata = \
         event_metadata.get_EventMetaData(
             event_metadata.EVENT_TYPE_HOST_ADDED)
     obj = VmHost()
     obj.name = 'TestVmHost'
     ipProfile = IpProfile()
     ipProfile.ipAddress = '10.10.10.1'
     obj.add_ipAddresses(ipProfile)
     storage_obj = StorageVolume()
     storage_obj.id = "storage_id"
     storage_obj.name = 'TestStorageVolume'
     storage_obj.connectionState = 'ACTIVE'
     storage_obj.size = 200
     storage_obj.free = 100
     storage_obj.volumeType = 'DIR'
     storage_obj.volumeId = 'TestVolumeId'
     storage_obj.createEpoch = long(time.time() * 1000)
     storage_obj.lastModifiedEpoch = long(time.time() * 1000)
     mount_point = HostMountPoint()
     mount_point.set_path('/var/lib/nova/instances')
     mount_point.set_vmHostId('TestVmHost')
     storage_obj.add_mountPoints(mount_point)
     obj.add_storageVolumeIds("storage_id")
     self.mox.StubOutWithMock(
         InventoryCacheManager, 'get_object_from_cache')
     InventoryCacheManager.get_object_from_cache(
         storage_obj.id,
         Constants.StorageVolume).AndReturn(storage_obj)
     self.mox.ReplayAll()
     payload = payload_generator.generate_payload(metadata, obj)
     self.assertEquals(payload['entity_type'],
                       obj.__class__.__name__)
     self.assertEquals(payload['name'], obj.name)
     self.assertEquals(payload['ipAddresses'],
                       ipProfile.ipAddress)
     self.assertEquals(payload['totalStorageSize'],
                       storage_obj.size)
     self.assertEquals(payload['storageUsed'],
                       storage_obj.free)
Exemple #6
0
 def testVmHostPayload_with_storage_size(self):
     self.flags(instances_path="/var/lib/nova/instances")
     metadata = \
         event_metadata.get_EventMetaData(
             event_metadata.EVENT_TYPE_HOST_ADDED)
     obj = VmHost()
     obj.name = 'TestVmHost'
     ipProfile = IpProfile()
     ipProfile.ipAddress = '10.10.10.1'
     obj.add_ipAddresses(ipProfile)
     storage_obj = StorageVolume()
     storage_obj.id = "storage_id"
     storage_obj.name = 'TestStorageVolume'
     storage_obj.connectionState = 'ACTIVE'
     storage_obj.size = 200
     storage_obj.free = 100
     storage_obj.volumeType = 'DIR'
     storage_obj.volumeId = 'TestVolumeId'
     storage_obj.createEpoch = long(time.time() * 1000)
     storage_obj.lastModifiedEpoch = long(time.time() * 1000)
     mount_point = HostMountPoint()
     mount_point.set_path('/var/lib/nova/instances')
     mount_point.set_vmHostId('TestVmHost')
     storage_obj.add_mountPoints(mount_point)
     obj.add_storageVolumeIds("storage_id")
     self.mox.StubOutWithMock(InventoryCacheManager,
                              'get_object_from_cache')
     InventoryCacheManager.get_object_from_cache(
         storage_obj.id, Constants.StorageVolume).AndReturn(storage_obj)
     self.mox.ReplayAll()
     payload = payload_generator.generate_payload(metadata, obj)
     self.assertEquals(payload['entity_type'], obj.__class__.__name__)
     self.assertEquals(payload['name'], obj.name)
     self.assertEquals(payload['ipAddresses'], ipProfile.ipAddress)
     self.assertEquals(payload['totalStorageSize'], storage_obj.size)
     self.assertEquals(payload['storageUsed'], storage_obj.free)
Exemple #7
0
class test_XMLUtils(unittest.TestCase):

    def setUp(self):
        self.utils = XMLUtils()
        self.ipProfile = IpProfile()
        self.ip_profile_list = []
        self.ipProfile.set_ipAddress('10.10.0.0')
        self.ipProfile.set_hostname('LOCALHOST')
        self.ipProfile.set_ipType("IPV4")
        self.ip_profile_list.append(self.ipProfile)

    def test_is_profile_in_list(self):
        result = self.utils.is_profile_in_list(
            self.ipProfile, self.ip_profile_list)
        self.assertTrue(result)

    def test_getNodeXML(self):
        xml = '<network><name> NAME </name></network>'
        result = self.utils.getNodeXML(xml, "address")
        self.assertTrue(len(result) == 0)
Exemple #8
0
class test_XMLUtils(unittest.TestCase):

    def setUp(self):
        self.utils = XMLUtils()
        self.ipProfile = IpProfile()
        self.ip_profile_list = []
        self.ipProfile.set_ipAddress('10.10.0.0')
        self.ipProfile.set_hostname('LOCALHOST')
        self.ipProfile.set_ipType("IPV4")
        self.ip_profile_list.append(self.ipProfile)

    def test_is_profile_in_list(self):
        result = self.utils.is_profile_in_list(
            self.ipProfile, self.ip_profile_list)
        self.assertTrue(result)

    def test_getNodeXML(self):
        xml = '<network><name> NAME </name></network>'
        result = self.utils.getNodeXML(xml, "address")
        self.assertTrue(len(result) == 0)