Adds nova client support for nova-manage vpn command

Adds "nova cloudpipe-configure" command
Adds shell tests for cloudpipe-list and cloudpipe-create commands which
already exist

This patch depends on https://review.openstack.org/#/c/15854/

Change-Id: I784f5bf0f25a2d8cae4b7c2c6ccf345842ffe352
Implements: blueprint apis-for-nova-manage
This commit is contained in:
Chris Yeoh 2012-11-26 14:21:35 +10:30
parent b9d60c1fd2
commit 4f6419b555
5 changed files with 45 additions and 0 deletions

View File

@ -16,6 +16,7 @@
"""Cloudpipe interface."""
from novaclient import base
from novaclient.v1_1 import networks
class Cloudpipe(base.Resource):
@ -46,3 +47,16 @@ class CloudpipeManager(base.ManagerWithFind):
Get a list of cloudpipe instances.
"""
return self._list('/os-cloudpipe', 'cloudpipes')
def update(self, address, port):
"""
Update VPN address and port for all networks associated
with the project defined by authentication
:param address: IP address
:param port: Port number
"""
body = {'configure_project': {'vpn_ip': address,
'vpn_port': port}}
self._update("/os-cloudpipe/configure-project", body)

View File

@ -269,6 +269,13 @@ def do_cloudpipe_create(cs, args):
cs.cloudpipe.create(args.project)
@utils.arg('address', metavar='<ip address>', help='New IP Address.')
@utils.arg('port', metavar='<port>', help='New Port.')
def do_cloudpipe_configure(cs, args):
"""Create a cloudpipe instance for the given project"""
cs.cloudpipe.update(args.address, args.port)
def _poll_for_status(poll_fn, obj_id, action, final_ok_states,
poll_period=5, show_progress=True,
status_field="status", silent=False):

View File

@ -453,6 +453,9 @@ class FakeHTTPClient(base_client.HTTPClient):
def post_os_cloudpipe(self, **ks):
return (202, {'instance_id': '9d5824aa-20e6-4b9f-b967-76a699fc51fd'})
def put_os_cloudpipe_configure_project(self, **kw):
return (202, None)
#
# Flavors
#

View File

@ -20,3 +20,9 @@ class CloudpipeTest(utils.TestCase):
body = {'cloudpipe': {'project_id': project}}
cs.assert_called('POST', '/os-cloudpipe', body)
self.assertTrue(isinstance(cp, str))
def test_update(self):
cs.cloudpipe.update("192.168.1.1", 2345)
body = {'configure_project': {'vpn_ip': "192.168.1.1",
'vpn_port': 2345}}
cs.assert_called('PUT', '/os-cloudpipe/configure-project', body)

View File

@ -600,6 +600,21 @@ class ShellTest(utils.TestCase):
self.run_command('network-show 1')
self.assert_called('GET', '/os-networks/1')
def test_cloudpipe_list(self):
self.run_command('cloudpipe-list')
self.assert_called('GET', '/os-cloudpipe')
def test_cloudpipe_create(self):
self.run_command('cloudpipe-create myproject')
body = {'cloudpipe': {'project_id': "myproject"}}
self.assert_called('POST', '/os-cloudpipe', body)
def test_cloudpipe_configure(self):
self.run_command('cloudpipe-configure 192.168.1.1 1234')
body = {'configure_project': {'vpn_ip': "192.168.1.1",
'vpn_port': '1234'}}
self.assert_called('PUT', '/os-cloudpipe/configure-project', body)
def test_backup(self):
self.run_command('backup sample-server back1 daily 1')
self.assert_called('POST', '/servers/1234/action',