Skip to content

Commit

Permalink
Merge pull request #303 from sig9org/addAciCreateBdSampleSpike
Browse files Browse the repository at this point in the history
Add aci-create-bd.py sample.
  • Loading branch information
michsmit99 committed Jun 12, 2017
2 parents 04f76a2 + 4ade537 commit 5662189
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ A tutorial and overview of the acitoolkit object model can be found in
the Documentation section found at
[http://datacenter.github.io/acitoolkit/](http://datacenter.github.io/acitoolkit/)


# Using Docker Image

```
docker run -it --name acitoolkit dockercisco/acitoolkit
```

# License

Copyright 2015 Cisco Systems, Inc.
Expand Down
53 changes: 53 additions & 0 deletions samples/aci-create-bd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python
"""
Sample of creating a BridgeDomain
"""

from acitoolkit.acitoolkit import Credentials, Session, Tenant, Context, BridgeDomain, Subnet

def main():
"""
Main execution routine
:return: None
"""
creds = Credentials('apic')
creds.add_argument('--tenant', help='The name of Tenant')
creds.add_argument('--vrf', help='The name of VRF')
creds.add_argument('--bd', help='The name of BridgeDomain')
creds.add_argument('--address', help='Subnet IPv4 Address')
creds.add_argument('--scope', help='The scope of subnet ("public", "private", "shared", "public,shared", "private,shared", "shared,public", "shared,private")')

args = creds.get()
session = Session(args.url, args.login, args.password)
session.login()

tenant = Tenant(args.tenant)
vrf = Context(args.vrf)
bd = BridgeDomain(args.bd, tenant)
bd.add_context(vrf)

if args.address is None:
bd.set_arp_flood('yes')
bd.set_unicast_route('no')
else:
bd.set_arp_flood('no')
bd.set_unicast_route('yes')

subnet = Subnet('', bd)
subnet.addr = args.address

if args.scope is None:
subnet.set_scope("private")
else:
subnet.set_scope(args.scope)

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 __name__ == '__main__':
main()

0 comments on commit 5662189

Please sign in to comment.