Skip to content

Commit 03583ee

Browse files
author
Fernando
committed
Refactor hw upgrade.
1 parent c1a6ecc commit 03583ee

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

SoftLayer/CLI/hardware/upgrade.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def cli(env, identifier, memory, network, drive_controller, public_bandwidth, ad
6868
if test:
6969
add_data_to_table(response, table)
7070
else:
71-
table.add_row(['order_date', response.get('orderDate')])
72-
table.add_row(['order_id', response.get('orderId')])
71+
table.add_row(['Order Date', response.get('orderDate')])
72+
table.add_row(['Order Id', response.get('orderId')])
7373
add_data_to_table(response['orderDetails'], table)
7474
place_order_table = get_place_order_information(response)
7575
table.add_row(['Place Order Information', place_order_table])
@@ -83,21 +83,21 @@ def add_data_to_table(response, table):
8383
"""Add the hardware server upgrade result to the table"""
8484
table.add_row(['location', utils.lookup(response, 'locationObject', 'longName')])
8585
table.add_row(['quantity', response.get('quantity')])
86-
table.add_row(['package_id', response.get('packageId')])
87-
table.add_row(['currency_short_name', response.get('currencyShortName')])
88-
table.add_row(['prorated_initial_charge', response.get('proratedInitialCharge')])
89-
table.add_row(['prorated_order_total', response.get('proratedOrderTotal')])
90-
table.add_row(['use_hourly_pricing', response.get('useHourlyPricing')])
86+
table.add_row(['Package Id', response.get('packageId')])
87+
table.add_row(['Currency Short Name', response.get('currencyShortName')])
88+
table.add_row(['Prorated Initial Charge', response.get('proratedInitialCharge')])
89+
table.add_row(['Prorated Order Total', response.get('proratedOrderTotal')])
90+
table.add_row(['Hourly Pricing', response.get('useHourlyPricing')])
9191
table_hardware = get_hardware_detail(response)
9292
table.add_row(['Hardware', table_hardware])
9393
table_prices = get_hardware_prices(response)
94-
table.add_row(['prices', table_prices])
94+
table.add_row(['Prices', table_prices])
9595

9696

9797
def get_place_order_information(response):
9898
"""Get the hardware server place order information."""
99-
table_place_order = formatting.Table(['id', 'account_id', 'status', 'Account CompanyName',
100-
'UserRecord FirstName', 'UserRecord lastName', 'UserRecord Username'])
99+
table_place_order = formatting.Table(['Id', 'Account Id', 'Status', 'Account CompanyName',
100+
'UserRecord FirstName', 'UserRecord LastName', 'UserRecord Username'])
101101
table_place_order.add_row([response.get('id'),
102102
response.get('accountId'),
103103
response.get('status'),
@@ -111,8 +111,8 @@ def get_place_order_information(response):
111111

112112
def get_hardware_detail(response):
113113
"""Get the hardware server detail."""
114-
table_hardware = formatting.Table(['account_id', 'hostname', 'domain'])
115-
for hardware in response['hardware']:
114+
table_hardware = formatting.Table(['Account Id', 'Hostname', 'Domain'])
115+
for hardware in response['Hardware']:
116116
table_hardware.add_row([hardware.get('accountId'),
117117
hardware.get('hostname'),
118118
hardware.get('domain')])
@@ -122,7 +122,7 @@ def get_hardware_detail(response):
122122

123123
def get_hardware_prices(response):
124124
"""Get the hardware server prices."""
125-
table_prices = formatting.Table(['id', 'hourlyRecurringFee', 'recurringFee', 'categories', 'Item Description',
125+
table_prices = formatting.Table(['Id', 'HourlyRecurringFee', 'RecurringFee', 'Categories', 'Item Description',
126126
'Item Units'])
127127
for price in response['prices']:
128128
categories = price.get('categories')[0]
@@ -138,9 +138,9 @@ def get_hardware_prices(response):
138138

139139
def get_order_detail(response):
140140
"""Get the hardware server order detail."""
141-
table_order_detail = formatting.Table(['billing_city', 'billing_country_code', 'billing_email',
142-
'billing_name_first', 'billing_name_last', 'billing_postal_code',
143-
'billing_state'])
141+
table_order_detail = formatting.Table(['Billing City', 'Billing Country Code', 'Billing Email',
142+
'Billing Name First', 'Billing Name Last', 'Billing Postal Code',
143+
'Billing State'])
144144
table_order_detail.add_row([utils.lookup(response, 'orderDetails', 'billingInformation', 'billingCity'),
145145
utils.lookup(response, 'orderDetails', 'billingInformation', 'billingCountryCode'),
146146
utils.lookup(response, 'orderDetails', 'billingInformation', 'billingEmail'),

SoftLayer/fixtures/SoftLayer_Product_Order.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
{
7070
"accountId": 1111,
7171
"domain": "testedit.com",
72-
"hostname": "bardcabero",
72+
"hostname": "test",
7373
"globalIdentifier": "81434794-af69-44d5-bb97-12312asdasdasd"
7474
}
7575
],
@@ -135,8 +135,8 @@
135135
"accountId": 1111111,
136136
"bareMetalInstanceFlag": 0,
137137
"domain": "testedit.com",
138-
"fullyQualifiedDomainName": "bardcabero.testedit.com",
139-
"hostname": "bardcabero",
138+
"fullyQualifiedDomainName": "test.testedit.com",
139+
"hostname": "test",
140140
"globalIdentifier": "81434794-af69-44d5-bb97-1111111"
141141
}
142142
],
@@ -205,8 +205,8 @@
205205
"accountId": 1234,
206206
"firstName": "test",
207207
"id": 3333,
208-
"lastName": "cabero",
209-
"username": "sl1234-dcabero"
208+
"lastName": "test",
209+
"username": "sl1234-test"
210210
}
211211
}
212212
}

SoftLayer/managers/hardware.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,8 @@ def get_maintenance_windows_id(self, location_id):
908908
result_windows = self.client['SoftLayer_Provisioning_Maintenance_Window'].getMaintenanceWindows(begin_date,
909909
end_date,
910910
location_id)
911-
return result_windows[0]['id']
911+
if len(result_windows) > 0:
912+
return result_windows[0].get('id')
912913

913914
@retry(logger=LOGGER)
914915
def get_instance(self, instance_id):

0 commit comments

Comments
 (0)