Talking to Nova
This commit is contained in:
@@ -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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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():
|
||||
|
||||
+17
-3
@@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user