Accept 1 and 2 as version choices

- removes all unused imports
- update .gitignore with new venv path

Change-Id: I3e8199b72dc83268115133d7c73335ffb6060f9a
This commit is contained in:
Brian Waldon 2011-12-09 14:26:06 -05:00
parent 6509fe253f
commit a905e5fe07
32 changed files with 35 additions and 53 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
.coverage .coverage
.novaclient-venv .venv
*,cover *,cover
cover cover
*.pyc *.pyc

View File

@ -14,6 +14,7 @@
# under the License. # under the License.
import copy import copy
from novaclient.keystone import tenants from novaclient.keystone import tenants
from novaclient.keystone import users from novaclient.keystone import users

View File

@ -22,7 +22,6 @@ Command-line interface to the OpenStack Nova API.
import argparse import argparse
import httplib2 import httplib2
import os import os
import prettytable
import sys import sys
from novaclient import exceptions as exc from novaclient import exceptions as exc
@ -105,8 +104,10 @@ class OpenStackComputeShell(object):
try: try:
actions_module = { actions_module = {
'1': shell_v1_0,
'1.0': shell_v1_0, '1.0': shell_v1_0,
'1.1': shell_v1_1, '1.1': shell_v1_1,
'2': shell_v1_1,
}[version] }[version]
except KeyError: except KeyError:
actions_module = shell_v1_0 actions_module = shell_v1_0
@ -212,8 +213,10 @@ class OpenStackComputeShell(object):
def get_api_class(self, version): def get_api_class(self, version):
try: try:
return { return {
"1": shell_v1_0.CLIENT_CLASS,
"1.0": shell_v1_0.CLIENT_CLASS, "1.0": shell_v1_0.CLIENT_CLASS,
"1.1": shell_v1_1.CLIENT_CLASS, "1.1": shell_v1_1.CLIENT_CLASS,
"2": shell_v1_1.CLIENT_CLASS,
}[version] }[version]
except KeyError: except KeyError:
return shell_v1_0.CLIENT_CLASS return shell_v1_0.CLIENT_CLASS

View File

@ -20,7 +20,6 @@ Base utilities to build API operation managers and objects on top of.
""" """
from novaclient import base from novaclient import base
from novaclient import exceptions
# Python 2.4 compat # Python 2.4 compat

View File

@ -17,7 +17,6 @@
import getpass import getpass
import os import os
import uuid
from novaclient import exceptions from novaclient import exceptions
from novaclient import utils from novaclient import utils

View File

@ -16,7 +16,6 @@
""" """
Keypair interface (1.1 extension). Keypair interface (1.1 extension).
""" """
import os
from novaclient import base from novaclient import base

View File

@ -6,8 +6,6 @@ wrong the tests might raise AssertionError. I've indicated in comments the
places where actual behavior differs from the spec. places where actual behavior differs from the spec.
""" """
import novaclient.client
def assert_has_keys(dict, required=[], optional=[]): def assert_has_keys(dict, required=[], optional=[]):
keys = dict.keys() keys = dict.keys()
@ -15,7 +13,6 @@ def assert_has_keys(dict, required=[], optional=[]):
try: try:
assert k in keys assert k in keys
except AssertionError: except AssertionError:
allowed_keys = set(required) | set(optional)
extra_keys = set(keys).difference(set(required + optional)) extra_keys = set(keys).difference(set(required + optional))
raise AssertionError("found unexpected keys: %s" % raise AssertionError("found unexpected keys: %s" %
list(extra_keys)) list(extra_keys))
@ -50,7 +47,6 @@ class FakeClient(object):
found = False found = False
for entry in self.client.callstack: for entry in self.client.callstack:
called = entry[0:2]
if expected == entry[0:2]: if expected == entry[0:2]:
found = True found = True
break break

View File

