Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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        
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
 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