diff options
author | Chigang(Justin) <chigang@huawei.com> | 2015-08-13 03:14:03 -0400 |
---|---|---|
committer | Chigang(Justin) <chigang@huawei.com> | 2015-08-18 03:56:06 -0400 |
commit | 3656b2525c9b4e8c5e1f45625adb1cd143425dc0 (patch) | |
tree | 0836bcdf3d093d3d4f6cd40e4deedcbf93ebc976 /ci/gen_ins_pkg_script.py | |
parent | 7951b094df92c40417ec66c4be58871911bbed07 (diff) |
Generate ppa repositories automatically
Openstack ppa repo will be generated by the patch.now we support
openstack(juno) on trusty/centos7.1. there are two steps about
how to generate the repo:
1. analyze the deployment script to find the deploying packages
2. use Docker as container to collect packages
JIRA: COMPASS-15
Change-Id: I74ac57b70455643ecf9d32effd44a2e46f404f4e
Signed-off-by: Chigang(Justin) <chigang@huawei.com>
Diffstat (limited to 'ci/gen_ins_pkg_script.py')
-rw-r--r-- | ci/gen_ins_pkg_script.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ci/gen_ins_pkg_script.py b/ci/gen_ins_pkg_script.py new file mode 100644 index 00000000..9ce71f4a --- /dev/null +++ b/ci/gen_ins_pkg_script.py @@ -0,0 +1,45 @@ +import yaml, os, sys +from Cheetah.Template import Template + +def get_file_list(root, arch): + files = [] + + dirs = os.listdir(os.path.join(root, 'roles')) + + for dir in dirs: + var_dir = os.path.join(root, 'roles', dir, 'vars') + for name in ['main.yml', arch + r'.yml']: + if os.path.exists(os.path.join(var_dir, name)): + files.append(os.path.join(var_dir, name)) + + return files + +def get_packages_name_list(file_list): + package_name_list = [] + + for file in file_list: + datas = yaml.load(open(file)) + for key, value in datas.items(): + if not key.endswith("packages") and not key.endswith("packages_noarch"): + continue + + if not value: + continue + + if value not in package_name_list: + package_name_list += value + + return package_name_list + +def generate_download_script(root, arch, tmpl): + package_name_list = get_packages_name_list(get_file_list(root, arch)) + + tmpl = Template(file=tmpl, searchList={'packages':package_name_list}) + + with open('install_packages.sh', 'w') as f: + f.write(tmpl.respond()) + +if __name__=='__main__': + # generate_download_script('ansible', 'Debian', 'Debian.tmpl') + generate_download_script(sys.argv[1], sys.argv[2], sys.argv[3]) + |