forked from cloudify-cosmo/cloudify-packager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.py
115 lines (88 loc) · 3.45 KB
/
get.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python
########
# Copyright (c) 2014 GigaSpaces Technologies Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
from packman import logger
from packman.packman import get_package_config as get_conf
from packman import utils
from packman import python
from packman import retrieve
lgr = logger.init()
def _prepare(package):
common = utils.Handler()
common.rmdir(package['sources_path'])
common.mkdir('{0}/archives'.format(package['sources_path']))
common.mkdir(package['package_path'])
def create_agent(package, download=False):
dl_handler = retrieve.Handler()
common = utils.Handler()
py_handler = python.Handler()
_prepare(package)
py_handler.make_venv(package['sources_path'])
if download:
tar_file = '{0}/{1}.tar.gz'.format(
package['sources_path'], package['name'])
for url in package['source_urls']:
dl_handler.download(url, file=tar_file)
common.untar(package['sources_path'], tar_file)
for module in package['modules']:
py_handler.pip(module, package['sources_path'])
def get_ubuntu_precise_agent(download=False):
package = get_conf('Ubuntu-precise-agent')
create_agent(package, download)
def get_ubuntu_trusty_agent(download=False):
package = get_conf('Ubuntu-trusty-agent')
create_agent(package, download)
def get_centos_final_agent(download=False):
package = get_conf('centos-Final-agent')
create_agent(package, download)
def get_debian_jessie_agent(download=False):
package = get_conf('debian-jessie-agent')
create_agent(package, download)
def get_celery(download=False):
package = get_conf('celery')
dl_handler = retrieve.Handler()
common = utils.Handler()
py_handler = python.Handler()
_prepare(package)
py_handler.make_venv(package['sources_path'])
tar_file = '{0}/{1}.tar.gz'.format(
package['sources_path'], package['name'])
for url in package['source_urls']:
dl_handler.download(url, file=tar_file)
common.untar(package['sources_path'], tar_file)
if download:
for module in package['modules']:
py_handler.pip(module, package['sources_path'])
def get_manager(download=False):
package = get_conf('manager')
dl_handler = retrieve.Handler()
common = utils.Handler()
py_handler = python.Handler()
_prepare(package)
py_handler.make_venv(package['sources_path'])
tar_file = '{0}/{1}.tar.gz'.format(
package['sources_path'], package['name'])
for url in package['source_urls']:
dl_handler.download(url, file=tar_file)
common.untar(package['sources_path'], tar_file)
common.mkdir(package['file_server_dir'])
common.cp(package['resources_path'], package['file_server_dir'])
if download:
for module in package['modules']:
py_handler.pip(module, package['sources_path'])
def main():
lgr.debug('VALIDATED!')
if __name__ == '__main__':
main()