diff --git a/doc/api_samples/servers/v2.69/servers-details-resp.json b/doc/api_samples/servers/v2.69/servers-details-resp.json index 251e16963e..458b7e846d 100644 --- a/doc/api_samples/servers/v2.69/servers-details-resp.json +++ b/doc/api_samples/servers/v2.69/servers-details-resp.json @@ -5,6 +5,11 @@ "id": "b6b0410f-b65f-4473-855e-5d82a71759e0", "status": "UNKNOWN", "tenant_id": "6f70656e737461636b20342065766572", + "security_groups": [ + { + "name": "default" + } + ], "links": [ { "href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/servers/b6b0410f-b65f-4473-855e-5d82a71759e0", @@ -17,4 +22,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index dfd77c2974..580679153a 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -1499,10 +1499,12 @@ class NeutronFixture(fixtures.Fixture): 'nova.network.neutronv2.api.API.remove_fixed_ip_from_instance', lambda *args, **kwargs: network_model.NetworkInfo.hydrate( NeutronFixture.nw_info)) + # TODO(stephenfin): This is a rubbish mock. We should instead mock the + # methods for the neutron client, like 'list_security_groups' self.test.stub_out( 'nova.network.security_group.neutron_driver.SecurityGroupAPI.' 'get_instances_security_groups_bindings', - lambda *args, **kwargs: {}) + self.fake_get_instance_security_group_bindings) # Stub out port binding APIs which go through a KSA client Adapter # rather than python-neutronclient. @@ -1532,6 +1534,13 @@ class NeutronFixture(fixtures.Fixture): # per port so we can reflect the status accurately. return fake_requests.FakeResponse(204) + @staticmethod + def fake_get_instance_security_group_bindings( + _, context, servers, detailed=False): + if detailed: + raise Exception('We do not support detailed view') + return {server['id']: [{'name': 'default'}] for server in servers} + def _get_first_id_match(self, id, list): filtered_list = [p for p in list if p['id'] == id] if len(filtered_list) > 0: diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.69/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.69/servers-details-resp.json.tpl index e634abc7d8..ca7dffc85d 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.69/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.69/servers-details-resp.json.tpl @@ -5,6 +5,11 @@ "id": "%(uuid)s", "status": "UNKNOWN", "tenant_id": "6f70656e737461636b20342065766572", + "security_groups": [ + { + "name": "default" + } + ], "links": [ { "href": "%(versioned_compute_endpoint)s/servers/%(uuid)s", @@ -17,4 +22,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 7b6310a215..f1ff6b540e 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -1261,9 +1261,9 @@ class ServerTestV269(ServersTestBase): # server is in the down cell. self.assertEqual('UNKNOWN', server['status']) self.assertIn(server['id'], self.down_cell_insts) - # the partial construct will have only 5 keys: - # created, tenant_id, status, id and links. - self.assertEqual(5, len(server)) + # the partial construct will have only 6 keys: + # created, tenant_id, security_groups, status, id and links. + self.assertEqual(6, len(server)) else: # server in up cell self.assertIn(server['id'], self.up_cell_insts) @@ -1367,8 +1367,8 @@ class ServerTestV269(ServersTestBase): if server['tenant_id'] != 'faker': self.assertIn(server['id'], self.down_cell_insts) # the partial construct will have only 5 keys: - # created, tenant_id, status, id and links - self.assertEqual(5, len(server)) + # created, tenant_id, security_groups, status, id and links + self.assertEqual(6, len(server)) else: # server in up cell if server['tenant_id'] != 'faker':