Revision 88e6558b
b/ci/snf-ci | ||
---|---|---|
8 | 8 |
|
9 | 9 |
CREATE_SERVER_CMD = "create" |
10 | 10 |
BUILD_SYNNEFO_CMD = "build" |
11 |
BUILD_DOCS_SYNNEFO_CMD = "docs" |
|
11 | 12 |
DEPLOY_SYNNEFO_CMD = "deploy" |
12 | 13 |
TEST_SYNNEFO_CMD = "test" |
13 | 14 |
RUN_BURNIN_CMD = "burnin" |
... | ... | |
16 | 17 |
AVAILABLE_COMMANDS = [ |
17 | 18 |
CREATE_SERVER_CMD, |
18 | 19 |
BUILD_SYNNEFO_CMD, |
20 |
BUILD_DOCS_SYNNEFO_CMD, |
|
19 | 21 |
DEPLOY_SYNNEFO_CMD, |
20 | 22 |
TEST_SYNNEFO_CMD, |
21 | 23 |
RUN_BURNIN_CMD, |
... | ... | |
28 | 30 |
command: |
29 | 31 |
* %s: Create the slave server |
30 | 32 |
* %s: Create debian packages for Synnefo in the created server |
33 |
* %s: Create documentation for Synnefo in the created server |
|
31 | 34 |
* %s: Deploy Synnefo in created server |
32 | 35 |
* %s: Run Synnefo unittests |
33 | 36 |
* %s: Run snf-burnin in the deployed Synnefo |
... | ... | |
35 | 38 |
* %s: Run all the available commands |
36 | 39 |
""" % tuple([CREATE_SERVER_CMD, |
37 | 40 |
BUILD_SYNNEFO_CMD, |
41 |
BUILD_DOCS_SYNNEFO_CMD, |
|
38 | 42 |
DEPLOY_SYNNEFO_CMD, |
39 | 43 |
TEST_SYNNEFO_CMD, |
40 | 44 |
RUN_BURNIN_CMD, |
... | ... | |
56 | 60 |
help="Download the debian packages that were created" |
57 | 61 |
" during the '%s' step in this directory" % |
58 | 62 |
BUILD_SYNNEFO_CMD) |
63 |
parser.add_option("--fetch-docs", dest="fetch_docs", |
|
64 |
default=None, |
|
65 |
help="Download the documentation that was created" |
|
66 |
" during the '%s' step in this directory" % |
|
67 |
BUILD_DOCS_SYNNEFO_CMD) |
|
59 | 68 |
parser.add_option("--schema", dest="schema", default=None, |
60 | 69 |
help="Schema for snf-deploy.") |
61 | 70 |
|
... | ... | |
92 | 101 |
synnefo_ci.clone_repo() |
93 | 102 |
if getattr(options, BUILD_SYNNEFO_CMD, False): |
94 | 103 |
synnefo_ci.build_synnefo() |
95 |
if options.fetch_packages: |
|
96 |
dest = os.path.abspath(options.fetch_packages) |
|
97 |
synnefo_ci.fetch_packages(dest=dest) |
|
104 |
if options.fetch_packages: |
|
105 |
dest = os.path.abspath(options.fetch_packages) |
|
106 |
synnefo_ci.fetch_packages(dest=dest) |
|
107 |
if getattr(options, BUILD_DOCS_SYNNEFO_CMD, False): |
|
108 |
synnefo_ci.build_documentation() |
|
109 |
if options.fetch_docs: |
|
110 |
dest = os.path.abspath(options.fetch_docs) |
|
111 |
synnefo_ci.fetch_documentation(dest=dest) |
|
98 | 112 |
if getattr(options, DEPLOY_SYNNEFO_CMD, False): |
99 | 113 |
synnefo_ci.deploy_synnefo(schema=options.schema) |
100 | 114 |
if getattr(options, TEST_SYNNEFO_CMD, False): |
b/ci/utils.py | ||
---|---|---|
10 | 10 |
import logging |
11 | 11 |
import fabric.api as fabric |
12 | 12 |
import subprocess |
13 |
import tempfile |
|
13 | 14 |
from ConfigParser import ConfigParser, DuplicateSectionError |
14 | 15 |
|
15 | 16 |
from kamaki.cli import config as kamaki_config |
... | ... | |
445 | 446 |
""" |
446 | 447 |
_run(cmd, False) |
447 | 448 |
|
449 |
|
|
450 |
@_check_fabric |
|
451 |
def build_documentation(self): |
|
452 |
self.logger.info("Build Synnefo documentation..") |
|
453 |
_run("pip install -U Sphinx", False) |
|
454 |
with fabric.cd("synnefo"): |
|
455 |
_run("./ci/make_docs.sh synnefo_documentation", False) |
|
456 |
|
|
457 |
def fetch_documentation(self, dest=None): |
|
458 |
if dest is None: |
|
459 |
dest = "synnefo_documentation" |
|
460 |
dest = os.path.abspath(dest) |
|
461 |
if not os.path.exists(dest): |
|
462 |
os.makedirs(dest) |
|
463 |
self.fetch_compressed("synnefo/synnefo_documentation", dest) |
|
464 |
self.logger.info("Downloaded documentation to %s" % |
|
465 |
_green(dest)) |
|
466 |
|
|
448 | 467 |
@_check_fabric |
449 | 468 |
def deploy_synnefo(self, schema=None): |
450 | 469 |
"""Deploy Synnefo using snf-deploy""" |
... | ... | |
520 | 539 |
_run(cmd, True) |
521 | 540 |
|
522 | 541 |
@_check_fabric |
523 |
def fetch_packages(self, dest=None): |
|
524 |
"""Download Synnefo packages""" |
|
525 |
self.logger.info("Download Synnefo packages") |
|
526 |
self.logger.debug("Create tarball with packages") |
|
527 |
cmd = """ |
|
528 |
tar czf synnefo_build-area.tgz synnefo_build-area |
|
529 |
""" |
|
542 |
def fetch_compressed(self, src, dest=None): |
|
543 |
self.logger.debug("Creating tarball of %s" % src) |
|
544 |
basename = os.path.basename(src) |
|
545 |
tar_file = basename + ".tgz" |
|
546 |
cmd = "tar czf %s %s" % (tar_file, src) |
|
530 | 547 |
_run(cmd, False) |
548 |
if not os.path.exists(dest): |
|
549 |
os.makedirs(dest) |
|
531 | 550 |
|
532 |
if dest is None: |
|
533 |
pkgs_dir = self.config.get('Global', 'pkgs_dir') |
|
534 |
else: |
|
535 |
pkgs_dir = dest |
|
536 |
|
|
537 |
self.logger.debug("Fetch packages to local dir %s" % pkgs_dir) |
|
538 |
# Create package directory if missing |
|
539 |
if not os.path.exists(pkgs_dir): |
|
540 |
os.makedirs(pkgs_dir) |
|
541 |
|
|
542 |
with fabric.quiet(): |
|
543 |
fabric.get("synnefo_build-area.tgz", pkgs_dir) |
|
544 |
|
|
545 |
pkgs_file = os.path.join(pkgs_dir, "synnefo_build-area.tgz") |
|
546 |
self._check_hash_sum(pkgs_file, "synnefo_build-area.tgz") |
|
551 |
tmp_dir = tempfile.mkdtemp() |
|
552 |
fabric.get(tar_file, tmp_dir) |
|
547 | 553 |
|
548 |
self.logger.debug("Untar packages file %s" % pkgs_file) |
|
554 |
dest_file = os.path.join(tmp_dir, tar_file) |
|
555 |
self._check_hash_sum(dest_file, tar_file) |
|
556 |
self.logger.debug("Untar packages file %s" % dest_file) |
|
549 | 557 |
cmd = """ |
550 | 558 |
cd %s |
551 |
tar xzf synnefo_build-area.tgz
|
|
552 |
cp synnefo_build-area/* %s
|
|
553 |
rm -r synnefo_build-area
|
|
554 |
""" % (pkgs_dir, dest)
|
|
559 |
tar xzf %s
|
|
560 |
cp -r %s/* %s
|
|
561 |
rm -r %s
|
|
562 |
""" % (tmp_dir, tar_file, src, dest, tmp_dir)
|
|
555 | 563 |
os.system(cmd) |
564 |
self.logger.info("Downloaded %s to %s" % |
|
565 |
(src, _green(dest))) |
|
566 |
|
|
567 |
@_check_fabric |
|
568 |
def fetch_packages(self, dest=None): |
|
569 |
if dest is None: |
|
570 |
dest = self.config.get('Global', 'pkgs_dir') |
|
571 |
dest = os.path.abspath(dest) |
|
572 |
if not os.path.exists(dest): |
|
573 |
os.makedirs(dest) |
|
574 |
self.fetch_compressed("synnefo_build-area", dest) |
|
556 | 575 |
self.logger.info("Downloaded debian packages to %s" % |
557 |
_green(pkgs_dir)) |
|
576 |
_green(dest)) |
Also available in: Unified diff