Rename v1_1 to v2

Module novaclient.v1_1 is used as implementation of V1.1, V2 and V3.
Since future development(microversioning) will be done across V2,
implementation should be done in appropriate module(to prevent misleading).

Despite the fact that implementation for all versions are equal, discover
method for contrib path worked only for v1.1. This patch fixes this bug and
modifies shell tests to check all versions.

Change-Id: Ib6798f4dfe177586302141f522dc593560ce6a5b
This commit is contained in:
Andrey Kurilin 2015-02-03 02:32:58 +02:00
parent 4e76f9590b
commit 0a60aae852
107 changed files with 218 additions and 156 deletions

View File

@ -46,7 +46,7 @@ and the version of the API with ``--os-compute-api-version``. Or set them as
an environment variables as well:: an environment variables as well::
export OS_AUTH_URL=http://example.com:8774/v1.1/ export OS_AUTH_URL=http://example.com:8774/v1.1/
export OS_COMPUTE_API_VERSION=1.1 export OS_COMPUTE_API_VERSION=2
If you are using Keystone, you need to set the OS_AUTH_URL to the keystone If you are using Keystone, you need to set the OS_AUTH_URL to the keystone
endpoint:: endpoint::
@ -69,7 +69,7 @@ There's also a complete Python API, but it has not yet been documented.
To use with nova, with keystone as the authentication system:: To use with nova, with keystone as the authentication system::
# use v2.0 auth with http://example.com:5000/v2.0/") # use v2.0 auth with http://example.com:5000/v2.0/")
>>> from novaclient.v1_1 import client >>> from novaclient.v2 import client
>>> nt = client.Client(USER, PASS, TENANT, AUTH_URL, service_type="compute") >>> nt = client.Client(USER, PASS, TENANT, AUTH_URL, service_type="compute")
>>> nt.flavors.list() >>> nt.flavors.list()
[...] [...]

View File

@ -60,5 +60,4 @@ For more information, see the reference:
:maxdepth: 2 :maxdepth: 2
ref/index ref/index
ref/v1_1/index ref/v2/index
ref/v3/index

View File

@ -71,17 +71,13 @@ def gen_ref(ver, title, names):
"pkg": pkg, "name": name}) "pkg": pkg, "name": name})
gen_ref(None, "Exceptions", ["exceptions"]) gen_ref(None, "Exceptions", ["exceptions"])
gen_ref("v1_1", "Version 1.1, Version 2 API Reference", gen_ref("v2", "Version 1.1, Version 2 API Reference, Version 3 API Reference",
["flavors", "images", "servers", "hosts", "agents", "aggregates", ["flavors", "images", "servers", "hosts", "agents", "aggregates",
"availability_zones", "certs", "fixed_ips", "floating_ip_pools", "availability_zones", "certs", "fixed_ips", "floating_ip_pools",
"floating_ips", "hypervisors", "keypairs", "limits", "networks", "floating_ips", "hypervisors", "keypairs", "limits", "networks",
"quota_classes", "quotas", "security_group_rules", "quota_classes", "quotas", "security_group_rules",
"security_groups", "services", "virtual_interfaces", "security_groups", "services", "virtual_interfaces",
"volume_snapshots", "volumes", "volume_types"]) "volume_snapshots", "volumes", "volume_types"])
gen_ref("v3", "Version 3 API Reference",
["flavors", "hosts", "agents", "aggregates", "availability_zones",
"certs", "hypervisors", "images", "keypairs", "quotas",
"quotas_classes", "servers", "services"])
# -- General configuration ---------------------------------------------------- # -- General configuration ----------------------------------------------------

View File

@ -25,8 +25,7 @@ Contents:
shell shell
api api
ref/index ref/index
ref/v1_1/index ref/v2/index
ref/v3/index
releases releases
Contributing Contributing

View File

@ -41,7 +41,7 @@ For example, in Bash you'd use::
export OS_PASSWORD=yadayadayada export OS_PASSWORD=yadayadayada
export OS_TENANT_NAME=myproject export OS_TENANT_NAME=myproject
export OS_AUTH_URL=http://... export OS_AUTH_URL=http://...
export OS_COMPUTE_API_VERSION=1.1 export OS_COMPUTE_API_VERSION=2
From there, all shell commands take the form:: From there, all shell commands take the form::

View File

