Exemplo n.º 1
0
 def _createCache(self):
     self.mox.StubOutWithMock(api, 'vm_host_get_all')
     vmhost = VmHost()
     vmhost.set_id('vmhost1')
     vmhost1 = VmHost()
     vmhost1.set_id('vmhost2')
     vm = Vm()
     vm.set_id('vm1')
     vm.set_powerState(Constants.VM_POWER_STATES[1])
     vm.set_vmHostId('vmhost1')
     vm1 = Vm()
     vm1.set_id('vm2')
     vm1.set_powerState(Constants.VM_POWER_STATES[1])
     vm1.set_vmHostId('vmhost2')
     vmhost.set_virtualMachineIds(['vm1', 'vm2'])
     stPool = StorageVolume()
     stPool.set_id('stpool1')
     subNet = Subnet()
     subNet.set_id('net1')
     api.vm_host_get_all(mox.IgnoreArg()).AndReturn([vmhost, vmhost1])
     self.mox.StubOutWithMock(api, 'vm_get_all')
     api.vm_get_all(mox.IgnoreArg()).AndReturn([vm, vm1])
     self.mox.StubOutWithMock(api, 'storage_volume_get_all')
     api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([stPool])
     self.mox.StubOutWithMock(api, 'subnet_get_all')
     api.subnet_get_all(mox.IgnoreArg()).AndReturn([subNet])
 def _createCache(self):
     self.mox.StubOutWithMock(api, "vm_host_get_all")
     vmhost = VmHost()
     vmhost.set_id("vmhost1")
     vmhost1 = VmHost()
     vmhost1.set_id("vmhost2")
     vm = Vm()
     vm.set_id("vm1")
     vm.set_powerState(Constants.VM_POWER_STATES[1])
     vm.set_vmHostId("vmhost1")
     vm1 = Vm()
     vm1.set_id("vm2")
     vm1.set_powerState(Constants.VM_POWER_STATES[1])
     vm1.set_vmHostId("vmhost2")
     vmhost.set_virtualMachineIds(["vm1", "vm2"])
     stPool = StorageVolume()
     stPool.set_id("stpool1")
     subNet = Subnet()
     subNet.set_id("net1")
     api.vm_host_get_all(mox.IgnoreArg()).AndReturn([vmhost, vmhost1])
     self.mox.StubOutWithMock(api, "vm_get_all")
     api.vm_get_all(mox.IgnoreArg()).AndReturn([vm, vm1])
     self.mox.StubOutWithMock(api, "storage_volume_get_all")
     api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([stPool])
     self.mox.StubOutWithMock(api, "subnet_get_all")
     api.subnet_get_all(mox.IgnoreArg()).AndReturn([subNet])
Exemplo n.º 3
0
    def test_host_removed_event(self):
        self.__mock_service_get_all_by_topic()
        deleted_host = VmHost()
        deleted_host.set_id('compute1')
        deleted_host.set_name('compute1')
        self.mox.StubOutWithMock(api, 'vm_host_get_all')
        api.vm_host_get_all(mox.IgnoreArg()).AndReturn([deleted_host])
        self.mox.StubOutWithMock(api, 'vm_get_all')
        api.vm_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'storage_volume_get_all')
        api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'subnet_get_all')
        api.subnet_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(nova_db, 'compute_node_get_all')
        nova_db.compute_node_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'vm_host_delete_by_ids')

        api.vm_host_delete_by_ids(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            'compute1',
            Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()
        compute_service = dict(host='host1')
        compute = dict(id='compute1', hypervisor_type='fake',
                       service=compute_service)
        rm_context = \
            rmcontext.ComputeRMContext(rmType=compute['hypervisor_type'],
                                       rmIpAddress=compute_service['host'],
                                       rmUserName='******',
                                       rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory().clear()

        InventoryCacheManager.get_all_compute_inventory()['compute1'] = \
            ComputeInventory(rm_context)
        InventoryCacheManager.get_compute_inventory(
            'compute1').update_compute_info(rm_context, deleted_host)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 1)
        inv_manager = InventoryManager()
        inv_manager._refresh_from_db(None)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 0)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_HOST_REMOVED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'VmHost')
        self.assertEquals(payload['entity_id'], deleted_host.id)
