From 0b1c535729f34cbf779b8377c6318f616c68169d Mon Sep 17 00:00:00 2001 From: "Jay Lau (Guangya Liu)" Date: Tue, 13 Jan 2015 17:51:15 -0500 Subject: [PATCH] Make replication controller client works 1) Rename replicationcontroller.py to replicationcontrollers.py 2) Add pod_data support in client (backend will be updated later) Change-Id: If315873a02bc896129e2ba41eb2a3d6fdd10b5ed Closes-Bug: #1410447 --- ...ller.py => test_replicationcontrollers.py} | 4 ++-- magnumclient/v1/client.py | 4 ++-- ...ontroller.py => replicationcontrollers.py} | 2 +- magnumclient/v1/shell.py | 19 ++++++++++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) rename magnumclient/tests/v1/{test_replicationcontroller.py => test_replicationcontrollers.py} (96%) rename magnumclient/v1/{replicationcontroller.py => replicationcontrollers.py} (97%) diff --git a/magnumclient/tests/v1/test_replicationcontroller.py b/magnumclient/tests/v1/test_replicationcontrollers.py similarity index 96% rename from magnumclient/tests/v1/test_replicationcontroller.py rename to magnumclient/tests/v1/test_replicationcontrollers.py index a6673c16..26ee3d7b 100644 --- a/magnumclient/tests/v1/test_replicationcontroller.py +++ b/magnumclient/tests/v1/test_replicationcontrollers.py @@ -18,7 +18,7 @@ import testtools from testtools import matchers from magnumclient.tests import utils -from magnumclient.v1 import replicationcontroller as rc +from magnumclient.v1 import replicationcontrollers as rcs RC1 = {'id': 123, @@ -77,7 +77,7 @@ class RCManagerTest(testtools.TestCase): def setUp(self): super(RCManagerTest, self).setUp() self.api = utils.FakeAPI(fake_responses) - self.mgr = rc.ReplicationControllerManager(self.api) + self.mgr = rcs.ReplicationControllerManager(self.api) def test_rc_list(self): rcs = self.mgr.list() diff --git a/magnumclient/v1/client.py b/magnumclient/v1/client.py index b5db3005..e9f4b332 100644 --- a/magnumclient/v1/client.py +++ b/magnumclient/v1/client.py @@ -22,7 +22,7 @@ from magnumclient.v1 import bays from magnumclient.v1 import containers from magnumclient.v1 import nodes from magnumclient.v1 import pods -from magnumclient.v1 import replicationcontroller as rc +from magnumclient.v1 import replicationcontrollers as rcs from magnumclient.v1 import services @@ -80,7 +80,7 @@ class Client(object): self.containers = containers.ContainerManager(self.http_client) self.nodes = nodes.NodeManager(self.http_client) self.pods = pods.PodManager(self.http_client) - self.rc = rc.ReplicationControllerManager(self.http_client) + self.rcs = rcs.ReplicationControllerManager(self.http_client) self.services = services.ServiceManager(self.http_client) def get_keystone_client(self, username=None, api_key=None, auth_url=None, diff --git a/magnumclient/v1/replicationcontroller.py b/magnumclient/v1/replicationcontrollers.py similarity index 97% rename from magnumclient/v1/replicationcontroller.py rename to magnumclient/v1/replicationcontrollers.py index 71d52487..2c94c4ab 100644 --- a/magnumclient/v1/replicationcontroller.py +++ b/magnumclient/v1/replicationcontrollers.py @@ -17,7 +17,7 @@ from magnumclient.common import utils from magnumclient import exceptions -CREATION_ATTRIBUTES = ['rc_definition_url'] +CREATION_ATTRIBUTES = ['bay_uuid', 'rc_definition_url', 'rc_data'] class ReplicationController(base.Resource): diff --git a/magnumclient/v1/shell.py b/magnumclient/v1/shell.py index 9537de83..e08cb853 100644 --- a/magnumclient/v1/shell.py +++ b/magnumclient/v1/shell.py @@ -241,14 +241,27 @@ def do_rc_list(cs, args): {'versions': _print_list_field('versions')}) -@utils.arg('--rc-file', - metavar='', +@utils.arg('--rc-url', + metavar='', help='Name/URL of the replication controller file to use for ' 'creating replication controllers.') +@utils.arg('--rc-file', + metavar='', + help='File path of the replication controller file to use for ' + 'creating replication controllers.') +@utils.arg('--bay-id', + required=True, + metavar='', + help='The bay ID.') def do_rc_create(cs, args): """Create a replication controller.""" opts = {} - opts['rc_definition_url'] = args.rc_file + opts['rc_definition_url'] = args.rc_url + opts['bay_uuid'] = args.bay_id + + if args.rc_file is not None and os.path.isfile(args.rc_file): + with open(args.rc_file, 'r') as f: + opts['rc_data'] = f.read() rc = cs.rcs.create(**opts) _show_rc(rc)