Guys, I need help, I'm a layman.
I have an installed network of the SRX300, but I already had many problems with the lack of energy.
To help you install a no-break even then a 20-minute battery life.
I would like to know how to make a script to turn off the juniper.
On windows I created a GPO to execute a command when I shut down the computer,
I do not know how to create the script to turn off Juniper equipment.
For simplicity, how can I make windows send a command to shut down a JUNIPER SRX300?
You can use Python to power off a Junos device from a Windows PC.
1. Install Python (Refer to PYEZ cookbook, link at the bootom)
2. Install Junos PYEZ library on Windows PC. (Refer to PYEZ cookbook, link at the bootom)
3. Open PowerShell and run the following commands, you can use the same in a Python script as well
4. Ensure netconf over ssh is enabled on SRX device
> show configuration system services netconfssh;
Windows PowerShellCopyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\jnet> pythonPython 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import jnpr.junos>>> from jnpr.junos import Device>>> from jnpr.junos.exception import ConnectError>>> srx=Device(host='<IP address of host>',user='root',password='password') << non-root should work if it has permissions.>>> from jnpr.junos.utils.sw import SW>>> srx.open()Device(<IP>)>>> sw=SW(srx)>>> print(sw.poweroff())Shutdown NOW![pid 98168]>>> print(sw.poweroff())
Stopping cron..Feb 24 20:24:58 jlaunchd: database-replication (PID 90347) terminate signal 15 sentFeb 24 20:24:59 jlaunchd: ethernet-connectivity-fault-management (PID 90348) terminate signal 15 sentFeb 24 20:24:59 jlaunchd: stats-agent (PID 90349) terminate signal 15 sentFeb 24 20:25:00 jlaunchd: transport-control (PID 90350) terminate signal 15 sentFeb 24 20:25:00 jlaunchd: SDN-Telemetry (PID 90353) terminate signal 15 sentFeb 24 20:25:00 jlaunchd: routing (PID 90354) terminate signal 15 sentFeb 24 20:25:01 jlaunchd: firewall (PID 90355) terminate signal 15 sentFeb 24 20:25:01 jlaunchd: chassis-control (PID 90356) terminate signal 15 sentFeb 24 20:25:01 jlaunchd: alarm-management (PID 90358) terminate signal 15 sentFeb 24 20:25:05 jlaunchd: craft-control (PID 18017) exited with status=0 Normal ExitWaiting (max 60 seconds) for system process `vnlru' to stop...doneWaiting (max 60 seconds) for system process `bufdaemon' to stop...doneWaiting (max 60 seconds) for system process `syncer' to stop...Syncing disks, vnodes remaining...0 0 0 0 doneAll buffers synced.Uptime: 49d5h6m19sbesw0: 4 Broadcom SDK kernel threads killedKhelp module "jsocket" can't unload until its refcount drops from 5 to 0.
The operating system has halted.Turning the system power off.
First of all I would like to thank you for answering me. I ran exactly the step-by-step and ran and hung up my Juniper. My question is that I saved the Script as PS1 (powershell) and it's error. I do not know if this is the correct procedure. I just could not automate the script.
You can save the file as shutdown.py, complete file contents at the bottom.
Open Powershell and change to the directory with the file in it, and execute the script
import jnpr.junosfrom jnpr.junos import Devicefrom jnpr.junos.exception import ConnectErrorsrx=Device(host='<IP address of host>',user='root',password='password')from jnpr.junos.utils.sw import SWsrx.open()sw=SW(srx)print(sw.poweroff())
Please mark the Solution as Accepted, Kudos are appreciated as well.
I performed the procedure exactly as explained, executed successfully.
Helped me a lot and I hope I can help other people.
Thank you very much.