Exemplo n.º 4
0
    def test_host_removed_event(self):
        self.__mock_service_get_all_by_topic()
        deleted_host = VmHost()
        deleted_host.set_id('compute1')
        deleted_host.set_name('compute1')
        self.mox.StubOutWithMock(api, 'vm_host_get_all')
        api.vm_host_get_all(mox.IgnoreArg()).AndReturn([deleted_host])
        self.mox.StubOutWithMock(api, 'vm_get_all')
        api.vm_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'storage_volume_get_all')
        api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'subnet_get_all')
        api.subnet_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(nova_db, 'compute_node_get_all')
        nova_db.compute_node_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'vm_host_delete_by_ids')

        api.vm_host_delete_by_ids(
            mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.StubOutWithMock(InventoryCacheManager,
                                 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            'compute1', Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()
        compute_service = dict(host='host1')
        compute = dict(id='compute1',
                       hypervisor_type='fake',
                       service=compute_service)
        rm_context = \
            rmcontext.ComputeRMContext(rmType=compute['hypervisor_type'
                                                      ], rmIpAddress=compute_service['host'],
                                       rmUserName='******', rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory().clear()

        InventoryCacheManager.get_all_compute_inventory(
        )['compute1'] = ComputeInventory(rm_context)
        InventoryCacheManager.get_compute_inventory(
            'compute1').update_compute_info(rm_context, deleted_host)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 1)
        inv_manager = InventoryManager()
        inv_manager._refresh_from_db(None)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 0)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_HOST_REMOVED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'VmHost')
        self.assertEquals(payload['entity_id'], deleted_host.id)
Exemplo n.º 5
0
    def test_host_removed_event_none_host(self):
        deleted_host = VmHost()
        deleted_host.set_id('compute1')
        deleted_host.set_name('compute1')
        self.mox.StubOutWithMock(api, 'vm_host_get_all')
        api.vm_host_get_all(mox.IgnoreArg()).AndReturn([deleted_host])
        self.mox.StubOutWithMock(api, 'vm_get_all')
        api.vm_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'storage_volume_get_all')
        api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'subnet_get_all')
        api.subnet_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(nova_db, 'compute_node_get_all')
        nova_db.compute_node_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'vm_host_delete_by_ids')

        api.vm_host_delete_by_ids(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)

        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            'compute1',
            Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()

        compute_service = dict(host='host1')
        compute = dict(id='compute1', hypervisor_type='fake',
                       service=compute_service)
        rm_context = \
            rmcontext.ComputeRMContext(rmType=compute['hypervisor_type'],
                                       rmIpAddress=compute_service['host'],
                                       rmUserName='******',
                                       rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory().clear()

        InventoryCacheManager.get_all_compute_inventory()['compute1'] = \
            ComputeInventory(rm_context)
        InventoryCacheManager.get_compute_inventory(
            'compute1').update_compute_info(rm_context, deleted_host)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 1)
        InventoryCacheManager.get_inventory_cache(
        )[Constants.VmHost][deleted_host.get_id()] = None

        inv_manager = InventoryManager()
        inv_manager._refresh_from_db(None)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 0)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
