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:
parent
6509fe253f
commit
a905e5fe07
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
.coverage
|
||||
.novaclient-venv
|
||||
.venv
|
||||
*,cover
|
||||
cover
|
||||
*.pyc
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
|
||||
from novaclient.keystone import tenants
|
||||
from novaclient.keystone import users
|
||||
|
||||
|
@ -22,7 +22,6 @@ Command-line interface to the OpenStack Nova API.
|
||||
import argparse
|
||||
import httplib2
|
||||
import os
|
||||
import prettytable
|
||||
import sys
|
||||
|
||||
from novaclient import exceptions as exc
|
||||
@ -105,8 +104,10 @@ class OpenStackComputeShell(object):
|
||||
|
||||
try:
|
||||
actions_module = {
|
||||
'1': shell_v1_0,
|
||||
'1.0': shell_v1_0,
|
||||
'1.1': shell_v1_1,
|
||||
'2': shell_v1_1,
|
||||
}[version]
|
||||
except KeyError:
|
||||
actions_module = shell_v1_0
|
||||
@ -212,8 +213,10 @@ class OpenStackComputeShell(object):
|
||||
def get_api_class(self, version):
|
||||
try:
|
||||
return {
|
||||
"1": shell_v1_0.CLIENT_CLASS,
|
||||
"1.0": shell_v1_0.CLIENT_CLASS,
|
||||
"1.1": shell_v1_1.CLIENT_CLASS,
|
||||
"2": shell_v1_1.CLIENT_CLASS,
|
||||
}[version]
|
||||
except KeyError:
|
||||
return shell_v1_0.CLIENT_CLASS
|
||||
|
@ -20,7 +20,6 @@ Base utilities to build API operation managers and objects on top of.
|
||||
"""
|
||||
|
||||
from novaclient import base
|
||||
from novaclient import exceptions
|
||||
|
||||
|
||||
# Python 2.4 compat
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import getpass
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from novaclient import exceptions
|
||||
from novaclient import utils
|
||||
|
@ -16,7 +16,6 @@
|
||||
"""
|
||||
Keypair interface (1.1 extension).
|
||||
"""
|
||||
import os
|
||||
|
||||
from novaclient import base
|
||||
|
||||
|
@ -6,8 +6,6 @@ wrong the tests might raise AssertionError. I've indicated in comments the
|
||||
places where actual behavior differs from the spec.
|
||||
"""
|
||||
|
||||
import novaclient.client
|
||||
|
||||
|
||||
def assert_has_keys(dict, required=[], optional=[]):
|
||||
keys = dict.keys()
|
||||
@ -15,7 +13,6 @@ def assert_has_keys(dict, required=[], optional=[]):
|
||||
try:
|
||||
assert k in keys
|
||||
except AssertionError:
|
||||
allowed_keys = set(required) | set(optional)
|
||||
extra_keys = set(keys).difference(set(required + optional))
|
||||
raise AssertionError("found unexpected keys: %s" %
|
||||
list(extra_keys))
|
||||
@ -50,7 +47,6 @@ class FakeClient(object):
|
||||
|
||||
found = False
|
||||
for entry in self.client.callstack:
|
||||
called = entry[0:2]
|
||||
if expected == entry[0:2]:
|
||||
found = True
|
||||
break
|
||||
|
@ -1,10 +1,8 @@
|
||||
import mock
|
||||
|
||||
from novaclient import base
|
||||
from novaclient import exceptions
|
||||
from novaclient.v1_0 import flavors
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,9 +1,8 @@
|
||||
import os
|
||||
import mock
|
||||
import httplib2
|
||||
|
||||
from novaclient.shell import OpenStackComputeShell
|
||||
from novaclient import exceptions
|
||||
import novaclient.shell
|
||||
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
|
||||
# way of asserting that certain API calls were made.
|
||||
global shell, _shell, assert_called, assert_called_anytime
|
||||
_shell = OpenStackComputeShell()
|
||||
_shell = novaclient.shell.OpenStackComputeShell()
|
||||
shell = lambda cmd: _shell.main(cmd.split())
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -1,6 +1,4 @@
|
||||
import httplib2
|
||||
import urllib
|
||||
import urlparse
|
||||
|
||||
from novaclient import client as base_client
|
||||
from novaclient.v1_0 import client
|
||||
|
@ -1,7 +1,7 @@
|
||||
import StringIO
|
||||
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
@ -10,7 +10,7 @@ cs = fakes.FakeClient()
|
||||
class AccountsTest(utils.TestCase):
|
||||
|
||||
def test_instance_creation_for_account(self):
|
||||
s = cs.accounts.create_instance_for(
|
||||
cs.accounts.create_instance_for(
|
||||
account_id='test_account',
|
||||
name="My server",
|
||||
image=1,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import httplib2
|
||||
import mock
|
||||
|
||||
from novaclient.v1_0 import client
|
||||
from novaclient import exceptions
|
||||
from novaclient.v1_0 import client
|
||||
from tests import utils
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from novaclient.v1_0 import backup_schedules
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,7 +1,7 @@
|
||||
from novaclient import exceptions
|
||||
from novaclient.v1_0 import flavors
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,6 +1,6 @@
|
||||
from novaclient.v1_0 import images
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,6 +1,6 @@
|
||||
from novaclient.v1_0 import ipgroups
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,8 +1,8 @@
|
||||
import StringIO
|
||||
|
||||
from novaclient.v1_0 import servers
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,10 +1,10 @@
|
||||
import os
|
||||
import mock
|
||||
|
||||
from novaclient.shell import OpenStackComputeShell
|
||||
from novaclient import exceptions
|
||||
from tests.v1_0 import fakes
|
||||
import novaclient.shell
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
class ShellTest(utils.TestCase):
|
||||
@ -19,7 +19,7 @@ class ShellTest(utils.TestCase):
|
||||
'NOVA_VERSION': '1.0',
|
||||
}
|
||||
|
||||
self.shell = OpenStackComputeShell()
|
||||
self.shell = novaclient.shell.OpenStackComputeShell()
|
||||
self.shell.get_api_class = lambda *_: fakes.FakeClient
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -1,9 +1,7 @@
|
||||
|
||||
import StringIO
|
||||
|
||||
from novaclient.v1_0 import zones
|
||||
from tests.v1_0 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_0 import fakes
|
||||
|
||||
|
||||
os = fakes.FakeClient()
|
||||
|
@ -19,7 +19,6 @@ def assert_has_keys(dict, required=[], optional=[]):
|
||||
keys = dict.keys()
|
||||
for k in required:
|
||||
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))
|
||||
if extra_keys:
|
||||
fail("found unexpected keys: %s" % list(extra_keys))
|
||||
|
@ -3,7 +3,6 @@ import json
|
||||
import mock
|
||||
import urlparse
|
||||
|
||||
|
||||
from novaclient.v1_1 import client
|
||||
from novaclient import exceptions
|
||||
from tests import utils
|
||||
|
@ -1,7 +1,7 @@
|
||||
from novaclient import exceptions
|
||||
from novaclient.v1_1 import flavors
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,7 +1,6 @@
|
||||
from novaclient import exceptions
|
||||
from novaclient.v1_1 import floating_ips
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,6 +1,6 @@
|
||||
from novaclient.v1_1 import images
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,6 +1,6 @@
|
||||
from novaclient.v1_1 import keypairs
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
from novaclient.v1_1 import limits
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -13,10 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
@ -26,12 +24,12 @@ class QuotaSetsTest(utils.TestCase):
|
||||
|
||||
def test_tenant_quotas_get(self):
|
||||
tenant_id = 'test'
|
||||
qs = cs.quotas.get(tenant_id)
|
||||
cs.quotas.get(tenant_id)
|
||||
cs.assert_called('GET', '/os-quota-sets/%s' % tenant_id)
|
||||
|
||||
def test_tenant_quotas_defaults(self):
|
||||
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)
|
||||
|
||||
def test_update_quota(self):
|
||||
|
@ -1,7 +1,6 @@
|
||||
from novaclient import exceptions
|
||||
from novaclient.v1_1 import security_group_rules
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,7 +1,6 @@
|
||||
from novaclient import exceptions
|
||||
from novaclient.v1_1 import security_groups
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -1,8 +1,8 @@
|
||||
import StringIO
|
||||
|
||||
from novaclient.v1_1 import servers
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
@ -3,7 +3,7 @@ import mock
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from novaclient.shell import OpenStackComputeShell
|
||||
import novaclient.shell
|
||||
from novaclient import exceptions
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
@ -23,7 +23,7 @@ class ShellTest(utils.TestCase):
|
||||
'NOVA_URL': 'http://no.where',
|
||||
}
|
||||
|
||||
self.shell = OpenStackComputeShell()
|
||||
self.shell = novaclient.shell.OpenStackComputeShell()
|
||||
self.shell.get_api_class = lambda *_: fakes.FakeClient
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -1,8 +1,7 @@
|
||||
import StringIO
|
||||
|
||||
from novaclient.v1_1 import zones
|
||||
from tests.v1_1 import fakes
|
||||
from tests import utils
|
||||
from tests.v1_1 import fakes
|
||||
|
||||
|
||||
os = fakes.FakeClient()
|
||||
|
Loading…
x
Reference in New Issue
Block a user