+ return result
+
+def imports(recipe_list):
+ logger = logging.getLogger(__name__)
+ if not recipe_list:
+ logger.info('Use default recipe because there is no import data')
+ recipe_list = default_recipe.getDefaultParameter()
+
+ recipe_parser = RecipeParser(recipe_list)
+ recipe_parser.parse()
+ result = {'recipes': recipe_parser.getRepositories()}
+ #result = {'imports': recipe_parser.getMergedRepositories()}
+ return result
+
+def exports(export_type, recipes, packages, outdir, filename=None):
+ logger = logging.getLogger(__name__)
+ #TODO validation should be checked before request
+ if not export_type:
+ export_type='ks'
+ logger.info('set default export format(.ks)')
+
+ if not recipes:
+ raise TICError(configmgr.message['recipes_not_define'])
+ if not packages or type(packages) is not list:
+ raise TICError(configmgr.message['no_package_to_install'])
+
+ recipe_parser = RecipeParser(recipes)
+ recipe_parser.parse()
+ result = None
+ if export_type == 'recipe':
+ recipe_path = recipe_parser.export2Recipe(packages, outdir, filename)
+ logger.info('export the recipe to %s' % recipe_path)
+ result = {'path': recipe_path}
+ elif export_type == 'ks':
+ # 1. create yaml files
+ yaml_info = recipe_parser.export2Yaml(packages, DEFAULT_KICKSTARTDIR)
+ # 2. create kickstart(.ks) using kickstarter tool
+ options = KSoption(yaml_info.configs, yaml_info.repos, yaml_info.cachedir)
+ kswriter(options)
+ # check whether the ks exists
+ recipe_info = recipe_parser.getMergedRecipe()
+ baseline=recipe_info['Recipe'].get('Baseline')
+ ksname= ''.join([recipe_info['Recipe'].get('FileName'), '.ks'])
+ kspath=os.path.join(yaml_info.cachedir, baseline, ksname)
+ logger.info('the kickstarter created the ks file (%s)' % kspath)
+ if not os.path.exists(kspath):
+ raise TICError('No ks file was created from kickstarter')
+ # copy the ks to output directory
+ output=copyfile(kspath, outdir, filename)
+ logger.info('export the ks to %s' % output)
+ result = {'path':output, 'arch':recipe_info['Recipe'].get('Architecture')}
+ return result
+
+def createimage(recipes, ksfile, outdir):
+ logger = logging.getLogger(__name__)
+
+ if recipes:
+ logger.info('the recipes option is not yet supported')
+ return
+
+ if not os.path.exists(ksfile) or os.path.isdir(ksfile):
+ raise TICError('kickstart file does not exist')
+
+ mic_command=['mic', 'cr', 'auto', ksfile]
+ if outdir:
+ mic_command.append('--outdir=%s' % outdir)