@ -1,10 +1,8 @@
import mock
from novaclient import base from novaclient import base
from novaclient import exceptions from novaclient import exceptions
from novaclient.v1_0 import flavors from novaclient.v1_0 import flavors
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,9 +1,8 @@
import os import os
import mock
import httplib2 import httplib2
from novaclient.shell import OpenStackComputeShell
from novaclient import exceptions from novaclient import exceptions
import novaclient.shell
from tests import utils from tests import utils
@ -23,7 +22,7 @@ class ShellTest(utils.TestCase):
# Make a fake shell object, a helping wrapper to call it, and a quick # Make a fake shell object, a helping wrapper to call it, and a quick
# way of asserting that certain API calls were made. # way of asserting that certain API calls were made.
global shell, _shell, assert_called, assert_called_anytime global shell, _shell, assert_called, assert_called_anytime
_shell = OpenStackComputeShell() _shell = novaclient.shell.OpenStackComputeShell()
shell = lambda cmd: _shell.main(cmd.split()) shell = lambda cmd: _shell.main(cmd.split())
def tearDown(self): def tearDown(self):

View File

@ -1,6 +1,4 @@
import httplib2 import httplib2
import urllib
import urlparse
from novaclient import client as base_client from novaclient import client as base_client
from novaclient.v1_0 import client from novaclient.v1_0 import client

View File

@ -1,7 +1,7 @@
import StringIO import StringIO
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()
@ -10,7 +10,7 @@ cs = fakes.FakeClient()
class AccountsTest(utils.TestCase): class AccountsTest(utils.TestCase):
def test_instance_creation_for_account(self): def test_instance_creation_for_account(self):
s = cs.accounts.create_instance_for( cs.accounts.create_instance_for(
account_id='test_account', account_id='test_account',
name="My server", name="My server",
image=1, image=1,

View File

@ -1,8 +1,8 @@
import httplib2 import httplib2
import mock import mock
from novaclient.v1_0 import client
from novaclient import exceptions from novaclient import exceptions
from novaclient.v1_0 import client
from tests import utils from tests import utils

View File

@ -1,6 +1,6 @@
from novaclient.v1_0 import backup_schedules from novaclient.v1_0 import backup_schedules
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,7 +1,7 @@
from novaclient import exceptions from novaclient import exceptions
from novaclient.v1_0 import flavors from novaclient.v1_0 import flavors
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,6 +1,6 @@
from novaclient.v1_0 import images from novaclient.v1_0 import images
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,6 +1,6 @@
from novaclient.v1_0 import ipgroups from novaclient.v1_0 import ipgroups
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,8 +1,8 @@
import StringIO import StringIO
from novaclient.v1_0 import servers from novaclient.v1_0 import servers
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,10 +1,10 @@
import os import os
import mock import mock
from novaclient.shell import OpenStackComputeShell
from novaclient import exceptions from novaclient import exceptions
from tests.v1_0 import fakes import novaclient.shell
from tests import utils from tests import utils
from tests.v1_0 import fakes
class ShellTest(utils.TestCase): class ShellTest(utils.TestCase):
@ -19,7 +19,7 @@ class ShellTest(utils.TestCase):
'NOVA_VERSION': '1.0', 'NOVA_VERSION': '1.0',
} }
self.shell = OpenStackComputeShell() self.shell = novaclient.shell.OpenStackComputeShell()
self.shell.get_api_class = lambda *_: fakes.FakeClient self.shell.get_api_class = lambda *_: fakes.FakeClient
def tearDown(self): def tearDown(self):

View File

@ -1,9 +1,7 @@
import StringIO
from novaclient.v1_0 import zones from novaclient.v1_0 import zones
from tests.v1_0 import fakes
from tests import utils from tests import utils
from tests.v1_0 import fakes
os = fakes.FakeClient() os = fakes.FakeClient()

View File

