Add 'vip_namespace' optional argument for fuel2 VIP create command

Create operation for VIP accepts 'vip_namespace' as optional parameter.
Its processing was added to VIP client as it was missing in the original
patch for adding the commands to the client.

Change-Id: Ibeab8f4c51758d13141b217daff613d90a0f40dd
Related-Bug: #1576255
This commit is contained in:
Artem Roma 2016-05-12 16:10:39 +03:00
parent a32c44471c
commit 719f85e78e
2 changed files with 8 additions and 9 deletions

View File

@ -66,13 +66,9 @@ class TestVipFacade(test_api.BaseLibTest):
self.assertEqual(written_yaml, expected_yaml)
def test_vip_create(self):
expected = {'ip_addr': '127.0.0.1', 'vip_name': 'test', 'network': 1}
vip_kwargs = {'ip_addr': '127.0.0.1', 'vip_name': 'test', 'network': 1,
'vip_namespace': 'test-namespace'}
request_post = self.m_request.post(self.res_uri, json={})
self.client.create(
self.env_id,
ip_addr=expected['ip_addr'],
vip_name=expected['vip_name'],
network=expected['network']
)
self.client.create(self.env_id, **vip_kwargs)
self.assertTrue(request_post.called)
self.assertEqual(request_post.last_request.json(), expected)
self.assertEqual(request_post.last_request.json(), vip_kwargs)

View File

@ -50,13 +50,16 @@ class VipClient(base_v1.BaseV1Client):
env.set_vips_data(vips_data)
@staticmethod
def create(env_id, ip_addr, network, vip_name):
def create(env_id, ip_addr, network, vip_name, vip_namespace=None):
env = objects.Environment(env_id)
vip_data = {
'ip_addr': ip_addr,
'network': network,
'vip_name': vip_name
}
if vip_namespace is not None:
vip_data['vip_namespace'] = vip_namespace
env.create_vip(**vip_data)