Пример #1
0
 def test_get_vlan_groups(self):
     """
     General test for pyhpecfm.fabric.get_vlan_groups function
     """
     test_vlan_groups = fabric.get_vlan_groups(cfm)
     my_attributes = ['lag_uuids', 'description', 'vlans', 'uuid', 'name']
     self.assertIs(type(test_vlan_groups), list)
     self.assertIs(type(test_vlan_groups[0]), dict)
     for i in test_vlan_groups[0].keys():
         self.assertIn(i, my_attributes)
Пример #2
0
 def test_get_vlan_groups_with_params(self):
     """
     General test for pyhpecfm.fabric.get_vlan_groups function with parameters to select
     a single VLAN group
     """
     params = {'name': 'My_New_VLAN_Group'}
     test_vlan_groups = fabric.get_vlan_groups(cfm, params=params)
     my_attributes = ['lag_uuids', 'description', 'vlans', 'uuid', 'name']
     self.assertIs(type(test_vlan_groups), list)
     self.assertIs(type(test_vlan_groups[0]), dict)
     for i in test_vlan_groups[0].keys():
         self.assertIn(i, my_attributes)
def get_vlans():

    # Get user informaation.
    creds = Sidekick.objects.first()
    username = creds.user.encode('utf-8')
    ipaddress = creds.ipaddress.encode('utf-8')
    password = creds.passwd.encode('utf-8')

    try:
        # Create client connection
        client = CFMClient(ipaddress, username, password)
        client.connect()
    except:
        error = 'Failed to obtain a client connetion to the CFM controller.'
        return error

    params = {}
    cfm_vlans = fabric.get_vlan_groups(client, params)

    return cfm_vlans