diff --git a/.env b/.env index 496197b..54ec8d1 100644 --- a/.env +++ b/.env @@ -1,8 +1,9 @@ OS_USERNAME=admin -OS_PASSWORD= +OS_PASSWORD=nVgmvBePxqPSxVkN7RwNKDJG OS_PROJECT_NAME=admin +OS_PROJECT_ID=8374bf1367ae40fdaf39f836b71d6bdb OS_USER_DOMAIN_NAME=Default OS_PROJECT_DOMAIN_NAME=Default -OS_AUTH_URL=http://10.10.110.251:5000/v3 +OS_AUTH_URL=http://192.168.50.75:5000/v3 OS_IDENTITY_API_VERSION=3 OS_INTERFACE=internal diff --git a/main.py b/main.py index a5a8028..8bde7ef 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ import myOpenstackApp y=myOpenstackApp.OSC y.initalise() # y.ks.getCatalog() -y.something() +print(y.something()) # print(y._keystone) print("Starting") \ No newline at end of file diff --git a/myOpenstackApp/OpenStackConnection.py b/myOpenstackApp/OpenStackConnection.py index 5c706cd..396d96a 100644 --- a/myOpenstackApp/OpenStackConnection.py +++ b/myOpenstackApp/OpenStackConnection.py @@ -27,18 +27,22 @@ class OpenStackConnection_x: self.ks=myopenstack_keystone(self) self.nova=myopenstack_nova(self) + + pass def something(_self): print(1) _self.ks.getCatalog() - _self.nova.showNovaURL() + print(_self.nova.getAllServers(os.getenv("OS_PROJECT_ID"))) def make_request(_self, getPost, url, data, apiEndpoint, scopedProjectID=""): log.debug("Making a request {} {} ".format(apiEndpoint,url)) # Default the scope project to the value set in .env.example, allow the user to override if required(EG creating backups) if scopedProjectID== "": + if len(str(os.getenv("OS_PROJECT_ID")))<8: + raise Exception("No OS_PROJECT_ID provided") scopedProjectID=os.getenv("OS_PROJECT_ID") else: scopedProjectID=scopedProjectID diff --git a/myOpenstackApp/__pycache__/OpenStackConnection.cpython-310.pyc b/myOpenstackApp/__pycache__/OpenStackConnection.cpython-310.pyc index 7af5cd0..67060d3 100644 Binary files a/myOpenstackApp/__pycache__/OpenStackConnection.cpython-310.pyc and b/myOpenstackApp/__pycache__/OpenStackConnection.cpython-310.pyc differ diff --git a/myOpenstackApp/__pycache__/keystone.cpython-310.pyc b/myOpenstackApp/__pycache__/keystone.cpython-310.pyc index d7c93bf..e4a3ece 100644 Binary files a/myOpenstackApp/__pycache__/keystone.cpython-310.pyc and b/myOpenstackApp/__pycache__/keystone.cpython-310.pyc differ diff --git a/myOpenstackApp/__pycache__/nova.cpython-310.pyc b/myOpenstackApp/__pycache__/nova.cpython-310.pyc index 949e6ad..4836ae3 100644 Binary files a/myOpenstackApp/__pycache__/nova.cpython-310.pyc and b/myOpenstackApp/__pycache__/nova.cpython-310.pyc differ diff --git a/myOpenstackApp/keystone.py b/myOpenstackApp/keystone.py index 0e5b5a7..2a9f545 100644 --- a/myOpenstackApp/keystone.py +++ b/myOpenstackApp/keystone.py @@ -55,7 +55,7 @@ class myopenstack_keystone(): # print(_endpoint) return(_endpoint) - def getEndpointByNameIDAndInterface(_self,name,interface): + def getEndpointByNameAndInterface(_self,name,interface): id=_self.getServicebyName(name)['id'] for _endpoint in _self.catalogData['endpoints']: if str(_endpoint['service_id']).lower()==str(id).lower(): diff --git a/myOpenstackApp/nova.py b/myOpenstackApp/nova.py index aa52a81..7b16e00 100644 --- a/myOpenstackApp/nova.py +++ b/myOpenstackApp/nova.py @@ -12,6 +12,20 @@ class myopenstack_nova(): def getKeystone(_self): _self.myOpenstackObject.keystone.echo() - def showNovaURL(_self): - print(_self.conn.novaURL) - _self.conn + def showNovaURL(_self): + return _self.conn.ks.getEndpointByNameAndInterface("nova","internal")["url"] + + + def getAllServers(_self,projectID): + + return _self.conn.make_request("GET", "/servers/detail?all_tenants=True&project_id="+projectID, + "",_self.conn.ks.getEndpointByNameAndInterface("nova","internal")["url"] ).json() + + + + def getAllFlavors(_self): + return ng_openstack.openstackRequest.openstackRequest("GET", "/flavors/detail", + "", "http://172.25.110.147:8774/v2.1").json() + + +