Skip to content

Commit ace9fee

Browse files
committed
global input sample
1 parent 4a926e6 commit ace9fee

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from cloudshell.workflow.orchestration.sandbox import Sandbox
2+
from cloudshell.workflow.orchestration.setup.default_setup_orchestrator import DefaultSetupWorkflow
3+
4+
5+
GLOBAL_INPUT_KEY = "My Global Input"
6+
7+
8+
def hello_world_from_global_input(sandbox, components=None):
9+
"""
10+
read global input and print out
11+
:param Sandbox sandbox:
12+
:param components:
13+
:return:
14+
"""
15+
api = sandbox.automation_api
16+
sb_id = sandbox.id
17+
global_inputs_dict = sandbox.global_inputs
18+
my_global = global_inputs_dict.get(GLOBAL_INPUT_KEY)
19+
if not my_global:
20+
raise ValueError("Key of {} not found in sandbox Global inputs".format(GLOBAL_INPUT_KEY))
21+
msg = "User value for input '{}' is '{}'".format(GLOBAL_INPUT_KEY, my_global)
22+
api.WriteMessageToReservationOutput(reservationId=sb_id, message=msg)
23+
24+
25+
sandbox = Sandbox()
26+
27+
DefaultSetupWorkflow().register(sandbox)
28+
sandbox.workflow.add_to_preparation(hello_world_from_global_input)
29+
30+
sandbox.execute_setup()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cloudshell-orch-core>=3.4.0.0,<3.5.0.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from quali_utils.quali_packaging import PackageEditor
2+
import sys
3+
4+
5+
def _flat_heirarchy(self, *args):
6+
strArgs = []
7+
for i, s in enumerate(args):
8+
if isinstance(s, list):
9+
strArgs.extend(self._flat_heirarchy(self, *tuple(s)))
10+
elif isinstance(s, tuple):
11+
strArgs.extend(self._flat_heirarchy(self, *s))
12+
elif isinstance(s, type(self)):
13+
pass
14+
elif sys.version_info[0] >= 3:
15+
if isinstance(s, str):
16+
strArgs.append('"{}"'.format(s))
17+
else:
18+
strArgs.append('"'+str(s).encode('UTF-8')+'"')
19+
return strArgs
20+
21+
22+
PACKAGE_PATH = r"C:\Users\natti.k\code\quali\cloudshell-api-script-samples\packaging-api-samples\quote bug test.zip"
23+
24+
p = PackageEditor()
25+
p.process._flat_heirarchy = _flat_heirarchy
26+
p.load(PACKAGE_PATH)
27+
x = p.change_topology_name_and_alias("quote bug test", "lolll")
28+
names = p.get_topology_names()
29+
topology_name = p.get_topology_names()[0]
30+
apps = p.get_apps(topology_name)
31+
app1 = apps[0]
32+
app1_name = app1.appResource.name
33+
34+
p.edit_app(topology_name=topology_name, app_name=app1_name, topology_app=app1)

0 commit comments

Comments
 (0)