Allow shorthand methods to behave like real ones

parent b03de839
...@@ -111,7 +111,6 @@ class Config: ...@@ -111,7 +111,6 @@ class Config:
setattr(self, 'master_url', master_url) setattr(self, 'master_url', master_url)
def init(config): def init(config):
"""Initialize Slap instance, connect to server and create """Initialize Slap instance, connect to server and create
aliases to common software releases""" aliases to common software releases"""
slap = slapos.slap.slap() slap = slapos.slap.slap()
...@@ -133,10 +132,18 @@ def init(config): ...@@ -133,10 +132,18 @@ def init(config):
# Create global variable too see available aliases # Create global variable too see available aliases
local['software_list'] = software_list local['software_list'] = software_list
# Create global shortcut functions to request instance and software # Create global shortcut functions to request instance and software
local['request'] = lambda software_release, reference: \ # XXX-Cedric : can we change given parameters to something like
slap.registerOpenOrder().request(software_release, reference) # *args, **kwargs, but without the bad parts, in order to be generic?
local['supply'] = lambda software_release, computer: \ def shorthandRequest(software_release, partition_reference,
slap.registerSupply().supply(software_release, computer) partition_parameter_kw=None, software_type=None, filter_kw=None,
state=None):
slap.registerOpenOrder().request(software_release, partition_reference,
partition_parameter_kw, software_type, filter_kw, state)
def shorthandSupply(software_release, computer_guid=None):
slap.registerSupply().supply(software_release, computer_guid)
local['request'] = shorthandRequest
local['supply'] = shorthandSupply
return local return local
def request(): def request():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment