mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix erros
This commit is contained in:
parent
22382726fa
commit
083530d8fa
1 changed files with 9 additions and 9 deletions
|
@ -5,9 +5,9 @@ import os
|
||||||
import argparse
|
import argparse
|
||||||
import types
|
import types
|
||||||
|
|
||||||
MONORAIL_URL = 'http://localhost:8080'
|
RACKHD_URL = 'http://localhost:8080'
|
||||||
|
|
||||||
class OnRackInventory(object):
|
class RackhdInventory(object):
|
||||||
def __init__(self, nodeids):
|
def __init__(self, nodeids):
|
||||||
self._inventory = {}
|
self._inventory = {}
|
||||||
for nodeid in nodeids:
|
for nodeid in nodeids:
|
||||||
|
@ -18,12 +18,12 @@ class OnRackInventory(object):
|
||||||
output += ',\n'
|
output += ',\n'
|
||||||
output = output[:-2]
|
output = output[:-2]
|
||||||
output += '}\n'
|
output += '}\n'
|
||||||
print output
|
print (output)
|
||||||
|
|
||||||
def _load_inventory_data(self, nodeid):
|
def _load_inventory_data(self, nodeid):
|
||||||
info = {}
|
info = {}
|
||||||
info['ohai'] = MONORAIL_URL + '/api/common/nodes/{0}/catalogs/ohai'.format(nodeid )
|
info['ohai'] = RACKHD_URL + '/api/common/nodes/{0}/catalogs/ohai'.format(nodeid )
|
||||||
info['lookup'] = MONORAIL_URL + '/api/common/lookups/?q={0}'.format(nodeid)
|
info['lookup'] = RACKHD_URL + '/api/common/lookups/?q={0}'.format(nodeid)
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
for key,url in info.iteritems():
|
for key,url in info.iteritems():
|
||||||
|
@ -52,8 +52,8 @@ class OnRackInventory(object):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#check if monorail url(ie:10.1.1.45:8080) is specified in the environment
|
#check if rackhd url(ie:10.1.1.45:8080) is specified in the environment
|
||||||
MONORAIL_URL = 'http://' + str(os.environ['MONORAIL'])
|
RACKHD_URL = 'http://' + str(os.environ['RACKHD_URL'])
|
||||||
except:
|
except:
|
||||||
#use default values
|
#use default values
|
||||||
pass
|
pass
|
||||||
|
@ -64,10 +64,10 @@ nodeids = []
|
||||||
try:
|
try:
|
||||||
nodeids += os.environ['nodeid'].split(',')
|
nodeids += os.environ['nodeid'].split(',')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
url = MONORAIL_URL + '/api/common/nodes'
|
url = RACKHD_URL + '/api/common/nodes'
|
||||||
r = requests.get( url, verify=False)
|
r = requests.get( url, verify=False)
|
||||||
data = json.loads(r.text)
|
data = json.loads(r.text)
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if entry['type'] == 'compute':
|
if entry['type'] == 'compute':
|
||||||
nodeids.append(entry['id'])
|
nodeids.append(entry['id'])
|
||||||
OnRackInventory(nodeids)
|
RackhdInventory(nodeids)
|
||||||
|
|
Loading…
Reference in a new issue