Exemplo n.º 6
0
    def test_host_removed_event_none_host(self):
        deleted_host = VmHost()
        deleted_host.set_id('compute1')
        deleted_host.set_name('compute1')
        self.mox.StubOutWithMock(api, 'vm_host_get_all')
        api.vm_host_get_all(mox.IgnoreArg()).AndReturn([deleted_host])
        self.mox.StubOutWithMock(api, 'vm_get_all')
        api.vm_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'storage_volume_get_all')
        api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'subnet_get_all')
        api.subnet_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(nova_db, 'compute_node_get_all')
        nova_db.compute_node_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'vm_host_delete_by_ids')

        api.vm_host_delete_by_ids(
            mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None)

        self.mox.StubOutWithMock(InventoryCacheManager,
                                 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            'compute1', Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()

        compute_service = dict(host='host1')
        compute = dict(id='compute1',
                       hypervisor_type='fake',
                       service=compute_service)
        rm_context = \
            rmcontext.ComputeRMContext(rmType=compute['hypervisor_type'
                                                      ], rmIpAddress=compute_service['host'],
                                       rmUserName='******', rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory().clear()

        InventoryCacheManager.get_all_compute_inventory(
        )['compute1'] = ComputeInventory(rm_context)
        InventoryCacheManager.get_compute_inventory(
            'compute1').update_compute_info(rm_context, deleted_host)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 1)
        InventoryCacheManager.get_inventory_cache()[Constants.VmHost][
            deleted_host.get_id()] = None

        inv_manager = InventoryManager()
        inv_manager._refresh_from_db(None)
        self.assertEquals(
            len(InventoryCacheManager.get_all_compute_inventory()), 0)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
Exemplo n.º 7
0
    def _initCache(self):

        # Read from DB all the vmHost objects and populate
        # the cache for each IP if cache is empty

        LOG.info(_('Entering into initCache'))
        computes = db.compute_node_get_all(get_admin_context())
        for compute in computes:
            compute_id = str(compute['id'])
            service = compute['service']
            self._add_compute_to_inventory(compute[
                                           'hypervisor_type'],
                                           compute_id, service['host'])

        vmhosts = api.vm_host_get_all(get_admin_context())
        vms = api.vm_get_all(get_admin_context())
        storageVolumes = api.storage_volume_get_all(get_admin_context())
        subNets = api.subnet_get_all(get_admin_context())
        self._updateInventory(vmhosts)
        self._updateInventory(vms)
        self._updateInventory(storageVolumes)
        self._updateInventory(subNets)

        LOG.info(_('Hosts obtained from db: %s') % str(len(vmhosts)))
        LOG.info(_('Vms obtained from db: %s') % str(len(vms)))
        LOG.info(_('Storage volumes obtained from db: %s') %
                 str(len(storageVolumes)))
        LOG.info(_('Subnets obtained from db: %s') % str(len(subNets)))

        LOG.info(_('Completed the initCache method'))
Exemplo n.º 8
0
 def _createCache(self):
     self.mox.StubOutWithMock(api, 'vm_host_get_all')
     vmhost = VmHost()
     vmhost.set_id('vmhost1')
     vm = Vm()
     vm.set_id('vm1')
     stPool = StorageVolume()
     stPool.set_id('stpool1')
     subnet = Subnet()
     subnet.set_id('bridge0')
     api.vm_host_get_all(mox.IgnoreArg()).AndReturn([vmhost])
     self.mox.StubOutWithMock(api, 'vm_get_all')
     api.vm_get_all(mox.IgnoreArg()).AndReturn([vm])
     self.mox.StubOutWithMock(api, 'storage_volume_get_all')
     api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([stPool])
     self.mox.StubOutWithMock(api, 'subnet_get_all')
     api.subnet_get_all(mox.IgnoreArg()).AndReturn([subnet])
Exemplo n.º 9
0
 def _createCache(self):
     self.mox.StubOutWithMock(api, 'vm_host_get_all')
     vmhost = VmHost()
     vmhost.set_id('vmhost1')
     vm = Vm()
     vm.set_id('vm1')
     stPool = StorageVolume()
     stPool.set_id('stpool1')
     subnet = Subnet()
     subnet.set_id('bridge0')
     api.vm_host_get_all(mox.IgnoreArg()).AndReturn([vmhost])
     self.mox.StubOutWithMock(api, 'vm_get_all')
     api.vm_get_all(mox.IgnoreArg()).AndReturn([vm])
     self.mox.StubOutWithMock(api, 'storage_volume_get_all')
     api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([stPool])
     self.mox.StubOutWithMock(api, 'subnet_get_all')
     api.subnet_get_all(mox.IgnoreArg()).AndReturn([subnet])
Exemplo n.º 10
0
    def test_load_compute_inventory(self):
        compute_service = dict(host='host2')
        compute = dict(id='compute2', hypervisor_type='fake',
                       service=compute_service)
        self.mox.StubOutWithMock(nova_db, 'compute_node_get_all')
        nova_db.compute_node_get_all(mox.IgnoreArg()).AndReturn([compute])
        self.mox.StubOutWithMock(api, 'vm_host_get_all')
        api.vm_host_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'vm_get_all')
        api.vm_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'storage_volume_get_all')
        api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([])
        self.mox.StubOutWithMock(api, 'subnet_get_all')
        api.subnet_get_all(mox.IgnoreArg()).AndReturn([])

        self.mox.ReplayAll()
        InventoryManager()
        compute_key_lst = InventoryCacheManager.get_all_compute_inventory(
        ).keys()
        self.assertTrue(len(compute_key_lst), 2)
