Skip to content

Commit 852d5e8

Browse files
Merge pull request #1123 from FernandoOjeda/fo_object_storage_apiType
Fix object storage apiType for S3 and Swift.
2 parents 0c21f70 + 10e23fd commit 852d5e8

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

SoftLayer/CLI/object_storage/list_accounts.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@ def cli(env):
1515

1616
mgr = SoftLayer.ObjectStorageManager(env.client)
1717
accounts = mgr.list_accounts()
18-
table = formatting.Table(['id', 'name'])
18+
table = formatting.Table(['id', 'name', 'apiType'])
1919
table.sortby = 'id'
20+
api_type = None
2021
for account in accounts:
22+
if 'vendorName' in account and account['vendorName'] == 'Swift':
23+
api_type = 'Swift'
24+
elif 'Cleversafe' in account['serviceResource']['name']:
25+
api_type = 'S3'
26+
2127
table.add_row([
2228
account['id'],
2329
account['username'],
30+
api_type,
2431
])
2532

2633
env.fout(table)

SoftLayer/fixtures/SoftLayer_Account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@
525525

526526
getNextInvoiceTotalAmount = 2
527527

528-
getHubNetworkStorage = [{'id': 12345, 'username': 'SLOS12345-1'},
529-
{'id': 12346, 'username': 'SLOS12345-2'}]
528+
getHubNetworkStorage = [{'id': 12345, 'username': 'SLOS12345-1', 'serviceResource': {'name': 'Cleversafe - US Region'}},
529+
{'id': 12346, 'username': 'SLOS12345-2', 'vendorName': 'Swift'}]
530530

531531
getIscsiNetworkStorage = [{
532532
'accountId': 1234,

SoftLayer/managers/object_storage.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
:license: MIT, see LICENSE for more details.
77
"""
88

9-
LIST_ACCOUNTS_MASK = '''mask(SoftLayer_Network_Storage_Hub_Swift)[
10-
id,username,notes
9+
LIST_ACCOUNTS_MASK = '''mask[
10+
id,username,notes,vendorName,serviceResource
1111
]'''
1212

1313
ENDPOINT_MASK = '''mask(SoftLayer_Network_Storage_Hub_Swift)[
@@ -29,12 +29,8 @@ def __init__(self, client):
2929

3030
def list_accounts(self):
3131
"""Lists your object storage accounts."""
32-
_filter = {
33-
'hubNetworkStorage': {'vendorName': {'operation': 'Swift'}},
34-
}
3532
return self.client.call('Account', 'getHubNetworkStorage',
36-
mask=LIST_ACCOUNTS_MASK,
37-
filter=_filter)
33+
mask=LIST_ACCOUNTS_MASK)
3834

3935
def list_endpoints(self):
4036
"""Lists the known object storage endpoints."""

tests/CLI/modules/object_storage_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def test_list_accounts(self):
1616

1717
self.assert_no_fail(result)
1818
self.assertEqual(json.loads(result.output),
19-
[{'id': 12345, 'name': 'SLOS12345-1'},
20-
{'id': 12346, 'name': 'SLOS12345-2'}])
19+
[{'apiType': 'S3', 'id': 12345, 'name': 'SLOS12345-1'},
20+
{'apiType': 'Swift', 'id': 12346, 'name': 'SLOS12345-2'}]
21+
)
2122

2223
def test_list_endpoints(self):
2324
accounts = self.set_mock('SoftLayer_Account', 'getHubNetworkStorage')

0 commit comments

Comments
 (0)