diff options
Diffstat (limited to 'deploy/post')
-rw-r--r-- | deploy/post/glance.py | 5 | ||||
-rw-r--r-- | deploy/post/keystoneauth.py | 6 | ||||
-rw-r--r-- | deploy/post/neutron.py | 9 | ||||
-rw-r--r-- | deploy/post/nova.py | 7 |
4 files changed, 15 insertions, 12 deletions
diff --git a/deploy/post/glance.py b/deploy/post/glance.py index 4171c8a8..79831ed0 100644 --- a/deploy/post/glance.py +++ b/deploy/post/glance.py @@ -14,10 +14,9 @@ from deploy.common import query import keystoneauth -class Glance(keystoneauth.Keystoneauth): +class Glance(keystoneauth.ClientBase): def __init__(self, version='2', openrc=None): - super(Glance, self).__init__(openrc) - self.client = glanceclient.Client(version, session=self.session) + super(Glance, self).__init__(glanceclient.Client, version, openrc) self.controller = self.client.images def create(self, name, path, diff --git a/deploy/post/keystoneauth.py b/deploy/post/keystoneauth.py index 664a794b..fb321d3f 100644 --- a/deploy/post/keystoneauth.py +++ b/deploy/post/keystoneauth.py @@ -64,3 +64,9 @@ class Keystoneauth(object): return reduce(parse_credential, [(k, v) for (k, v) in raws.iteritems() if k in maps], defaultdict(dict)) + + +class ClientBase(Keystoneauth): + def __init__(self, klass, version, openrc): + super(ClientBase, self).__init__(openrc) + self.client = klass(version, session=self.session) diff --git a/deploy/post/neutron.py b/deploy/post/neutron.py index dc2e30b2..77791ea8 100644 --- a/deploy/post/neutron.py +++ b/deploy/post/neutron.py @@ -6,16 +6,15 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from neutronclient.neutron import client as neutronclient +from neutronclient.neutron import client from deploy.common import query import keystoneauth -class Neutron(object): - def __init__(self, api_v='2', openrc=None): - session = keystoneauth.Keystoneauth(openrc).session - self.client = neutronclient.Client(api_v, session=session) +class Neutron(keystoneauth.ClientBase): + def __init__(self, version='2', openrc=None): + super(Neutron, self).__init__(client.Client, version, openrc) def create_network(self, name, body): if not self.get_network_by_name(name): diff --git a/deploy/post/nova.py b/deploy/post/nova.py index 6f5eae91..2b92450a 100644 --- a/deploy/post/nova.py +++ b/deploy/post/nova.py @@ -6,16 +6,15 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import novaclient.client +from novaclient import client from deploy.common import query import keystoneauth -class Nova(keystoneauth.Keystoneauth): +class Nova(keystoneauth.ClientBase): def __init__(self, version='2', openrc=None): - super(Nova, self).__init__(openrc) - self.client = novaclient.client.Client(version, session=self.session) + super(Nova, self).__init__(client.Client, version, openrc) self.flavors = self.client.flavors def create_flavor(self, name, ram, vcpus, disk, is_public=True): |