Exemplo n.º 11
0
    def _initCache(self):

        # Read from DB all the vmHost objects and populate
        # the cache for each IP if cache is empty

        LOG.info(_(" Entering into initCache"))
        vmhosts = api.vm_host_get_all(get_admin_context())
        vms = api.vm_get_all(get_admin_context())
        storageVolumes = api.storage_volume_get_all(get_admin_context())
        subNets = api.subnet_get_all(get_admin_context())
        self._updateInventory(vmhosts)
        self._updateInventory(vms)
        self._updateInventory(storageVolumes)
        self._updateInventory(subNets)

        LOG.info(_("Hosts obtained from db ") % vmhosts)
        LOG.info(_("Vms obtained from db ") % vms)
        LOG.info(_("Storage volumes obtained from db ") % storageVolumes)

        LOG.info(_("Completed the initCache method"))
Exemplo n.º 12
0
    def _initCache(self):

        # Read from DB all the vmHost objects and populate
        # the cache for each IP if cache is empty

        LOG.info(_(' Entering into initCache'))
        vmhosts = api.vm_host_get_all(get_admin_context())
        vms = api.vm_get_all(get_admin_context())
        storageVolumes = api.storage_volume_get_all(get_admin_context())
        subNets = api.subnet_get_all(get_admin_context())
        self._updateInventory(vmhosts)
        self._updateInventory(vms)
        self._updateInventory(storageVolumes)
        self._updateInventory(subNets)

        LOG.info(_('Hosts obtained from db ') % vmhosts)
        LOG.info(_('Vms obtained from db ') % vms)
        LOG.info(_('Storage volumes obtained from db ')
                 % storageVolumes)

        LOG.info(_('Completed the initCache method'))
