Пример #1
0
 def findNetworkUIDs(self):
     networks = cpauto.Network(self.session)
     order = []
     output = networks.show_all(500, 0, order, 'uid')
     output_dictionary = output.json()
     helplist = output_dictionary['objects']
     return helplist
Пример #2
0
 def isNetworkExists(self, uid, ip, mask):
         network = cpauto.Network(self.session)
         output = network.show(uid)
         print output
         outputdictfromserver = output.json()
         print outputdictfromserver
         IP = outputdictfromserver['subnet4'] 
         MASK = outputdictfromserver['mask-length4']
         #print "object: {} {}".format(IP, MASK)
         if (str(IP) == ip and str(MASK) == mask):
              return True
         else: 
              return False
Пример #3
0
def test_delete(core_client, mgmt_server_base_uri, name, uid, params):
    endpoint = mgmt_server_base_uri + 'delete-network'
    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')

        nc = cpauto.Network(core_client)
        r = nc.delete(name=name, uid=uid, params=params)

        assert r.status_code == 200
        assert r.json() == resp_body
Пример #4
0
def test_show_all(core_client, mgmt_server_base_uri, limit, offset, order,
                  details_level):
    endpoint = mgmt_server_base_uri + 'show-networks'
    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')

        nc = cpauto.Network(core_client)
        r = nc.show_all(limit=limit,
                        offset=offset,
                        order=order,
                        details_level=details_level)

        assert r.status_code == 200
        assert r.json() == resp_body
Пример #5
0
 def addNetwork(self, name, dic):
     network = cpauto.Network(self.session)
     output = network.add(name, params=dic)
     print output.json()
     #print >>log.txt, output.json()
     return output.status_code   
Пример #6
0
import cpauto

session = cpauto.CoreClient('admin', 'cisco123', '192.168.0.250')
output = session.login()

output.status_code

networks = cpauto.Network(session)
output = networks.show_all()
print type(output)
print output

outputdictfromserver = output.json()
print type(outputdictfromserver)

print outputdictfromserver

helplist = outputdictfromserver['objects']
print helplist

finallistofnetworksuid = []

IP = ''
mask = ''

#find uid of subnet

count01 = 0
count02 = len(helplist)

while count01 < count02: