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 _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 _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 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_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)