From 5e8ae369cddf0b20003c33b8576769f11a723e5c Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 22 Dec 2010 16:43:47 -0800 Subject: [PATCH 01/10] Basic Easy API functionality --- nova/tests/easy_unittest.py | 85 +++++++++++++++++++++++++++++++++++++ run_tests.py | 1 + 2 files changed, 86 insertions(+) create mode 100644 nova/tests/easy_unittest.py diff --git a/nova/tests/easy_unittest.py b/nova/tests/easy_unittest.py new file mode 100644 index 00000000..ed223831 --- /dev/null +++ b/nova/tests/easy_unittest.py @@ -0,0 +1,85 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Tests for Easy API.""" + +import json +import logging + +import webob + +from nova import context +from nova import exception +from nova import test +from nova import utils +from nova.api import easy + + +class FakeService(object): + def echo(self, context, data): + return {'data': data} + + def context(self, context): + return {'user': context.user_id, + 'project': context.project_id} + + +class EasyTestCase(test.TestCase): + def setUp(self): + super(EasyTestCase, self).setUp() + easy.register_service('fake', FakeService()) + self.router = easy.ReqParamsMiddleware( + easy.JsonParamsMiddleware( + easy.SundayMorning())) + self.auth_router = easy.DelegatedAuthMiddleware(self.router) + self.context = context.RequestContext('user1', 'proj1') + + def tearDown(self): + easy.EASY_ROUTES = {} + + def test_delegated_auth(self): + req = webob.Request.blank('/fake/context') + req.headers['X-OpenStack-User'] = 'user1' + req.headers['X-OpenStack-Project'] = 'proj1' + resp = req.get_response(self.auth_router) + data = json.loads(resp.body) + self.assertEqual(data['user'], 'user1') + self.assertEqual(data['project'], 'proj1') + + def test_json_params(self): + req = webob.Request.blank('/fake/echo') + req.environ['openstack.context'] = self.context + req.method = 'POST' + req.body = 'json=%s' % json.dumps({'data': 'foo'}) + resp = req.get_response(self.router) + resp_parsed = json.loads(resp.body) + self.assertEqual(resp_parsed['data'], 'foo') + + def test_req_params(self): + req = webob.Request.blank('/fake/echo') + req.environ['openstack.context'] = self.context + req.method = 'POST' + req.body = 'data=foo' + resp = req.get_response(self.router) + resp_parsed = json.loads(resp.body) + self.assertEqual(resp_parsed['data'], 'foo') + + def test_proxy(self): + proxy = easy.Proxy(self.router) + rv = proxy.fake.echo(self.context, data='baz') + self.assertEqual(rv['data'], 'baz') diff --git a/run_tests.py b/run_tests.py index 6a4b7f1a..d3cf8f69 100644 --- a/run_tests.py +++ b/run_tests.py @@ -59,6 +59,7 @@ from nova.tests.api_unittest import * from nova.tests.auth_unittest import * from nova.tests.cloud_unittest import * from nova.tests.compute_unittest import * +from nova.tests.easy_unittest import * from nova.tests.flags_unittest import * from nova.tests.misc_unittest import * from nova.tests.network_unittest import * From 614526b7d35f58640854690cfa715a6296621a51 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 22 Dec 2010 16:52:16 -0800 Subject: [PATCH 02/10] remove some yields that snuck in --- nova/tests/cloud_unittest.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nova/tests/cloud_unittest.py b/nova/tests/cloud_unittest.py index 70d2c44d..1398a986 100644 --- a/nova/tests/cloud_unittest.py +++ b/nova/tests/cloud_unittest.py @@ -140,15 +140,15 @@ class CloudTestCase(test.TestCase): kwargs = {'image_id': image_id, 'instance_type': instance_type, 'max_count': max_count} - rv = yield self.cloud.run_instances(self.context, **kwargs) + rv = self.cloud.run_instances(self.context, **kwargs) instance_id = rv['instancesSet'][0]['instanceId'] - output = yield self.cloud.get_console_output(context=self.context, + output = self.cloud.get_console_output(context=self.context, instance_id=[instance_id]) self.assertEquals(b64decode(output['output']), 'FAKE CONSOLE OUTPUT') # TODO(soren): We need this until we can stop polling in the rpc code # for unit tests. greenthread.sleep(0.3) - rv = yield self.cloud.terminate_instances(self.context, [instance_id]) + rv = self.cloud.terminate_instances(self.context, [instance_id]) def test_key_generation(self): result = self._create_key('test') @@ -186,7 +186,7 @@ class CloudTestCase(test.TestCase): kwargs = {'image_id': image_id, 'instance_type': instance_type, 'max_count': max_count} - rv = yield self.cloud.run_instances(self.context, **kwargs) + rv = self.cloud.run_instances(self.context, **kwargs) # TODO: check for proper response instance_id = rv['reservationSet'][0].keys()[0] instance = rv['reservationSet'][0][instance_id][0] @@ -209,7 +209,7 @@ class CloudTestCase(test.TestCase): for instance in reservations[reservations.keys()[0]]: instance_id = instance['instance_id'] logging.debug("Terminating instance %s" % instance_id) - rv = yield self.compute.terminate_instance(instance_id) + rv = self.compute.terminate_instance(instance_id) def test_instance_update_state(self): def instance(num): From 89df9c1e9dbf05b841da7963966d3d0b01217f7f Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 22 Dec 2010 17:53:42 -0800 Subject: [PATCH 03/10] added tests to ensure the easy api works as a backend for Compute API --- nova/tests/cloud_unittest.py | 2 ++ nova/tests/compute_unittest.py | 9 ++++++--- nova/tests/easy_unittest.py | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/nova/tests/cloud_unittest.py b/nova/tests/cloud_unittest.py index 1398a986..4439c131 100644 --- a/nova/tests/cloud_unittest.py +++ b/nova/tests/cloud_unittest.py @@ -22,6 +22,7 @@ import logging from M2Crypto import BIO from M2Crypto import RSA import os +import shutil import tempfile import time @@ -293,6 +294,7 @@ class CloudTestCase(test.TestCase): self.assertEqual('Foo Img', img.metadata['description']) self._fake_set_image_description(self.context, 'ami-testing', '') self.assertEqual('', img.metadata['description']) + shutil.rmtree(pathdir) def test_update_of_instance_display_fields(self): inst = db.instance_create(self.context, {}) diff --git a/nova/tests/compute_unittest.py b/nova/tests/compute_unittest.py index 348bb335..0bebd1c5 100644 --- a/nova/tests/compute_unittest.py +++ b/nova/tests/compute_unittest.py @@ -75,7 +75,7 @@ class ComputeTestCase(test.TestCase): ref = self.compute_api.create_instances(self.context, FLAGS.default_instance_type, None, **instance) try: - self.assertNotEqual(ref[0].display_name, None) + self.assertNotEqual(ref[0]['display_name'], None) finally: db.instance_destroy(self.context, ref[0]['id']) @@ -87,9 +87,12 @@ class ComputeTestCase(test.TestCase): 'project_id': self.project.id} group = db.security_group_create(self.context, values) ref = self.compute_api.create_instances(self.context, - FLAGS.default_instance_type, None, security_group=['default']) + instance_type=FLAGS.default_instance_type, + image_id=None, + security_group=['default']) try: - self.assertEqual(len(ref[0]['security_groups']), 1) + self.assertEqual(len(db.security_group_get_by_instance( + self.context, ref[0]['id'])), 1) finally: db.security_group_destroy(self.context, group['id']) db.instance_destroy(self.context, ref[0]['id']) diff --git a/nova/tests/easy_unittest.py b/nova/tests/easy_unittest.py index ed223831..81990d84 100644 --- a/nova/tests/easy_unittest.py +++ b/nova/tests/easy_unittest.py @@ -28,7 +28,8 @@ from nova import exception from nova import test from nova import utils from nova.api import easy - +from nova.compute import api as compute_api +from nova.tests import cloud_unittest class FakeService(object): def echo(self, context, data): @@ -83,3 +84,19 @@ class EasyTestCase(test.TestCase): proxy = easy.Proxy(self.router) rv = proxy.fake.echo(self.context, data='baz') self.assertEqual(rv['data'], 'baz') + + +class EasyCloudTestCase(cloud_unittest.CloudTestCase): + def setUp(self): + super(EasyCloudTestCase, self).setUp() + compute_handle = compute_api.ComputeAPI(self.cloud.network_manager, + self.cloud.image_service) + easy.register_service('compute', compute_handle) + self.router = easy.JsonParamsMiddleware(easy.SundayMorning()) + proxy = easy.Proxy(self.router) + self.cloud.compute_api = proxy.compute + + def tearDown(self): + super(EasyCloudTestCase, self).tearDown() + easy.EASY_ROUTES = {} + From dcf59211af4d945ec0f0cc0673abefac7db9281d Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 27 Dec 2010 15:15:24 -0800 Subject: [PATCH 04/10] Added stack command-line tool --- bin/nova-easy-api | 61 +++++++++++++++ bin/stack | 145 ++++++++++++++++++++++++++++++++++++ nova/tests/easy_unittest.py | 6 +- 3 files changed, 209 insertions(+), 3 deletions(-) create mode 100755 bin/nova-easy-api create mode 100755 bin/stack diff --git a/bin/nova-easy-api b/bin/nova-easy-api new file mode 100755 index 00000000..e8e86b4f --- /dev/null +++ b/bin/nova-easy-api @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# pylint: disable-msg=C0103 +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Starter script for Nova Easy API.""" + +import gettext +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +gettext.install('nova', unicode=1) + +from nova import flags +from nova import utils +from nova import wsgi +from nova.api import easy +from nova.compute import api as compute_api + + +FLAGS = flags.FLAGS +flags.DEFINE_integer('easy_port', 8001, 'Easy API port') +flags.DEFINE_string('easy_host', '0.0.0.0', 'Easy API host') + +if __name__ == '__main__': + utils.default_flagfile() + FLAGS(sys.argv) + + easy.register_service('compute', compute_api.ComputeAPI()) + easy.register_service('reflect', easy.Reflection()) + router = easy.SundayMorning() + with_json = easy.JsonParamsMiddleware(router) + with_req = easy.ReqParamsMiddleware(with_json) + with_auth = easy.DelegatedAuthMiddleware(with_req) + + server = wsgi.Server() + server.start(with_auth, FLAGS.easy_port, host=FLAGS.easy_host) + server.wait() diff --git a/bin/stack b/bin/stack new file mode 100755 index 00000000..284dbf4f --- /dev/null +++ b/bin/stack @@ -0,0 +1,145 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""CLI for the Easy API.""" + +import eventlet +eventlet.monkey_patch() + +import os +import pprint +import sys +import textwrap +import urllib +import urllib2 + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +import gflags +from nova import utils + + +FLAGS = gflags.FLAGS +gflags.DEFINE_string('host', '127.0.0.1', 'Easy API host') +gflags.DEFINE_integer('port', 8001, 'Easy API host') +gflags.DEFINE_string('user', 'user1', 'Easy API username') +gflags.DEFINE_string('project', 'proj1', 'Easy API project') + + +USAGE = """usage: stack [options] [arg1=value arg2=value] + + `stack help` should output the list of available controllers + `stack ` should output the available methods for that controller + `stack help ` should do the same + `stack help ` should output info for a method +""" + + +def format_help(d): + """Format help text, keys are labels and values are descriptions.""" + indent = max([len(k) for k in d]) + out = [] + for k, v in d.iteritems(): + t = textwrap.TextWrapper(initial_indent=' %s ' % k.ljust(indent), + subsequent_indent=' ' * (indent + 6)) + out.extend(t.wrap(v)) + return out + + +def help_all(): + rv = do_request('reflect', 'get_controllers') + out = format_help(rv) + return (USAGE + str(FLAGS.MainModuleHelp()) + + '\n\nAvailable controllers:\n' + + '\n'.join(out) + '\n') + + +def help_controller(controller): + rv = do_request('reflect', 'get_methods') + methods = dict([(k.split('/')[2], v) for k, v in rv.iteritems() + if k.startswith('/%s' % controller)]) + return ('Available methods for %s:\n' % controller + + '\n'.join(format_help(methods))) + + +def help_method(controller, method): + rv = do_request('reflect', + 'get_method_info', + {'method': '/%s/%s' % (controller, method)}) + + sig = '%s(%s):' % (method, ', '.join(['='.join(x) for x in rv['args']])) + out = textwrap.wrap(sig, subsequent_indent=' ' * len('%s(' % method)) + out.append('\n' + rv['doc']) + return '\n'.join(out) + + +def do_request(controller, method, params=None): + if params: + data = urllib.urlencode(params) + else: + data = None + + url = 'http://%s:%s/%s/%s' % (FLAGS.host, FLAGS.port, controller, method) + headers = {'X-OpenStack-User': FLAGS.user, + 'X-OpenStack-Project': FLAGS.project} + + req = urllib2.Request(url, data, headers) + resp = urllib2.urlopen(req) + return utils.loads(resp.read()) + + +if __name__ == '__main__': + args = FLAGS(sys.argv) + + cmd = args.pop(0) + if not args: + print help_all() + sys.exit() + + first = args.pop(0) + if first == 'help': + action = help_all + params = [] + if args: + params.append(args.pop(0)) + action = help_controller + if args: + params.append(args.pop(0)) + action = help_method + print action(*params) + sys.exit(0) + + controller = first + if not args: + print help_controller(controller) + sys.exit() + + method = args.pop(0) + params = {} + for x in args: + key, value = args.split('=', 1) + params[key] = value + + pprint.pprint(do_request(controller, method, params)) diff --git a/nova/tests/easy_unittest.py b/nova/tests/easy_unittest.py index 81990d84..cd13c771 100644 --- a/nova/tests/easy_unittest.py +++ b/nova/tests/easy_unittest.py @@ -31,6 +31,7 @@ from nova.api import easy from nova.compute import api as compute_api from nova.tests import cloud_unittest + class FakeService(object): def echo(self, context, data): return {'data': data} @@ -49,7 +50,7 @@ class EasyTestCase(test.TestCase): easy.SundayMorning())) self.auth_router = easy.DelegatedAuthMiddleware(self.router) self.context = context.RequestContext('user1', 'proj1') - + def tearDown(self): easy.EASY_ROUTES = {} @@ -61,7 +62,7 @@ class EasyTestCase(test.TestCase): data = json.loads(resp.body) self.assertEqual(data['user'], 'user1') self.assertEqual(data['project'], 'proj1') - + def test_json_params(self): req = webob.Request.blank('/fake/echo') req.environ['openstack.context'] = self.context @@ -99,4 +100,3 @@ class EasyCloudTestCase(cloud_unittest.CloudTestCase): def tearDown(self): super(EasyCloudTestCase, self).tearDown() easy.EASY_ROUTES = {} - From 6e8112123129253e58cf5bc90250daa9e708a70e Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 4 Jan 2011 14:07:46 -0800 Subject: [PATCH 05/10] rename Easy API to Direct API --- bin/{nova-easy-api => nova-direct-api} | 20 +++++------ .../{easy_unittest.py => test_direct.py} | 36 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) rename bin/{nova-easy-api => nova-direct-api} (75%) rename nova/tests/{easy_unittest.py => test_direct.py} (77%) diff --git a/bin/nova-easy-api b/bin/nova-direct-api similarity index 75% rename from bin/nova-easy-api rename to bin/nova-direct-api index e8e86b4f..43046e6c 100755 --- a/bin/nova-easy-api +++ b/bin/nova-direct-api @@ -37,25 +37,25 @@ gettext.install('nova', unicode=1) from nova import flags from nova import utils from nova import wsgi -from nova.api import easy +from nova.api import direct from nova.compute import api as compute_api FLAGS = flags.FLAGS -flags.DEFINE_integer('easy_port', 8001, 'Easy API port') -flags.DEFINE_string('easy_host', '0.0.0.0', 'Easy API host') +flags.DEFINE_integer('direct_port', 8001, 'Direct API port') +flags.DEFINE_string('direct_host', '0.0.0.0', 'Direct API host') if __name__ == '__main__': utils.default_flagfile() FLAGS(sys.argv) - easy.register_service('compute', compute_api.ComputeAPI()) - easy.register_service('reflect', easy.Reflection()) - router = easy.SundayMorning() - with_json = easy.JsonParamsMiddleware(router) - with_req = easy.ReqParamsMiddleware(with_json) - with_auth = easy.DelegatedAuthMiddleware(with_req) + direct.register_service('compute', compute_api.ComputeAPI()) + direct.register_service('reflect', direct.Reflection()) + router = direct.Router() + with_json = direct.JsonParamsMiddleware(router) + with_req = direct.PostParamsMiddleware(with_json) + with_auth = direct.DelegatedAuthMiddleware(with_req) server = wsgi.Server() - server.start(with_auth, FLAGS.easy_port, host=FLAGS.easy_host) + server.start(with_auth, FLAGS.direct_port, host=FLAGS.direct_host) server.wait() diff --git a/nova/tests/easy_unittest.py b/nova/tests/test_direct.py similarity index 77% rename from nova/tests/easy_unittest.py rename to nova/tests/test_direct.py index cd13c771..d73c64ce 100644 --- a/nova/tests/easy_unittest.py +++ b/nova/tests/test_direct.py @@ -16,7 +16,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""Tests for Easy API.""" +"""Tests for Direct API.""" import json import logging @@ -27,7 +27,7 @@ from nova import context from nova import exception from nova import test from nova import utils -from nova.api import easy +from nova.api import direct from nova.compute import api as compute_api from nova.tests import cloud_unittest @@ -41,18 +41,18 @@ class FakeService(object): 'project': context.project_id} -class EasyTestCase(test.TestCase): +class DirectTestCase(test.TestCase): def setUp(self): - super(EasyTestCase, self).setUp() - easy.register_service('fake', FakeService()) - self.router = easy.ReqParamsMiddleware( - easy.JsonParamsMiddleware( - easy.SundayMorning())) - self.auth_router = easy.DelegatedAuthMiddleware(self.router) + super(DirectTestCase, self).setUp() + direct.register_service('fake', FakeService()) + self.router = direct.PostParamsMiddleware( + direct.JsonParamsMiddleware( + direct.Router())) + self.auth_router = direct.DelegatedAuthMiddleware(self.router) self.context = context.RequestContext('user1', 'proj1') def tearDown(self): - easy.EASY_ROUTES = {} + direct.ROUTES = {} def test_delegated_auth(self): req = webob.Request.blank('/fake/context') @@ -82,21 +82,21 @@ class EasyTestCase(test.TestCase): self.assertEqual(resp_parsed['data'], 'foo') def test_proxy(self): - proxy = easy.Proxy(self.router) + proxy = direct.Proxy(self.router) rv = proxy.fake.echo(self.context, data='baz') self.assertEqual(rv['data'], 'baz') -class EasyCloudTestCase(cloud_unittest.CloudTestCase): +class DirectCloudTestCase(cloud_unittest.CloudTestCase): def setUp(self): - super(EasyCloudTestCase, self).setUp() + super(DirectCloudTestCase, self).setUp() compute_handle = compute_api.ComputeAPI(self.cloud.network_manager, self.cloud.image_service) - easy.register_service('compute', compute_handle) - self.router = easy.JsonParamsMiddleware(easy.SundayMorning()) - proxy = easy.Proxy(self.router) + direct.register_service('compute', compute_handle) + self.router = direct.JsonParamsMiddleware(direct.Router()) + proxy = direct.Proxy(self.router) self.cloud.compute_api = proxy.compute def tearDown(self): - super(EasyCloudTestCase, self).tearDown() - easy.EASY_ROUTES = {} + super(DirectCloudTestCase, self).tearDown() + direct.ROUTES = {} From 4cb5b29071a98c45c088f7ce51f881eaa29e8859 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 4 Jan 2011 14:37:04 -0800 Subject: [PATCH 06/10] fix typo in stack tool --- bin/stack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/stack b/bin/stack index 284dbf4f..42feacd6 100755 --- a/bin/stack +++ b/bin/stack @@ -139,7 +139,7 @@ if __name__ == '__main__': method = args.pop(0) params = {} for x in args: - key, value = args.split('=', 1) + key, value = x.split('=', 1) params[key] = value pprint.pprint(do_request(controller, method, params)) From 862f28c0e210b77c397268598fe0cefdcede4f9e Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 4 Jan 2011 14:39:48 -0800 Subject: [PATCH 07/10] rename easy to direct in the scripts --- bin/nova-direct-api | 2 +- bin/stack | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/nova-direct-api b/bin/nova-direct-api index 43046e6c..e7dd14fb 100755 --- a/bin/nova-direct-api +++ b/bin/nova-direct-api @@ -18,7 +18,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Starter script for Nova Easy API.""" +"""Starter script for Nova Direct API.""" import gettext import os diff --git a/bin/stack b/bin/stack index 42feacd6..7a6ce596 100755 --- a/bin/stack +++ b/bin/stack @@ -17,7 +17,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""CLI for the Easy API.""" +"""CLI for the Direct API.""" import eventlet eventlet.monkey_patch() @@ -42,10 +42,10 @@ from nova import utils FLAGS = gflags.FLAGS -gflags.DEFINE_string('host', '127.0.0.1', 'Easy API host') -gflags.DEFINE_integer('port', 8001, 'Easy API host') -gflags.DEFINE_string('user', 'user1', 'Easy API username') -gflags.DEFINE_string('project', 'proj1', 'Easy API project') +gflags.DEFINE_string('host', '127.0.0.1', 'Direct API host') +gflags.DEFINE_integer('port', 8001, 'Direct API host') +gflags.DEFINE_string('user', 'user1', 'Direct API username') +gflags.DEFINE_string('project', 'proj1', 'Direct API project') USAGE = """usage: stack [options] [arg1=value arg2=value] From e544747620fcda84bcefb39d719960ae9922de23 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Fri, 7 Jan 2011 13:02:55 -0800 Subject: [PATCH 08/10] set the hostname factory in the service init --- nova/tests/test_direct.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_direct.py b/nova/tests/test_direct.py index d73c64ce..78ad8ffe 100644 --- a/nova/tests/test_direct.py +++ b/nova/tests/test_direct.py @@ -72,7 +72,7 @@ class DirectTestCase(test.TestCase): resp_parsed = json.loads(resp.body) self.assertEqual(resp_parsed['data'], 'foo') - def test_req_params(self): + def test_post_params(self): req = webob.Request.blank('/fake/echo') req.environ['openstack.context'] = self.context req.method = 'POST' From 2ab3145b9d706eb50169f3c36ff0ec3929900358 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Fri, 7 Jan 2011 16:05:06 -0800 Subject: [PATCH 09/10] some small cleanups --- nova/tests/test_direct.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nova/tests/test_direct.py b/nova/tests/test_direct.py index 5c6ecd90..8a74b229 100644 --- a/nova/tests/test_direct.py +++ b/nova/tests/test_direct.py @@ -101,7 +101,3 @@ class DirectCloudTestCase(test_cloud.CloudTestCase): def tearDown(self): super(DirectCloudTestCase, self).tearDown() direct.ROUTES = {} - -if __name__ == '__main__': - import unittest - unittest.main() From db99e0f29794cb24525db20b3f55668a868b1be6 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Fri, 14 Jan 2011 17:44:47 -0800 Subject: [PATCH 10/10] pep8 --- nova/tests/test_console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/tests/test_console.py b/nova/tests/test_console.py index 69e2109e..85bf9445 100644 --- a/nova/tests/test_console.py +++ b/nova/tests/test_console.py @@ -130,4 +130,3 @@ class ConsoleTestCase(test.TestCase): self.context, console_id) db.instance_destroy(self.context, instance_id) -