Exemplo n.º 13
0
    def test_subnet_get_all(self):
        subnet = Subnet()
        subnet.set_id('subnet-01')
        subnet.set_name('subnet-01')
        groupIdType = GroupIdType()
        groupIdType.set_id('groupId-01')
        groupIdType.add_networkTypes('MAPPED')
        groupIdType.add_networkTypes('TUNNEL')
        subnet.add_groupIdTypes(groupIdType)
        subnet.set_networkAddress('1.1.1.1')
        subnet.set_networkMask('255.255.255.0')
        subnet.add_networkSources('VS_NETWORK')
        subnet.set_ipType('IPV4')
        subnet.set_isPublic(True)
        subnet.set_isShareable(True)
        subnet.add_dnsServers('test-dns01')
        subnet.set_dnsDomain('test_Domain')
        subnet.add_dnsSearchSuffixes('dnsSearchSuffixes')
        subnet.add_defaultGateways('defaultGateways')
        subnet.set_msDomainName('msDomainName')
        subnet.set_msDomainType('DOMAIN')
        subnet.add_winsServers('winsServers')
        subnet.add_ntpDateServers('ntpDateServers')
        subnet.set_vlanId(1)
        subnet.set_isBootNetwork(True)
        subnet.add_deploymentServices('deploymentServices')
        subnet.add_parentIds('parentIds')
        subnet.add_childIds('childIds')
        subnet.set_isTrunk(True)
        subnet.add_redundancyPeerIds('redundancyPeerIds')
        subnet.set_redundancyMasterId('redundancyMasterId')
        subnet.set_isNativeVlan(False)
        healthnmon_db_api.subnet_save(self.admin_context, subnet)
        subnets = healthnmon_db_api.subnet_get_all(self.admin_context)

        self.assertFalse(subnets is None,
                         'subnet all returned a none list')
        self.assertTrue(len(subnets) == 1,
                        'subnet all returned invalid number of list')

        indexOfThesubnet = -1
        for subn in subnets:
            if subn.get_id() == subnet.get_id():
                indexOfThesubnet = subnets.index(subn)
                break

        self.assertTrue(subnets[indexOfThesubnet].get_id()
                        == 'subnet-01', 'Subnet id mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_name()
                        == 'subnet-01', 'Subnet name mismatch')

        groupIdType = subnets[indexOfThesubnet].get_groupIdTypes()[0]
        self.assertTrue(
            groupIdType.get_id() == 'groupId-01', 'Group id mismatch')
        self.assertTrue(groupIdType.get_networkTypes(
        )[0] == 'MAPPED', 'Network Type mismatch')
        self.assertTrue(groupIdType.get_networkTypes(
        )[1] == 'TUNNEL', 'Network Type mismatch')

        self.assertTrue(
            groupIdType.get_id() == 'groupId-01', 'Group id mismatch')
        self.assertTrue(
            groupIdType.get_id() == 'groupId-01', 'Group id mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_networkAddress(
        ) == '1.1.1.1', 'Network Address mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_networkMask(
        ) == '255.255.255.0', 'Subnet mask mismatch')
        self.assertFalse(len(subnets[indexOfThesubnet].get_networkSources(
        )) == 0, 'Network Sources didn\'t get updated')
        self.assertTrue(subnets[indexOfThesubnet].get_networkSources(
        )[0] == 'VS_NETWORK', 'Network Sources mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_ipType()
                        == 'IPV4', 'Ip Type mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_isPublic(),
                        'Subnet isPublic returned false')
        self.assertTrue(subnets[indexOfThesubnet].get_isShareable(),
                        'Subnet isShareable returned false')
        self.assertTrue(subnets[indexOfThesubnet].get_dnsServers(
        )[0] == 'test-dns01', 'DnsServer mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_dnsDomain(
        ) == 'test_Domain', 'DnsDomain mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_dnsSearchSuffixes(
        )[0] == 'dnsSearchSuffixes', 'Subnet isShareable returned false')
        self.assertTrue(subnets[indexOfThesubnet].get_defaultGateways(
        )[0] == 'defaultGateways', 'defaultGateways mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_msDomainName(
        ) == 'msDomainName', 'msDomainName mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_msDomainType(
        ) == 'DOMAIN', 'DOMAIN mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_winsServers(
        )[0] == 'winsServers', 'winsServers mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_ntpDateServers(
        )[0] == 'ntpDateServers', 'ntpDateServers mismatch')
        self.assertTrue(
            subnets[indexOfThesubnet].get_vlanId() == '1', 'vlanId mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_isBootNetwork(),
                        'IsbootNetwork returned False')
        self.assertTrue(subnets[indexOfThesubnet].get_deploymentServices(
        )[0] == 'deploymentServices', 'deploymentServices mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_parentIds(
        )[0] == 'parentIds', 'parentIds mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_childIds()[0]
                        == 'childIds', 'childIds mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_isTrunk(),
                        'IsTrunk returned False')

        self.assertTrue(subnets[indexOfThesubnet].get_redundancyPeerIds(
        )[0] == 'redundancyPeerIds', 'redundancyPeerIds mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_redundancyMasterId(
        ) == 'redundancyMasterId', 'redundancyMasterId mismatch')
        self.assertFalse(subnets[indexOfThesubnet].get_isNativeVlan(),
                         'IsNativePlan should be false')
