Tempest: add tempest test cases for server interface attaching

Change-Id: Icd08828641aaf3d1dd2d4bd71fec627e92cd342d
Partial-Bug: #1697813
This commit is contained in:
liusheng 2017-06-16 11:07:18 +08:00
parent 6fec2da0d9
commit e25a3deeba
2 changed files with 31 additions and 0 deletions

View File

@ -167,3 +167,23 @@ class BaremetalComputeAPIServersTest(base.BaseBaremetalComputeTest):
fixed_ip = nic['fixed_ips'][0]
self.assertIn('subnet_id', fixed_ip)
self.assertIn('ip_address', fixed_ip)
def test_server_attach_interface(self):
self._ensure_states_before_test()
nics_before = self.baremetal_compute_client.server_get_networks(
self.server_ids[0])
self.baremetal_compute_client.server_attach_interface(
self.server_ids[0], net_id=self.net_id)
nics_after = self.baremetal_compute_client.server_get_networks(
self.server_ids[0])
self.assertEqual(len(nics_before) + 1, len(nics_after))
for nic in nics_after:
self.assertIn('network_id', nic)
self.assertIn('port_id', nic)
self.assertIn('floating_ip', nic)
self.assertIn('port_type', nic)
self.assertIn('mac_address', nic)
self.assertIsInstance(nic['fixed_ips'], list)
fixed_ip = nic['fixed_ips'][0]
self.assertIn('subnet_id', fixed_ip)
self.assertIn('ip_address', fixed_ip)

View File

@ -190,6 +190,17 @@ class BaremetalComputeClient(rest_client.RestClient):
body = self.deserialize(body)['nics']
return rest_client.ResponseBodyList(resp, body)
def server_attach_interface(self, server_id, net_id):
uri = '%s/servers/%s/networks/interfaces' % (self.uri_prefix,
server_id)
body = {"net_id": net_id}
body = self.serialize(body)
resp, body = self.post(uri, body)
self.expected_success(204, resp.status)
if body:
body = self.deserialize(body)
return rest_client.ResponseBody(resp, body)
class BaremetalNodeClient(rest_client.RestClient):
version = '1'