Beispiel #1
0
		def __init__(self,ip_address,obj):
			self.username = '******'
			self.password = '******'
			self.cdplistener = None
			self.myapp = NetworkApplication.get_instance()
			self.obj = obj
			if not self.myapp.name == "onePK-Python-Shell-CLI":
				self.myapp.name = "onePK-Python-Shell-CLI"
			#self.myapp.name = "onePK-Python-Shell-CLI-" + str(random.randint(0,10000))
			self.address = ip_address
			self.native = self.jconnect() 
Beispiel #2
0
		def __init__(self,ip_address,obj):
			self.username = '******'
			self.password = '******'
			self.cdplistener = None
			self.myapp = NetworkApplication.get_instance()
			self.obj = obj
			if not self.myapp.name == "onePK-Python-Shell-CLI":
				self.myapp.name = "onePK-Python-Shell-CLI"
			#self.myapp.name = "onePK-Python-Shell-CLI-" + str(random.randint(0,10000))
			self.address = ip_address
			self.native = self.jconnect() 
Beispiel #3
0
 def __init__(self):
     super(onepk, self).__init__()
     self._host = None
     self._username = '******'
     self._password = '******'
     self._device = None
     self._name = None
     self._version_info = None
     self._connected = False
     self.myapp = NetworkApplication.get_instance()
     if not self.myapp.name == "PNIL-ONEP":
         self.myapp.name = "PNIL-ONEP"
Beispiel #4
0
 def __init__(self):
     super(onepk, self).__init__()
     self._host = None
     self._username = '******'
     self._password = '******'
     self._device = None
     self._name = None
     self._version_info = None
     self._connected = False
     self.myapp = NetworkApplication.get_instance()
     if not self.myapp.name == "PNIL-ONEP":
         self.myapp.name = "PNIL-ONEP"
Beispiel #5
0
	def __init__(self,ip,username='******',password='******'):
	
		self.ip = ip
		self.username = username
		self.password = password

		self.myapp = NetworkApplication.get_instance()
		if not self.myapp.name == 'onePK-Python-Course-app':
			self.myapp.name == 'onePK-Python-Course-app'

		self.session_config = SessionConfig(SessionConfig.SessionTransportMode.TLS)
		self.session_config.ca_certs = "/home/cisco/ca.pem"
Beispiel #6
0
    def __init__(self, ip, username='******', password='******'):

        self.ip = ip
        self.username = username
        self.password = password

        self.myapp = NetworkApplication.get_instance()
        if not self.myapp.name == 'onePK-Python-Course-app':
            self.myapp.name == 'onePK-Python-Course-app'

        self.session_config = SessionConfig(
            SessionConfig.SessionTransportMode.TLS)
        self.session_config.ca_certs = "/home/cisco/ca.pem"
Beispiel #7
0
    def connect(self, applicationName):
        """
        Obtains a NetworkApplication instance, sets the name to applicationName, gets a network element for the IP
        address in the command line arguments or tutorial.properties file - both via the string format and an InetAddress
        formed from the IP address string - and then tries to connect to the Network Element with the username and
        password supplied, or from the tutorial.properties file.
        
        @param applicationName: The NetworkApplication name is set to this value.
        @return True if the connection succeeded without exception, else false.
        @throws OnepException
        """
        
        #  START SNIPPET: init_myapp
        network_application = NetworkApplication.get_instance()
        #  END SNIPPET: init_myapp
        
        #  START SNIPPET: name_myapp   
        network_application.name = applicationName
        #  END SNIPPET: name_myapp
        
        #  START SNIPPET: get_ne_opt1
        self.network_element = network_application.get_network_element(self.element_address)
        #  END SNIPPET: get_ne_opt1
        if self.network_element == None:
            logger.error("Failed to get network element")
            sys.exit(1)

        logger.info("We have a NetworkElement : " + self.network_element.__str__())
        
        #  START SNIPPET: connect
        session_config = SessionConfig(SessionConfig.SessionTransportMode.TLS) #default is TLS
        if self.transport.lower() == "tcp" or self.transport == "0":
            session_config = SessionConfig(SessionConfig.SessionTransportMode.SOCKET)
        elif self.transport.lower() == "tipc" or self.transport == "2":
            session_config = SessionConfig(SessionConfig.SessionTransportMode.TIPC)

        # Set the path to the root CA certificates
        session_config.caCerts = self.root_cert_path

        self.session_handle = self.network_element.connect(self.username, self.password, session_config)
        #  END SNIPPET: connect
        
        if self.session_handle == None:
            #  START SNIPPET: loggerError
            logger.error("Failed to connect to NetworkElement - ")
            #  END SNIPPET: loggerError
            return False
        logger.info("Successful connection to NetworkElement - " )
        return True