mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix raising when a 'GB' format invalid plan is supplied
This commit is contained in:
parent
3afb50d5a2
commit
2ba4fc4cea
1 changed files with 26 additions and 21 deletions
|
@ -1021,36 +1021,41 @@ def decode_linode_plan_label(label):
|
|||
"""
|
||||
sizes = avail_sizes()
|
||||
|
||||
if label not in sizes and "GB" not in label:
|
||||
plan = label.split()
|
||||
|
||||
if len(plan) != 2:
|
||||
if label not in sizes:
|
||||
if "GB" in label:
|
||||
raise SaltCloudException(
|
||||
'Invalid Linode plan ({}) specified - call avail_sizes() for all available options'.format(label)
|
||||
)
|
||||
else:
|
||||
plan = label.split()
|
||||
|
||||
plan_type = plan[0]
|
||||
try:
|
||||
plan_size = int(plan[1])
|
||||
except Exception as e:
|
||||
plan_size = 0
|
||||
if len(plan) != 2:
|
||||
raise SaltCloudException(
|
||||
'Invalid Linode plan ({}) specified - call avail_sizes() for all available options'.format(label)
|
||||
)
|
||||
|
||||
if plan_type == "Linode" and plan_size == 1024:
|
||||
plan_type = "Nanode"
|
||||
plan_type = plan[0]
|
||||
try:
|
||||
plan_size = int(plan[1])
|
||||
except Exception as e:
|
||||
plan_size = 0
|
||||
|
||||
plan_size = plan_size/1024
|
||||
new_label = "{} {}GB".format(plan_type, plan_size)
|
||||
if plan_type == "Linode" and plan_size == 1024:
|
||||
plan_type = "Nanode"
|
||||
|
||||
if new_label not in sizes:
|
||||
raise SaltCloudException(
|
||||
'Invalid Linode plan ({}) specified - call avail_sizes() for all available options'.format(new_label)
|
||||
)
|
||||
plan_size = plan_size/1024
|
||||
new_label = "{} {}GB".format(plan_type, plan_size)
|
||||
|
||||
log.warning("An outdated Linode plan label was detected in your Cloud profile ({})."
|
||||
" Please update the profile to use"
|
||||
" the new label format ({}) for the requested Linode plan size.".format(label, new_label))
|
||||
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
|
||||
log.warning("An outdated Linode plan label was detected in your Cloud profile ({})."
|
||||
" Please update the profile to use"
|
||||
" the new label format ({}) for the requested Linode plan size.".format(label, new_label))
|
||||
|
||||
label = new_label
|
||||
|
||||
return sizes[label]['PLANID']
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue