Skip to content

Commit

Permalink
Fix credentials issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Nov 6, 2015
1 parent 4992574 commit 79fa98e
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions django/load_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ def main():
arista_group = InventoryGroup.objects.get_or_create(group_name='arista')
print arista_group

# Create credential object
arista_creds = Credentials.objects.get_or_create(
username='admin1',
password=passwd,
description='Arista credentials'
)
print arista_creds

# Create four switch objects
for switch_name, ssh_port, ip_addr in my_switches:
switch_obj = NetworkSwitch.objects.get_or_create(
Expand All @@ -27,24 +35,10 @@ def main():
ip_address=ip_addr,
management_ip=management_ip,
port=ssh_port,
group_name=arista_group[0]
group_name=arista_group[0],
credentials = arista_creds[0],
)
print switch_obj

# Create credential object
arista_creds = Credentials.objects.get_or_create(
username='admin1',
password=passwd,
description='Arista credentials'
)
print arista_creds

# Bind switches to credentials
net_devices = NetworkSwitch.objects.all()
print net_devices
for my_switch in net_devices:
my_switch.credentials = arista_creds[0]
my_switch.save()

if __name__ == "__main__":
main()

0 comments on commit 79fa98e

Please sign in to comment.