Skip to content

Commit 03d3c8e

Browse files
#1026 resolving pull request feedback
1 parent 3e770a2 commit 03d3c8e

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

SoftLayer/CLI/columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def mask(self):
5757
def get_formatter(columns):
5858
"""This function returns a callback to use with click options.
5959
60-
The returend function parses a comma-separated value and returns a new
60+
The returned function parses a comma-separated value and returns a new
6161
ColumnFormatter.
6262
6363
:param columns: a list of Column instances

SoftLayer/CLI/virt/capacity/create.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@
77
from SoftLayer.CLI import formatting
88
from SoftLayer.managers.vs_capacity import CapacityManager as CapacityManager
99

10-
10+
from pprint import pprint as pp
1111
@click.command(epilog=click.style("""WARNING: Reserved Capacity is on a yearly contract"""
1212
""" and not cancelable until the contract is expired.""", fg='red'))
1313
@click.option('--name', '-n', required=True, prompt=True,
1414
help="Name for your new reserved capacity")
15-
@click.option('--datacenter', '-d', required=True, prompt=True,
16-
help="Datacenter shortname")
1715
@click.option('--backend_router_id', '-b', required=True, prompt=True,
1816
help="backendRouterId, create-options has a list of valid ids to use.")
19-
@click.option('--capacity', '-c', required=True, prompt=True,
17+
@click.option('--flavor', '-f', required=True, prompt=True,
2018
help="Capacity keyname (C1_2X2_1_YEAR_TERM for example).")
21-
@click.option('--quantity', '-q', required=True, prompt=True,
19+
@click.option('--instances', '-i', required=True, prompt=True,
2220
help="Number of VSI instances this capacity reservation can support.")
2321
@click.option('--test', is_flag=True,
2422
help="Do not actually create the virtual server")
2523
@environment.pass_env
26-
def cli(env, name, datacenter, backend_router_id, capacity, quantity, test=False):
24+
def cli(env, name, backend_router_id, flavor, instances, test=False):
2725
"""Create a Reserved Capacity instance.
2826
2927
*WARNING*: Reserved Capacity is on a yearly contract and not cancelable until the contract is expired.
@@ -32,10 +30,9 @@ def cli(env, name, datacenter, backend_router_id, capacity, quantity, test=False
3230

3331
result = manager.create(
3432
name=name,
35-
datacenter=datacenter,
3633
backend_router_id=backend_router_id,
37-
capacity=capacity,
38-
quantity=quantity,
34+
flavor=flavor,
35+
instances=instances,
3936
test=test)
4037

4138
if test:
@@ -44,14 +41,14 @@ def cli(env, name, datacenter, backend_router_id, capacity, quantity, test=False
4441
table.add_row(['Name', container['name']])
4542
table.add_row(['Location', container['locationObject']['longName']])
4643
for price in container['prices']:
47-
table.add_row([price['item']['keyName'], price['item']['description']])
48-
table.add_row(['Total', result['postTaxRecurring']])
44+
table.add_row(['Contract', price['item']['description']])
45+
table.add_row(['Hourly Total', result['postTaxRecurring']])
4946
else:
5047
table = formatting.Table(['Name', 'Value'], "Reciept")
5148
table.add_row(['Order Date', result['orderDate']])
5249
table.add_row(['Order ID', result['orderId']])
5350
table.add_row(['status', result['placedOrder']['status']])
5451
for item in result['placedOrder']['items']:
5552
table.add_row([item['categoryCode'], item['description']])
56-
table.add_row(['Total', result['orderDetails']['postTaxRecurring']])
53+
table.add_row(['Hourly Total', result['orderDetails']['postTaxRecurring']])
5754
env.fout(table)

SoftLayer/CLI/virt/capacity/create_options.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ def cli(env):
1414
"""List options for creating Reserved Capacity"""
1515
manager = CapacityManager(env.client)
1616
items = manager.get_create_options()
17+
# pp(items)
1718
items.sort(key=lambda term: int(term['capacity']))
18-
table = formatting.Table(["KeyName", "Description", "Term", "Hourly Price"], title="Reserved Capacity Options")
19+
table = formatting.Table(["KeyName", "Description", "Term", "Default Hourly Price Per Instance"],
20+
title="Reserved Capacity Options")
1921
table.align["Hourly Price"] = "l"
2022
table.align["Description"] = "l"
2123
table.align["KeyName"] = "l"
@@ -25,6 +27,7 @@ def cli(env):
2527
])
2628
env.fout(table)
2729

30+
2831
regions = manager.get_available_routers()
2932
location_table = formatting.Table(['Location', 'POD', 'BackendRouterId'], 'Orderable Locations')
3033
for region in regions:
@@ -38,6 +41,6 @@ def get_price(item):
3841
"""Finds the price with the default locationGroupId"""
3942
the_price = "No Default Pricing"
4043
for price in item.get('prices', []):
41-
if price.get('locationGroupId') == '':
44+
if not price.get('locationGroupId'):
4245
the_price = "%0.4f" % float(price['hourlyRecurringFee'])
4346
return the_price

SoftLayer/managers/vs_capacity.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,22 @@ def get_available_routers(self, dc=None):
9797
# Step 4, return the data.
9898
return regions
9999

100-
def create(self, name, datacenter, backend_router_id, capacity, quantity, test=False):
100+
def create(self, name, backend_router_id, flavor, instances, test=False):
101101
"""Orders a Virtual_ReservedCapacityGroup
102102
103103
:param string name: Name for the new reserved capacity
104-
:param string datacenter: like 'dal13'
105104
:param int backend_router_id: This selects the pod. See create_options for a list
106-
:param string capacity: Capacity KeyName, see create_options for a list
107-
:param int quantity: Number of guest this capacity can support
105+
:param string flavor: Capacity KeyName, see create_options for a list
106+
:param int instances: Number of guest this capacity can support
108107
:param bool test: If True, don't actually order, just test.
109108
"""
110-
args = (self.capacity_package, datacenter, [capacity])
109+
110+
# Since orderManger needs a DC id, just send in 0, the API will ignore it
111+
args = (self.capacity_package, 0, [flavor])
111112
extras = {"backendRouterId": backend_router_id, "name": name}
112113
kwargs = {
113114
'extras': extras,
114-
'quantity': quantity,
115+
'quantity': instances,
115116
'complex_type': 'SoftLayer_Container_Product_Order_Virtual_ReservedCapacity',
116117
'hourly': True
117118
}
@@ -135,6 +136,7 @@ def create_guest(self, capacity_id, test, guest_object):
135136
}
136137
137138
"""
139+
138140
vs_manager = VSManager(self.client)
139141
mask = "mask[instances[id, billingItem[id, item[id,keyName]]], backendRouter[id, datacenter[name]]]"
140142
capacity = self.get_object(capacity_id, mask=mask)
@@ -147,6 +149,8 @@ def create_guest(self, capacity_id, test, guest_object):
147149
guest_object['flavor'] = flavor
148150
guest_object['datacenter'] = capacity['backendRouter']['datacenter']['name']
149151

152+
# Reserved capacity only supports SAN as of 20181008
153+
guest_object['local_disk'] = False
150154
template = vs_manager.verify_create_instance(**guest_object)
151155
template['reservedCapacityId'] = capacity_id
152156
if guest_object.get('ipv6'):

0 commit comments

Comments
 (0)