-
Notifications
You must be signed in to change notification settings - Fork 194
Fix object storage credentials. #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
allmightyspiff
merged 5 commits into
softlayer:master
from
FernandoOjeda:fo_object_storage_credentials
Apr 23, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """Manages Object Storage S3 Credentials.""" | ||
| # :license: MIT, see LICENSE for more details. | ||
|
|
||
| import importlib | ||
| import os | ||
|
|
||
| import click | ||
|
|
||
| CONTEXT = {'help_option_names': ['-h', '--help'], | ||
| 'max_content_width': 999} | ||
|
|
||
|
|
||
| class CapacityCommands(click.MultiCommand): | ||
| """Loads module for object storage S3 credentials related commands.""" | ||
|
|
||
| def __init__(self, **attrs): | ||
| click.MultiCommand.__init__(self, **attrs) | ||
| self.path = os.path.dirname(__file__) | ||
|
|
||
| def list_commands(self, ctx): | ||
| """List all sub-commands.""" | ||
| commands = [] | ||
| for filename in os.listdir(self.path): | ||
| if filename == '__init__.py': | ||
| continue | ||
| if filename.endswith('.py'): | ||
| commands.append(filename[:-3].replace("_", "-")) | ||
| commands.sort() | ||
| return commands | ||
|
|
||
| def get_command(self, ctx, cmd_name): | ||
| """Get command for click.""" | ||
| path = "%s.%s" % (__name__, cmd_name) | ||
| path = path.replace("-", "_") | ||
| module = importlib.import_module(path) | ||
| return getattr(module, 'cli') | ||
|
|
||
|
|
||
| # Required to get the sub-sub-sub command to work. | ||
| @click.group(cls=CapacityCommands, context_settings=CONTEXT) | ||
| def cli(): | ||
| """Base command for all object storage credentials S3 related concerns""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """Create credentials for an IBM Cloud Object Storage Account.""" | ||
| # :license: MIT, see LICENSE for more details. | ||
|
|
||
| import click | ||
|
|
||
| import SoftLayer | ||
| from SoftLayer.CLI import environment | ||
| from SoftLayer.CLI import formatting | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.argument('identifier') | ||
| @environment.pass_env | ||
| def cli(env, identifier): | ||
| """Create credentials for an IBM Cloud Object Storage Account""" | ||
|
|
||
| mgr = SoftLayer.ObjectStorageManager(env.client) | ||
| credential = mgr.create_credential(identifier) | ||
| table = formatting.Table(['id', 'password', 'username', 'type_name']) | ||
| table.sortby = 'id' | ||
| table.add_row([ | ||
| credential['id'], | ||
| credential['password'], | ||
| credential['username'], | ||
| credential['type']['name'] | ||
| ]) | ||
|
|
||
| env.fout(table) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """Delete the credential of an Object Storage Account.""" | ||
| # :license: MIT, see LICENSE for more details. | ||
|
|
||
| import click | ||
|
|
||
| import SoftLayer | ||
| from SoftLayer.CLI import environment | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.argument('identifier') | ||
| @click.option('--credential_id', '-c', type=click.INT, | ||
| help="This is the credential id associated with the volume") | ||
| @environment.pass_env | ||
| def cli(env, identifier, credential_id): | ||
| """Delete the credential of an Object Storage Account.""" | ||
|
|
||
| mgr = SoftLayer.ObjectStorageManager(env.client) | ||
| credential = mgr.delete_credential(identifier, credential_id=credential_id) | ||
|
|
||
| env.fout(credential) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| """ Credential limits for this IBM Cloud Object Storage account.""" | ||
| # :license: MIT, see LICENSE for more details. | ||
|
|
||
| import click | ||
|
|
||
| import SoftLayer | ||
| from SoftLayer.CLI import environment | ||
| from SoftLayer.CLI import formatting | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.argument('identifier') | ||
| @environment.pass_env | ||
| def cli(env, identifier): | ||
| """Credential limits for this IBM Cloud Object Storage account.""" | ||
|
|
||
| mgr = SoftLayer.ObjectStorageManager(env.client) | ||
| credential_limit = mgr.limit_credential(identifier) | ||
| table = formatting.Table(['limit']) | ||
| table.add_row([ | ||
| credential_limit, | ||
| ]) | ||
|
|
||
| env.fout(table) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| """Retrieve credentials used for generating an AWS signature. Max of 2.""" | ||
| # :license: MIT, see LICENSE for more details. | ||
|
|
||
| import click | ||
|
|
||
| import SoftLayer | ||
| from SoftLayer.CLI import environment | ||
| from SoftLayer.CLI import formatting | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.argument('identifier') | ||
| @environment.pass_env | ||
| def cli(env, identifier): | ||
| """Retrieve credentials used for generating an AWS signature. Max of 2.""" | ||
|
|
||
| mgr = SoftLayer.ObjectStorageManager(env.client) | ||
| credential_list = mgr.list_credential(identifier) | ||
| table = formatting.Table(['id', 'password', 'username', 'type_name']) | ||
|
|
||
| for credential in credential_list: | ||
| table.add_row([ | ||
| credential['id'], | ||
| credential['password'], | ||
| credential['username'], | ||
| credential['type']['name'] | ||
| ]) | ||
|
|
||
| env.fout(table) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
SoftLayer/fixtures/SoftLayer_Network_Storage_Hub_Cleversafe_Account.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| credentialCreate = { | ||
| "accountId": "12345", | ||
| "createDate": "2019-04-05T13:25:25-06:00", | ||
| "id": 11111, | ||
| "password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXMkAFhDOjHqYJva", | ||
| "username": "XfHhBNBPlPdlWyaPPJAI", | ||
| "type": { | ||
| "description": "A credential for generating S3 Compatible Signatures.", | ||
| "keyName": "S3_COMPATIBLE_SIGNATURE", | ||
| "name": "S3 Compatible Signature" | ||
| } | ||
| } | ||
|
|
||
| getCredentials = [ | ||
| { | ||
| "accountId": "12345", | ||
| "createDate": "2019-04-05T13:25:25-06:00", | ||
| "id": 11111, | ||
| "password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXMkAFhDOjHqYJva", | ||
| "username": "XfHhBNBPlPdlWyaPPJAI", | ||
| "type": { | ||
| "description": "A credential for generating S3 Compatible Signatures.", | ||
| "keyName": "S3_COMPATIBLE_SIGNATURE", | ||
| "name": "S3 Compatible Signature" | ||
| } | ||
| }, | ||
| { | ||
| "accountId": "12345", | ||
| "createDate": "2019-04-05T13:25:25-06:00", | ||
| "id": 11111, | ||
| "password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXMkAFhDOjHqYJva", | ||
| "username": "XfHhBNBPlPdlWyaPPJAI", | ||
| "type": { | ||
| "description": "A credential for generating S3 Compatible Signatures.", | ||
| "keyName": "S3_COMPATIBLE_SIGNATURE", | ||
| "name": "S3 Compatible Signature" | ||
| } | ||
| } | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.