Skip to content

Commit

Permalink
more pylint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Smith committed Apr 3, 2015
1 parent 9202235 commit a9b9e83
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 97 deletions.
2 changes: 1 addition & 1 deletion applications/snapback/aciconfigdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def run(self):
time.sleep(seconds)
else:
delta = datetime.datetime.now() - start
seconds = delta.seconds + delta.days * (24*60*60)
seconds = delta.seconds + delta.days * (24 * 60 * 60)
self._next_snapshot_time = start
time.sleep(seconds)

Expand Down
93 changes: 50 additions & 43 deletions samples/aci-create-ospf-external.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,57 @@
Sample of creating OSPF interface
"""

from acitoolkit.acitoolkit import *
from acitoolkit.acitoolkit import Credentials, Session, Tenant, Context
from acitoolkit.acitoolkit import OutsideEPG, Interface, L2Interface
from acitoolkit.acitoolkit import L3Interface, OSPFRouter, OSPFInterfacePolicy
from acitoolkit.acitoolkit import OSPFInterface, Contract

creds = Credentials('apic')
args = creds.get()
session = Session(args.url, args.login, args.password)
session.login()
def main():
creds = Credentials('apic')
args = creds.get()
session = Session(args.url, args.login, args.password)
session.login()

tenant = Tenant('Cisco-Demo')
context = Context('ctx1', tenant)
outside = OutsideEPG('out-1', tenant)
outside.add_context(context)
phyif = Interface('eth', '1', '101', '1', '46')
phyif.speed = '1G'
l2if = L2Interface('eth 1/101/1/46', 'vlan', '1')
l2if.attach(phyif)
l3if = L3Interface('l3if')
l3if.set_l3if_type('l3-port')
l3if.set_mtu('1500')
l3if.set_addr('1.1.1.2/30')
l3if.add_context(context)
l3if.attach(l2if)
rtr = OSPFRouter('rtr-1')
rtr.set_router_id('23.23.23.23')
rtr.set_node_id('101')
ifpol = OSPFInterfacePolicy('myospf-pol', tenant)
ifpol.set_nw_type('p2p')
ospfif = OSPFInterface('ospfif-1', router=rtr, area_id='1')
ospfif.auth_key = 'password'
ospfif.int_policy_name = ifpol.name
ospfif.auth_keyid = '1'
ospfif.auth_type = 'simple'
tenant.attach(ospfif)
ospfif.networks.append('55.5.5.0/24')
ospfif.attach(l3if)
contract1 = Contract('contract-1')
outside.provide(contract1)
contract2 = Contract('contract-2')
outside.consume(contract2)
outside.attach(ospfif)
tenant = Tenant('Cisco-Demo')
context = Context('ctx1', tenant)
outside = OutsideEPG('out-1', tenant)
outside.add_context(context)
phyif = Interface('eth', '1', '101', '1', '46')
phyif.speed = '1G'
l2if = L2Interface('eth 1/101/1/46', 'vlan', '1')
l2if.attach(phyif)
l3if = L3Interface('l3if')
l3if.set_l3if_type('l3-port')
l3if.set_mtu('1500')
l3if.set_addr('1.1.1.2/30')
l3if.add_context(context)
l3if.attach(l2if)
rtr = OSPFRouter('rtr-1')
rtr.set_router_id('23.23.23.23')
rtr.set_node_id('101')
ifpol = OSPFInterfacePolicy('myospf-pol', tenant)
ifpol.set_nw_type('p2p')
ospfif = OSPFInterface('ospfif-1', router=rtr, area_id='1')
ospfif.auth_key = 'password'
ospfif.int_policy_name = ifpol.name
ospfif.auth_keyid = '1'
ospfif.auth_type = 'simple'
tenant.attach(ospfif)
ospfif.networks.append('55.5.5.0/24')
ospfif.attach(l3if)
contract1 = Contract('contract-1')
outside.provide(contract1)
contract2 = Contract('contract-2')
outside.consume(contract2)
outside.attach(ospfif)

print(tenant.get_json())
resp = session.push_to_apic(tenant.get_url(),
tenant.get_json())
print(tenant.get_json())
resp = session.push_to_apic(tenant.get_url(),
tenant.get_json())

if not resp.ok:
print('%% Error: Could not push configuration to APIC')
print(resp.text)
if not resp.ok:
print('%% Error: Could not push configuration to APIC')
print(resp.text)

if __name__ == '__main__':
main()

0 comments on commit a9b9e83

Please sign in to comment.