@ -773,9 +773,9 @@ def _construct_http_client(username=None, password=None, project_id=None,
def get_client_class(version): def get_client_class(version):
version_map = { version_map = {
'1.1': 'novaclient.v1_1.client.Client', '1.1': 'novaclient.v2.client.Client',
'2': 'novaclient.v1_1.client.Client', '2': 'novaclient.v2.client.Client',
'3': 'novaclient.v1_1.client.Client', '3': 'novaclient.v2.client.Client',
} }
try: try:
client_path = version_map[str(version)] client_path = version_map[str(version)]

View File

@ -55,9 +55,9 @@ import novaclient.extension
from novaclient.i18n import _ from novaclient.i18n import _
from novaclient.openstack.common import cliutils from novaclient.openstack.common import cliutils
from novaclient import utils from novaclient import utils
from novaclient.v1_1 import shell as shell_v1_1 from novaclient.v2 import shell as shell_v2
DEFAULT_OS_COMPUTE_API_VERSION = "1.1" DEFAULT_OS_COMPUTE_API_VERSION = "2"
DEFAULT_NOVA_ENDPOINT_TYPE = 'publicURL' DEFAULT_NOVA_ENDPOINT_TYPE = 'publicURL'
# NOTE(cyeoh): Having the service type dependent on the API version # NOTE(cyeoh): Having the service type dependent on the API version
# is pretty ugly, but we have to do this because traditionally the # is pretty ugly, but we have to do this because traditionally the
@ -446,12 +446,12 @@ class OpenStackComputeShell(object):
try: try:
actions_module = { actions_module = {
'1.1': shell_v1_1, '1.1': shell_v2,
'2': shell_v1_1, '2': shell_v2,
'3': shell_v1_1, '3': shell_v2,
}[version] }[version]
except KeyError: except KeyError:
actions_module = shell_v1_1 actions_module = shell_v2
self._find_actions(subparsers, actions_module) self._find_actions(subparsers, actions_module)
self._find_actions(subparsers, self) self._find_actions(subparsers, self)
@ -491,6 +491,10 @@ class OpenStackComputeShell(object):
def _discover_via_contrib_path(self, version): def _discover_via_contrib_path(self, version):
module_path = os.path.dirname(os.path.abspath(__file__)) module_path = os.path.dirname(os.path.abspath(__file__))
version_str = "v%s" % version.replace('.', '_') version_str = "v%s" % version.replace('.', '_')
# NOTE(akurilin): v1.1, v2 and v3 have one implementation, so
# we should discover contrib modules in one place.
if version_str in ["v1_1", "v3"]:
version_str = "v2"
ext_path = os.path.join(module_path, version_str, 'contrib') ext_path = os.path.join(module_path, version_str, 'contrib')
ext_glob = os.path.join(ext_path, "*.py") ext_glob = os.path.join(ext_path, "*.py")

View File

@ -15,7 +15,7 @@ from keystoneclient.auth.identity import v2
from keystoneclient import fixture from keystoneclient import fixture
from keystoneclient import session from keystoneclient import session
from novaclient.v1_1 import client as v1_1client from novaclient.v2 import client as v2client
IDENTITY_URL = 'http://identityserver:5000/v2.0' IDENTITY_URL = 'http://identityserver:5000/v2.0'
COMPUTE_URL = 'http://compute.host' COMPUTE_URL = 'http://compute.host'
@ -51,10 +51,10 @@ class V1(fixtures.Fixture):
self.client = self.new_client() self.client = self.new_client()
def new_client(self): def new_client(self):
return v1_1client.Client(username='xx', return v2client.Client(username='xx',
api_key='xx', api_key='xx',
project_id='xx', project_id='xx',
auth_url=self.identity_url) auth_url=self.identity_url)
class SessionV1(V1): class SessionV1(V1):
@ -62,4 +62,4 @@ class SessionV1(V1):
def new_client(self): def new_client(self):
self.session = session.Session() self.session = session.Session()
self.session.auth = v2.Password(self.identity_url, 'xx', 'xx') self.session.auth = v2.Password(self.identity_url, 'xx', 'xx')
return v1_1client.Client(session=self.session) return v2client.Client(session=self.session)

View File

@ -28,7 +28,7 @@ except ImportError:
from novaclient import auth_plugin from novaclient import auth_plugin
from novaclient import exceptions from novaclient import exceptions
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import client from novaclient.v2 import client
def mock_http_request(resp=None): def mock_http_request(resp=None):

View File

@ -14,8 +14,8 @@
from novaclient import base from novaclient import base
from novaclient import exceptions from novaclient import exceptions
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1 import flavors from novaclient.v2 import flavors
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -24,7 +24,7 @@ import requests
import novaclient.client import novaclient.client
import novaclient.extension import novaclient.extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
import novaclient.v1_1.client import novaclient.v2.client
class ClientConnectionPoolTest(utils.TestCase): class ClientConnectionPoolTest(utils.TestCase):
@ -138,57 +138,57 @@ class ClientTest(utils.TestCase):
def test_get_client_class_v3(self): def test_get_client_class_v3(self):
output = novaclient.client.get_client_class('3') output = novaclient.client.get_client_class('3')
self.assertEqual(output, novaclient.v1_1.client.Client) self.assertEqual(output, novaclient.v2.client.Client)
def test_get_client_class_v2(self): def test_get_client_class_v2(self):
output = novaclient.client.get_client_class('2') output = novaclient.client.get_client_class('2')
self.assertEqual(output, novaclient.v1_1.client.Client) self.assertEqual(output, novaclient.v2.client.Client)
def test_get_client_class_v2_int(self): def test_get_client_class_v2_int(self):
output = novaclient.client.get_client_class(2) output = novaclient.client.get_client_class(2)
self.assertEqual(output, novaclient.v1_1.client.Client) self.assertEqual(output, novaclient.v2.client.Client)
def test_get_client_class_v1_1(self): def test_get_client_class_v1_1(self):
output = novaclient.client.get_client_class('1.1') output = novaclient.client.get_client_class('1.1')
self.assertEqual(output, novaclient.v1_1.client.Client) self.assertEqual(output, novaclient.v2.client.Client)
def test_get_client_class_unknown(self): def test_get_client_class_unknown(self):
self.assertRaises(novaclient.exceptions.UnsupportedVersion, self.assertRaises(novaclient.exceptions.UnsupportedVersion,
novaclient.client.get_client_class, '0') novaclient.client.get_client_class, '0')
def test_client_with_os_cache_enabled(self): def test_client_with_os_cache_enabled(self):
cs = novaclient.v1_1.client.Client("user", "password", "project_id", cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", os_cache=True) auth_url="foo/v2", os_cache=True)
self.assertEqual(True, cs.os_cache) self.assertEqual(True, cs.os_cache)
self.assertEqual(True, cs.client.os_cache) self.assertEqual(True, cs.client.os_cache)
def test_client_with_os_cache_disabled(self): def test_client_with_os_cache_disabled(self):
cs = novaclient.v1_1.client.Client("user", "password", "project_id", cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", os_cache=False) auth_url="foo/v2", os_cache=False)
self.assertEqual(False, cs.os_cache) self.assertEqual(False, cs.os_cache)
self.assertEqual(False, cs.client.os_cache) self.assertEqual(False, cs.client.os_cache)
def test_client_with_no_cache_enabled(self): def test_client_with_no_cache_enabled(self):
cs = novaclient.v1_1.client.Client("user", "password", "project_id", cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", no_cache=True) auth_url="foo/v2", no_cache=True)
self.assertEqual(False, cs.os_cache) self.assertEqual(False, cs.os_cache)
self.assertEqual(False, cs.client.os_cache) self.assertEqual(False, cs.client.os_cache)
def test_client_with_no_cache_disabled(self): def test_client_with_no_cache_disabled(self):
cs = novaclient.v1_1.client.Client("user", "password", "project_id", cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2", no_cache=False) auth_url="foo/v2", no_cache=False)
self.assertEqual(True, cs.os_cache) self.assertEqual(True, cs.os_cache)
self.assertEqual(True, cs.client.os_cache) self.assertEqual(True, cs.client.os_cache)
def test_client_set_management_url_v1_1(self): def test_client_set_management_url_v1_1(self):
cs = novaclient.v1_1.client.Client("user", "password", "project_id", cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2") auth_url="foo/v2")
cs.set_management_url("blabla") cs.set_management_url("blabla")
self.assertEqual("blabla", cs.client.management_url) self.assertEqual("blabla", cs.client.management_url)
def test_client_get_reset_timings_v1_1(self): def test_client_get_reset_timings_v1_1(self):
cs = novaclient.v1_1.client.Client("user", "password", "project_id", cs = novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2") auth_url="foo/v2")
self.assertEqual(0, len(cs.get_timings())) self.assertEqual(0, len(cs.get_timings()))
cs.client.times.append("somevalue") cs.client.times.append("somevalue")
self.assertEqual(1, len(cs.get_timings())) self.assertEqual(1, len(cs.get_timings()))
@ -201,8 +201,8 @@ class ClientTest(utils.TestCase):
def test_contextmanager_v1_1(self, mock_http_client): def test_contextmanager_v1_1(self, mock_http_client):
fake_client = mock.Mock() fake_client = mock.Mock()
mock_http_client.return_value = fake_client mock_http_client.return_value = fake_client
with novaclient.v1_1.client.Client("user", "password", "project_id", with novaclient.v2.client.Client("user", "password", "project_id",
auth_url="foo/v2"): auth_url="foo/v2"):
pass pass
self.assertTrue(fake_client.open_session.called) self.assertTrue(fake_client.open_session.called)
self.assertTrue(fake_client.close_session.called) self.assertTrue(fake_client.close_session.called)

View File

@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1 import client from novaclient.v2 import client
class FakeClient(fakes.FakeClient): class FakeClient(fakes.FakeClient):

View File

@ -18,8 +18,8 @@ Assisted volume snapshots - to be used by Cinder and not end users.
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1.contrib import fakes from novaclient.tests.unit.v2.contrib import fakes
from novaclient.v1_1.contrib import assisted_volume_snapshots as assisted_snaps from novaclient.v2.contrib import assisted_volume_snapshots as assisted_snaps
extensions = [ extensions = [

View File

@ -16,8 +16,8 @@
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1.contrib import fakes from novaclient.tests.unit.v2.contrib import fakes
from novaclient.v1_1.contrib import baremetal from novaclient.v2.contrib import baremetal
extensions = [ extensions = [

View File

@ -15,8 +15,8 @@
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1.contrib import fakes from novaclient.tests.unit.v2.contrib import fakes
from novaclient.v1_1.contrib import cells from novaclient.v2.contrib import cells
extensions = [ extensions = [

View File

@ -15,8 +15,8 @@
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1.contrib import fakes from novaclient.tests.unit.v2.contrib import fakes
from novaclient.v1_1.contrib import instance_action from novaclient.v2.contrib import instance_action
extensions = [ extensions = [

View File

@ -13,8 +13,8 @@
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1.contrib import list_extensions from novaclient.v2.contrib import list_extensions
extensions = [ extensions = [

View File

@ -12,8 +12,8 @@
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1.contrib import migrations from novaclient.v2.contrib import migrations
extensions = [ extensions = [
extension.Extension(migrations.__name__.split(".")[-1], extension.Extension(migrations.__name__.split(".")[-1],

View File

@ -18,8 +18,8 @@ External event triggering for servers, not to be used by users.
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1.contrib import fakes from novaclient.tests.unit.v2.contrib import fakes
from novaclient.v1_1.contrib import server_external_events as ext_events from novaclient.v2.contrib import server_external_events as ext_events
extensions = [ extensions = [

View File

@ -15,8 +15,8 @@
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1.contrib import fakes from novaclient.tests.unit.v2.contrib import fakes
from novaclient.v1_1.contrib import tenant_networks from novaclient.v2.contrib import tenant_networks
extensions = [ extensions = [

View File

@ -25,7 +25,7 @@ from novaclient import client as base_client
from novaclient import exceptions from novaclient import exceptions
from novaclient.tests.unit import fakes from novaclient.tests.unit import fakes
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import client from novaclient.v2 import client
class FakeClient(fakes.FakeClient, client.Client): class FakeClient(fakes.FakeClient, client.Client):

View File

@ -16,7 +16,7 @@
from novaclient.tests.unit.fixture_data import agents as data from novaclient.tests.unit.fixture_data import agents as data
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import agents from novaclient.v2 import agents
class AgentsTest(utils.FixturedTestCase): class AgentsTest(utils.FixturedTestCase):

View File

@ -16,7 +16,7 @@
from novaclient.tests.unit.fixture_data import aggregates as data from novaclient.tests.unit.fixture_data import aggregates as data
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import aggregates from novaclient.v2 import aggregates
class AggregatesTest(utils.FixturedTestCase): class AggregatesTest(utils.FixturedTestCase):

View File

@ -20,7 +20,7 @@ import requests
from novaclient import exceptions from novaclient import exceptions
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import client from novaclient.v2 import client
class AuthenticateAgainstKeystoneTests(utils.TestCase): class AuthenticateAgainstKeystoneTests(utils.TestCase):

View File

@ -19,13 +19,13 @@ import six
from novaclient.tests.unit.fixture_data import availability_zones as data from novaclient.tests.unit.fixture_data import availability_zones as data
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import availability_zones from novaclient.v2 import availability_zones
class AvailabilityZoneTest(utils.FixturedTestCase): class AvailabilityZoneTest(utils.FixturedTestCase):
# NOTE(cyeoh): import shell here so the V3 version of # NOTE(cyeoh): import shell here so the V3 version of
# this class can inherit off the v3 version of shell # this class can inherit off the v3 version of shell
from novaclient.v1_1 import shell # noqa from novaclient.v2 import shell # noqa
data_fixture_class = data.V1 data_fixture_class = data.V1

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import certs as data from novaclient.tests.unit.fixture_data import certs as data
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import certs from novaclient.v2 import certs
class CertsTest(utils.FixturedTestCase): class CertsTest(utils.FixturedTestCase):

View File

@ -15,7 +15,7 @@ import uuid
from keystoneclient import session from keystoneclient import session
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import client from novaclient.v2 import client
class ClientTest(utils.TestCase): class ClientTest(utils.TestCase):

View File

@ -16,7 +16,7 @@ import six
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import cloudpipe as data from novaclient.tests.unit.fixture_data import cloudpipe as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import cloudpipe from novaclient.v2 import cloudpipe
class CloudpipeTest(utils.FixturedTestCase): class CloudpipeTest(utils.FixturedTestCase):

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1 import flavor_access from novaclient.v2 import flavor_access
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -17,8 +17,8 @@ import mock
from novaclient import exceptions from novaclient import exceptions
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1 import flavors from novaclient.v2 import flavors
class FlavorsTest(utils.TestCase): class FlavorsTest(utils.TestCase):

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import floatingips as data from novaclient.tests.unit.fixture_data import floatingips as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import floating_ip_dns from novaclient.v2 import floating_ip_dns
class FloatingIPDNSDomainTest(utils.FixturedTestCase): class FloatingIPDNSDomainTest(utils.FixturedTestCase):

View File

@ -17,7 +17,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import floatingips as data from novaclient.tests.unit.fixture_data import floatingips as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import floating_ip_pools from novaclient.v2 import floating_ip_pools
class TestFloatingIPPools(utils.FixturedTestCase): class TestFloatingIPPools(utils.FixturedTestCase):

View File

@ -17,7 +17,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import floatingips as data from novaclient.tests.unit.fixture_data import floatingips as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import floating_ips from novaclient.v2 import floating_ips
class FloatingIPsTest(utils.FixturedTestCase): class FloatingIPsTest(utils.FixturedTestCase):

View File

@ -16,7 +16,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import floatingips as data from novaclient.tests.unit.fixture_data import floatingips as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import floating_ips_bulk from novaclient.v2 import floating_ips_bulk
class FloatingIPsBulkTest(utils.FixturedTestCase): class FloatingIPsBulkTest(utils.FixturedTestCase):

View File

@ -16,7 +16,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import fping as data from novaclient.tests.unit.fixture_data import fping as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import fping from novaclient.v2 import fping
class FpingTest(utils.FixturedTestCase): class FpingTest(utils.FixturedTestCase):

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import hosts as data from novaclient.tests.unit.fixture_data import hosts as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import hosts from novaclient.v2 import hosts
class HostsTest(utils.FixturedTestCase): class HostsTest(utils.FixturedTestCase):

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import images as data from novaclient.tests.unit.fixture_data import images as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import images from novaclient.v2 import images
class ImagesTest(utils.FixturedTestCase): class ImagesTest(utils.FixturedTestCase):

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import keypairs as data from novaclient.tests.unit.fixture_data import keypairs as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import keypairs from novaclient.v2 import keypairs
class KeypairsTest(utils.FixturedTestCase): class KeypairsTest(utils.FixturedTestCase):

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import limits as data from novaclient.tests.unit.fixture_data import limits as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import limits from novaclient.v2 import limits
class LimitsTest(utils.FixturedTestCase): class LimitsTest(utils.FixturedTestCase):

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import networks as data from novaclient.tests.unit.fixture_data import networks as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import networks from novaclient.v2 import networks
class NetworksTest(utils.FixturedTestCase): class NetworksTest(utils.FixturedTestCase):

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -15,7 +15,7 @@ from novaclient import exceptions
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import security_group_rules as data from novaclient.tests.unit.fixture_data import security_group_rules as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import security_group_rules from novaclient.v2 import security_group_rules
class SecurityGroupRulesTest(utils.FixturedTestCase): class SecurityGroupRulesTest(utils.FixturedTestCase):

View File

@ -14,7 +14,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import security_groups as data from novaclient.tests.unit.fixture_data import security_groups as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import security_groups from novaclient.v2 import security_groups
class SecurityGroupsTest(utils.FixturedTestCase): class SecurityGroupsTest(utils.FixturedTestCase):

View File

@ -16,7 +16,7 @@
from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import server_groups as data from novaclient.tests.unit.fixture_data import server_groups as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import server_groups from novaclient.v2 import server_groups
class ServerGroupsTest(utils.FixturedTestCase): class ServerGroupsTest(utils.FixturedTestCase):

View File

@ -21,7 +21,7 @@ from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import floatingips from novaclient.tests.unit.fixture_data import floatingips
from novaclient.tests.unit.fixture_data import servers as data from novaclient.tests.unit.fixture_data import servers as data
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.v1_1 import servers from novaclient.v2 import servers
class ServersTest(utils.FixturedTestCase): class ServersTest(utils.FixturedTestCase):

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1 import services from novaclient.v2 import services
class ServicesTest(utils.TestCase): class ServicesTest(utils.TestCase):

View File

@ -30,8 +30,8 @@ import novaclient.client
from novaclient import exceptions from novaclient import exceptions
import novaclient.shell import novaclient.shell
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
import novaclient.v1_1.shell import novaclient.v2.shell
class ShellFixture(fixtures.Fixture): class ShellFixture(fixtures.Fixture):
@ -54,7 +54,7 @@ class ShellTest(utils.TestCase):
'NOVA_USERNAME': 'username', 'NOVA_USERNAME': 'username',
'NOVA_PASSWORD': 'password', 'NOVA_PASSWORD': 'password',
'NOVA_PROJECT_ID': 'project_id', 'NOVA_PROJECT_ID': 'project_id',
'OS_COMPUTE_API_VERSION': '1.1', 'OS_COMPUTE_API_VERSION': '2',
'NOVA_URL': 'http://no.where', 'NOVA_URL': 'http://no.where',
'OS_AUTH_URL': 'http://no.where/v2.0', 'OS_AUTH_URL': 'http://no.where/v2.0',
} }
@ -644,7 +644,7 @@ class ShellTest(utils.TestCase):
cmd = 'boot --image 1 --flavor 1 --min-count 3 --max-count 1 serv' cmd = 'boot --image 1 --flavor 1 --min-count 3 --max-count 1 serv'
self.assertRaises(exceptions.CommandError, self.run_command, cmd) self.assertRaises(exceptions.CommandError, self.run_command, cmd)
@mock.patch('novaclient.v1_1.shell._poll_for_status') @mock.patch('novaclient.v2.shell._poll_for_status')
def test_boot_with_poll(self, poll_method): def test_boot_with_poll(self, poll_method):
self.run_command('boot --flavor 1 --image 1 some-server --poll') self.run_command('boot --flavor 1 --image 1 some-server --poll')
self.assert_called_anytime( self.assert_called_anytime(
@ -1088,7 +1088,7 @@ class ShellTest(utils.TestCase):
self.assertRaises(exceptions.CommandError, self.assertRaises(exceptions.CommandError,
self.run_command, 'show xxx') self.run_command, 'show xxx')
@mock.patch('novaclient.v1_1.shell.utils.print_dict') @mock.patch('novaclient.v2.shell.utils.print_dict')
def test_print_server(self, mock_print_dict): def test_print_server(self, mock_print_dict):
self.run_command('show 5678') self.run_command('show 5678')
args, kwargs = mock_print_dict.call_args args, kwargs = mock_print_dict.call_args
@ -2225,7 +2225,7 @@ class ShellTest(utils.TestCase):
'/os-migrations?cell_name=child1&host=host1' '/os-migrations?cell_name=child1&host=host1'
'&status=finished') '&status=finished')
@mock.patch('novaclient.v1_1.shell._find_server') @mock.patch('novaclient.v2.shell._find_server')
@mock.patch('os.system') @mock.patch('os.system')
def test_ssh(self, mock_system, mock_find_server): def test_ssh(self, mock_system, mock_find_server):
class FakeResources(object): class FakeResources(object):
@ -2273,7 +2273,7 @@ class ShellTest(utils.TestCase):
mock_system.assert_called_with("ssh -6 -p22 " mock_system.assert_called_with("ssh -6 -p22 "
"root@2607:f0d0:1002::4 -1") "root@2607:f0d0:1002::4 -1")
@mock.patch('novaclient.v1_1.shell._find_server') @mock.patch('novaclient.v2.shell._find_server')
@mock.patch('os.system') @mock.patch('os.system')
def test_ssh_multinet(self, mock_system, mock_find_server): def test_ssh_multinet(self, mock_system, mock_find_server):
class FakeResources(object): class FakeResources(object):
@ -2338,6 +2338,28 @@ class ShellTest(utils.TestCase):
self.assert_called('DELETE', '/os-server-groups/12345', pos=-2) self.assert_called('DELETE', '/os-server-groups/12345', pos=-2)
class ShellTestV11(ShellTest):
FAKE_ENV = {
'NOVA_USERNAME': 'username',
'NOVA_PASSWORD': 'password',
'NOVA_PROJECT_ID': 'project_id',
'OS_COMPUTE_API_VERSION': '1.1',
'NOVA_URL': 'http://no.where',
'OS_AUTH_URL': 'http://no.where/v2.0',
}
class ShellTestV3(ShellTest):
FAKE_ENV = {
'NOVA_USERNAME': 'username',
'NOVA_PASSWORD': 'password',
'NOVA_PROJECT_ID': 'project_id',
'OS_COMPUTE_API_VERSION': '3',
'NOVA_URL': 'http://no.where',
'OS_AUTH_URL': 'http://no.where/v2.0',
}
class ShellWithSessionClientTest(ShellTest): class ShellWithSessionClientTest(ShellTest):
def setUp(self): def setUp(self):
@ -2354,7 +2376,7 @@ class GetSecgroupTest(utils.TestCase):
'security_groups.get.return_value': 'sec_group', 'security_groups.get.return_value': 'sec_group',
'security_groups.list.return_value': [], 'security_groups.list.return_value': [],
}) })
result = novaclient.v1_1.shell._get_secgroup(cs, '1') result = novaclient.v2.shell._get_secgroup(cs, '1')
self.assertEqual('sec_group', result) self.assertEqual('sec_group', result)
cs.security_groups.get.assert_called_once_with('1') cs.security_groups.get.assert_called_once_with('1')
@ -2363,7 +2385,7 @@ class GetSecgroupTest(utils.TestCase):
'security_groups.get.return_value': 'sec_group', 'security_groups.get.return_value': 'sec_group',
'security_groups.list.return_value': [], 'security_groups.list.return_value': [],
}) })
result = novaclient.v1_1.shell._get_secgroup( result = novaclient.v2.shell._get_secgroup(
cs, 'c0c32459-dc5f-44dc-9a0a-473b28bac831') cs, 'c0c32459-dc5f-44dc-9a0a-473b28bac831')
self.assertEqual('sec_group', result) self.assertEqual('sec_group', result)
cs.security_groups.get.assert_called_once_with( cs.security_groups.get.assert_called_once_with(
@ -2375,7 +2397,7 @@ class GetSecgroupTest(utils.TestCase):
'security_groups.list.return_value': [], 'security_groups.list.return_value': [],
}) })
self.assertRaises(exceptions.CommandError, self.assertRaises(exceptions.CommandError,
novaclient.v1_1.shell._get_secgroup, novaclient.v2.shell._get_secgroup,
cs, cs,
'abc') 'abc')
@ -2387,7 +2409,7 @@ class GetSecgroupTest(utils.TestCase):
'security_groups.list.return_value': [group_one, group_one], 'security_groups.list.return_value': [group_one, group_one],
}) })
self.assertRaises(exceptions.NoUniqueMatch, self.assertRaises(exceptions.NoUniqueMatch,
novaclient.v1_1.shell._get_secgroup, novaclient.v2.shell._get_secgroup,
cs, cs,
'group_one') 'group_one')
@ -2396,7 +2418,7 @@ class GetFirstEndpointTest(utils.TestCase):
def test_only_one_endpoint(self): def test_only_one_endpoint(self):
"""If there is only one endpoint, it is returned.""" """If there is only one endpoint, it is returned."""
endpoint = {"url": "test"} endpoint = {"url": "test"}
result = novaclient.v1_1.shell._get_first_endpoint([endpoint], "XYZ") result = novaclient.v2.shell._get_first_endpoint([endpoint], "XYZ")
self.assertEqual(endpoint, result) self.assertEqual(endpoint, result)
def test_multiple_endpoints(self): def test_multiple_endpoints(self):
@ -2409,7 +2431,7 @@ class GetFirstEndpointTest(utils.TestCase):
{"region": "ORD", "number": 1}, {"region": "ORD", "number": 1},
{"region": "ORD", "number": 2} {"region": "ORD", "number": 2}
] ]
result = novaclient.v1_1.shell._get_first_endpoint(endpoints, "ORD") result = novaclient.v2.shell._get_first_endpoint(endpoints, "ORD")
self.assertEqual(endpoints[1], result) self.assertEqual(endpoints[1], result)
def test_multiple_endpoints_but_none_suitable(self): def test_multiple_endpoints_but_none_suitable(self):
@ -2423,11 +2445,11 @@ class GetFirstEndpointTest(utils.TestCase):
{"region": "STU"} {"region": "STU"}
] ]
self.assertRaises(LookupError, self.assertRaises(LookupError,
novaclient.v1_1.shell._get_first_endpoint, novaclient.v2.shell._get_first_endpoint,
endpoints, "ORD") endpoints, "ORD")
def test_no_endpoints(self): def test_no_endpoints(self):
"""If there are no endpoints available, an exception is raised.""" """If there are no endpoints available, an exception is raised."""
self.assertRaises(LookupError, self.assertRaises(LookupError,
novaclient.v1_1.shell._get_first_endpoint, novaclient.v2.shell._get_first_endpoint,
[], "ORD") [], "ORD")

View File

@ -14,8 +14,8 @@
import datetime import datetime
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1 import usage from novaclient.v2 import usage
class UsageTest(utils.TestCase): class UsageTest(utils.TestCase):

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v1_1 import fakes from novaclient.tests.unit.v2 import fakes
from novaclient.v1_1 import volumes from novaclient.v2 import volumes
cs = fakes.FakeClient() cs = fakes.FakeClient()

View File

@ -1,4 +1,3 @@
# Copyright (c) 2012 OpenStack Foundation
# #
# All Rights Reserved. # All Rights Reserved.
# #
@ -14,4 +13,31 @@
# 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.v1_1.client import Client # noqa # NOTE(akurilin): This module is left for backward compatibility. Feel free to
# remove it, when openstack project will use correct way to
# obtain novaclient object.
# Known problems:
# * python-openstackclient -
# https://bugs.launchpad.net/python-openstackclient/+bug/1418024
# * neutron - https://bugs.launchpad.net/neutron/+bug/1418017
import sys
import warnings
from novaclient import v2
warnings.warn("Module novaclient.v1_1 is deprecated (taken as a basis for "
"novaclient.v2). "
"The preferable way to get client class or object you can find "
"in novaclient.client module.")
class MovedModule(object):
def __init__(self, new_module):
self.new_module = new_module
def __getattr__(self, attr):
return getattr(self.new_module, attr)
sys.modules["novaclient.v1_1"] = MovedModule(v2)

16
novaclient/v2/__init__.py Normal file
View File

@ -0,0 +1,16 @@
#
# 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.
from novaclient.v2.client import Client # noqa

View File

@ -14,39 +14,39 @@
# under the License. # under the License.
from novaclient import client from novaclient import client
from novaclient.v1_1 import agents from novaclient.v2 import agents
from novaclient.v1_1 import aggregates from novaclient.v2 import aggregates
from novaclient.v1_1 import availability_zones from novaclient.v2 import availability_zones
from novaclient.v1_1 import certs from novaclient.v2 import certs
from novaclient.v1_1 import cloudpipe from novaclient.v2 import cloudpipe
from novaclient.v1_1 import fixed_ips from novaclient.v2 import fixed_ips
from novaclient.v1_1 import flavor_access from novaclient.v2 import flavor_access
from novaclient.v1_1 import flavors from novaclient.v2 import flavors
from novaclient.v1_1 import floating_ip_dns from novaclient.v2 import floating_ip_dns
from novaclient.v1_1 import floating_ip_pools from novaclient.v2 import floating_ip_pools
from novaclient.v1_1 import floating_ips from novaclient.v2 import floating_ips
from novaclient.v1_1 import floating_ips_bulk from novaclient.v2 import floating_ips_bulk
from novaclient.v1_1 import fping from novaclient.v2 import fping
from novaclient.v1_1 import hosts from novaclient.v2 import hosts
from novaclient.v1_1 import hypervisors from novaclient.v2 import hypervisors
from novaclient.v1_1 import images from novaclient.v2 import images
from novaclient.v1_1 import keypairs from novaclient.v2 import keypairs
from novaclient.v1_1 import limits from novaclient.v2 import limits
from novaclient.v1_1 import networks from novaclient.v2 import networks
from novaclient.v1_1 import quota_classes from novaclient.v2 import quota_classes
from novaclient.v1_1 import quotas from novaclient.v2 import quotas
from novaclient.v1_1 import security_group_default_rules from novaclient.v2 import security_group_default_rules
from novaclient.v1_1 import security_group_rules from novaclient.v2 import security_group_rules
from novaclient.v1_1 import security_groups from novaclient.v2 import security_groups
from novaclient.v1_1 import server_groups from novaclient.v2 import server_groups
from novaclient.v1_1 import servers from novaclient.v2 import servers
from novaclient.v1_1 import services from novaclient.v2 import services
from novaclient.v1_1 import usage from novaclient.v2 import usage
from novaclient.v1_1 import versions from novaclient.v2 import versions
from novaclient.v1_1 import virtual_interfaces from novaclient.v2 import virtual_interfaces
from novaclient.v1_1 import volume_snapshots from novaclient.v2 import volume_snapshots
from novaclient.v1_1 import volume_types from novaclient.v2 import volume_types
from novaclient.v1_1 import volumes from novaclient.v2 import volumes
class Client(object): class Client(object):

View File

@ -15,7 +15,7 @@
from novaclient.i18n import _ from novaclient.i18n import _
from novaclient.openstack.common import cliutils from novaclient.openstack.common import cliutils
from novaclient.v1_1 import shell from novaclient.v2 import shell
@cliutils.arg( @cliutils.arg(

View File

@ -28,7 +28,7 @@ from six.moves.urllib import parse
from novaclient import base from novaclient import base
from novaclient import crypto from novaclient import crypto
from novaclient.i18n import _ from novaclient.i18n import _
from novaclient.v1_1 import security_groups from novaclient.v2 import security_groups
REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD' REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'

Some files were not shown because too many files have changed in this diff Show More