def test_create_invalid_duplicate_networktype(self): controller_interface1 = dbutils.create_test_interface( ifname='enp0s3', forihostid=self.controller.id) dbutils.create_test_interface_network( interface_id=controller_interface1.id, network_id=self.oam_network.id) controller_interface2 = dbutils.create_test_interface( ifname='enp0s8', forihostid=self.controller.id) controller_interface_network = dbutils.post_get_test_interface_network( interface_uuid=controller_interface2.uuid, network_uuid=self.oam_network.uuid) self._post_and_check(controller_interface_network, expect_errors=True)
def test_create_pxeboot_interface_network(self): controller_interface = dbutils.create_test_interface( ifname='enp0s8', forihostid=self.controller.id) worker_interface = dbutils.create_test_interface( ifname='enp0s8', forihostid=self.worker.id) controller_interface_network = dbutils.post_get_test_interface_network( interface_uuid=controller_interface.uuid, network_uuid=self.pxeboot_network.uuid) self._post_and_check(controller_interface_network, expect_errors=False) worker_interface_network = dbutils.post_get_test_interface_network( interface_uuid=worker_interface.uuid, network_uuid=self.pxeboot_network.uuid) self._post_and_check(worker_interface_network, expect_errors=False)
def setUp(self): super(InterfaceDataNetworkTestCase, self).setUp() p = mock.patch.object(api_if_v1, '_get_lower_interface_macs') self.mock_lower_macs = p.start() self.mock_lower_macs.return_value = { 'enp0s18': '08:00:27:8a:87:48', 'enp0s19': '08:00:27:ea:93:8e' } self.addCleanup(p.stop) p = mock.patch('sysinv.common.utils.is_aio_simplex_system') self.mock_utils_is_aio_simplex_system = p.start() self.mock_utils_is_aio_simplex_system.return_value = True self.addCleanup(p.stop) self.system = dbutils.create_test_isystem() self.load = dbutils.create_test_load() self.controller = dbutils.create_test_ihost( id='1', uuid=None, forisystemid=self.system.id, hostname='controller-0', personality=constants.CONTROLLER, subfunctions=constants.WORKER, administrative=constants.ADMIN_UNLOCKED, invprovision=constants.PROVISIONED, ) self.datanetwork = dbutils.create_test_datanetwork( name='test1', uuid=str(uuid.uuid4()), network_type=constants.DATANETWORK_TYPE_VLAN, mtu=1500) self.if_sriov0 = dbutils.create_test_interface( ifname='sriov0', ifclass=constants.INTERFACE_CLASS_PCI_SRIOV, forihostid=self.controller.id, ihost_uuid=self.controller.uuid) self.if_data0 = dbutils.create_test_interface( ifname='data0', ifclass=constants.INTERFACE_CLASS_DATA, forihostid=self.controller.id, ihost_uuid=self.controller.uuid) self.if_sriov1 = dbutils.create_test_interface( ifname='sriov1', ifclass=constants.INTERFACE_CLASS_PCI_SRIOV, forihostid=self.controller.id, ihost_uuid=self.controller.uuid)
def _create_test_host_platform_interface(self, host): network_types = [ constants.NETWORK_TYPE_OAM, constants.NETWORK_TYPE_MGMT, constants.NETWORK_TYPE_CLUSTER_HOST, constants.NETWORK_TYPE_STORAGE ] ifnames = ['oam', 'mgmt', 'cluster', 'storage'] index = 0 ifaces = [] for nt, name in zip(network_types, ifnames): if (host.personality == constants.WORKER and nt == constants.NETWORK_TYPE_OAM): continue dbutils.create_test_ethernet_port(name='eth%s' % index, host_id=host['id'], interface_id=index, pciaddr='0000:00:00.%s' % index, dev_id=0) interface = dbutils.create_test_interface( ifname=name, ifclass=constants.INTERFACE_CLASS_PLATFORM, forihostid=host['id'], ihost_uuid=host['uuid']) iface = self.dbapi.iinterface_get(interface['uuid']) ifaces.append(iface) network = self.dbapi.network_get_by_type(nt) dbutils.create_test_interface_network(interface_id=iface.id, network_id=network.id) index = index + 1 return ifaces
def _create_mgmt_interface_network(self, interface='mgmt'): self.address_pool_mgmt = dbutils.create_test_address_pool( id=1, network='192.168.204.0', name='management', ranges=[['192.168.204.2', '192.168.204.254']], prefix=24) self.mgmt_network = dbutils.create_test_network( id=1, name='mgmt', type=constants.NETWORK_TYPE_MGMT, link_capacity=1000, vlan_id=2, address_pool_id=self.address_pool_mgmt.id) self.mgmt_interface = dbutils.create_test_interface( ifname=interface, id=1, ifclass=constants.INTERFACE_CLASS_PLATFORM, forihostid=self.controller.id, ihost_uuid=self.controller.uuid, networktypelist=[constants.NETWORK_TYPE_MGMT]) dbutils.create_test_interface_network( interface_id=self.mgmt_interface.id, network_id=self.mgmt_network.id)
def test_bad_host_state(self): interface = dbutils.create_test_interface( ifname="test0", ifclass=constants.INTERFACE_CLASS_PLATFORM, forihostid=self.worker.id, ihost_uuid=self.worker.uuid) address = dbutils.create_test_address(interface_id=interface.id, name="enptest01", family=self.oam_subnet.version, address=str(self.oam_subnet[25]), prefix=self.oam_subnet.prefixlen) self.assertEqual(address["interface_id"], interface.id) # unlock the worker dbapi = dbutils.db_api.get_instance() worker = dbapi.ihost_update( self.worker.uuid, {"administrative": constants.ADMIN_UNLOCKED}) self.assertEqual(worker['administrative'], constants.ADMIN_UNLOCKED) response = self.delete(self.get_single_url(address.uuid), headers=self.API_HEADERS, expect_errors=True) self.assertEqual(response.content_type, 'application/json') self.assertEqual(response.status_code, http_client.INTERNAL_SERVER_ERROR) self.assertIn("administrative state = unlocked", response.json['error_message'])
def _create_cluster_host_interface_network(self, interface='cluster-host'): self.address_pool_cluster_host = dbutils.create_test_address_pool( id=2, network='192.168.206.0', name='cluster-host', ranges=[['192.168.206.2', '192.168.206.254']], prefix=24) self.cluster_host_network = dbutils.create_test_network( id=2, name='cluster-host', type=constants.NETWORK_TYPE_CLUSTER_HOST, link_capacity=10000, vlan_id=3, address_pool_id=self.address_pool_cluster_host.id) self.cluster_host_interface = dbutils.create_test_interface( ifname=interface, id=2, ifclass=constants.INTERFACE_CLASS_PLATFORM, forihostid=self.controller.id, ihost_uuid=self.controller.uuid, networktypelist=[constants.NETWORK_TYPE_CLUSTER_HOST]) dbutils.create_test_interface_network( interface_id=self.cluster_host_interface.id, network_id=self.cluster_host_network.id)
def test_no_cluster_host_on_controller(self): worker_interface = dbutils.create_test_interface( ifname='enp0s3', forihostid=self.worker.id) worker_interface_network = dbutils.post_get_test_interface_network( interface_uuid=worker_interface.uuid, network_uuid=self.cluster_host_network.uuid) self._post_and_check(worker_interface_network, expect_errors=True)
def test_orphaned_routes(self): interface = dbutils.create_test_interface( ifname="test0", ifclass=constants.INTERFACE_CLASS_PLATFORM, forihostid=self.worker.id, ihost_uuid=self.worker.uuid) address = dbutils.create_test_address(interface_id=interface.id, name="enptest01", family=self.oam_subnet.version, address=str(self.oam_subnet[25]), prefix=self.oam_subnet.prefixlen) self.assertEqual(address["interface_id"], interface.id) route = dbutils.create_test_route( interface_id=interface.id, family=4, network='10.10.10.0', prefix=24, gateway=str(self.oam_subnet[1]), ) self.assertEqual(route['gateway'], str(self.oam_subnet[1])) response = self.delete(self.get_single_url(address.uuid), headers=self.API_HEADERS, expect_errors=True) self.assertEqual(response.content_type, 'application/json') self.assertEqual(response.status_code, http_client.CONFLICT) self.assertIn( "Address %s is in use by a route to %s/%d via %s" % (address["address"], route["network"], route["prefix"], route["gateway"]), response.json['error_message'])
def test_create_address_platform_interface(self): if self.oam_subnet.version == 4: ipv4_mode, ipv6_mode = (constants.IPV4_STATIC, constants.IPV6_DISABLED) else: ipv4_mode, ipv6_mode = (constants.IPV4_DISABLED, constants.IPV6_STATIC) # Create platform interface, patch to make static interface = dbutils.create_test_interface( ifname="platformip", ifclass=constants.INTERFACE_CLASS_PLATFORM, forihostid=self.worker.id, ihost_uuid=self.worker.uuid) response = self.patch_dict_json('%s/%s' % (self.IFACE_PREFIX, interface['uuid']), ipv4_mode=ipv4_mode, ipv6_mode=ipv6_mode) self.assertEqual('application/json', response.content_type) self.assertEqual(response.status_code, http_client.OK) self.assertEqual(response.json['ifclass'], 'platform') self.assertEqual(response.json['ipv4_mode'], ipv4_mode) self.assertEqual(response.json['ipv6_mode'], ipv6_mode) # Verify an address associated with the interface can be created self._test_create_address_success('platformtest', str(self.oam_subnet[25]), self.oam_subnet.prefixlen, None, interface.uuid)
def test_create_invalid_network_on_data_interface(self): controller_interface = dbutils.create_test_interface( ifname='enp0s3', ifclass=constants.NETWORK_TYPE_DATA, forihostid=self.controller.id) controller_interface_network = dbutils.post_get_test_interface_network( interface_uuid=controller_interface.uuid, network_uuid=self.cluster_host_network.uuid) self._post_and_check(controller_interface_network, expect_errors=True)
def test_aemode_invalid_mgmt(self): controller_interface = dbutils.create_test_interface( ifname='name', forihostid=self.controller.id, ifclass=constants.INTERFACE_CLASS_PLATFORM, iftype=constants.INTERFACE_TYPE_AE, aemode='balanced', txhashpolicy='layer2') controller_interface_network = dbutils.post_get_test_interface_network( interface_uuid=controller_interface.uuid, network_uuid=self.mgmt_network.uuid) self._post_and_check(controller_interface_network, expect_errors=True)
def test_modify_ptp_transport_invalid(self): # If the host is unlocked it must have a ptp interface with an IP to set to UDP self.dbapi.ihost_update(self.worker.id, {'clock_synchronization': constants.PTP}) self.dbapi.ihost_update(self.worker.id, {'administrative': constants.ADMIN_UNLOCKED}) interface = { 'id': 1, 'uuid': str(uuid.uuid4()), 'forihostid': self.worker.id, 'ifname': 'ptpif', 'iftype': constants.INTERFACE_TYPE_ETHERNET, 'imac': '02:11:22:33:44:11', 'ifclass': constants.INTERFACE_CLASS_PLATFORM, 'ptp_role': constants.INTERFACE_PTP_ROLE_MASTER } dbutils.create_test_interface(**interface) self.modify_ptp_failure( self.transport_udp, "Invalid system configuration for UDP based PTP transport")
def test_create_invalid_duplicate_mgmt_interface_network(self): controller_interface = dbutils.create_test_interface( ifname='enp0s8', forihostid=self.controller.id) dbutils.create_test_interface_network( interface_id=controller_interface.id, network_id=self.mgmt_network.id) worker_interface = dbutils.create_test_interface( ifname='enp0s8', forihostid=self.worker.id) dbutils.create_test_interface_network(interface_id=worker_interface.id, network_id=self.mgmt_network.id) controller_interface_network = dbutils.post_get_test_interface_network( interface_uuid=controller_interface.uuid, network_uuid=self.mgmt_network.uuid) self._post_and_check(controller_interface_network, expect_errors=True) worker_interface_network = dbutils.post_get_test_interface_network( interface_uuid=worker_interface.uuid, network_uuid=self.mgmt_network.uuid) self._post_and_check(worker_interface_network, expect_errors=True)
def test_modify_ptp_transport_valid(self): # With no ptp hosts we should be able to modify ptp transport self.modify_ptp(self.transport_udp) self.modify_ptp(self.transport_l2) # If the host is locked we can set the transport to UDP self.dbapi.ihost_update(self.worker.id, {'clock_synchronization': constants.PTP}) self.modify_ptp(self.transport_udp) self.modify_ptp(self.transport_l2) # If the host is unlocked it must have a ptp interface with an IP to set to UDP self.dbapi.ihost_update(self.worker.id, {'administrative': constants.ADMIN_UNLOCKED}) interface = { 'id': 1, 'uuid': str(uuid.uuid4()), 'forihostid': self.worker.id, 'ifname': 'ptpif', 'iftype': constants.INTERFACE_TYPE_ETHERNET, 'imac': '02:11:22:33:44:11', 'uses': [], 'used_by': [], 'ifclass': constants.INTERFACE_CLASS_PLATFORM, 'ipv4_mode': 'static', 'ptp_role': constants.INTERFACE_PTP_ROLE_MASTER } dbutils.create_test_interface(**interface) address = { 'interface_id': '1', 'family': 4, 'prefix': 24, 'address': '192.168.1.2' } dbutils.create_test_address(**address) self.modify_ptp(self.transport_udp) self.modify_ptp(self.transport_l2)
def test_delete_address_with_interface(self): interface = dbutils.create_test_interface( ifname="test0", ifclass=constants.INTERFACE_CLASS_PLATFORM, forihostid=self.worker.id, ihost_uuid=self.worker.uuid) address = dbutils.create_test_address(interface_id=interface.id, name="enptest01", family=self.oam_subnet.version, address=str(self.oam_subnet[25]), prefix=self.oam_subnet.prefixlen) self.assertEqual(address["interface_id"], interface.id) response = self.delete(self.get_single_url(address.uuid), headers=self.API_HEADERS) self.assertEqual(response.status_code, http_client.NO_CONTENT)
def setUp(self): super(ProfileTestCase, self).setUp() self.dbapi = dbapi.get_instance() self.system = dbutils.create_test_isystem() self.load = dbutils.create_test_load() self.controller = dbutils.create_test_ihost( id='1', uuid=None, forisystemid=self.system.id, hostname='controller-0', personality=constants.CONTROLLER, subfunctions=constants.CONTROLLER, invprovision=constants.PROVISIONED, ) self.worker = dbutils.create_test_ihost( id='2', uuid=None, forisystemid=self.system.id, hostname='worker-0', personality=constants.WORKER, subfunctions=constants.WORKER, mgmt_mac='01:02.03.04.05.C0', mgmt_ip='192.168.24.12', invprovision=constants.PROVISIONED, ) self.profile = { 'profilename': 'profile-node1', 'ihost_uuid': self.controller.uuid, } self.ctrlnode = self.dbapi.inode_create(self.controller.id, dbutils.get_test_node(id=1)) self.ctrlcpu = self.dbapi.icpu_create( self.controller.id, dbutils.get_test_icpu( id=1, cpu=0, forihostid=self.controller.id, forinodeid=self.ctrlnode.id, )) self.ctrlif = dbutils.create_test_interface( forihostid=self.controller.id) self.port1 = dbutils.create_test_ethernet_port( id='1', name=self.ctrlif.ifname, host_id=self.controller.id, interface_id=self.ctrlif.id, mac='08:00:27:43:60:11') self.ctrlmemory = self.dbapi.imemory_create( self.controller.id, dbutils.get_test_imemory(id=1, hugepages_configured=True, forinodeid=self.ctrlcpu.forinodeid)) self.compnode = self.dbapi.inode_create(self.worker.id, dbutils.get_test_node(id=2)) self.compcpu = self.dbapi.icpu_create( self.worker.id, dbutils.get_test_icpu(id=5, cpu=3, forinodeid=self.compnode.id, forihostid=self.worker.id)) self.compcpuapp = self.dbapi.icpu_create( self.worker.id, dbutils.get_test_icpu( id=6, cpu=4, forinodeid=self.compnode.id, forihostid=self.worker.id, allocated_function=constants.APPLICATION_FUNCTION)) self.compmemory = self.dbapi.imemory_create( self.worker.id, dbutils.get_test_imemory(id=2, Hugepagesize=constants.MIB_1G, forinodeid=self.compcpu.forinodeid)) self.disk = self.dbapi.idisk_create( self.worker.id, dbutils.get_test_idisk(device_node='/dev/sdb', device_type=constants.DEVICE_TYPE_HDD)) self.lvg = self.dbapi.ilvg_create( self.worker.id, dbutils.get_test_lvg(lvm_vg_name=constants.LVG_NOVA_LOCAL)) self.pv = self.dbapi.ipv_create( self.worker.id, dbutils.get_test_pv(lvm_vg_name=constants.LVG_NOVA_LOCAL, disk_or_part_uuid=self.disk.uuid))