Skip to content

Commit

Permalink
add hourly/monthly API option
Browse files Browse the repository at this point in the history
  • Loading branch information
Markos Gogoulos committed Mar 7, 2016
1 parent e151c17 commit c989658
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/mist/io/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ def create_machine(user, cloud_id, key_id, machine_name, location_id,
azure_port_bindings='', hostname='', plugins=None,
disk_size=None, disk_path=None,
post_script_id='', post_script_params='', cloud_init='',
associate_floating_ip=False, associate_floating_ip_subnet=None, project_id=None, bare_metal=False):
associate_floating_ip=False, associate_floating_ip_subnet=None, project_id=None, bare_metal=False, hourly=True):

"""Creates a new virtual machine on the specified cloud.
Expand Down Expand Up @@ -1719,7 +1719,7 @@ def create_machine(user, cloud_id, key_id, machine_name, location_id,
elif conn.type is Provider.SOFTLAYER:
node = _create_machine_softlayer(conn, key_id, private_key, public_key,
machine_name, image, size,
location, bare_metal, cloud_init)
location, bare_metal, cloud_init, hourly)
elif conn.type is Provider.DIGITAL_OCEAN:
node = _create_machine_digital_ocean(conn, key_id, private_key,
public_key, machine_name,
Expand Down Expand Up @@ -2104,7 +2104,7 @@ def _create_machine_nephoscale(conn, key_name, private_key, public_key,


def _create_machine_softlayer(conn, key_name, private_key, public_key,
machine_name, image, size, location, bare_metal, cloud_init):
machine_name, image, size, location, bare_metal, cloud_init, hourly):
"""Create a machine in Softlayer.
Here there is no checking done, all parameters are expected to be
Expand Down Expand Up @@ -2150,7 +2150,8 @@ def _create_machine_softlayer(conn, key_name, private_key, public_key,
location=location,
sshKeys=server_key,
bare_metal=bare_metal,
postInstallScriptUri=postInstallScriptUri
postInstallScriptUri=postInstallScriptUri,
ex_hourly=hourly
)
except Exception as e:
raise MachineCreationError("Softlayer, got exception %s" % e, e)
Expand Down
2 changes: 1 addition & 1 deletion src/mist/io/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def create_machine_async(email, cloud_id, key_id, machine_name, location_id,
docker_port_bindings={}, docker_exposed_ports={},
azure_port_bindings='', hostname='', plugins=None,
disk_size=None, disk_path=None,
cloud_init='', associate_floating_ip=False, associate_floating_ip_subnet=None, project_id=None, bare_metal=False):
cloud_init='', associate_floating_ip=False, associate_floating_ip_subnet=None, project_id=None, bare_metal=False, hourly=True):
from multiprocessing.dummy import Pool as ThreadPool
from mist.io.methods import create_machine
from mist.io.exceptions import MachineCreationError
Expand Down
3 changes: 2 additions & 1 deletion src/mist/io/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ def create_machine(request):
associate_floating_ip_subnet = request.json_body.get('attach_floating_ip_subnet', None)
project_id = request.json_body.get('project', None)
bare_metal = request.json_body.get('bare_metal', False)
hourly = request.json_body.get('hourly', True)
except Exception as e:
raise RequiredParameterMissingError(e)

Expand All @@ -538,7 +539,7 @@ def create_machine(request):
'cloud_init': cloud_init,
'associate_floating_ip': associate_floating_ip,
'associate_floating_ip_subnet': associate_floating_ip_subnet,
'project_id': project_id, 'bare_metal': bare_metal}
'project_id': project_id, 'bare_metal': bare_metal, 'hourly': hourly}
if not async:
ret = methods.create_machine(user, *args, **kwargs)
else:
Expand Down

0 comments on commit c989658

Please sign in to comment.