Exemplo n.º 14
0
    def test_subnet_get_all(self):
        subnet = Subnet()
        subnet.set_id('subnet-01')
        subnet.set_name('subnet-01')
        groupIdType = GroupIdType()
        groupIdType.set_id('groupId-01')
        groupIdType.add_networkTypes('MAPPED')
        groupIdType.add_networkTypes('TUNNEL')
        subnet.add_groupIdTypes(groupIdType)
        subnet.set_networkAddress('1.1.1.1')
        subnet.set_networkMask('255.255.255.0')
        subnet.add_networkSources('VS_NETWORK')
        subnet.set_ipType('IPV4')
        subnet.set_isPublic(True)
        subnet.set_isShareable(True)
        subnet.add_dnsServers('test-dns01')
        subnet.set_dnsDomain('test_Domain')
        subnet.add_dnsSearchSuffixes('dnsSearchSuffixes')
        subnet.add_defaultGateways('defaultGateways')
        subnet.set_msDomainName('msDomainName')
        subnet.set_msDomainType('DOMAIN')
        subnet.add_winsServers('winsServers')
        subnet.add_ntpDateServers('ntpDateServers')
        subnet.set_vlanId(1)
        subnet.set_isBootNetwork(True)
        subnet.add_deploymentServices('deploymentServices')
        subnet.add_parentIds('parentIds')
        subnet.add_childIds('childIds')
        subnet.set_isTrunk(True)
        subnet.add_redundancyPeerIds('redundancyPeerIds')
        subnet.set_redundancyMasterId('redundancyMasterId')
        subnet.set_isNativeVlan(False)
        healthnmon_db_api.subnet_save(self.admin_context, subnet)
        subnets = healthnmon_db_api.subnet_get_all(self.admin_context)

        self.assertFalse(subnets is None,
                         'subnet all returned a none list')
        self.assertTrue(len(subnets) == 1,
                        'subnet all returned invalid number of list')

        indexOfThesubnet = -1
        for subn in subnets:
            if subn.get_id() == subnet.get_id():
                indexOfThesubnet = subnets.index(subn)
                break

        self.assertTrue(subnets[indexOfThesubnet].get_id()
                        == 'subnet-01', 'Subnet id mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_name()
                        == 'subnet-01', 'Subnet name mismatch')

        groupIdType = subnets[indexOfThesubnet].get_groupIdTypes()[0]
        self.assertTrue(
            groupIdType.get_id() == 'groupId-01', 'Group id mismatch')
        self.assertTrue(groupIdType.get_networkTypes(
        )[0] == 'MAPPED', 'Network Type mismatch')
        self.assertTrue(groupIdType.get_networkTypes(
        )[1] == 'TUNNEL', 'Network Type mismatch')

        self.assertTrue(
            groupIdType.get_id() == 'groupId-01', 'Group id mismatch')
        self.assertTrue(
            groupIdType.get_id() == 'groupId-01', 'Group id mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_networkAddress(
        ) == '1.1.1.1', 'Network Address mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_networkMask(
        ) == '255.255.255.0', 'Subnet mask mismatch')
        self.assertFalse(len(subnets[indexOfThesubnet].get_networkSources(
        )) == 0, 'Network Sources didn\'t get updated')
        self.assertTrue(subnets[indexOfThesubnet].get_networkSources(
        )[0] == 'VS_NETWORK', 'Network Sources mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_ipType()
                        == 'IPV4', 'Ip Type mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_isPublic(),
                        'Subnet isPublic returned false')
        self.assertTrue(subnets[indexOfThesubnet].get_isShareable(),
                        'Subnet isShareable returned false')
        self.assertTrue(subnets[indexOfThesubnet].get_dnsServers(
        )[0] == 'test-dns01', 'DnsServer mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_dnsDomain(
        ) == 'test_Domain', 'DnsDomain mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_dnsSearchSuffixes(
        )[0] == 'dnsSearchSuffixes', 'Subnet isShareable returned false')
        self.assertTrue(subnets[indexOfThesubnet].get_defaultGateways(
        )[0] == 'defaultGateways', 'defaultGateways mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_msDomainName(
        ) == 'msDomainName', 'msDomainName mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_msDomainType(
        ) == 'DOMAIN', 'DOMAIN mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_winsServers(
        )[0] == 'winsServers', 'winsServers mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_ntpDateServers(
        )[0] == 'ntpDateServers', 'ntpDateServers mismatch')
        self.assertTrue(
            subnets[indexOfThesubnet].get_vlanId() == '1', 'vlanId mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_isBootNetwork(),
                        'IsbootNetwork returned False')
        self.assertTrue(subnets[indexOfThesubnet].get_deploymentServices(
        )[0] == 'deploymentServices', 'deploymentServices mismatch')

        self.assertTrue(subnets[indexOfThesubnet].get_parentIds(
        )[0] == 'parentIds', 'parentIds mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_childIds()[0]
                        == 'childIds', 'childIds mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_isTrunk(),
                        'IsTrunk returned False')

        self.assertTrue(subnets[indexOfThesubnet].get_redundancyPeerIds(
        )[0] == 'redundancyPeerIds', 'redundancyPeerIds mismatch')
        self.assertTrue(subnets[indexOfThesubnet].get_redundancyMasterId(
        ) == 'redundancyMasterId', 'redundancyMasterId mismatch')
        self.assertFalse(subnets[indexOfThesubnet].get_isNativeVlan(),
                         'IsNativePlan should be false')