Talking to Nova
This commit is contained in:
parent
2bbce47b28
commit
c3ca5939b4
5
.env
5
.env
|
@ -1,8 +1,9 @@
|
||||||
OS_USERNAME=admin
|
OS_USERNAME=admin
|
||||||
OS_PASSWORD=
|
OS_PASSWORD=nVgmvBePxqPSxVkN7RwNKDJG
|
||||||
OS_PROJECT_NAME=admin
|
OS_PROJECT_NAME=admin
|
||||||
|
OS_PROJECT_ID=8374bf1367ae40fdaf39f836b71d6bdb
|
||||||
OS_USER_DOMAIN_NAME=Default
|
OS_USER_DOMAIN_NAME=Default
|
||||||
OS_PROJECT_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_IDENTITY_API_VERSION=3
|
||||||
OS_INTERFACE=internal
|
OS_INTERFACE=internal
|
||||||
|
|
2
main.py
2
main.py
|
@ -7,7 +7,7 @@ import myOpenstackApp
|
||||||
y=myOpenstackApp.OSC
|
y=myOpenstackApp.OSC
|
||||||
y.initalise()
|
y.initalise()
|
||||||
# y.ks.getCatalog()
|
# y.ks.getCatalog()
|
||||||
y.something()
|
print(y.something())
|
||||||
# print(y._keystone)
|
# print(y._keystone)
|
||||||
|
|
||||||
print("Starting")
|
print("Starting")
|
|
@ -27,18 +27,22 @@ class OpenStackConnection_x:
|
||||||
|
|
||||||
self.ks=myopenstack_keystone(self)
|
self.ks=myopenstack_keystone(self)
|
||||||
self.nova=myopenstack_nova(self)
|
self.nova=myopenstack_nova(self)
|
||||||
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def something(_self):
|
def something(_self):
|
||||||
print(1)
|
print(1)
|
||||||
_self.ks.getCatalog()
|
_self.ks.getCatalog()
|
||||||
_self.nova.showNovaURL()
|
print(_self.nova.getAllServers(os.getenv("OS_PROJECT_ID")))
|
||||||
|
|
||||||
|
|
||||||
def make_request(_self, getPost, url, data, apiEndpoint, scopedProjectID=""):
|
def make_request(_self, getPost, url, data, apiEndpoint, scopedProjectID=""):
|
||||||
log.debug("Making a request {} {} ".format(apiEndpoint,url))
|
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)
|
# Default the scope project to the value set in .env.example, allow the user to override if required(EG creating backups)
|
||||||
if scopedProjectID== "":
|
if scopedProjectID== "":
|
||||||
|
if len(str(os.getenv("OS_PROJECT_ID")))<8:
|
||||||
|
raise Exception("No OS_PROJECT_ID provided")
|
||||||
scopedProjectID=os.getenv("OS_PROJECT_ID")
|
scopedProjectID=os.getenv("OS_PROJECT_ID")
|
||||||
else:
|
else:
|
||||||
scopedProjectID=scopedProjectID
|
scopedProjectID=scopedProjectID
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -55,7 +55,7 @@ class myopenstack_keystone():
|
||||||
# print(_endpoint)
|
# print(_endpoint)
|
||||||
return(_endpoint)
|
return(_endpoint)
|
||||||
|
|
||||||
def getEndpointByNameIDAndInterface(_self,name,interface):
|
def getEndpointByNameAndInterface(_self,name,interface):
|
||||||
id=_self.getServicebyName(name)['id']
|
id=_self.getServicebyName(name)['id']
|
||||||
for _endpoint in _self.catalogData['endpoints']:
|
for _endpoint in _self.catalogData['endpoints']:
|
||||||
if str(_endpoint['service_id']).lower()==str(id).lower():
|
if str(_endpoint['service_id']).lower()==str(id).lower():
|
||||||
|
|
|
@ -12,6 +12,20 @@ class myopenstack_nova():
|
||||||
def getKeystone(_self):
|
def getKeystone(_self):
|
||||||
_self.myOpenstackObject.keystone.echo()
|
_self.myOpenstackObject.keystone.echo()
|
||||||
|
|
||||||
def showNovaURL(_self):
|
def showNovaURL(_self):
|
||||||
print(_self.conn.novaURL)
|
return _self.conn.ks.getEndpointByNameAndInterface("nova","internal")["url"]
|
||||||
_self.conn
|
|
||||||
|
|
||||||
|
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