|
9 | 9 |
|
10 | 10 | from .fm.tenant import FMCloudCredentials |
11 | 11 | from .fm.virtualnetworks import FMVirtualNetwork |
12 | | -from .fm.instances import FMInstance, FMInstanceEncryptionMode |
13 | | -from .fm.instancesettingstemplates import FMInstanceSettingsTemplate |
14 | | -from dataikuapi.fm.instances import FMAWSInstanceCreator, FMAzureInstanceCreator |
| 12 | +from .fm.instances import FMInstance, FMInstanceEncryptionMode, FMAWSInstanceCreator, FMAzureInstanceCreator |
| 13 | +from .fm.instancesettingstemplates import FMInstanceSettingsTemplate, FMAWSInstanceSettingsTemplateCreator, FMAzureInstanceSettingsTemplateCreator |
15 | 14 |
|
16 | 15 | class FMClient(object): |
17 | 16 | """Entry point for the FM API client""" |
@@ -159,62 +158,17 @@ def get_instance_template(self, template_id): |
159 | 158 | template = self._perform_tenant_json("GET", "/instance-settings-templates/%s" % template_id) |
160 | 159 | return FMInstanceSettingsTemplate(self, template) |
161 | 160 |
|
162 | | - |
163 | | - def create_instance_template(self, label, |
164 | | - setupActions=None, license=None, |
165 | | - awsKeyPairName=None, startupInstanceProfileArn=None, runtimeInstanceProfileArn=None, |
166 | | - restrictAwsMetadataServerAccess=True, dataikuAwsAPIAccessMode="NONE", dataikuAwsKeypairStorageMode=None, |
167 | | - dataikuAwsAccessKeyId=None, dataikuAwsSecretAccessKey=None, |
168 | | - dataikuAwsSecretAccessKeyAwsSecretName=None, awsSecretsManagerRegion=None, |
169 | | - azureSshKey=None, startupManagedIdentity=None, runtimeManagedIdentity=None): |
| 161 | + def new_instance_template_creator(self, label): |
170 | 162 | """ |
171 | | - Create an Instance Template |
172 | | -
|
173 | | - :param str label: The label of the Instance Settings Template |
174 | | -
|
175 | | - :param list setupActions: Optional, a list of :class:`dataikuapi.fm.instancesettingstemplates.FMSetupAction` to be played on an instance |
176 | | - :param str license: Optional, overrides the license set in Cloud Setup |
177 | | -
|
178 | | - :param str awsKeyPairName: Optional, AWS Only, the name of an AWS key pair to add to the instance. Needed to get SSH access to the DSS instance, using the centos user. |
179 | | - :param str startupInstanceProfileArn: Optional, AWS Only, the ARN of the Instance profile assigned to the DSS instance at startup time |
180 | | - :param str runtimeInstanceProfileArn: Optional, AWS Only, the ARN of the Instance profile assigned to the DSS instance at runtime |
181 | | - :param boolean restrictAwsMetadataServerAccess: Optional, AWS Only, If true, restrict the access to the metadata server access. Defaults to true |
182 | | - :param str dataikuAwsAPIAccessMode: Optional, AWS Only, the access mode DSS is using to connect to the AWS API. If "NONE" DSS will use the Instance Profile, If "KEYPAIR", an AWS access key id and secret will be securely given to the dataiku account. |
183 | | - :param str dataikuAwsKeypairStorageMode: Optional, AWS Only, the storage mode of the AWS api key. Accepts "NONE", "INLINE_ENCRYPTED" or "AWS_SECRETS_MANAGER" |
184 | | - :param str dataikuAwsAccessKeyId: Optional, AWS Only, AWS Access Key ID. Only needed if dataikuAwsAPIAccessMode is "KEYPAIR" |
185 | | - :param str dataikuAwsSecretAccessKey: Optional, AWS Only, AWS Access Key Secret. Only needed if dataikuAwsAPIAccessMode is "KEYPAIR" and dataikuAwsKeypairStorageMode is "INLINE_ENCRYPTED" |
186 | | - :param str dataikuAwsSecretAccessKeyAwsSecretName: Optional, AWS Only, ASM secret name. Only needed if dataikuAwsAPIAccessMode is "KEYPAIR" and dataikuAwsKeypairStorageMode is "AWS_SECRET_MANAGER" |
187 | | - :param str awsSecretsManagerRegion: Optional, AWS Only |
| 163 | + Instantiate a new instance template creator |
188 | 164 |
|
189 | | - :param str azureSshKey: Optional, Azure Only, the ssh public key to add to the instance. Needed to get SSH access to the DSS instance, using the centos user. |
190 | | - :param str startupManagedIdentity: Optional, Azure Only, the managed identity assigned to the DSS instance at startup time |
191 | | - :param str runtimeManagedIdentity: Optional, Azure Only, the managed identity assigned to the DSS instance at runtime |
192 | | -
|
193 | | - :return: requested instance settings template |
194 | | - :rtype: :class:`dataikuapi.fm.instancesettingstemplates.FMInstanceSettingsTemplate` |
| 165 | + :param str label: The label of the instance |
| 166 | + :rtype: :class:`dataikuapi.fm.instancesettingstemplates.FMInstanceSettingsTemplateCreator` |
195 | 167 | """ |
196 | | - |
197 | | - data = { |
198 | | - "label": label, |
199 | | - "setupActions": setupActions, |
200 | | - "license": license, |
201 | | - "awsKeyPairName": awsKeyPairName, |
202 | | - "startupInstanceProfileArn": startupInstanceProfileArn, |
203 | | - "runtimeInstanceProfileArn": runtimeInstanceProfileArn, |
204 | | - "restrictAwsMetadataServerAccess": restrictAwsMetadataServerAccess, |
205 | | - "dataikuAwsAPIAccessMode": "dataikuAwsAPIAccessMode", |
206 | | - "dataikuAwsKeypairStorageMode": dataikuAwsKeypairStorageMode, |
207 | | - "dataikuAwsAccessKeyId": dataikuAwsAccessKeyId, |
208 | | - "dataikuAwsSecretAccessKey": dataikuAwsSecretAccessKey, |
209 | | - "dataikuAwsSecretAccessKeyAwsSecretName": dataikuAwsSecretAccessKeyAwsSecretName, |
210 | | - "awsSecretsManagerRegion": awsSecretsManagerRegion, |
211 | | - "azureSshKey": azureSshKey, |
212 | | - "startupManagedIdentity": startupManagedIdentity, |
213 | | - "runtimeManagedIdentity": runtimeManagedIdentity |
214 | | - } |
215 | | - |
216 | | - template = self._perform_tenant_json("POST", "/instance-settings-templates", body=data) |
217 | | - return FMInstanceSettingsTemplate(self, template) |
| 168 | + if self.cloud == "AWS": |
| 169 | + return FMAWSInstanceSettingsTemplateCreator(self, label) |
| 170 | + elif self.cloud == "Azure": |
| 171 | + return FMAzureInstanceSettingsTemplateCreator(self, label) |
218 | 172 |
|
219 | 173 |
|
220 | 174 | ######################################################## |
@@ -251,6 +205,7 @@ def new_instance_creator(self, label, instance_settings_template_id, virtual_net |
251 | 205 | :param str instance_settings_template: The instance settings template id this instance should be based on |
252 | 206 | :param str virtual_network: The virtual network where the instance should be spawned |
253 | 207 | :param str image_id: The ID of the DSS runtime image (ex: dss-9.0.3-default) |
| 208 | + :rtype: :class:`dataikuapi.fm.instances.FMInstanceCreator` |
254 | 209 | """ |
255 | 210 | if self.cloud == "AWS": |
256 | 211 | return FMAWSInstanceCreator(self, label, instance_settings_template_id, virtual_network_id, image_id) |
|
0 commit comments