Commit 1c5fcb24 authored by Marco Mariani's avatar Marco Mariani

cli refactoring: supply, remove

parent cd813da7
...@@ -78,6 +78,8 @@ setup(name=name, ...@@ -78,6 +78,8 @@ setup(name=name,
'node format = slapos.cli.format:FormatCommand', 'node format = slapos.cli.format:FormatCommand',
'node register = slapos.cli.register:RegisterCommand', 'node register = slapos.cli.register:RegisterCommand',
'console = slapos.cli.console:ConsoleCommand', 'console = slapos.cli.console:ConsoleCommand',
'supply = slapos.cli.supply:SupplyCommand',
'remove = slapos.cli.remove:RemoveCommand',
] ]
}, },
test_suite="slapos.tests", test_suite="slapos.tests",
......
# -*- coding: utf-8 -*-
import logging
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, do_remove, ClientConfig
class RemoveCommand(ClientConfigCommand):
log = logging.getLogger(__name__)
def get_parser(self, prog_name):
ap = super(RemoveCommand, self).get_parser(prog_name)
ap.add_argument('software_url',
help='Your software url')
ap.add_argument('none',
help="Target node")
return ap
def take_action(self, args):
configuration_parser = self.fetch_config(args)
config = ClientConfig(args, configuration_parser)
local = init(config)
do_remove(args.software_url, args.node, local)
# -*- coding: utf-8 -*-
import logging
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, do_supply, ClientConfig
class SupplyCommand(ClientConfigCommand):
log = logging.getLogger(__name__)
def get_parser(self, prog_name):
ap = super(SupplyCommand, self).get_parser(prog_name)
ap.add_argument('software_url',
help='Your software url')
ap.add_argument('node',
help="Target node")
return ap
def take_action(self, args):
configuration_parser = self.fetch_config(args)
config = ClientConfig(args, configuration_parser)
local = init(config)
do_supply(args.software_url, args.node, local)
...@@ -52,11 +52,11 @@ class Parser(OptionParser): ...@@ -52,11 +52,11 @@ class Parser(OptionParser):
action="store", action="store",
help="Url of SlapOS Master to use."), help="Url of SlapOS Master to use."),
Option("-k", "--key_file", Option("-k", "--key_file",
action="store", action="store",
help="SSL Authorisation key file."), help="SSL Authorisation key file."),
Option("-c", "--cert_file", Option("-c", "--cert_file",
action="store", action="store",
help="SSL Authorisation certificate file.") help="SSL Authorisation certificate file.")
]) ])
def check_args(self): def check_args(self):
...@@ -220,7 +220,7 @@ def request(): ...@@ -220,7 +220,7 @@ def request():
"couple of minutes to get connection informations.") "couple of minutes to get connection informations.")
exit(2) exit(2)
def _supply(software_url, computer_id, local, remove=False): def do_supply(software_url, computer_id, local, remove=False):
""" """
Request installation of Software Release Request installation of Software Release
'software_url' on computer 'computer_id'. 'software_url' on computer 'computer_id'.
...@@ -245,6 +245,9 @@ def _supply(software_url, computer_id, local, remove=False): ...@@ -245,6 +245,9 @@ def _supply(software_url, computer_id, local, remove=False):
) )
print 'Done.' print 'Done.'
def do_remove(software_url, node, local):
do_supply(software_url, node, local, remove=True)
def supply(): def supply():
""" """
Run when invoking slapos supply. Mostly argument parsing. Run when invoking slapos supply. Mostly argument parsing.
...@@ -260,7 +263,8 @@ def supply(): ...@@ -260,7 +263,8 @@ def supply():
args = parser.parse_args() args = parser.parse_args()
config = ClientConfig(args, get_config_parser(args.configuration_file)) config = ClientConfig(args, get_config_parser(args.configuration_file))
_supply(args.software_url, args.node, init(config)) local = init(config)
do_supply(args.software_url, args.node, local)
def remove(): def remove():
""" """
...@@ -277,7 +281,8 @@ def remove(): ...@@ -277,7 +281,8 @@ def remove():
args = parser.parse_args() args = parser.parse_args()
config = ClientConfig(args, get_config_parser(args.configuration_file)) config = ClientConfig(args, get_config_parser(args.configuration_file))
_supply(args.software_url, args.node, init(config), remove=True) local = init(config)
do_remove(args.software_url, args.node, local)
def do_console(local): def do_console(local):
......
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