You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As netmiko specifies there should be a device type, IP Address, username and a password so I made a model named devices and what I am trying to do is when I click on each device created in a table it should execute netmiko with the four credentials such as Device type, IP Address, Username and password for the specific device selected or clicked and it should allow me to type a command which can be executed by a press of button
View.py
This is the connection code but I am confused how to get data from the Model (Device) and pass it here or when I select a device from the view it should get the credential to this method
def connection_manage(request):
if request.method == "POST":
form = CommandForm(request.POST)
if form.is_valid():
from netmiko import ConnectHandler
device = {}
device['device_type'] = 'cisco_ios'
device['ip'] = 'DESKTOP-CT4RSIT'
device['username'] = ''
device['password'] = ''
cmd = request.POST.get('command', '')
conn = ConnectHandler(**device)
output = conn.send_command(cmd)
return render(request, 'connect.html', {'form': form, 'output': output})
else:
form = CommandForm()
return render(request, 'connect.html', {'form': form})
form.py
class CommandForm(BSModalForm):
command = forms.CharField(label='Command to execute')
class Meta:
model = Device
exclude = ['timestamp', 'publication_date', 'device_type']
First Setup needed
when i click on this one it should make me able to enter all details manually and press execute
enter all fields manually and execute
this is the view from the website but whatever I type it still going to connect to cisco_ios
output
The second Setup needed
when I click on the each filed button it should pop a modal which is currently working with all fields populated and when I type and command and execute it should run for the specified device
The text was updated successfully, but these errors were encountered:
As netmiko specifies there should be a device type, IP Address, username and a password so I made a model named devices and what I am trying to do is when I click on each device created in a table it should execute netmiko with the four credentials such as Device type, IP Address, Username and password for the specific device selected or clicked and it should allow me to type a command which can be executed by a press of button
can you please help me with the code
urs.py
path('execute/',connection_manage, name='execute_device'),
First Setup needed
when i click on this one it should make me able to enter all details manually and press execute
enter all fields manually and execute
this is the view from the website but whatever I type it still going to connect to cisco_ios
output
The second Setup needed
when I click on the each filed button it should pop a modal which is currently working with all fields populated and when I type and command and execute it should run for the specified device
The text was updated successfully, but these errors were encountered: