Able to search catalog

This commit is contained in:
Cory Hawkless 2022-10-13 12:54:30 +10:30
parent b43c082424
commit 581b605b0e
2 changed files with 37 additions and 14 deletions

View File

@ -6,8 +6,15 @@ import json
import ng_openstack
x=ng_openstack.OpenstackConnection("Fido",10)
print (x.keystone.getAllProjects())
# x.keystone.getAllProjects()
x.keystone.getCatalog()
# print (x.keystone.catalogData)
neutronService=x.keystone.getServicebyName("Neutron")
print(neutronService)
neutronEndpointInternal=x.keystone.getEndpointByServiceIDAndInterface(neutronService['id'],"internal")
print(neutronEndpointInternal)
# token = ng_openstack.auth.getToken(os.getenv("OS_USERNAME"), os.getenv("OS_PASSWORD"),
# os.getenv("OS_USER_DOMAIN_NAME"), os.getenv("OS_USER_DOMAIN_NAME"),

View File

@ -20,19 +20,35 @@ class Openstack_Keystone():
def getCatalog():
catalogData=json.dumps(ng_openstack.openstackRequest.openstackRequest("GET", "endpoints", "",
os.getenv("OS_AUTH_URL")).json())
def getCatalog(_self):
catalogData=_self.requestor.make_request("GET", "endpoints", "",
os.getenv("OS_AUTH_URL")).json()
serviceData=json.dumps(ng_openstack.openstackRequest.openstackRequest("GET", "services", "",
os.getenv("OS_AUTH_URL")).json())
print(serviceData)
return serviceData
serviceData=_self.requestor.make_request("GET", "services", "",
os.getenv("OS_AUTH_URL")).json()
# print(serviceData)
_self.serviceData=serviceData
_self.catalogData=catalogData
return catalogData
def getServicebyID(id):
print(serviceData)
# for _service in service_Data['services']:
# if _service['id']==id:
# return(_service)
def getServicebyID(_self,id):
# print(_self.serviceData)
for _service in _self.serviceData['services']:
if str(_service['id']).lower()==str(id).lower():
# print(_service)
return(_service)
def getServicebyName(_self,name):
for _service in _self.serviceData['services']:
if str(_service['name']).lower()==str(name).lower():
# print(_service)
return(_service)
def getEndpointByServiceIDAndInterface(_self,id,interface):
for _endpoint in _self.catalogData['endpoints']:
if str(_endpoint['service_id']).lower()==str(id).lower():
if str(_endpoint['interface']).lower()==str(interface).lower():
# print(_endpoint)
return(_endpoint)