def _get_client(self): ipaddress = self.config['ipaddress'] username = self.config['username'] password = self.config['password'] client = CFMClient(ipaddress, username, password) client.connect() return client
def access_client(): # 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 return client
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
def main_select(): #import cfm_api_utils as c ipaddress=request.form['ipaddress'] user=request.form['user'] passwd=request.form['passwd'] # Authenticat to the controller client=CFMClient(ipaddress,user,passwd) client.connect() # Build database entry to save creds creds = Sidekick(user=user,passwd=passwd,ipaddress=ipaddress) # Save the record try: creds.save() except: error="ERR001 - Failed to save login credentials" return render_template('sidekick/dberror.html', error=error) # Turn on to build num db on initial run # num = 1 # num = Number(num) # try: # creds.save() # except: # error = "ERR000 - Could not create number database" # return render_template('sidekick/dberror.html', error=error) # Returns a list a auto generated charts charts=build_charts() # Get the switches from the controller and save to the mongo database try: switches=fabric.get_switches(client) except: error="ERR-LOGIN - Failed to log into CFM controller" return render_template('sidekick/dberror.html', error=error) switch_data=[] # Process switch datat from plexxi API for switch in switches: health=switch['health'] ip_address=switch['ip_address'] mac_address=switch['mac_address'] name=switch['name'] sw_version=switch['sw_version'] uuid=switch['uuid'] # Write to switches database switch_info=Switches(health=health,ip_address=ip_address, mac_address=mac_address, name=name, sw_version=sw_version, uuid=uuid) # Save the record try: switch_info.save() except: error="ERR001X - Failed to save switch information" return render_template('sidekick/dberror.html', error=error) # Build list to write out to user interface out=[health,ip_address,mac_address,name,sw_version] switch_data.append(out) return render_template('main/sidekick1.html',u=user,i=ipaddress,g1_data=charts[0],g2_data=charts[1],s=switch_data)
from pyhpecfm.client import CFMClient from pyhpecfm import fabric ipaddress = '172.18.1.66' username = '******' password = '******' client = CFMClient(ipaddress, username, password) client.connect() params = { 'count_only': False, 'mac_attachemnts': False, 'mac_learning': True, 'ports': True, 'port_type': 'access', 'tag': True, 'type': 'provisioned', 'vlan_groups': True } cfm_lags = fabric.get_lags(client, params) print cfm_lags