| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
from __future__ import absolute_import, division, print_function |
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
DOCUMENTATION = ''' |
| 9 |
--- |
| 10 |
module: azure_rm_ml_datastore_info |
| 11 |
version_added: "3.16.0" |
| 12 |
short_description: List ML Data resources |
| 13 |
description: |
| 14 |
- List ML Data resources. |
| 15 |
options: |
| 16 |
name: |
| 17 |
description: |
| 18 |
- Name of the datastore. |
| 19 |
type: str |
| 20 |
required: false |
| 21 |
resource_group: |
| 22 |
description: |
| 23 |
- Name of resource group. |
| 24 |
required: true |
| 25 |
type: str |
| 26 |
ml_workspace: |
| 27 |
description: |
| 28 |
- Name of the Azure ML workspace. |
| 29 |
required: true |
| 30 |
type: str |
| 31 |
|
| 32 |
extends_documentation_fragment: |
| 33 |
- azure.azcollection.azure |
| 34 |
|
| 35 |
author: |
| 36 |
- Bill Peck (@p3ck) |
| 37 |
''' |
| 38 |
|
| 39 |
EXAMPLES = ''' |
| 40 |
- name: List Specific ML datastore |
| 41 |
azure.azcollection.azure_rm_ml_datastore_info: |
| 42 |
name: MyData |
| 43 |
resource_group: myResourceGroup |
| 44 |
ml_workspace: myMLWorkspace |
| 45 |
|
| 46 |
- name: List ML datastore |
| 47 |
azure.azcollection.azure_rm_ml_datastore_info: |
| 48 |
resource_group: myResourceGroup |
| 49 |
ml_workspace: myMLWorkspace |
| 50 |
''' |
| 51 |
|
| 52 |
RETURN = ''' |
| 53 |
ml_datastore: |
| 54 |
description: |
| 55 |
- Datastore that was just created or updated. |
| 56 |
returned: always |
| 57 |
type: dict |
| 58 |
sample: [ |
| 59 |
{ |
| 60 |
"account_name": "workspacstoragexxxxxxxxx", |
| 61 |
"container_name": "datastorexxxxxxxxx-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", |
| 62 |
"credentials": {}, |
| 63 |
"description": "here is a description", |
| 64 |
"endpoint": "core.windows.net", |
| 65 |
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-datastore/providers/Microsoft.MachineLearningServices/workspaces/workspaceexxxxxxxx/datastores/datastorexxxxxxxxx", |
| 66 |
"name": "datastorexxxxxxxxx", |
| 67 |
"protocol": "https", |
| 68 |
"tags": {}, |
| 69 |
"type": "azure_blob", |
| 70 |
} |
| 71 |
] |
| 72 |
''' |
| 73 |
|
| 74 |
|
| 75 |
try: |
| 76 |
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ml import MLClientCommon |
| 77 |
from azure.core.exceptions import ResourceNotFoundError |
| 78 |
except ImportError: |
| 79 |
|
| 80 |
pass |
| 81 |
|
| 82 |
|
| 83 |
class AzureRMMLDatastoreInfo(MLClientCommon): |
| 84 |
def __init__(self): |
| 85 |
|
| 86 |
self.module_arg_spec = dict( |
| 87 |
name=dict( |
| 88 |
type='str', |
| 89 |
required=False, |
| 90 |
), |
| 91 |
resource_group=dict( |
| 92 |
type='str', |
| 93 |
required=True, |
| 94 |
), |
| 95 |
ml_workspace=dict( |
| 96 |
type='str', |
| 97 |
required=True, |
| 98 |
), |
| 99 |
) |
| 100 |
|
| 101 |
self._client = None |
| 102 |
self.ml_registry = None |
| 103 |
|
| 104 |
self.results = dict( |
| 105 |
ml_datastores=[] |
| 106 |
) |
| 107 |
|
| 108 |
super(AzureRMMLDatastoreInfo, self).__init__(self.module_arg_spec, |
| 109 |
supports_tags=False, |
| 110 |
supports_check_mode=True, |
| 111 |
facts_module=True, |
| 112 |
) |
| 113 |
|
| 114 |
def exec_module(self, **kwargs): |
| 115 |
|
| 116 |
for key in list(self.module_arg_spec.keys()): |
| 117 |
setattr(self, key, kwargs[key]) |
| 118 |
|
| 119 |
if self.name: |
| 120 |
try: |
| 121 |
result = self.client.datastores.get(name=self.name, |
| 122 |
include_secrets=False) |
| 123 |
ml_datastores = [self.entity_to_dict(result)] |
| 124 |
except ResourceNotFoundError: |
| 125 |
ml_datastores = [] |
| 126 |
else: |
| 127 |
results = self.client.datastores.list(include_secrets=False) |
| 128 |
|
| 129 |
ml_datastores = [self.entity_to_dict(x) for x in results] |
| 130 |
|
| 131 |
self.results['ml_datastores'] = ml_datastores |
| 132 |
return self.results |
| 133 |
|
| 134 |
|
| 135 |
def main(): |
| 136 |
AzureRMMLDatastoreInfo() |
| 137 |
|
| 138 |
|
| 139 |
if __name__ == '__main__': |
| 140 |
main() |