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_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_test_address_pool(self, name, subnet, ranges=None): if not ranges: ranges = [(str(subnet[2]), str(subnet[-2]))] pool = dbutils.create_test_address_pool(name=name, network=str(subnet.network), family=subnet.version, prefix=subnet.prefixlen, ranges=ranges) self.address_pools.append(pool) return pool
def _create_test_network(self, name, nettype, subnet, ranges=None): if not ranges: ranges = [(str(subnet[2]), str(subnet[-2]))] pool = dbutils.create_test_address_pool(name=name, network=str(subnet.network), prefix=subnet.prefixlen, ranges=ranges) self.address_pools.append(pool) network = dbutils.create_test_network(type=nettype, address_pool_id=pool.id) self.networks.append(network) return network
def test_delete_address_from_pool(self): pool = dbutils.create_test_address_pool( name='testpool', network='192.168.204.0', ranges=[['192.168.204.2', '192.168.204.254']], prefix=24) address = dbutils.create_test_address(name="enptest01", family=4, address='192.168.204.4', prefix=24, address_pool_id=pool.id) self.assertEqual(address['pool_uuid'], pool.uuid) with mock.patch('sysinv.common.utils.is_initial_config_complete', lambda: True): 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 has been allocated from pool; " "cannot be manually deleted", response.json['error_message'])
def setUp(self): super(InterfaceNetworkTestCase, 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) 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.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.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.address_pool_oam = dbutils.create_test_address_pool( id=3, network='128.224.150.0', name='oam', ranges=[['128.224.150.1', '128.224.151.254']], prefix=23) self.oam_network = dbutils.create_test_network( id=3, name='oam', type=constants.NETWORK_TYPE_OAM, address_pool_id=self.address_pool_oam.id) self.oam_address = dbutils.create_test_address( family=2, address='10.10.10.3', prefix=24, name='controller-0-oam', address_pool_id=self.address_pool_oam.id) self.address_pool_pxeboot = dbutils.create_test_address_pool( id=4, network='192.168.202.0', name='pxeboot', ranges=[['192.168.202.2', '192.168.202.254']], prefix=23) self.pxeboot_network = dbutils.create_test_network( id=4, type=constants.NETWORK_TYPE_PXEBOOT, address_pool_id=self.address_pool_pxeboot.id) self.pxeboot_address = dbutils.create_test_address( family=2, address='192.168.202.3', prefix=24, name='controller-0-pxeboot', address_pool_id=self.address_pool_pxeboot.id)
def setUp(self): super(InterfaceNetworkTestCase, self).setUp() 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.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.address_pool_infra = dbutils.create_test_address_pool( id=2, network='192.168.205.0', name='infrastructure', ranges=[['192.168.205.2', '192.168.205.254']], prefix=24) self.infra_network = dbutils.create_test_network( id=2, name='infra', type=constants.NETWORK_TYPE_INFRA, link_capacity=10000, vlan_id=3, address_pool_id=self.address_pool_infra.id) self.address_pool_oam = dbutils.create_test_address_pool( id=3, network='128.224.150.0', name='oam', ranges=[['128.224.150.1', '128.224.151.254']], prefix=23) self.oam_network = dbutils.create_test_network( id=3, name='oam', type=constants.NETWORK_TYPE_OAM, address_pool_id=self.address_pool_oam.id) self.address_pool_pxeboot = dbutils.create_test_address_pool( id=4, network='192.168.202.0', name='pxeboot', ranges=[['192.168.202.2', '192.168.202.254']], prefix=23) self.pxeboot_network = dbutils.create_test_network( id=4, type=constants.NETWORK_TYPE_PXEBOOT, address_pool_id=self.address_pool_pxeboot.id)