Commit dd189996 authored by Marco Mariani's avatar Marco Mariani

moved old entry points for supply, remove, console

parent 38888da7
......@@ -61,7 +61,7 @@ setup(name=name,
'slapproxy = slapos.proxy:main',
'slapproxy-query = slapos.proxy.query:main',
# Deprecated entry points
'slapconsole = slapos.client:slapconsole',
'slapconsole = slapos.cli_legacy.console:console',
'slapformat = slapos.cli_legacy.format:main',
'slapgrid = slapos.grid.slapgrid:run',
'slapgrid-sr = slapos.grid.slapgrid:runSoftwareRelease',
......
# -*- coding: utf-8 -*-
import argparse
import os
import sys
from slapos.client import ClientConfig, init, do_console, get_config_parser
def console():
usage = """usage: %s [options] CONFIGURATION_FILE
slapconsole allows you interact with slap API. You can play with the global
"slap" object and with the global "request" method.
examples :
>>> # Request instance
>>> request(kvm, "myuniquekvm")
>>> # Request software installation on owned computer
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")""" % sys.argv[0]
ap = argparse.ArgumentParser(usage=usage)
ap.add_argument('-u', '--master_url',
default=None,
action="store",
help='Url of SlapOS Master to use.')
ap.add_argument('-k', '--key_file',
action="store",
help="SSL Authorisation key file.")
ap.add_argument('-c', '--cert_file',
action="store",
help="SSL Authorisation certificate file.")
ap.add_argument('configuration_file',
help='path to slapos.cfg')
options = ap.parse_args()
if not os.path.isfile(options.configuration_file):
ap.error("%s: Not found or not a regular file." % options.configuration_file)
config = ClientConfig(options, get_config_parser(options.configuration_file))
local = init(config)
do_console(local)
......@@ -30,11 +30,12 @@ import argparse
import ConfigParser
import os
import sys
from slapos.cli_legacy.bang import main as bang
from slapos.client import slapconsole as console
from slapos.client import request as request
from slapos.client import remove as remove
from slapos.client import supply as supply
from slapos.cli_legacy.console import console
from slapos.client import request
from slapos.cli_legacy.remove import remove
from slapos.cli_legacy.supply import supply
from slapos.cli_legacy.format import main as format
from slapos.cli_legacy.cache import cache_lookup
from slapos.grid.slapgrid import runComputerPartition as instance
......@@ -88,7 +89,7 @@ def checkOption(option):
if key in element:
return True
sys.argv.append(key)
if len(option) > 1 :
if len(option) > 1:
sys.argv = sys.argv + option[1:]
return True
......@@ -226,4 +227,3 @@ Node subcommands usage:
'forum. Please also make sure that SlapOS Node is up to '
'date.' % exception)
sys.exit(1)
# -*- coding: utf-8 -*-
import argparse
from slapos.client import ClientConfig, init, do_remove, get_config_parser
def remove():
"""
Run when invoking slapos remove. Mostly argument parsing.
"""
parser = argparse.ArgumentParser()
parser.add_argument('configuration_file',
help='SlapOS configuration file')
parser.add_argument('software_url',
help='Your software url')
parser.add_argument('node',
help='Target node')
args = parser.parse_args()
config = ClientConfig(args, get_config_parser(args.configuration_file))
local = init(config)
do_remove(args.software_url, args.node, local)
# -*- coding: utf-8 -*-
import argparse
from slapos.client import ClientConfig, init, do_supply, get_config_parser
def supply():
"""
Run when invoking slapos supply. Mostly argument parsing.
"""
parser = argparse.ArgumentParser()
parser.add_argument('configuration_file',
help='SlapOS configuration file')
parser.add_argument('software_url',
help='Your software url')
parser.add_argument('node',
help='Target node')
args = parser.parse_args()
config = ClientConfig(args, get_config_parser(args.configuration_file))
local = init(config)
do_supply(args.software_url, args.node, local)
......@@ -28,13 +28,13 @@
##############################################################################
import argparse
import atexit
import ConfigParser
import pprint
import os
from slapos.slap import ResourceNotReady
import pprint
import slapos.slap.slap
import sys
import atexit
from slapos.slap import ResourceNotReady
def argToDict(element):
......@@ -184,6 +184,7 @@ def request():
"couple of minutes to get connection informations.")
exit(2)
def do_supply(software_url, computer_id, local, remove=False):
"""
Request installation of Software Release
......@@ -209,45 +210,10 @@ def do_supply(software_url, computer_id, local, remove=False):
)
print 'Done.'
def do_remove(software_url, node, local):
do_supply(software_url, node, local, remove=True)
def supply():
"""
Run when invoking slapos supply. Mostly argument parsing.
"""
# XXX-Cedric: move argument parsing to main entry point
parser = argparse.ArgumentParser()
parser.add_argument("configuration_file",
help="SlapOS configuration file")
parser.add_argument("software_url",
help="Your software url")
parser.add_argument("node",
help="Target node")
args = parser.parse_args()
config = ClientConfig(args, get_config_parser(args.configuration_file))
local = init(config)
do_supply(args.software_url, args.node, local)
def remove():
"""
Run when invoking slapos remove. Mostly argument parsing.
"""
# XXX-Cedric: move argument parsing to main entry point
parser = argparse.ArgumentParser()
parser.add_argument("configuration_file",
help="SlapOS configuration file.")
parser.add_argument("software_url",
help="Your software url")
parser.add_argument("node",
help="Target node")
args = parser.parse_args()
config = ClientConfig(args, get_config_parser(args.configuration_file))
local = init(config)
do_remove(args.software_url, args.node, local)
def do_console(local):
# try to enable readline with completion and history
......@@ -271,48 +237,3 @@ def do_console(local):
atexit.register(save_history)
__import__("code").interact(banner="", local=local)
def slapconsole():
"""Ran when invoking slapconsole"""
# Parse arguments
usage = """usage: %s [options] CONFIGURATION_FILE
slapconsole allows you interact with slap API. You can play with the global
"slap" object and with the global "request" method.
examples :
>>> # Request instance
>>> request(kvm, "myuniquekvm")
>>> # Request software installation on owned computer
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")""" % sys.argv[0]
ap = argparse.ArgumentParser(usage=usage)
ap.add_argument('-u', '--master_url',
default=None,
action="store",
help='Url of SlapOS Master to use.')
ap.add_argument('-k', '--key_file',
action="store",
help="SSL Authorisation key file.")
ap.add_argument('-c', '--cert_file',
action="store",
help="SSL Authorisation certificate file.")
ap.add_argument('configuration_file',
help='path to slapos.cfg')
options = ap.parse_args()
if not os.path.isfile(options.configuration_file):
ap.error("%s: Not found or not a regular file." % options.configuration_file)
config = ClientConfig(options, get_config_parser(options.configuration_file))
local = init(config)
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