Exemple #1
0
    def discovery_devices(self, net_address, block):
        conn = Connectivity()
        live_hosts = []

        if block == 1:
            if conn.check_connectivity(net_address):
                live_hosts.append(net_address)
                found_msg = QMessageBox()
                found_msg.Icon(QMessageBox.Information)
                found_msg.setWindowTitle("Device Found")
                found_msg.setText(f"{net_address} found and added")
            else:
                not_found_msg = QMessageBox()
                not_found_msg.Icon(QMessageBox.Critical)
                not_found_msg.setWindowTitle("Error")
                not_found_msg.setText(
                    f"{net_address} not reachable or SNMP community not configured"
                )
        else:
            subnet_4_octets = net_address.split('.')
            subnet_3_octets = subnet_4_octets[0] + '.' + subnet_4_octets[
                1] + '.' + subnet_4_octets[2]

            for host in range(block - 1):
                ip = subnet_3_octets + '.' + str(
                    int(subnet_4_octets[3]) + host)
                print(f"test ip: {ip}")
                if conn.check_connectivity(ip):
                    live_hosts.append(ip)

        return live_hosts
Exemple #2
0
    def login_execute(self):
        username = self.edit_username.text()
        password = self.edit_password.text()
        devices = []
        self.export_data = []

        for device in self.edit_list_of_devices.text().split(','):
            devices.append(device.strip(' '))
        commands = self.edit_commands.text().split(',')

        tshoot = TshootBackend(username, password)
        result = tshoot.get_config(commands, devices)
        if not result:
            error_msg = QMessageBox()
            error_msg.Icon(QMessageBox.Critical)
            error_msg.setWindowTitle("Error")
            error_msg.setText(
                """Connection could not be made to one of the devices, 
            check username/password and connectivity to devices""")
            error_msg.show()
            return

        # clear the output plain textedit box
        self.ptedit_output.clear()
        for key, value in result.items():
            self.ptedit_output.appendPlainText("\n*********************")
            self.ptedit_output.appendPlainText(f"Device Name(ip): {key}")
            self.ptedit_output.appendPlainText("**********************\n")
            self.export_data.append("\n" + key)
            # populate with new outputs
            for data in value:
                self.ptedit_output.appendPlainText(
                    data.replace("\r", "").strip("\n"))
                self.export_data.append(data.replace("\r", "").strip("\n"))
Exemple #3
0
 def open_interface_diag(self):
     self.ip = self.edit_ip_add.text()
     #print(self.device_type)
     if self.device_type.lower() == "junos":
         msg = QMessageBox()
         msg.Icon(QMessageBox.Information)
         msg.setWindowTitle("Feature Info")
         msg.setText("Only Juniper Layer 3 interfaces are implemented yet!")
         msg.exec()
     else:
         self.intfDiag = L2IntfConfig(self.ip, self.username, self.password)
         self.intfDiag.show()