def bvt_emdeviso_post(): """Handles requests from BIGIP teams. All the logic needed to translate the user input into what makes sense to us happens right here. """ CONFIG_FILE = 'config/shared/web_emdeviso_request.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('em')).read())) # Prepare placeholders in our config our_config.update({'stages': {'main': {'setup': {'install': {'parameters': {}}}}}}) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) plugins = our_config.plugins # Append submitter's email to recipient list if data.get('email'): plugins.email.to.append(data['email']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage v = None if data.get('iso'): params = our_config.stages.main.setup['install'].parameters params['custom iso'] = data['iso'] v = version_from_metadata(data['iso']) if data.get('hfiso'): params = our_config.stages.main.setup['install'].parameters params['custom hf iso'] = data['hfiso'] v = version_from_metadata(data['hfiso']) # Find the RTM ISO that goes with this HF image. if not data.get('iso'): params['custom iso'] = isofile(v.version, product=str(v.product)) args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) args.append('--tc=stages.enabled:1') args.append('--eval-attr=rank > 0 and rank < 11') args.append('--with-email') #args.append('--with-bvtinfo') args.append('--with-irack') args.append('{VENV}/%s' % CONFIG.paths.em) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = app.router.build('status', task_id=result.id) return dict(status=result.status, id=result.id, link=link)
def bvt_bigiq_post(): """Handles requests from BIGIP teams for BIGIQ BVT, all modules except ASM. All the logic needed to translate the user input into what makes sense to us happens right here. """ LOG.info("BIG-IQ CM: Called") BVTINFO_PROJECT_PATTERN = '(\D+)?([\d+\.]{6,})-?(eng-?\w*|hf\d+|hf-\w+)?' CONFIG_FILE = CONFIG.web.config['bigiq-tmos'] # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) LOG.info("BIG-IQ CM POST Request: " + str(data)) data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness(CONFIG, 'bigiq-tmos')).read())) # Prepare placeholders in our config our_config.update({'group_vars': {'tmos.bigip': {'f5_install': {}}}}) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'testdata': {}}) plugins = our_config.plugins # Append submitter's email to recipient list if data.get('submitted_by'): plugins.email.to.append(data['submitted_by']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage params = our_config.group_vars['tmos.bigip'].f5_install testdata = our_config.testdata match = re.match(BVTINFO_PROJECT_PATTERN, data['project']) if match: params['version'] = match.group(2) if match.group(3): params['hf'] = match.group(3) else: params['version'] = data['project'] params['build'] = data['build'] testdata.image = params['image'] = data.get('custom_iso') testdata.hfimage = params['hfimage'] = data.get('custom_hf_iso') params.product = 'bigip' #if not min_version_validator(params.build, params.version, params.hotfix, # params.product, min_ver=CONFIG.global_min_supported): # raise ValueError('Requested version not supported') # bottle.response.status = 406 # return dict(message='Requested version not supported') args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) args.append('--tc=group_vars.all.pave:true') args.append('--eval-attr=rank >= 1 and rank <= 10') args.append('--with-email') args.append('--with-irack') args.append('{VENV}/%s' % CONFIG.suites.root) v = plugins.email.variables v.args = args v.project = data['project'] v.version = params.version v.build = params.build LOG.info("BIG-IQ CM Nose Args: " + str(v)) LOG.info("BIG-IQ CM ourconfig: " + str(our_config)) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = common_app.router.build('status', task_id=result.id) cm_result = dict(status=result.status, id=result.id, link=link) LOG.info("BIG-IQ CM Result: " + str(cm_result)) return cm_result
def bvt_basic_post(): """Handles requests from BIGIP teams. All the logic needed to translate the user input into what makes sense to us happens right here. """ LOG.info("BASIC: Called") BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(eng-?\w*|hf\d+|hf-\w+)?' TESTS_DEBUG = 'tests/solar/bvt/integration/filesystem/' CONFIG_FILE = 'config/shared/web_bvt_request.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) LOG.info("BASIC: POST Request: " + str(data)) data._referer = bottle.request.url # data = bottle.request.json # BUG: The iRack reservation-based picker is flawed. It'll always select # the nearest available harness, stacking all workers on just one. # with IrackInterface(address=CONFIG.irack.address, # timeout=30, # username=CONFIG.irack.username, # password=CONFIG.irack.apikey, # ssl=False) as irack: # config_dir = os.path.dirname(CONFIG_WEB_FILE) # harness_files = [os.path.join(config_dir, x) for x in CONFIG.web.harnesses] # our_config = RCMD.irack.pick_best_harness(harness_files, ifc=irack) our_config = AttrDict(yaml.load(open(get_harness('em')).read())) # Prepare placeholders in our config our_config.update({ 'stages': { 'main': { 'setup': { 'install-bigips': { 'parameters': {} } } } } }) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'plugins': {'bvtinfo': {}}}) plugins = our_config.plugins # Set BVTInfo data plugins.bvtinfo.project = data['project'] plugins.bvtinfo.build = data['build'] # Append submitter's email to recipient list if data.get('submitted_by'): plugins.email.to.append(data['submitted_by']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage params = our_config.stages.main.setup['install-bigips'].parameters match = re.match(BVTINFO_PROJECT_PATTERN, data['project']) if match: params['version'] = match.group(2) if match.group(3): params['hotfix'] = match.group(3) else: params['version'] = data['project'] params['build'] = data['build'] params['custom iso'] = data.get('custom_iso') params['custom hf iso'] = data.get('custom_hf_iso') params.product = 'bigip' if not min_version_validator(params.build, params.version, params.hotfix, params.product, min_ver=CONFIG.global_min_supported): # raise ValueError('Requested version not supported') bottle.response.status = 406 return dict(message='Requested version not supported') args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) if data.get('debug'): args.append('--tc=stages.enabled:1') tests = [ os.path.join('{VENV}', x) for x in re.split('\s+', ( data.get('tests') or TESTS_DEBUG).strip()) ] args.extend(tests) else: args.append('--tc=stages.enabled:1') args.append('--eval-attr=rank > 0 and rank < 11') args.append('--with-email') # args.append('--with-bvtinfo') args.append('--with-irack') args.append('{VENV}/%s' % CONFIG.paths.em) v = plugins.email.variables v.args = args v.project = data['project'] v.version = params.version v.build = params.build LOG.info("BASIC: our_config: " + str(our_config)) LOG.info("BASIC: args: " + str(args)) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = common_app.router.build('status', task_id=result.id) basic_result = dict(status=result.status, id=result.id, link=link) LOG.info("BASIC: Result: " + str(basic_result)) return basic_result
def bvt_basic_post2(): """Handles EM BVT requests. """ LOG.info("ATOM EMBVT: Called") HOOK_NAME = 'em-bvt' TESTS_DEBUG = 'tests/solar/bvt/integration/filesystem/' CONFIG_FILE = 'config/shared/web_bvt_request.yaml' data = AttrDict(json.load(bottle.request.body)) data._referer = bottle.request.url LOG.info("ATOM EMBVT: POST Request: " + str(data)) our_config = AttrDict(yaml.load(open(get_harness('em')).read())) # Prepare placeholders in our config our_config.update({ 'stages': { 'main': { 'setup': { 'install-bigips': { 'parameters': {} } } } } }) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'plugins': {'atom': {'bigip': {}}, 'bvtinfo': {}}}) plugins = our_config.plugins # Set ATOM data plugins.atom.bigip.request_id = data.content.id plugins.atom.bigip.name = HOOK_NAME # Append submitter's email to recipient list if data.content.requestor.email: plugins.email.to.append(data.content.requestor.email) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage params = our_config.stages.main.setup['install-bigips'].parameters branch = data.content.build.branch version = data.content.build.version params['version'] = branch.name params['build'] = version.primary if int(version.level): params['hotfix'] = version.level params['custom hf iso'] = sanitize_atom_path(data.content.build.iso) else: params['custom iso'] = sanitize_atom_path(data.content.build.iso) params.product = 'bigip' # TODO: Remove this when bvtinfo goes offline # Set BVTInfo data plugins.bvtinfo.project = branch.name plugins.bvtinfo.build = version.old_build_number args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) if data.get('debug'): args.append('--tc=stages.enabled:1') tests = [ os.path.join('{VENV}', x) for x in re.split('\s+', ( data.get('tests') or TESTS_DEBUG).strip()) ] args.extend(tests) else: args.append('--tc=stages.enabled:1') args.append('--eval-attr=rank > 0 and rank < 11') args.append('--with-email') args.append('--with-atom') # args.append('--with-bvtinfo') if not min_version_validator(params.build, params.version, params.hotfix, params.product, iso=data.content.build.iso, min_ver=CONFIG.global_min_supported): args.append( '--with-atom-no-go=The requested product/version is not supported by this test suite.' ) args.append('--with-irack') # args.append('--with-qkview=never') # args.append('{VENV}/tests/solar/bvt/') args.append('{VENV}/%s' % CONFIG.paths.em) v = plugins.email.variables v.args = args v.project = data.content.build.branch.name v.version = data.content.build.version.version v.build = data.content.build.version.build LOG.info("ATOM EMBVT: Nose Args: " + str(args)) LOG.info("ATOM EMBVT: our_config: " + str(our_config)) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = common_app.router.build('status', task_id=result.id) LOG.info("ATOM EMBVT: Status: " + str(result.status) + ", ID: " + str(result.id) + ", Link: " + str(link)) embvt_result = dict(status=result.status, id=result.id, link=link) LOG.info("ATOM EMBVT: Result: " + str(embvt_result)) return embvt_result
def bvt_emdeviso_post(): """Handles requests from BIGIP teams. All the logic needed to translate the user input into what makes sense to us happens right here. """ LOG.info("EMDEVISO: Called") CONFIG_FILE = 'config/shared/web_emdeviso_request.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) LOG.info("EMDEVISO: POST Request: " + str(data)) data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('em')).read())) # Prepare placeholders in our config our_config.update( {'stages': { 'main': { 'setup': { 'install': { 'parameters': {} } } } }}) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) plugins = our_config.plugins # Append submitter's email to recipient list if data.get('email'): plugins.email.to.append(data['email']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage v = None if data.get('iso'): params = our_config.stages.main.setup['install'].parameters params['custom iso'] = data['iso'] v = version_from_metadata(data['iso']) if data.get('hfiso'): params = our_config.stages.main.setup['install'].parameters params['custom hf iso'] = data['hfiso'] v = version_from_metadata(data['hfiso']) # Find the RTM ISO that goes with this HF image. if not data.get('iso'): params['custom iso'] = isofile(v.version, product=str(v.product)) args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) args.append('--tc=stages.enabled:1') args.append('--eval-attr=rank > 0 and rank < 11') args.append('--with-email') # args.append('--with-bvtinfo') args.append('--with-irack') args.append('{VENV}/%s' % CONFIG.paths.em) LOG.info("EMDEVISO: Nose Args: " + str(args)) LOG.info("EMDEVISO: our_config: " + str(our_config)) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = common_app.router.build('status', task_id=result.id) emdeviso_result = dict(status=result.status, id=result.id, link=link) LOG.info("EMDEVISO: Result: " + str(emdeviso_result)) return emdeviso_result
def bvt_basic_post2(): """Handles EM BVT requests. """ HOOK_NAME = 'em-bvt' TESTS_DEBUG = 'tests/solar/bvt/integration/filesystem/' CONFIG_FILE = 'config/shared/web_bvt_request.yaml' data = AttrDict(json.load(bottle.request.body)) data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('em')).read())) # Prepare placeholders in our config our_config.update({'stages': {'main': {'setup': {'install-bigips': {'parameters': {}}}}}}) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'plugins': {'atom': {'bigip': {}}, 'bvtinfo': {}}}) plugins = our_config.plugins # Set ATOM data plugins.atom.bigip.request_id = data.content.id plugins.atom.bigip.name = HOOK_NAME # Append submitter's email to recipient list if data.content.requestor.email: plugins.email.to.append(data.content.requestor.email) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage params = our_config.stages.main.setup['install-bigips'].parameters branch = data.content.build.branch version = data.content.build.version params['version'] = branch.name params['build'] = version.primary if int(version.level): params['hotfix'] = version.level params['custom hf iso'] = sanitize_atom_path(data.content.build.iso) else: params['custom iso'] = sanitize_atom_path(data.content.build.iso) params.product = 'bigip' # TODO: Remove this when bvtinfo goes offline # Set BVTInfo data plugins.bvtinfo.project = branch.name plugins.bvtinfo.build = version.old_build_number args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) if data.get('debug'): args.append('--tc=stages.enabled:1') tests = [os.path.join('{VENV}', x) for x in re.split('\s+', (data.get('tests') or TESTS_DEBUG).strip())] args.extend(tests) else: args.append('--tc=stages.enabled:1') args.append('--eval-attr=rank > 0 and rank < 11') args.append('--with-email') args.append('--with-atom') args.append('--with-bvtinfo') if not min_version_validator(params.build, params.version, params.hotfix, params.product, iso=data.content.build.iso, min_ver=CONFIG.supported): args.append('--with-atom-no-go=The requested product/version is not supported by this test suite.') args.append('--with-irack') # args.append('--with-qkview=never') # args.append('{VENV}/tests/solar/bvt/') args.append('{VENV}/%s' % CONFIG.paths.em) v = plugins.email.variables v.args = args v.project = data.content.build.branch.name v.version = data.content.build.version.version v.build = data.content.build.version.build result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = app.router.build('status', task_id=result.id) return dict(status=result.status, id=result.id, link=link)
def bvt_bigiq_post(): """Handles requests from BIGIP teams for BIGIQ BVT. All the logic needed to translate the user input into what makes sense to us happens right here. """ BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(eng-?\w*|hf\d+|hf-\w+)?' CONFIG_FILE = 'config/shared/web_bvt_request_bigiq.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('bigiq-tmos')).read())) # Prepare placeholders in our config our_config.update({'stages': {'main': {'setup': {'install-bigips': {'parameters': {}}}}}}) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'plugins': {'bvtinfo': {'bigip': {}}}}) plugins = our_config.plugins # Set BVTInfo data plugins.bvtinfo.project = data['project'] plugins.bvtinfo.build = data['build'] plugins.bvtinfo.bigip.name = 'bigiq-bvt' # Append submitter's email to recipient list if data.get('submitted_by'): plugins.email.to.append(data['submitted_by']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage params = our_config.stages.main.setup['install-bigips'].parameters match = re.match(BVTINFO_PROJECT_PATTERN, data['project']) if match: params['version'] = match.group(2) if match.group(3): params['hotfix'] = match.group(3) else: params['version'] = data['project'] params['build'] = data['build'] params['custom iso'] = data.get('custom_iso') params['custom hf iso'] = data.get('custom_hf_iso') params.product = 'bigip' if not min_version_validator(params.build, params.version, params.hotfix, params.product, min_ver=CONFIG.supported): # raise ValueError('Requested version not supported') bottle.response.status = 406 return dict(message='Requested version not supported') args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) args.append('--tc=stages.enabled:1') # For chuckanut++ args.append('--eval-attr=rank >= 5 and rank <= 10') args.append('--with-email') args.append('--with-bvtinfo') args.append('--with-irack') args.append('{VENV}/%s' % CONFIG.paths.tc) v = plugins.email.variables v.args = args v.project = data['project'] v.version = params.version v.build = params.build # return dict(config=our_config, args=args) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = app.router.build('status', task_id=result.id) return dict(status=result.status, id=result.id, link=link)
def bvt_deviso_post(): """Handles requests from Dev team for user builds ISOs. """ # BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(hf\d+)?' DEFAULT_SUITE = 'bvt' SUITES = {'bvt': '%s/' % CONFIG.paths.current, 'dev': '%s/cloud/external/devtest_wrapper.py' % CONFIG.paths.current, 'dev-cloud': '%s/cloud/external/restservicebus.py' % CONFIG.paths.current } CONFIG_FILE = 'config/shared/web_deviso_request.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) # data = bottle.request.json data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('bigiq')).read())) # Prepare placeholders in our config our_config.update({'stages': {'main': {'setup': {'install': {'parameters': {}}}}}}) our_config.update({'stages': {'main': {'setup': {'install-bigips': {'parameters': {}}}}}}) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) plugins = our_config.plugins # Append submitter's email to recipient list if data.get('email'): plugins.email.to.append(data['email']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage v = None if data.get('iso'): params = our_config.stages.main.setup['install'].parameters params['custom iso'] = data['iso'] v = version_from_metadata(data['iso']) if data.get('hfiso'): params = our_config.stages.main.setup['install'].parameters params['custom hf iso'] = data['hfiso'] v = version_from_metadata(data['hfiso']) # Find the RTM ISO that goes with this HF image. if not data.get('iso'): params['custom iso'] = isofile(v.version, product=str(v.product)) args = [] args[:] = NOSETESTS_ARGS rank = Literal('rank') expr = (rank > Literal(0)) & (rank < Literal(11)) # Include all migrated tests, example: functional/standalone/security/migrated/... # Assumption is that all tests are rank=505 expr |= rank == Literal(505) # Only Greenflash tests have extended attributes if v is None or v >= 'bigiq 4.5': # build hamode argument if data.ha: hamode = Literal('hamode') expr2 = Or() for x in data.ha: if x != 'standalone': expr2 += [In(String(x.upper()), hamode)] if 'standalone' in data.ha: expr &= (~hamode | expr2) else: expr &= hamode & expr2 if data.ui: uimode = Literal('uimode') if data.ui == 'api': expr &= ~uimode elif data.ui == 'ui': expr &= uimode & (uimode > Literal(0)) else: raise ValueError('Unknown value {}'.format(data.ui)) if data.module: module = Literal('module') expr2 = Or() for x in data.module: expr2 += [In(String(x.upper()), module)] expr &= (module & expr2) args.append('--tc-file={VENV}/%s' % CONFIG_FILE) # Default is our BVT suite. if v: suite = os.path.join(CONFIG.suites.root, CONFIG.suites[v.version]) else: suite = SUITES[data.get('suite', DEFAULT_SUITE)] args.append('--tc=stages.enabled:1') # XXX: No quotes around the long argument value! args.append('--eval-attr={}'.format(str(expr))) args.append('--with-email') # args.append('--collect-only') args.append('--with-irack') args.append('{VENV}/%s' % suite) v = plugins.email.variables v.args = args v.iso = data.iso v.module = data.module result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = app.router.build('status', task_id=result.id) return dict(status=result.status, id=result.id, link=link)
def bvt_basic_post(): """Handles requests from BIGIP teams. All the logic needed to translate the user input into what makes sense to us happens right here. """ BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(eng-?\w*|hf\d+|hf-\w+)?' TESTS_DEBUG = 'tests/solar/bvt/integration/filesystem/' CONFIG_FILE = 'config/shared/web_bvt_request.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) data._referer = bottle.request.url # data = bottle.request.json # BUG: The iRack reservation-based picker is flawed. It'll always select # the nearest available harness, stacking all workers on just one. # with IrackInterface(address=CONFIG.irack.address, # timeout=30, # username=CONFIG.irack.username, # password=CONFIG.irack.apikey, # ssl=False) as irack: # config_dir = os.path.dirname(CONFIG_WEB_FILE) # harness_files = [os.path.join(config_dir, x) for x in CONFIG.web.harnesses] # our_config = RCMD.irack.pick_best_harness(harness_files, ifc=irack) our_config = AttrDict(yaml.load(open(get_harness('em')).read())) # Prepare placeholders in our config our_config.update({'stages': {'main': {'setup': {'install-bigips': {'parameters': {}}}}}}) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'plugins': {'bvtinfo': {}}}) plugins = our_config.plugins # Set BVTInfo data plugins.bvtinfo.project = data['project'] plugins.bvtinfo.build = data['build'] # Append submitter's email to recipient list if data.get('submitted_by'): plugins.email.to.append(data['submitted_by']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage params = our_config.stages.main.setup['install-bigips'].parameters match = re.match(BVTINFO_PROJECT_PATTERN, data['project']) if match: params['version'] = match.group(2) if match.group(3): params['hotfix'] = match.group(3) else: params['version'] = data['project'] params['build'] = data['build'] params['custom iso'] = data.get('custom_iso') params['custom hf iso'] = data.get('custom_hf_iso') params.product = 'bigip' if not min_version_validator(params.build, params.version, params.hotfix, params.product, min_ver=CONFIG.supported): # raise ValueError('Requested version not supported') bottle.response.status = 406 return dict(message='Requested version not supported') args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) if data.get('debug'): args.append('--tc=stages.enabled:1') tests = [os.path.join('{VENV}', x) for x in re.split('\s+', (data.get('tests') or TESTS_DEBUG).strip())] args.extend(tests) else: args.append('--tc=stages.enabled:1') args.append('--eval-attr=rank > 0 and rank < 11') args.append('--with-email') args.append('--with-bvtinfo') args.append('--with-irack') args.append('{VENV}/%s' % CONFIG.paths.em) v = plugins.email.variables v.args = args v.project = data['project'] v.version = params.version v.build = params.build result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = app.router.build('status', task_id=result.id) return dict(status=result.status, id=result.id, link=link)
def bvt_deviso_post(): """ Handles requests from Dev team for user builds ISOs. Input POST request looks similar to this: { '_referer': 'http://shiraz/internaltest', u 'module': [u 'access', u 'adc', u 'afm', u 'asm', u 'avr', u 'cloud', u 'device', u 'system', u 'platform'], u 'bigip_v': u '12.0.0', u 'hfiso': u '/path/to/hf.iso', u 'iso': u '/path/to/base.iso', u 'custom iso': u'/path/to/custom.iso', u 'custom hf iso': u'/path/to/custom-hf.iso', u 'ui': False, u 'testruntype': u 'biq-standard-bvt', u 'ha': [u 'standalone'], u 'email': u '*****@*****.**' } """ LOG.info("DEVISO: Called") # BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(hf\d+)?' DEFAULT_SUITE = 'bvt' SUITES = { 'bvt': '%s/' % CONFIG.paths.current, 'dev': '%s/cloud/external/devtest_wrapper.py' % CONFIG.paths.current, 'dev-cloud': '%s/cloud/external/restservicebus.py' % CONFIG.paths.current } CONFIG_FILE = 'config/shared/web_deviso_request.yaml' BIGIP_V = CONFIG.bigip_versions AUTOMATION_RUN_TYPES = CONFIG.automation_run_types # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) # data = bottle.request.json LOG.info("DEVISO: POST Request: " + str(data)) data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('bigiq')).read())) # Prepare placeholders in our config our_config.update( {'stages': { 'main': { 'setup': { 'install': { 'parameters': {} } } } }}) our_config.update({ 'stages': { 'main': { 'setup': { 'install-bigips': { 'parameters': {} } } } } }) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) plugins = our_config.plugins # Append submitter's email to recipient list if data.get('email'): plugins.email.to.append(data['email']) plugins.email.to.extend(CONFIG.web.recipients) # Set BIGIP version config if data.get('bigip_v') in BIGIP_V: bigip_cfg = BIGIP_V[data['bigip_v']] else: bigip_cfg = BIGIP_V['default'] # If a custom BIG-IP Base is specified, then do NOT append this .yaml if data.get('custom_bigip_iso') is None: our_config.setdefault('$extends', []).append(bigip_cfg) # Set BIG-IQ version and build in the install stage v = None if data.get('iso'): params = our_config.stages.main.setup['install'].parameters params['custom iso'] = data['iso'] v = version_from_metadata(data['iso']) if data.get('hfiso'): params = our_config.stages.main.setup['install'].parameters params['custom hf iso'] = data['hfiso'] v = version_from_metadata(data['hfiso']) # Find the RTM ISO that goes with this HF image. if not data.get('iso'): params['custom iso'] = isofile(v.version, product=str(v.product)) # Set the BIG-IP version and build in the install stage, if it was # specified in the POST request. if data.get('custom_bigip_iso'): params = our_config.stages.main.setup['install-bigips'].parameters params['custom iso'] = data['custom_bigip_iso'] # Only append BIG-IP HF info if a Base was specified if data.get('custom_bigip_hf_iso'): params = our_config.stages.main.setup['install-bigips'].parameters params['custom hf iso'] = data['custom_bigip_hf_iso'] args = [] args[:] = NOSETESTS_ARGS # Set the NOSE rank string based on the automation type expr = Literal(AUTOMATION_RUN_TYPES[data['testruntype']]) # Only Greenflash tests have extended attributes if v is None or v >= 'bigiq 4.5': # build hamode argument if data.ha: hamode = Literal('hamode') expr2 = Or() for x in data.ha: if x != 'standalone': expr2 += [In(String(x.upper()), hamode)] if 'standalone' in data.ha: expr &= (~hamode | expr2) else: expr &= hamode & expr2 if data.ui: uimode = Literal('uimode') if data.ui == 'api': expr &= ~uimode elif data.ui == 'ui': expr &= uimode & (uimode > Literal(0)) else: raise ValueError('Unknown value {}'.format(data.ui)) if data.module: module = Literal('module') expr2 = Or() for x in data.module: expr2 += [In(String(x.upper()), module)] expr &= (module & expr2) args.append('--tc-file={VENV}/%s' % CONFIG_FILE) # Default is our BVT suite. if v: suite = os.path.join(CONFIG.suites.root, CONFIG.suites[v.version]) else: suite = SUITES[data.get('suite', DEFAULT_SUITE)] args.append('--tc=stages.enabled:1') # XXX: No quotes around the long argument value! args.append('--eval-attr={}'.format(str(expr))) args.append('--with-email') # args.append('--collect-only') args.append('--with-irack') args.append('{VENV}/%s' % suite) v = plugins.email.variables v.args = args v.iso = data.iso v.module = data.module LOG.info("DEVISO: Nose Args: " + str(v)) LOG.info("DEVISO: our_config: " + str(our_config)) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = common_app.router.build('status', task_id=result.id) deviso_result = dict(status=result.status, id=result.id, link=link) LOG.info("DEVISO: Result: " + str(deviso_result)) return deviso_result
def bvt_deviso_post(): """Handles requests from Dev team for user builds ISOs. """ # BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(hf\d+)?' DEFAULT_SUITE = 'bvt' SUITES = { 'bvt': '%s/' % CONFIG.paths.current, 'dev': '%s/cloud/external/devtest_wrapper.py' % CONFIG.paths.current, 'dev-cloud': '%s/cloud/external/restservicebus.py' % CONFIG.paths.current } CONFIG_FILE = 'config/shared/web_deviso_request.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) # data = bottle.request.json data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('bigiq')).read())) # Prepare placeholders in our config our_config.update( {'stages': { 'main': { 'setup': { 'install': { 'parameters': {} } } } }}) our_config.update({ 'stages': { 'main': { 'setup': { 'install-bigips': { 'parameters': {} } } } } }) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) plugins = our_config.plugins # Append submitter's email to recipient list if data.get('email'): plugins.email.to.append(data['email']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage v = None if data.get('iso'): params = our_config.stages.main.setup['install'].parameters params['custom iso'] = data['iso'] v = version_from_metadata(data['iso']) if data.get('hfiso'): params = our_config.stages.main.setup['install'].parameters params['custom hf iso'] = data['hfiso'] v = version_from_metadata(data['hfiso']) # Find the RTM ISO that goes with this HF image. if not data.get('iso'): params['custom iso'] = isofile(v.version, product=str(v.product)) args = [] args[:] = NOSETESTS_ARGS rank = Literal('rank') expr = (rank > Literal(0)) & (rank < Literal(11)) # Include all migrated tests, example: functional/standalone/security/migrated/... # Assumption is that all tests are rank=505 expr |= rank == Literal(505) # Only Greenflash tests have extended attributes if v is None or v >= 'bigiq 4.5': # build hamode argument if data.ha: hamode = Literal('hamode') expr2 = Or() for x in data.ha: if x != 'standalone': expr2 += [In(String(x.upper()), hamode)] if 'standalone' in data.ha: expr &= (~hamode | expr2) else: expr &= hamode & expr2 if data.ui: uimode = Literal('uimode') if data.ui == 'api': expr &= ~uimode elif data.ui == 'ui': expr &= uimode & (uimode > Literal(0)) else: raise ValueError('Unknown value {}'.format(data.ui)) if data.module: module = Literal('module') expr2 = Or() for x in data.module: expr2 += [In(String(x.upper()), module)] expr &= (module & expr2) args.append('--tc-file={VENV}/%s' % CONFIG_FILE) # Default is our BVT suite. if v: suite = os.path.join(CONFIG.suites.root, CONFIG.suites[v.version]) else: suite = SUITES[data.get('suite', DEFAULT_SUITE)] args.append('--tc=stages.enabled:1') # XXX: No quotes around the long argument value! args.append('--eval-attr={}'.format(str(expr))) args.append('--with-email') # args.append('--collect-only') args.append('--with-irack') args.append('{VENV}/%s' % suite) v = plugins.email.variables v.args = args v.iso = data.iso v.module = data.module result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = app.router.build('status', task_id=result.id) return dict(status=result.status, id=result.id, link=link)
def bvt_bigiq_post(): """Handles requests from BIGIP teams for BIGIQ BVT. All the logic needed to translate the user input into what makes sense to us happens right here. """ BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(eng-?\w*|hf\d+|hf-\w+)?' CONFIG_FILE = 'config/shared/web_bvt_request_bigiq.yaml' # For people who don't like to set the application/json header. data = AttrDict(json.load(bottle.request.body)) data._referer = bottle.request.url our_config = AttrDict(yaml.load(open(get_harness('bigiq-tmos')).read())) # Prepare placeholders in our config our_config.update({ 'stages': { 'main': { 'setup': { 'install-bigips': { 'parameters': {} } } } } }) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'plugins': {'bvtinfo': {'bigip': {}}}}) plugins = our_config.plugins # Set BVTInfo data plugins.bvtinfo.project = data['project'] plugins.bvtinfo.build = data['build'] plugins.bvtinfo.bigip.name = 'bigiq-bvt' # Append submitter's email to recipient list if data.get('submitted_by'): plugins.email.to.append(data['submitted_by']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage params = our_config.stages.main.setup['install-bigips'].parameters match = re.match(BVTINFO_PROJECT_PATTERN, data['project']) if match: params['version'] = match.group(2) if match.group(3): params['hotfix'] = match.group(3) else: params['version'] = data['project'] params['build'] = data['build'] params['custom iso'] = data.get('custom_iso') params['custom hf iso'] = data.get('custom_hf_iso') params.product = 'bigip' if not min_version_validator(params.build, params.version, params.hotfix, params.product, min_ver=CONFIG.supported): # raise ValueError('Requested version not supported') bottle.response.status = 406 return dict(message='Requested version not supported') args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) args.append('--tc=stages.enabled:1') # For chuckanut++ args.append('--eval-attr=rank >= 5 and rank <= 10') args.append('--with-email') args.append('--with-bvtinfo') args.append('--with-irack') args.append('{VENV}/%s' % CONFIG.paths.tc) v = plugins.email.variables v.args = args v.project = data['project'] v.version = params.version v.build = params.build # return dict(config=our_config, args=args) result = nosetests.delay(our_config, args, data) # @UndefinedVariable link = app.router.build('status', task_id=result.id) return dict(status=result.status, id=result.id, link=link)
def bvt_test_post(): """Handles requests from BIGIP teams for BIGIQ BVT, all modules except ASM. All the logic needed to translate the user input into what makes sense to us happens right here. """ LOG.info("BIG-IQ CM: Called") BVTINFO_PROJECT_PATTERN = '(\D+)?(\d+\.\d+\.\d+)-?(eng-?\w*|hf\d+|hf-\w+)?' # For people who don't like to set the application/json header. print bottle.request.body.read() data = AttrDict(json.load(bottle.request.body)) LOG.info("BIG-IQ CM POST Request: " + str(data)) data._referer = bottle.request.url CONFIG_FILE = 'config/web_request_demo.yaml' our_config = AttrDict(yaml.load(open(CONFIG_FILE).read())) if data.get('devices'): our_config.update({'devices': data['devices']}) # Prepare placeholders in our config our_config.update({ 'stages': { 'main': { 'setup': { 'install-bigips': { 'parameters': {} } } } } }) our_config.update({'plugins': {'email': {'to': [], 'variables': {}}}}) our_config.update({'plugins': {'json_reporter': {}}}) #our_config.update({'plugins': {'bvtinfo': {'bigip': {}}}}) tests = data.get('tests', [CONFIG.paths.default]) #LOG.info(tests) plugins = our_config.plugins # Set BVTInfo data #plugins.bvtinfo.project = data['project'] #plugins.bvtinfo.build = data['build'] #plugins.bvtinfo.bigip.name = 'bigiq-bvt' plugins.json_reporter['callback url'] = data.get('endpoint') # Append submitter's email to recipient list if data.get('submitted_by'): plugins.email.to.append(data['submitted_by']) plugins.email.to.extend(CONFIG.web.recipients) # Set version and build in the install stage # params = our_config.stages.main.setup['install-bigips'].parameters # match = re.match(BVTINFO_PROJECT_PATTERN, data['project']) # if match: # params['version'] = match.group(2) # if match.group(3): # params['hotfix'] = match.group(3) # else: # params['version'] = data['project'] # params['build'] = data['build'] # params['custom iso'] = data.get('custom_iso') # params['custom hf iso'] = data.get('custom_hf_iso') # params.product = 'bigip' # # if not min_version_validator(params.build, params.version, params.hotfix, # params.product, min_ver=CONFIG.supported): # # raise ValueError('Requested version not supported') # bottle.response.status = 406 # return dict(message='Requested version not supported') args = [] args[:] = NOSETESTS_ARGS args.append('--tc-file={VENV}/%s' % CONFIG_FILE) #args.append('--tc=stages.enabled:1') # For chuckanut++ #args.append('--eval-attr=rank >= 1 and rank <= 10') #args.append('--with-email') # args.append('--with-bvtinfo') args.append('--with-irack') args.append('--with-jsonreport') args.append('--with-qkview=never') args.extend('{VENV}/%s' % x for x in tests) v = plugins.email.variables v.args = args # v.project = data['project'] # v.version = params.version # v.build = params.build LOG.info("BIG-IQ CM Nose Args: " + str(v)) LOG.info("BIG-IQ CM ourconfig: " + str(our_config)) # return dict(config=our_config, args=args) result = nosetests.delay(our_config, args, data) # @UndefinedVariable #result = AttrDict(id='1234', status="OK") link = common_app.router.build('status', task_id=result.id) cm_result = dict(status=result.status, id=result.id, link=link) LOG.info("BIG-IQ CM Result: " + str(cm_result)) return cm_result