Able to search catalog

This commit is contained in:
Cory Hawkless 2022-10-13 12:55:57 +10:30
parent 581b605b0e
commit 74ebac01fd
2 changed files with 16 additions and 8 deletions

View File

@ -11,9 +11,9 @@ x.keystone.getCatalog()
# print (x.keystone.catalogData) # print (x.keystone.catalogData)
neutronService=x.keystone.getServicebyName("Neutron") # neutronService=x.keystone.getServicebyName("Neutron")
print(neutronService) # print(neutronService)
neutronEndpointInternal=x.keystone.getEndpointByServiceIDAndInterface(neutronService['id'],"internal") neutronEndpointInternal=x.keystone.getEndpointByNameIDAndInterface("NeuTrOn","internal")
print(neutronEndpointInternal) print(neutronEndpointInternal)
# token = ng_openstack.auth.getToken(os.getenv("OS_USERNAME"), os.getenv("OS_PASSWORD"), # token = ng_openstack.auth.getToken(os.getenv("OS_USERNAME"), os.getenv("OS_PASSWORD"),

View File

@ -47,8 +47,16 @@ class Openstack_Keystone():
def getEndpointByServiceIDAndInterface(_self,id,interface): def getEndpointByServiceIDAndInterface(_self,id,interface):
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():
if str(_endpoint['interface']).lower()==str(interface).lower(): if str(_endpoint['interface']).lower()==str(interface).lower():
# print(_endpoint) # print(_endpoint)
return(_endpoint) return(_endpoint)
def getEndpointByNameIDAndInterface(_self,name,interface):
serviceID=_self.getServicebyName(name)['id']
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)