Commit 9964c960 authored by Gabriel Monnerat's avatar Gabriel Monnerat

Merge branch 'master', remote branch 'origin' into slave_instance

parents 07d32c9f 6e8579dd
from test_suite import SavedTestSuite, ProjectTestSuite from test_suite import SavedTestSuite, ProjectTestSuite
class VIFIB(SavedTestSuite, ProjectTestSuite): class VIFIB(SavedTestSuite, ProjectTestSuite):
_bt_list = [
'erp5_configurator_vifib',
'vifib_base',
'vifib_core',
'vifib_crm',
'vifib_data',
'vifib_data_category',
'vifib_data_web',
'vifib_erp5',
'vifib_forge_release',
'vifib_l10n_fr',
'vifib_mysql_innodb_catalog',
'vifib_open_trade',
'vifib_slap',
'vifib_software_pdm',
'vifib_upgrader',
'vifib_web',
]
_product_list = ['Vifib'] _product_list = ['Vifib']
_saved_test_id = 'Products.Vifib.tests.VifibMixin' _saved_test_id = 'Products.Vifib.tests.VifibMixin'
...@@ -29,6 +29,7 @@ import slapos.slap.slap ...@@ -29,6 +29,7 @@ import slapos.slap.slap
from slapos.slap import ResourceNotReady from slapos.slap import ResourceNotReady
import sys import sys
import os
from optparse import OptionParser, Option from optparse import OptionParser, Option
import ConfigParser import ConfigParser
...@@ -61,6 +62,19 @@ class Parser(OptionParser): ...@@ -61,6 +62,19 @@ class Parser(OptionParser):
(options, args) = self.parse_args() (options, args) = self.parse_args()
if len(args) == 0: if len(args) == 0:
self.error("Incorrect number of arguments") self.error("Incorrect number of arguments")
elif not os.path.isfile(args[0]):
self.error("%s: Not found or not a regular file." % args[0])
return options, args
class RequestParser(Parser):
def check_args(self):
"""
Check arguments
"""
(options, args) = Parser.check_args(self)
if len(args) < 3:
self.error("Incorrect number of arguments")
return options, args return options, args
...@@ -77,16 +91,22 @@ class Config: ...@@ -77,16 +91,22 @@ class Config:
configuration_parser = ConfigParser.SafeConfigParser() configuration_parser = ConfigParser.SafeConfigParser()
configuration_parser.read(configuration_file_path) configuration_parser.read(configuration_file_path)
# Merges the arguments and configuration # Merges the arguments and configuration
for section in ("slapconsole",): for section in ('slapos', 'slapconsole'):
configuration_dict = dict(configuration_parser.items(section)) try:
for key in configuration_dict: configuration_dict = dict(configuration_parser.items(section))
if not getattr(self, key, None): except ConfigParser.NoSectionError:
pass
else:
for key in configuration_dict:
setattr(self, key, configuration_dict[key]) setattr(self, key, configuration_dict[key])
configuration_dict = dict(configuration_parser.items('slapos'))
setattr(self, 'master_url', configuration_dict['master_url']) master_url = getattr(self, 'master_url', None)
if not master_url:
if not self.master_url: raise ValueError("No option 'master_url'")
raise ValueError('master_url is required.') elif master_url.startswith('https') and \
not getattr(self, 'key_file', None) and \
not getattr(self, 'cert_file', None):
raise ValueError("No option 'key_file' and/or 'cert_file'")
def init(config): def init(config):
...@@ -98,7 +118,10 @@ def init(config): ...@@ -98,7 +118,10 @@ def init(config):
local = globals().copy() local = globals().copy()
local['slap'] = slap local['slap'] = slap
# Create aliases as global variables # Create aliases as global variables
alias = config.alias.split('\n') try:
alias = config.alias.split('\n')
except AttributeError:
alias = []
software_list = [] software_list = []
for software in alias: for software in alias:
if software is not '': if software is not '':
...@@ -120,8 +143,8 @@ def request(): ...@@ -120,8 +143,8 @@ def request():
usage = """usage: %s [options] CONFIGURATION_FILE SOFTWARE_INSTANCE INSTANCE_REFERENCE usage = """usage: %s [options] CONFIGURATION_FILE SOFTWARE_INSTANCE INSTANCE_REFERENCE
slapos-request allows you to request slapos instances.""" % sys.argv[0] slapos-request allows you to request slapos instances.""" % sys.argv[0]
config = Config() config = Config()
arguments = Parser(usage=usage).check_args()[1] options, arguments = RequestParser(usage=usage).check_args()
config.setConfig(*Parser(usage=usage).check_args()) config.setConfig(options, arguments[0])
local = init(config) local = init(config)
......
...@@ -623,7 +623,7 @@ class Slapgrid(object): ...@@ -623,7 +623,7 @@ class Slapgrid(object):
server_url=self.master_url, server_url=self.master_url,
software_release_url=software_url, software_release_url=software_url,
certificate_repository_path=self.certificate_repository_path, certificate_repository_path=self.certificate_repository_path,
console=self.console console=self.console, buildout=self.buildout
) )
if computer_partition.getState() == "destroyed": if computer_partition.getState() == "destroyed":
try: try:
......
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