Skip to content

Commit

Permalink
changes imports in openstack.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Blazej Fitrzyk committed Dec 6, 2024
1 parent 920ec48 commit 99afb3b
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions utils/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
import os
import logging

import keystoneclient
import keystoneauth1
import glanceclient
import novaclient
import keystoneclient.auth.identity
import keystoneclient.client
import keystoneauth1.session
import keystoneauth1.identity.v3

import glanceclient.client
import novaclient.client


class OpenstackAuthenticator:
def __init__(self):
self.auth_url = os.getenv("OS_AUTH_URL")

@abc.abstractmethod
def authenticate(self):
self.session = keystoneauth1.session.Session(auth=self._auth())
keystoneauth1.session.Session
# get a keystone client
#self.kc = keystoneclient.client.Client("3", session=self.session, auth_url=self.session.auth.auth_url)
self.kc = keystoneclient.client.Client(session=self.session)

@abc.abstractmethod
def _auth(self):
Expand Down Expand Up @@ -58,10 +62,7 @@ def _auth(self):
def authenticate(self):
super().authenticate()

# get a keystone client
self.kc = keystoneclient.client.Client("3", session=self.session, auth_url=self.session.auth.auth_url)

# and authenticate it
# and authenticate the client
self.kc.authenticate(
token=self.sess.get_auth_headers()["X-Auth-Token"],
project_id=self.session.get_project_id(),
Expand All @@ -84,12 +85,6 @@ def _auth(self):
auth_url=self.auth_url,
auth_methods=[application_credential]
)

def authenticate(self):
super().authenticate()

# get a keystone client
self.kc = keystoneclient.v3.client.Client(session=self.session)


class AuthenticatedClient():
Expand Down

0 comments on commit 99afb3b

Please sign in to comment.