Talking to Nova
This commit is contained in:
parent
2bbce47b28
commit
c3ca5939b4
5
.env
5
.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
|
||||
|
|
2
main.py
2
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")
|
|
@ -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():
|
||||
|
|
|
@ -13,5 +13,19 @@ class myopenstack_nova():
|
|||
_self.myOpenstackObject.keystone.echo()
|
||||
|
||||
def showNovaURL(_self):
|
||||
print(_self.conn.novaURL)
|
||||
_self.conn
|
||||
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()
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue