mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #42811 from hibbert/allow_creation_token_boto_efs/develop
develop: Allow creation_token to be passed into create_file_system an…
This commit is contained in:
commit
b72718ee82
@ -135,6 +135,7 @@ def create_file_system(name,
|
||||
key=None,
|
||||
profile=None,
|
||||
region=None,
|
||||
creation_token=None,
|
||||
**kwargs):
|
||||
'''
|
||||
Creates a new, empty file system.
|
||||
@ -146,6 +147,10 @@ def create_file_system(name,
|
||||
(string) - The PerformanceMode of the file system. Can be either
|
||||
generalPurpose or maxIO
|
||||
|
||||
creation_token
|
||||
(string) - A unique name to be used as reference when creating an EFS.
|
||||
This will ensure idempotency. Set to name if not specified otherwise
|
||||
|
||||
returns
|
||||
(dict) - A dict of the data for the elastic file system
|
||||
|
||||
@ -155,10 +160,11 @@ def create_file_system(name,
|
||||
|
||||
salt 'my-minion' boto_efs.create_file_system efs-name generalPurpose
|
||||
'''
|
||||
import os
|
||||
import base64
|
||||
creation_token = base64.b64encode(os.urandom(46), ['-', '_'])
|
||||
tags = [{"Key": "Name", "Value": name}]
|
||||
|
||||
if creation_token is None:
|
||||
creation_token = name
|
||||
|
||||
tags = {"Key": "Name", "Value": name}
|
||||
|
||||
client = _get_conn(key=key, keyid=keyid, profile=profile, region=region)
|
||||
|
||||
@ -372,6 +378,7 @@ def get_file_systems(filesystemid=None,
|
||||
key=None,
|
||||
profile=None,
|
||||
region=None,
|
||||
creation_token=None,
|
||||
**kwargs):
|
||||
'''
|
||||
Get all EFS properties or a specific instance property
|
||||
@ -380,6 +387,12 @@ def get_file_systems(filesystemid=None,
|
||||
filesystemid
|
||||
(string) - ID of the file system to retrieve properties
|
||||
|
||||
creation_token
|
||||
(string) - A unique token that identifies an EFS.
|
||||
If fileysystem created via create_file_system this would
|
||||
either be explictitly passed in or set to name.
|
||||
You can limit your search with this.
|
||||
|
||||
returns
|
||||
(list[dict]) - list of all elastic file system properties
|
||||
|
||||
@ -393,9 +406,16 @@ def get_file_systems(filesystemid=None,
|
||||
result = None
|
||||
client = _get_conn(key=key, keyid=keyid, profile=profile, region=region)
|
||||
|
||||
if filesystemid:
|
||||
if filesystemid and creation_token:
|
||||
response = client.describe_file_systems(FileSystemId=filesystemid,
|
||||
CreationToken=creation_token)
|
||||
result = response["FileSystems"]
|
||||
elif filesystemid:
|
||||
response = client.describe_file_systems(FileSystemId=filesystemid)
|
||||
result = response["FileSystems"]
|
||||
elif creation_token:
|
||||
response = client.describe_file_systems(CreationToken=creation_token)
|
||||
result = response["FileSystems"]
|
||||
else:
|
||||
response = client.describe_file_systems()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user