Skip to content

Instantly share code, notes, and snippets.

@TomerAdmon
Created June 22, 2022 10:33
Show Gist options
  • Save TomerAdmon/7d3e33db178803bf5a754f9925b1b98a to your computer and use it in GitHub Desktop.
Save TomerAdmon/7d3e33db178803bf5a754f9925b1b98a to your computer and use it in GitHub Desktop.
from cloudshell.workflow.orchestration.sandbox import Sandbox
from cloudshell.workflow.orchestration.setup.default_setup_orchestrator import DefaultSetupWorkflow
from cloudshell.helpers.scripts.cloudshell_dev_helpers import attach_to_cloudshell_as
attach_to_cloudshell_as('admin', 'admin', 'Global', '16e8fb96-6678-4971-b0c3-5fae4276a9ef', 'localhost')
def configure_apps(sandbox, something):
"""
:param Sandbox sandbox:
:param dict[str, App] components
:return:
"""
components = sandbox.components.apps
sandbox.automation_api.WriteMessageToReservationOutput(reservationId=sandbox.id,
message='configure_apps started')
for app in components.items():
sandbox.apps_configuration.set_config_param(app=app[1], alias='telegraf',
key='SANDBOX',
value=sandbox.id)
sandbox.apps_configuration.set_config_param(app=app[1], alias='telegraf',
key='HOSTNAME',
value=app[0])
sandbox.apps_configuration.apply_apps_configurations(components.values())
sandbox = Sandbox()
DefaultSetupWorkflow().register(sandbox, enable_configuration=False)
sandbox.workflow.add_to_configuration(function=configure_apps,
components=sandbox.components.apps)
sandbox.execute_setup()
try:
sandbox.automation_api.EnqueueCommand(sandbox.id, 'monitor', 'Service', 'monitor', printOutput=True)
except:
print("No monitoring")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment