def test_construct(self): mock_context = mock.Mock() mock_context.name = 'baz' test_router = model.Router('foo', 'bar', mock_context, 'qux') self.assertEqual(test_router.stack_name, 'baz-bar-foo') self.assertEqual(test_router.stack_if_name, 'baz-bar-foo-if0') self.assertEqual(test_router.external_gateway_info, 'qux')
def test__add_instance(self, mock_template): attrs = { 'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10', 'floating_ip_assoc': 'some-vm', 'availability_zone': 'zone' } test_server = model.Server('foo', self.mock_context, attrs) self.mock_context.flavors = ['flavor1', 'flavor2', 'some-flavor'] mock_network = mock.Mock() mock_network.name = 'some-network' mock_network.stack_name = 'some-network-stack' mock_network.allowed_address_pairs = ["1", "2"] mock_network.vnic_type = 'normal' mock_network.subnet_stack_name = 'some-network-stack-subnet' mock_network.provider = 'sriov' mock_network.external_network = 'ext_net' mock_network.router = model.Router('some-router', 'some-network', self.mock_context, 'ext_net') test_server._add_instance(mock_template, 'some-server', [mock_network], 'hints') mock_template.add_port.assert_called_with( 'some-server-some-network-port', mock_network.stack_name, mock_network.subnet_stack_name, mock_network.vnic_type, sec_group_id=self.mock_context.secgroup_name, provider=mock_network.provider, allowed_address_pairs=mock_network.allowed_address_pairs) mock_template.add_floating_ip.assert_called_with( 'some-server-fip', mock_network.external_network, 'some-server-some-network-port', 'bar-some-network-some-router-if0', 'some-secgroup') mock_template.add_floating_ip_association.assert_called_with( 'some-server-fip-assoc', 'some-server-fip', 'some-server-some-network-port') mock_template.add_server.assert_called_with( 'some-server', 'some-image', flavor='some-flavor', flavors=['flavor1', 'flavor2', 'some-flavor'], ports=['some-server-some-network-port'], user=self.mock_context.user, key_name=self.mock_context.keypair_name, user_data='', scheduler_hints='hints', availability_zone='zone')
def test_construct_has_external_network(self): attrs = {'external_network': 'ext_net'} test_network = model.Network('foo', self.mock_context, attrs) exp_router = model.Router('router', 'foo', self.mock_context, 'ext_net') self.assertEqual(test_network.router.stack_name, exp_router.stack_name) self.assertEqual(test_network.router.stack_if_name, exp_router.stack_if_name) self.assertEqual(test_network.router.external_gateway_info, exp_router.external_gateway_info)
def test__add_instance(self, mock_template): attrs = { 'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10', 'floating_ip_assoc': 'some-vm' } test_server = model.Server('foo', self.mock_context, attrs) mock_network = mock.Mock() mock_network.name = 'some-network' mock_network.stack_name = 'some-network-stack' mock_network.subnet_stack_name = 'some-network-stack-subnet' mock_network.provider = 'sriov' mock_network.external_network = 'ext_net' mock_network.router = model.Router('some-router', 'some-network', self.mock_context, 'ext_net') test_server._add_instance(mock_template, 'some-server', [mock_network], 'hints') mock_template.add_port.assert_called_with( 'some-server-some-network-port', mock_network.stack_name, mock_network.subnet_stack_name, sec_group_id=self.mock_context.secgroup_name, provider=mock_network.provider) mock_template.add_floating_ip.assert_called_with( 'some-server-fip', mock_network.external_network, 'some-server-some-network-port', 'bar-some-network-some-router-if0', 'some-secgroup') mock_template.add_floating_ip_association.assert_called_with( 'some-server-fip-assoc', 'some-server-fip', 'some-server-some-network-port') mock_template.add_server.assert_called_with( 'some-server', 'some-image', 'some-flavor', ports=['some-server-some-network-port'], user=self.mock_context.user, key_name=self.mock_context.keypair_name, scheduler_hints='hints')