Skip to content

Commit

Permalink
pylint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Smith committed Apr 1, 2015
1 parent 27294f8 commit d2df011
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 40 deletions.
82 changes: 44 additions & 38 deletions samples/aci-create-static-endpoint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2014 Cisco Systems
# Copyright (c) 2014, 2015 Cisco Systems, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
Expand Down Expand Up @@ -27,7 +27,7 @@
Before running, please make sure that the credentials.py
file has the URL, LOGIN, and PASSWORD set for your APIC environment.
"""
import acitoolkit.acitoolkit as ACI
import acitoolkit.acitoolkit as aci
import credentials

# Define static values to pass (edit these if you wish to set differently)
Expand All @@ -40,47 +40,53 @@
'encap_type': 'vlan',
'encap_id': '5'}

# Login to the APIC
session = ACI.Session(credentials.URL, credentials.LOGIN, credentials.PASSWORD)
resp = session.login()
if not resp.ok:
print('%% Could not login to APIC')
def main():
# Login to the APIC
session = aci.Session(credentials.URL, credentials.LOGIN, credentials.PASSWORD)
resp = session.login()
if not resp.ok:
print('%% Could not login to APIC')

# Create the Tenant, App Profile, and EPG
tenant = ACI.Tenant(TENANT_NAME)
app = ACI.AppProfile(APP_NAME, tenant)
epg = ACI.EPG(EPG_NAME, app)
# Create the Tenant, App Profile, and EPG
tenant = aci.Tenant(TENANT_NAME)
app = aci.AppProfile(APP_NAME, tenant)
epg = aci.EPG(EPG_NAME, app)

# Create the physical interface object
intf = ACI.Interface(INTERFACE['type'],
INTERFACE['pod'],
INTERFACE['node'],
INTERFACE['module'],
INTERFACE['port'])
# Create the physical interface object
intf = aci.Interface(INTERFACE['type'],
INTERFACE['pod'],
INTERFACE['node'],
INTERFACE['module'],
INTERFACE['port'])

# Create a VLAN interface and attach to the physical interface
vlan_intf = ACI.L2Interface(VLAN['name'], VLAN['encap_type'], VLAN['encap_id'])
vlan_intf.attach(intf)
# Create a VLAN interface and attach to the physical interface
vlan_intf = aci.L2Interface(VLAN['name'], VLAN['encap_type'], VLAN['encap_id'])
vlan_intf.attach(intf)

# Attach the EPG to the VLAN interface
epg.attach(vlan_intf)
# Attach the EPG to the VLAN interface
epg.attach(vlan_intf)

# Create the Endpoint
mac = '00:11:11:11:11:11'
ip = '10.10.5.5'
ep = ACI.Endpoint(name=mac,
parent=epg)
ep.mac = mac
ep.ip = ip
# Create the Endpoint
mac = '00:11:11:11:11:11'
ip = '10.10.5.5'
ep = aci.Endpoint(name=mac,
parent=epg)
ep.mac = mac
ep.ip = ip

# Assign it to the L2Interface
ep.attach(vlan_intf)
# Assign it to the L2Interface
ep.attach(vlan_intf)

print('JSON to be pushed: ' + str(tenant.get_json()))
print('JSON to be pushed: ' + str(tenant.get_json()))

# Push it all to the APIC
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)
# Push it all to the APIC
resp = tenant.push_to_apic(session)
if not resp.ok:
print('%% Error: Could not push configuration to APIC')
print(resp.text)

if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
4 changes: 2 additions & 2 deletions samples/aci-create-tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def main():
if not resp.ok:
print('%% Could not login to APIC')

# Create the Tenant, App Profile, and EPG
# Create the Tenant
tenant = aci.Tenant(args.tenant)

# Push it all to the APIC
# Push the tenant to the APIC
resp = session.push_to_apic(tenant.get_url(),
tenant.get_json())
if not resp.ok:
Expand Down

0 comments on commit d2df011

Please sign in to comment.