def findHostUIDs(self): hosts = cpauto.Host(self.session) order = [] output = hosts.show_all(500, 0, order, 'uid') output_dictionary = output.json() helplist = output_dictionary['objects'] return helplist
def isHostExist(self, uid, ip): host = cpauto.Host(self.session) output = host.show(uid) outputdictfromserver = output.json() #print outputdictfromserver IP = outputdictfromserver['ipv4-address'] #print IP if (str(IP) == ip): return True # else: return False
def test_delete(core_client, mgmt_server_base_uri, name, uid, params): endpoint = mgmt_server_base_uri + 'delete-host' with responses.RequestsMock() as rsps: resp_body = {'foo': 'bar', 'message': 'OK'} rsps.add(responses.POST, endpoint, json=resp_body, status=200, content_type='application/json') c = cpauto.Host(core_client) r = c.delete(name=name, uid=uid, params=params) assert r.status_code == 200 assert r.json() == resp_body
def test_show_all(core_client, mgmt_server_base_uri, limit, offset, order, details_level): endpoint = mgmt_server_base_uri + 'show-hosts' with responses.RequestsMock() as rsps: resp_body = {'foo': 'bar', 'message': 'OK'} rsps.add(responses.POST, endpoint, json=resp_body, status=200, content_type='application/json') c = cpauto.Host(core_client) r = c.show_all(limit=limit, offset=offset, order=order, details_level=details_level) assert r.status_code == 200 assert r.json() == resp_body
def addHost(self, name, IP, dic): host = cpauto.Host(self.session) output = host.add(name, IP, ipv4_address='', ipv6_address='' , params=dic) print output.json() #print >>log.txt, output.json() return output.status_code