@@ -25,11 +25,24 @@ def delete(self):
2525 future = self .client ._perform_tenant_json ("DELETE" , "/instance-settings-templates/%s" % self .id )
2626 return FMFuture .from_resp (self .client , future )
2727
28+ def add_setup_action (self , setup_action ):
29+ """
30+ Add a setup_action
31+
32+ :param object setup_action: a :class:`dataikuapi.fm.instancesettingstemplates.FMSetupAction`
33+ """
34+ self .ist_data ['setupActions' ].append (setup_action )
35+ self .save ()
36+
37+
2838class FMSetupAction (dict ):
2939 def __init__ (self , setupActionType , params = None ):
3040 """
31- param: object setupActionType: the type (`:class: FMSetupActionType`) of the SetupAction
32- param: str params: the parameters of the SetupAction in a json-encoded string
41+ A class representing a SetupAction
42+
43+ Do not create this directly, use:
44+ - :meth:`dataikuapi.fm.instancesettingstemplates.FMSetupAction.add_authorized_key`
45+
3346 """
3447 data = {
3548 "type" : setupActionType .value ,
@@ -39,9 +52,31 @@ def __init__(self, setupActionType, params=None):
3952
4053 super (FMSetupAction , self ).__init__ (data )
4154
42- class FMSetupActionAddAuthorizedKey (FMSetupAction ):
43- def __init__ (self , ssh_key ):
44- super (FMSetupActionAddAuthorizedKey , self ).__init__ (FMSetupActionType .ADD_AUTHORIZED_KEY , {"sshKey" : ssh_key })
55+ @staticmethod
56+ def add_authorized_key (ssh_key ):
57+ """
58+ Return a ADD_AUTHORIZED_KEY SetupAction
59+ """
60+ return FMSetupAction (FMSetupActionType .ADD_AUTHORIZED_KEY , {"sshKey" : ssh_key })
61+
62+ @staticmethod
63+ def run_ansible_task (stage , yaml_string ):
64+ """
65+ Return a RUN_ANSIBLE_TASK SetupAction
66+
67+ :params object stage: a :class:`dataikuapi.fm.instancesettingstemplates.FMSetupActionStage`
68+ :params str yaml_string: a yaml encoded string defining the ansibles tasks to run
69+ """
70+ return FMSetupAction (FMSetupActionType .RUN_ANSIBLE_TASKS , {"stage" : stage .value , "ansibleTasks" : yaml_string })
71+
72+ @staticmethod
73+ def install_system_packages (packages ):
74+ """
75+ Return an INSTALL_SYSTEM_PACKAGES SetupAction
76+
77+ :params list packages: List of packages to install
78+ """
79+ return FMSetupAction (FMSetupActionType .INSTALL_SYSTEM_PACKAGES , {"packages" : packages })
4580
4681class FMSetupActionType (Enum ):
4782 RUN_ANSIBLE_TASKS = "RUN_ANSIBLE_TASKS"
@@ -56,3 +91,8 @@ class FMSetupActionType(Enum):
5691 ADD_AUTHORIZED_KEY = "ADD_AUTHORIZED_KEY"
5792 INSTALL_JDBC_DRIVER = "INSTALL_JDBC_DRIVER"
5893 SETUP_ADVANCED_SECURITY = "SETUP_ADVANCED_SECURITY"
94+
95+ class FMSetupActionStage (Enum ):
96+ after_dss_startup = "after_dss_startup"
97+ after_install = "after_install"
98+ before_install = "before_install"
0 commit comments