cancel
Showing results for 
Search instead for 
Did you mean: 

Change Python task from "reboot" to "reboot all" so slots reboot as well.

Change Python task from "reboot" to "reboot all" so slots reboot as well.

Joshua_Beddingf
New Contributor II

There is a python task in Site Engine called "Restart Device".  It works well and I have it schedules for 2am on Sundays when no one is here.

But it only reboots the x465 and none of the x400 slots (port extenders).  The cli command to make all the devices reboot is "reboot all".  How can I modify the Python script to do "reboot all"?

I have tried to create a CLI task, and that task works, but I cannot seem to schedule saved CLI tasks to run at a certain day and time.

5 REPLIES 5

deborahle3351
New Contributor
 

Changing the Python task from reboot to reboot all should do the trick if you want the slots to reboot as well. Just make sure the command is supported by your setup and test it first to avoid any unexpected impact.

 

michs23
New Contributor

@Joshua_Beddingf wrote:

There is a python task in Site Engine called "Restart Device".  It works well and I have it schedules for 2am on Sundays when no one is here.

But it only reboots the x465 and none of the x400 slots (port extenders).  The cli command to make all the devices reboot is "reboot all".  How can I modify the Python script to do "reboot all"?

I have tried to create a CLI task, and that task works, but I cannot seem to schedule saved CLI tasks to run at a certain day and time.


The api.reboot() call itself is likely correct, but the script needs to specify which device to reboot. Consult the API documentation for device selection methods (e.g., api.select_device(), api.get_devices()). If rebooting multiple devices, iterate through the device list and call api.reboot() for each one after selecting it. The errors you're seeing are due to the lack of device selection, not the reboot() method itself.

The device selection is done in Site Engine.  It sends the api call to each device I select.  The problem is the port extender topology of the x465 / v400 system needs a different command then "reboot".  To reboot the system you have to send "reboot all".  The v400 port extender switches are not indinivually addressable.  They are controlled by the master switch - the x465.

 

Joshua_Beddingf
New Contributor II

The problem is it seems to be doing an API call.  This is the Python script in SIte Engine.  It looks like it is using "cli_result = api.reboot()"  Changing that to be api.reboot all() gets an error.  Trying api.reboot(all) gets an error.  So it seems the Python script is not running an embedded CLI command - it is calling an api.


# @METADATASTART
#@DetailDescriptionStart
################################################################
# System Script
#
# Script : Resets the target device
# Revision : 1.0
# Last updated : 4/24/2018
# Purpose : To reset the target device
#
################################################################
#@DetailDescriptionEnd
################################################################################
# Default Command Timeout
################################################################################
# @VariableFieldLabel (description = "Command Timeout in seconds",
# name = commandTimeout,
# type = String,
# scope = global,
# required = no
# )
# @SectionEnd
# @MetaDataEnd
from xmclib import emc_vars
from xmclib import logger
from xmclib import cli
from device import api

try:
cli_result = api.reboot()
cli.process_result(cli_result, emc_results)

except Exception as e:
cli.process_exception(e, emc_results)

GTM-P2G8KFN