@ -19,7 +19,6 @@ def assert_has_keys(dict, required=[], optional=[]):
keys = dict.keys() keys = dict.keys()
for k in required: for k in required:
assert_in(k, keys, "required key %s missing from %s" % (k, dict)) assert_in(k, keys, "required key %s missing from %s" % (k, dict))
allowed_keys = set(required) | set(optional)
extra_keys = set(keys).difference(set(required + optional)) extra_keys = set(keys).difference(set(required + optional))
if extra_keys: if extra_keys:
fail("found unexpected keys: %s" % list(extra_keys)) fail("found unexpected keys: %s" % list(extra_keys))

View File

@ -3,7 +3,6 @@ import json
import mock import mock
import urlparse import urlparse
from novaclient.v1_1 import client from novaclient.v1_1 import client
from novaclient import exceptions from novaclient import exceptions
from tests import utils from tests import utils

View File

@ -1,7 +1,7 @@
from novaclient import exceptions from novaclient import exceptions
from novaclient.v1_1 import flavors from novaclient.v1_1 import flavors
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,7 +1,6 @@
from novaclient import exceptions
from novaclient.v1_1 import floating_ips from novaclient.v1_1 import floating_ips
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,6 +1,6 @@
from novaclient.v1_1 import images from novaclient.v1_1 import images
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,6 +1,6 @@
from novaclient.v1_1 import keypairs from novaclient.v1_1 import keypairs
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,7 +1,7 @@
from novaclient.v1_1 import limits from novaclient.v1_1 import limits
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -13,10 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from novaclient import exceptions
from novaclient.v1_1 import quotas
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()
@ -26,12 +24,12 @@ class QuotaSetsTest(utils.TestCase):
def test_tenant_quotas_get(self): def test_tenant_quotas_get(self):
tenant_id = 'test' tenant_id = 'test'
qs = cs.quotas.get(tenant_id) cs.quotas.get(tenant_id)
cs.assert_called('GET', '/os-quota-sets/%s' % tenant_id) cs.assert_called('GET', '/os-quota-sets/%s' % tenant_id)
def test_tenant_quotas_defaults(self): def test_tenant_quotas_defaults(self):
tenant_id = 'test' tenant_id = 'test'
q = cs.quotas.defaults(tenant_id) cs.quotas.defaults(tenant_id)
cs.assert_called('GET', '/os-quota-sets/%s/defaults' % tenant_id) cs.assert_called('GET', '/os-quota-sets/%s/defaults' % tenant_id)
def test_update_quota(self): def test_update_quota(self):

View File

@ -1,7 +1,6 @@
from novaclient import exceptions
from novaclient.v1_1 import security_group_rules from novaclient.v1_1 import security_group_rules
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,7 +1,6 @@
from novaclient import exceptions
from novaclient.v1_1 import security_groups from novaclient.v1_1 import security_groups
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,8 +1,8 @@
import StringIO import StringIO
from novaclient.v1_1 import servers from novaclient.v1_1 import servers
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -3,7 +3,7 @@ import mock
import sys import sys
import tempfile import tempfile
from novaclient.shell import OpenStackComputeShell import novaclient.shell
from novaclient import exceptions from novaclient import exceptions
from tests.v1_1 import fakes from tests.v1_1 import fakes
from tests import utils from tests import utils
@ -23,7 +23,7 @@ class ShellTest(utils.TestCase):
'NOVA_URL': 'http://no.where', 'NOVA_URL': 'http://no.where',
} }
self.shell = OpenStackComputeShell() self.shell = novaclient.shell.OpenStackComputeShell()
self.shell.get_api_class = lambda *_: fakes.FakeClient self.shell.get_api_class = lambda *_: fakes.FakeClient
def tearDown(self): def tearDown(self):

View File

@ -1,8 +1,7 @@
import StringIO
from novaclient.v1_1 import zones from novaclient.v1_1 import zones
from tests.v1_1 import fakes
from tests import utils from tests import utils
from tests.v1_1 import fakes
os = fakes.FakeClient() os = fakes.FakeClient()