def _provisioning_overrider(self, sandbox, components): """ :param Sandbox sandbox: :return: """ api = sandbox.automation_api default_setup_instance = DefaultSetupWorkflow() sandbox.logger.info("Executing non-default provisioning") reservation_details = api.GetReservationDetails(sandbox.id) default_setup_instance._deploy_result = DefaultSetupLogic.deploy_apps_in_reservation( api=api, reservation_details=reservation_details, reservation_id=sandbox.id, logger=sandbox.logger) DefaultSetupLogic.validate_all_apps_deployed( deploy_results=default_setup_instance._deploy_result, logger=sandbox.logger) sandbox.components.refresh_components(sandbox=sandbox) return None
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.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")
def custom_function(sandbox, components): """ :param Sandbox sandbox: """ for resource in components: if '/' in resource: continue sandbox.automation_api.SetResourceLiveStatus(resource, 'Online') res = sandbox.automation_api.GetReservationDetails(sandbox.id) for route in res.ReservationDescription.RequestedRoutesInfo: sandbox.automation_api.ConnectRoutesInReservation( sandbox.id, endpoints=[route.Source, route.Target], mappingType=route.RouteType) pass sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox) resources = sandbox.components.resources sandbox.workflow.on_connectivity_ended(custom_function, resources) sandbox.execute_setup()
from cloudshell.workflow.orchestration.sandbox import Sandbox from cloudshell.workflow.orchestration.setup.default_setup_orchestrator import DefaultSetupWorkflow from configure_apps import configure_sandbox_owner_mail_on_app sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox, enable_configuration=False) sandbox.workflow.add_to_configuration(configure_sandbox_owner_mail_on_app) 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()
from cloudshell.helpers.scripts.cloudshell_dev_helpers import attach_to_cloudshell_as from cloudshell.workflow.orchestration.sandbox import Sandbox from cloudshell.workflow.orchestration.setup.default_setup_orchestrator import DefaultSetupWorkflow from provisioning_override import custom_provisioning attach_to_cloudshell_as(user="******", password="******", domain="Global", reservation_id="be71319c-cf01-4adc-a560-bf41596d824f", server_address="localhost") sandbox = Sandbox() DefaultSetupWorkflow().register(sandbox, enable_provisioning=False) cpi = custom_provisioning() sandbox.workflow.add_to_provisioning(cpi.provisioning_overrider, None) sandbox.execute_setup()
def __init__(self, sandbox: Sandbox, config: TrainingWorkflowConfig = None): self.sandbox = sandbox self.default_setup_workflow = DefaultSetupWorkflow() self.config = config if config else TrainingWorkflowConfig() # bootstrap setup workflow data and services self._bootstrap()