Skip to content

Commit 4ffe956

Browse files
authored
CLI: Makes the price shown more accurate for virtual and hardware detail (#763)
Incorporates the child prices into the price for virtual and hardware detail. This impacts: `slcli virtual detail [ID] --price` `slcli hardware detail [ID] --price` It also adjusts the default masks for detailing hardware and virtual instances.
1 parent 14692fc commit 4ffe956

File tree

8 files changed

+46
-14
lines changed

8 files changed

+46
-14
lines changed

SoftLayer/CLI/hardware/detail.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,15 @@ def cli(env, identifier, passwords, price):
8181
table.add_row(['notes', result['notes']])
8282

8383
if price:
84-
table.add_row(['price rate',
85-
utils.lookup(result,
86-
'billingItem',
87-
'nextInvoiceTotalRecurringAmount')])
84+
total_price = utils.lookup(result,
85+
'billingItem',
86+
'nextInvoiceTotalRecurringAmount') or 0
87+
total_price += sum(p['nextInvoiceTotalRecurringAmount']
88+
for p
89+
in utils.lookup(result,
90+
'billingItem',
91+
'children') or [])
92+
table.add_row(['price_rate', total_price])
8893

8994
if passwords:
9095
pass_table = formatting.Table(['username', 'password'])

SoftLayer/CLI/virt/detail.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,15 @@ def cli(env, identifier, passwords=False, price=False):
8181
table.add_row(['notes', result['notes']])
8282

8383
if price:
84-
table.add_row(['price rate',
85-
result['billingItem']['recurringFee']])
84+
total_price = utils.lookup(result,
85+
'billingItem',
86+
'nextInvoiceTotalRecurringAmount') or 0
87+
total_price += sum(p['nextInvoiceTotalRecurringAmount']
88+
for p
89+
in utils.lookup(result,
90+
'billingItem',
91+
'children') or [])
92+
table.add_row(['price_rate', total_price])
8693

8794
if passwords:
8895
pass_table = formatting.Table(['software', 'username', 'password'])

SoftLayer/fixtures/SoftLayer_Hardware_Server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
'id': 6327,
88
'recurringFee': 1.54,
99
'nextInvoiceTotalRecurringAmount': 16.08,
10+
'children': [
11+
{'nextInvoiceTotalRecurringAmount': 1},
12+
{'nextInvoiceTotalRecurringAmount': 1},
13+
{'nextInvoiceTotalRecurringAmount': 1},
14+
{'nextInvoiceTotalRecurringAmount': 1},
15+
{'nextInvoiceTotalRecurringAmount': 1},
16+
],
1017
'orderItem': {
1118
'order': {
1219
'userRecord': {

SoftLayer/fixtures/SoftLayer_Virtual_Guest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
'status': {'keyName': 'ACTIVE', 'name': 'Active'},
77
'billingItem': {
88
'id': 6327,
9-
'recurringFee': 1.54,
9+
'nextInvoiceTotalRecurringAmount': 1.54,
10+
'children': [
11+
{'nextInvoiceTotalRecurringAmount': 1},
12+
{'nextInvoiceTotalRecurringAmount': 1},
13+
{'nextInvoiceTotalRecurringAmount': 1},
14+
{'nextInvoiceTotalRecurringAmount': 1},
15+
{'nextInvoiceTotalRecurringAmount': 1},
16+
],
1017
'orderItem': {
1118
'order': {
1219
'userRecord': {

SoftLayer/managers/hardware.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ def get_hardware(self, hardware_id, **kwargs):
213213
version,
214214
referenceCode]],
215215
passwords[username,password]],'''
216-
'billingItem.nextInvoiceTotalRecurringAmount,'
216+
'billingItem['
217+
'id,nextInvoiceTotalRecurringAmount,'
218+
'children[nextInvoiceTotalRecurringAmount],'
219+
'orderItem.order.userRecord[username]'
220+
'],'
217221
'hourlyBillingFlag,'
218222
'tagReferences[id,tag[name,id]],'
219223
'networkVlans[id,vlanNumber,networkSpace],'
220-
'billingItem.orderItem.order.userRecord[username],'
221224
'remoteManagementAccounts[username,password]'
222225
)
223226

SoftLayer/managers/vs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,13 @@ def get_instance(self, instance_id, **kwargs):
214214
referenceCode]]],'''
215215
'hourlyBillingFlag,'
216216
'userData,'
217-
'billingItem.recurringFee,'
217+
'billingItem['
218+
'id,nextInvoiceTotalRecurringAmount,'
219+
'children[categoryCode,nextInvoiceTotalRecurringAmount],'
220+
'orderItem.order.userRecord[username]'
221+
'],'
218222
'tagReferences[id,tag[name,id]],'
219-
'networkVlans[id,vlanNumber,networkSpace],'
220-
'billingItem.orderItem.order.userRecord[username]'
223+
'networkVlans[id,vlanNumber,networkSpace]'
221224
)
222225

223226
return self.guest.getObject(id=instance_id, **kwargs)

tests/CLI/modules/server_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_server_details(self):
4343
'os': 'Ubuntu',
4444
'os_version': 'Ubuntu 12.04 LTS',
4545
'owner': 'chechu',
46-
'price rate': 16.08,
46+
'price_rate': 21.08,
4747
'private_ip': '10.1.0.2',
4848
'ptr': '2.0.1.10.in-addr.arpa',
4949
'public_ip': '172.16.1.100',

tests/CLI/modules/vs_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_detail_vs(self):
5252
'os': 'Ubuntu',
5353
'os_version': '12.04-64 Minimal for VSI',
5454
'notes': 'notes',
55-
'price rate': 1.54,
55+
'price_rate': 6.54,
5656
'tags': ['production'],
5757
'private_cpu': {},
5858
'private_ip': '10.45.19.37',

0 commit comments

Comments
 (0)