def main(): sandbox = Sandbox() #session = script_helpers.get_api_session() #sandbox_id = script_helpers.get_reservation_context_details().id #sandbox_resources = session.GetReservationDetails(sandbox_id).ReservationDescription.Resources sandbox_resources = sandbox.automation_api.GetReservationDetails( sandbox.id).ReservationDescription.Resources static_vms = [ res for res in sandbox_resources if res.ResourceModelName == 'vCenter Static VM' ] if static_vms.__len__() > 0: for static_vm in static_vms: sandbox.automation_api.ExecuteResourceConnectedCommand( reservationId=sandbox.id, resourceFullPath=static_vm.Name, commandName='PowerOn', commandTag='power', parameterValues=[], printOutput=True) else: session.WriteMessageToReservationOutput( reservationId=sandbox.id, message='No Static VMs to turn on!') #sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox) sandbox.execute_setup()
def main(): # Get list of vCenter Static VMs sandbox = Sandbox() sandbox_resources = sandbox.automation_api.GetReservationDetails( sandbox.id).ReservationDescription.Resources static_vms = [ res for res in sandbox_resources if res.ResourceModelName == 'vCenter Static VM' ] # If any, iterate through if len(static_vms) > 0: for static_vm in static_vms: if sandbox.automation_api.GetResourceLiveStatus( resourceFullPath=static_vm.Name ).liveStatusName != "Online": if static_vm.Shared: # Get number of reservations resource is currently in res_count = 0 for r in sandbox.automation_api.GetResourceAvailability( [static_vm.Name], True).Resources: for res in r.Reservations: res_count += 1 if res_count == 1: # If no other reservation, resource is unshared, powered on, then re shared # Unshared and re shared because shared resources cannot be powered on and off sandbox.automation_api.SetResourceSharedState( sandbox.id, [static_vm.Name], False) sandbox.automation_api.ExecuteResourceConnectedCommand( reservationId=sandbox.id, resourceFullPath=static_vm.Name, commandName='PowerOn', commandTag='power', parameterValues=[], printOutput=True) sandbox.automation_api.SetResourceSharedState( sandbox.id, [static_vm.Name], True) # If resource is in another reservation, it should already be powered on and can be skipped here else: # Power on any non shared resources sandbox.automation_api.ExecuteResourceConnectedCommand( reservationId=sandbox.id, resourceFullPath=static_vm.Name, commandName='PowerOn', commandTag='power', parameterValues=[], printOutput=True) else: sandbox.automation_api.WriteMessageToReservationOutput( reservationId=sandbox.id, message='No Static VMs to turn on!') # Default Sandbox Setup DefaultSetupWorkflow().register(sandbox) sandbox.execute_setup()
def main(): sandbox = Sandbox() sandbox.automation_api.WriteMessageToReservationOutput(reservationId=sandbox.id, message='Starting to execute the cool stuff!') DefaultSetupWorkflow().register(sandbox, enable_configuration=False) # Disable OOTB configuration sandbox.workflow.add_to_configuration(function=configure_apps, components=sandbox.components.apps) sandbox.execute_setup()
def main(): sandbox = Sandbox() sandbox.logger.info('starting main') sandbox.automation_api.WriteMessageToReservationOutput(reservationId=sandbox.id, message='Starting apps based on their priority') DefaultSetupWorkflow().register(sandbox, enable_connectivity=False,enable_configuration=False) # Disable OOTB configuration sandbox.workflow.add_to_connectivity(function=start_apps, components=sandbox.components.apps) sandbox.execute_setup()
def main(): sandbox = Sandbox() sandbox.automation_api.WriteMessageToReservationOutput( reservationId=sandbox.id, message='Starting to execute the cool stuff!') DefaultSetupWorkflow().register( sandbox, enable_configuration=False) # Disable OOTB configuration sandbox.workflow.add_to_configuration(function=configure_apps, components=sandbox.components.apps) sandbox.execute_setup()
def main(): sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox) route_details = sandbox.automation_api.GetReservationDetails( sandbox.id).ReservationDescription.TopologiesRouteInfo # stage hooks: sandbox.workflow.add_to_connectivity(function=do_route_connections, components=route_details) sandbox.execute_setup()
def main(): sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox) w2output = sandbox.automation_api.WriteMessageToReservationOutput model_list = ['Arista EOS Router'] for model in model_list: route_helper = RouteCommandHelper(device_model=model) w2output(sandbox.id, 'Queueing Route Disconnection for {}'.format(model)) sandbox.workflow.add_to_teardown(function=SandboxOrchPlugins().disconnect_routes_by_device_type(), components=route_helper) sandbox.execute_setup()
def main(): sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox) bark_inputs = OrderedDict() bark_inputs['Times'] = '3' cmd_helper = ResourceCommandHelper(command_name='bark', inputs=bark_inputs) # stage hooks: sandbox.workflow.add_to_configuration( function=SandboxOrchPlugins().run_resource_command_on_all, components=cmd_helper) sandbox.execute_setup()
def main(): # Default Setup Process sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox) sandbox.execute_setup() # Additional Setup Process # Connect All L1 Routes L1CC = L1ConnectionController() L1CC.ChangeStateOfAllL1Routes("Connect") # Set Config # insert code here work_config = WorkConfig() work_config.input_config_all("Config Path")
from cloudshell.workflow.orchestration.sandbox import Sandbox from cloudshell.orch.training.setup_orchestrator import TrainingSetupWorkflow import cloudshell.helpers.scripts.cloudshell_dev_helpers as dev_helpers if dev_helpers.is_dev_mode(): dev_helpers.attach_to_cloudshell_as( 'admin', 'admin', 'Global', 'a563eb82-a81f-4ec7-b328-4abb427e0992') sandbox = Sandbox() workflow = TrainingSetupWorkflow(sandbox) workflow.register() workflow.initialize() sandbox.execute_setup()
from cloudshell.workflow.orchestration.sandbox import Sandbox from cloudshell.workflow.orchestration.setup.default_setup_orchestrator import DefaultSetupWorkflow sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox) sandbox.execute_setup()
def main(): sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox, enable_configuration=False) sandbox.workflow.add_to_configuration(function=azure_app_extention, components=sandbox.components.apps) sandbox.execute_setup()
# Juniper Router Config #message = "Juniper Router Configuration File: "+Sandbox.global_inputs['Juniper Router Configuration File'] #Sandbox.automation_api.WriteMessageToReservationOutput(reservationId=Sandbox.id,message=message) if __name__ == '__main__': Sandbox = Sandbox() DefaultSetupWorkflow().register(Sandbox) #, enable_configuration=False # For each configurable resource, load its config if (Sandbox.global_inputs['Router Configuration File Set'] ).lower() not in ('none'): for resource_name, resource in Sandbox.components.resources.iteritems( ): if "/" in resource_name: continue if "FTP" in resource_name: continue # If not a Cisco or Juniper device, don't load config if "cisco" in resource_name.lower( ) or "juniper" in resource_name.lower(): Sandbox.workflow.add_to_configuration(function=loadConfig, components=resource_name) Sandbox.workflow.on_provisioning_ended( function=showGlobalInputs, components=Sandbox.components.resources) Sandbox.workflow.add_to_connectivity(function=connect_l1, components=None) #Sandbox.workflow.on_configuration_ended(function=execute_autoload_on_ixvm, components=Sandbox.components.apps) Sandbox.execute_setup()