def test_build_network_config(self): net = utils.get_test_network_info(1) config = tilera.build_network_config(net) self.assertIn('eth0', config) self.assertNotIn('eth1', config) net = utils.get_test_network_info(2) config = tilera.build_network_config(net) self.assertIn('eth0', config) self.assertIn('eth1', config)
def test_build_network_config(self): net = utils.get_test_network_info(1, legacy_model=False) config = tilera.build_network_config(net) self.assertIn('eth0', config) self.assertNotIn('eth1', config) net = utils.get_test_network_info(2, legacy_model=False) config = tilera.build_network_config(net) self.assertIn('eth0', config) self.assertIn('eth1', config)
def test_inject_into_image(self): self._create_node() files = [] self.instance['hostname'] = 'fake hostname' files.append(('/etc/hostname', 'fake hostname')) self.instance['key_data'] = 'fake ssh key' net_info = utils.get_test_network_info(1) net = tilera.build_network_config(net_info) admin_password = '******' self.mox.StubOutWithMock(disk_api, 'inject_data') disk_api.inject_data( admin_password=admin_password, image=tilera.get_image_file_path(self.instance), key='fake ssh key', metadata=None, partition=None, net=net, files=files, ).AndReturn(True) self.mox.ReplayAll() self.driver._inject_into_image( self.context, self.node, self.instance, network_info=net_info, admin_password=admin_password, injected_files=None) self.mox.VerifyAll()
def test_build_network_config_dhcp(self): self.flags(net_config_template="$pybasedir/nova/virt/baremetal/" "net-dhcp.ubuntu.template", group="baremetal") net = utils.get_test_network_info() net[0]["network"]["subnets"][0]["ips"][0]["address"] = "1.2.3.4" config = tilera.build_network_config(net) self.assertIn("iface eth0 inet dhcp", config) self.assertNotIn("address 1.2.3.4", config)
def test_inject_into_image(self): self._create_node() files = [] self.instance["hostname"] = "fake hostname" files.append(("/etc/hostname", "fake hostname")) self.instance["key_data"] = "fake ssh key" net_info = utils.get_test_network_info(1) net = tilera.build_network_config(net_info) admin_password = "******" self.mox.StubOutWithMock(os.path, "exists") os.path.exists(mox.IgnoreArg()).AndReturn(True) self.mox.StubOutWithMock(disk_api, "inject_data") disk_api.inject_data( admin_password=admin_password, image=tilera.get_image_file_path(self.instance), key="fake ssh key", metadata=None, partition=None, net=net, files=files, ).AndReturn(True) self.mox.ReplayAll() self.driver._inject_into_image( self.context, self.node, self.instance, network_info=net_info, admin_password=admin_password, injected_files=None, ) self.mox.VerifyAll()
def test_build_network_config_static(self): self.config( net_config_template='$pybasedir/nova/virt/baremetal/' 'net-static.ubuntu.template', group='baremetal', ) net = utils.get_test_network_info() net[0][1]['ips'][0]['ip'] = '1.2.3.4' config = tilera.build_network_config(net) self.assertIn('iface eth0 inet static', config) self.assertIn('address 1.2.3.4', config)
def test_build_network_config_dhcp(self): self.flags( net_config_template='$pybasedir/nova/virt/baremetal/' 'net-dhcp.ubuntu.template', group='baremetal', ) net = utils.get_test_network_info() net[0]['network']['subnets'][0]['ips'][0]['address'] = '1.2.3.4' config = tilera.build_network_config(net) self.assertIn('iface eth0 inet dhcp', config) self.assertNotIn('address 1.2.3.4', config)
def test_build_network_config_dhcp(self): self.flags( net_config_template='$pybasedir/nova/virt/baremetal/' 'net-dhcp.ubuntu.template', group='baremetal', ) net = utils.get_test_network_info() net[0]['network']['subnets'][0]['ips'][0]['address'] = '1.2.3.4' config = tilera.build_network_config(net) self.assertIn('iface eth0 inet dhcp', config) self.assertNotIn('address 1.2.3.4', config)