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
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']
_saved_test_id = 'Products.Vifib.tests.VifibMixin'
......@@ -29,6 +29,7 @@ import slapos.slap.slap
from slapos.slap import ResourceNotReady
import sys
import os
from optparse import OptionParser, Option
import ConfigParser
......@@ -61,6 +62,19 @@ class Parser(OptionParser):
(options, args) = self.parse_args()
if len(args) == 0:
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
......@@ -77,16 +91,22 @@ class Config:
configuration_parser = ConfigParser.SafeConfigParser()
configuration_parser.read(configuration_file_path)
# Merges the arguments and configuration
for section in ("slapconsole",):
for section in ('slapos', 'slapconsole'):
try:
configuration_dict = dict(configuration_parser.items(section))
except ConfigParser.NoSectionError:
pass
else:
for key in configuration_dict:
if not getattr(self, key, None):
setattr(self, key, configuration_dict[key])
configuration_dict = dict(configuration_parser.items('slapos'))
setattr(self, 'master_url', configuration_dict['master_url'])
if not self.master_url:
raise ValueError('master_url is required.')
master_url = getattr(self, 'master_url', None)
if not master_url:
raise ValueError("No option 'master_url'")
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):
......@@ -98,7 +118,10 @@ def init(config):
local = globals().copy()
local['slap'] = slap
# Create aliases as global variables
try:
alias = config.alias.split('\n')
except AttributeError:
alias = []
software_list = []
for software in alias:
if software is not '':
......@@ -120,8 +143,8 @@ def request():
usage = """usage: %s [options] CONFIGURATION_FILE SOFTWARE_INSTANCE INSTANCE_REFERENCE
slapos-request allows you to request slapos instances.""" % sys.argv[0]
config = Config()
arguments = Parser(usage=usage).check_args()[1]
config.setConfig(*Parser(usage=usage).check_args())
options, arguments = RequestParser(usage=usage).check_args()
config.setConfig(options, arguments[0])
local = init(config)
......
......@@ -623,7 +623,7 @@ class Slapgrid(object):
server_url=self.master_url,
software_release_url=software_url,
certificate_repository_path=self.certificate_repository_path,
console=self.console
console=self.console, buildout=self.buildout
)
if computer_partition.getState() == "destroyed":
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