Skip to content

Commit f06f584

Browse files
authored
Merge pull request #72 from cloudify-cosmo/upgrade-example-scripts-to-fabric2
upgrade to fabric2
2 parents a0be89d + 2305f88 commit f06f584

9 files changed

Lines changed: 184 additions & 114 deletions

File tree

.circleci/config.yml

Lines changed: 82 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ executors:
2727
machine:
2828
image: ubuntu-1604:201903-01
2929

30+
cloudify-machine-510:
31+
machine:
32+
image: ubuntu-1604:201903-01
3033

3134
commands:
3235
run_unittest:
@@ -74,16 +77,16 @@ commands:
7477
exit 1
7578
fi
7679
77-
generate_py27_wagon:
80+
generate_py27py36_wagon:
7881
steps:
7982
- run:
8083
name: Create Workspace Build directory.
8184
command: mkdir -p workspace/build
8285
- run:
83-
name: Build py27 Wagon
86+
name: Build py27py36 Wagon
8487
command: |
8588
git clone https://github.com/cloudify-cosmo/cloudify-wagon-build-containers.git
86-
docker build -t cloudify-centos-7-wagon-builder cloudify-wagon-build-containers/centos_7
89+
docker build -t cloudify-centos-7-wagon-builder cloudify-wagon-build-containers/centos_7_py2py3
8790
docker run -v ~/project/:/packaging cloudify-centos-7-wagon-builder
8891
- run:
8992
name: copy wagon to workspace
@@ -93,36 +96,16 @@ commands:
9396
paths:
9497
- build/*
9598

96-
generate_py3_wagon:
97-
steps:
98-
- run:
99-
name: Create Workspace Build directory.
100-
command: mkdir -p workspace/build
101-
- run:
102-
name: Build py3 Wagon
103-
command: |
104-
git clone https://github.com/cloudify-cosmo/cloudify-wagon-build-containers.git
105-
docker build -t cloudify-centos-7-py3-wagon-builder cloudify-wagon-build-containers/centos_7_py3
106-
docker run -v ~/project/:/packaging cloudify-centos-7-py3-wagon-builder
107-
- run:
108-
name: copy wagon to workspace
109-
command: cp *.wgn workspace/build/
110-
- persist_to_workspace:
111-
root: workspace
112-
paths:
113-
- build/*
114-
115-
116-
generate_rhel_py27_wagon:
99+
generate_rhel_py27py36_wagon:
117100
steps:
118101
- run:
119102
name: Create Workspace Build directory.
120103
command: mkdir -p workspace/build
121104
- run:
122-
name: Build RHEL 27 Wagon
105+
name: Build RHEL py27py36 Wagon
123106
command: |
124107
git clone https://github.com/cloudify-cosmo/cloudify-wagon-build-containers.git
125-
docker build -t cloudify-redhat-7-wagon-builder cloudify-wagon-build-containers/redhat_7 --build-arg USERNAME="$USERNAME" --build-arg PASSWORD="$PASSWORD"
108+
docker build -t cloudify-redhat-7-wagon-builder cloudify-wagon-build-containers/redhat_7_py2py3 --build-arg USERNAME="$USERNAME" --build-arg PASSWORD="$PASSWORD"
126109
docker run -v ~/project/:/packaging cloudify-redhat-7-wagon-builder
127110
- run:
128111
name: copy wagon to workspace
@@ -132,7 +115,7 @@ commands:
132115
paths:
133116
- build/*
134117

135-
run_integration_tests:
118+
run_integration_tests_505:
136119
steps:
137120
- run:
138121
name: "Pull Submodules"
@@ -146,7 +129,8 @@ commands:
146129
command: pip install -U pip
147130
- run:
148131
name: install cloudify
149-
command: pip install -U cloudify==5.0.0 pytest==4.6.3 pyyaml==3.10
132+
command: |
133+
pip install -r test-requirements.txt
150134
- run:
151135
name: download manager docker image
152136
command: wget http://repository.cloudifysource.org/cloudify/5.0.5/ga-release/cloudify-docker-manager-5.0.5.tar
@@ -167,6 +151,41 @@ commands:
167151
command: pip install https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/latest.zip
168152
- run: pytest -s .circleci/test_examples.py
169153

154+
run_integration_tests_510:
155+
steps:
156+
- run:
157+
name: "Pull Submodules"
158+
command: |
159+
git submodule update --init --recursive --remote
160+
- attach_workspace:
161+
at: workspace
162+
- run:
163+
name: update pip
164+
command: pip install -U pip
165+
- run:
166+
name: install cloudify
167+
command: |
168+
pip install -r test-requirements.txt
169+
- run:
170+
name: download manager docker image
171+
command: wget http://repository.cloudifysource.org/cloudify/5.1.0/.dev1-release/cloudify-manager-aio-docker-5.1.0.dev1.tar
172+
- run:
173+
name: load docker image
174+
command: docker load -i cloudify-manager-aio-docker-5.1.0.dev1.tar
175+
- run:
176+
name: retain space by dumping the tar
177+
command: rm cloudify-manager-aio-docker-5.1.0.dev1.tar
178+
- run:
179+
name: show images
180+
command: docker images
181+
- run:
182+
name: start docker container
183+
command: docker run --name cfy_manager -d --restart unless-stopped -v /sys/fs/cgroup:/sys/fs/cgroup:ro --tmpfs /run --tmpfs /run/lock --security-opt seccomp:unconfined --cap-add SYS_ADMIN --network host cloudify-manager-aio:latest
184+
- run:
185+
name: install local project
186+
command: pip install https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/latest.zip
187+
- run: pytest -s .circleci/test_examples.py
188+
170189
release_plugin:
171190
steps:
172191
- run:
@@ -223,24 +242,32 @@ jobs:
223242
executor: wagon_generator
224243
steps:
225244
- checkout
226-
- generate_py27_wagon
245+
- generate_py27py36_wagon
227246
# - generate_py3_wagon # TODO: When we have Python3 Manager Integration Test.
228247

229248
rhel_wagon:
230249
executor: wagon_generator
231250
steps:
232251
- checkout
233-
- generate_rhel_py27_wagon
234-
252+
- generate_rhel_py27py36_wagon
235253

236-
integration_tests:
254+
integration_tests_505:
237255
executor: cloudify-machine
238256
environment:
239257
CLOUDIFY_SSL_TRUST_ALL: true
240-
IAAS: gcp
258+
IAAS: openstack
241259
steps:
242260
- checkout
243-
- run_integration_tests
261+
- run_integration_tests_505
262+
263+
integration_tests_510:
264+
executor: cloudify-machine-510
265+
environment:
266+
CLOUDIFY_SSL_TRUST_ALL: true
267+
IAAS: openstack
268+
steps:
269+
- checkout
270+
- run_integration_tests_510
244271

245272
release:
246273
executor: py27
@@ -263,10 +290,18 @@ workflows:
263290
filters:
264291
branches:
265292
only: /([0-9\.]*\-build|master)/
266-
- integration_tests:
293+
- integration_tests_505:
294+
requires:
295+
- wagon
296+
- rhel_wagon
297+
filters:
298+
branches:
299+
only: /([0-9\.]*\-build|master)/
300+
- integration_tests_510:
267301
requires:
268302
- wagon
269303
- rhel_wagon
304+
- integration_tests_505
270305
filters:
271306
branches:
272307
only: /([0-9\.]*\-build|master)/
@@ -275,9 +310,12 @@ workflows:
275310
branches:
276311
only: /master/
277312
requires:
313+
- unittests_py27
314+
- unittests_py36
278315
- wagon
279316
- rhel_wagon
280-
- integration_tests
317+
- integration_tests_505
318+
- integration_tests_510
281319
nightly:
282320
triggers:
283321
- schedule:
@@ -298,10 +336,17 @@ workflows:
298336
filters:
299337
branches:
300338
only: /([0-9\.]*\-build|master)/
301-
- integration_tests:
339+
- integration_tests_505:
302340
requires:
303341
- wagon
304342
- rhel_wagon
305343
filters:
306344
branches:
307345
only: /([0-9\.]*\-build|master)/
346+
- integration_tests_510:
347+
requires:
348+
- wagon
349+
- rhel_wagon
350+
filters:
351+
branches:
352+
only: /([0-9\.]*\-build|master)/

.circleci/test_examples.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,29 @@
2424
cleanup_on_failure, prepare_test
2525
)
2626

27-
OS_VERSION = '3.2.15'
27+
OS_VERSION = '3.2.16'
2828
OS_WAGON = 'https://github.com/cloudify-cosmo/cloudify-openstack-plugin/' \
29-
'releases/download/{v}/cloudify_openstack_plugin-{v}-py27-none-' \
30-
'linux_x86_64-centos-Core.wgn'.format(v=OS_VERSION)
31-
OS_PLUGIN = 'https://github.com/cloudify-cosmo/' \
32-
'cloudify-openstack-plugin/releases/download/' \
33-
'{v}/plugin.yaml'.format(v=OS_VERSION)
34-
PLUGINS_TO_UPLOAD = [(OS_WAGON, OS_PLUGIN)]
29+
'releases/download/{v}/cloudify_openstack_plugin-{v}-' \
30+
'centos-Core-py27.py36-none-linux_x86_64.wgn'.format(v=OS_VERSION)
31+
OS_PLUGIN = 'https://github.com/cloudify-cosmo/cloudify-openstack-plugin/' \
32+
'releases/download/{v}/plugin.yaml'.format(v=OS_VERSION)
33+
'''Temporary until all the plugins in the bundle will
34+
released with py2py3 wagons'''
35+
UT_VERSION = '1.23.5'
36+
UT_WAGON = 'https://github.com/cloudify-incubator/cloudify-utilities-plugin/' \
37+
'releases/download/{v}/cloudify_utilities_plugin-{v}-centos' \
38+
'-Core-py27.py36-none-linux_x86_64.wgn'.format(v=UT_VERSION)
39+
UT_PLUGIN = 'https://github.com/cloudify-incubator/cloudify-utilities-' \
40+
'plugin/releases/download/{v}/plugin.yaml'.format(v=UT_VERSION)
41+
FAB_VERSION = '2.0.4'
42+
FAB_WAGON = 'https://github.com/cloudify-cosmo/cloudify-fabric-plugin/' \
43+
'releases/download/{v}/cloudify_fabric_plugin-{v}-centos-' \
44+
'Core-py27.py36-none-linux_x86_64.wgn'.format(v=FAB_VERSION)
45+
FAB_PLUGIN = 'https://github.com/cloudify-cosmo/cloudify-fabric-plugin/' \
46+
'releases/download/{v}/plugin.yaml'.format(v=FAB_VERSION)
47+
48+
PLUGINS_TO_UPLOAD = [(OS_WAGON, OS_PLUGIN), (UT_WAGON, UT_PLUGIN),
49+
(FAB_WAGON, FAB_PLUGIN)]
3550

3651

3752
SECRETS_TO_CREATE = {
@@ -54,7 +69,7 @@
5469

5570
prepare_test(plugins=PLUGINS_TO_UPLOAD,
5671
secrets=SECRETS_TO_CREATE,
57-
plugin_test=False)
72+
plugin_test=False, execute_bundle_upload=False)
5873

5974
virtual_machine_list = ['examples/blueprint.yaml']
6075
infra_path = 'examples/blueprint-examples/virtual-machine/{0}.yaml'

examples/scripts/configure.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import logging
2525
from tempfile import mkstemp
2626

27-
from fabric.api import run, put, sudo
27+
from fabric2 import task
2828
RUN_WITH = 'source /home/centos/host_pool_service/bin/activate &&'
2929

3030
from cloudify import ctx
@@ -34,14 +34,14 @@
3434
POOL_CFG_PATH = os.path.join(BASE_DIR, 'pool.yaml')
3535

3636

37-
def get_key_content(key_file, logger):
37+
def get_key_content(key_file, logger, connection):
3838
'''Downloads a key and returns the key contents'''
3939
tfd, target_path = mkstemp()
4040
os.close(tfd)
4141
logger.debug('Downloading key file "{0}" to path "{1}"'
4242
.format(key_file, target_path))
4343
local_key_file = ctx.download_resource(key_file)
44-
put(local_key_file, target_path)
44+
connection.put(local_key_file, target_path)
4545
keycontent = None
4646
with open(target_path, 'r') as f_key:
4747
keycontent = f_key.read()
@@ -51,7 +51,7 @@ def get_key_content(key_file, logger):
5151
return keycontent
5252

5353

54-
def set_host_key_content(cfg, logger):
54+
def set_host_key_content(cfg, logger, connection):
5555
'''Replaces host key file string with key content
5656
5757
:param dict cfg: Host-Pool configuration data
@@ -67,7 +67,7 @@ def set_host_key_content(cfg, logger):
6767
# Default key file was specified, let's convert and use
6868
logger.debug('Default key file: "{0}"'.format(default_key_file))
6969
cfg['default']['credentials']['key'] = \
70-
get_key_content(default_key_file, logger)
70+
get_key_content(default_key_file, logger, connection)
7171
del cfg['default']['credentials']['key_file']
7272

7373
# Get the host keys
@@ -81,7 +81,7 @@ def set_host_key_content(cfg, logger):
8181
# Default key file was specified, let's convert and use
8282
logger.debug('Host key file: "{0}"'.format(host_key_file))
8383
host['credentials']['key'] = \
84-
get_key_content(host_key_file, logger)
84+
get_key_content(host_key_file, logger, connection)
8585
del host['credentials']['key_file']
8686
return cfg
8787

@@ -130,7 +130,8 @@ def get_hostpool_logger(mod, debug=False,
130130
return logger
131131

132132

133-
def main():
133+
@task
134+
def main(connection):
134135
'''Entry point'''
135136

136137
logger = get_hostpool_logger('configure',
@@ -146,7 +147,7 @@ def main():
146147
.format(ctx.node.properties['pool'], POOL_CFG_PATH))
147148
local_file = ctx.download_resource(ctx.node.properties['pool'],
148149
target_path=POOL_CFG_PATH)
149-
put(local_file, POOL_CFG_PATH)
150+
connection.put(local_file, POOL_CFG_PATH)
150151

151152
# if not os.path.exists(POOL_CFG_PATH):
152153
# raise NonRecoverableError('Configuration file for the Host-Pool '
@@ -162,7 +163,7 @@ def main():
162163
raise NonRecoverableError('Configuration file for the Host-Pool '
163164
'service is not valid YAML')
164165
logger.info('Converting host key files from blueprint')
165-
seed_config = set_host_key_content(cfg, logger)
166+
seed_config = set_host_key_content(cfg, logger, connection)
166167
ctx.instance.runtime_properties['seed_config'] = seed_config
167168

168169
# main()

0 commit comments

Comments
 (0)