mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Fix Linode plan selection
This commit is contained in:
parent
93420950d3
commit
cf534c7314
@ -1035,7 +1035,40 @@ def get_plan_id(kwargs=None, call=None):
|
||||
'The get_plan_id function requires a \'label\'.'
|
||||
)
|
||||
|
||||
return avail_sizes()[label]['PLANID']
|
||||
sizes = avail_sizes()
|
||||
|
||||
if label not in sizes:
|
||||
# Linode plan labels have changed from e.g. Linode 1024 to Linode 1GB
|
||||
if "GB" not in label:
|
||||
plan = label.split()
|
||||
|
||||
# label is invalid if it isn't a space-separated string
|
||||
if len(plan) != 2:
|
||||
raise SaltCloudException(
|
||||
'Invalid Linode plan ({}) specified - call avail_sizes() for all available options'.format(label)
|
||||
)
|
||||
|
||||
plan_type = plan[0]
|
||||
try:
|
||||
plan_size = int(plan[1])
|
||||
except:
|
||||
plan_size = 0
|
||||
|
||||
if plan_type == "Linode" and plan_size == 1024:
|
||||
plan_type = "Nanode"
|
||||
|
||||
# translate from MB to GB
|
||||
plan_size = plan_size/1024
|
||||
new_label = "{} {}GB".format(plan_type, plan_size)
|
||||
|
||||
if new_label not in sizes:
|
||||
raise SaltCloudException(
|
||||
'Invalid Linode plan ({}) specified - call avail_sizes() for all available options'.format(new_label)
|
||||
)
|
||||
|
||||
label = new_label
|
||||
|
||||
return sizes[label]['PLANID']
|
||||
|
||||
|
||||
def get_private_ip(vm_):
|
||||
|
Loading…
Reference in New Issue
Block a user