summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorJustin chi <chigang@huawei.com>2017-06-25 09:18:54 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-06-25 09:18:54 +0000
commited147fd2ae4e8f8fdcfbc4b5e04602b316b466b8 (patch)
tree736df682895eaf2331f953338046668b9ae8dbda /build
parent2c4925a0f3edbd37fbba44319a14e336f3c33bd1 (diff)
parent4402f7a29bd660260c59b03541141df4f5dfa3fe (diff)
Merge "replace build.conf with yaml"
Diffstat (limited to 'build')
-rw-r--r--build/build.conf42
-rw-r--r--build/build.yaml41
-rw-r--r--build/parser.py104
3 files changed, 145 insertions, 42 deletions
diff --git a/build/build.conf b/build/build.conf
deleted file mode 100644
index fea50c80..00000000
--- a/build/build.conf
+++ /dev/null
@@ -1,42 +0,0 @@
-TIMEOUT=10
-
-# PACKAGE_URL will be reset in Jenkins for different branch
-export PACKAGE_URL=${PACKAGE_URL:-http://artifacts.opnfv.org/compass4nfv/package/master}
-
-# Jumphost OS version
-# export CENTOS_BASE=${CENTOS_BASE:-$PACKAGE_URL/CentOS-7-x86_64-Minimal-1511.iso}
-
-# Compass git repository
-# export COMPASS_CORE=${COMPASS_CORE:-https://github.com/openstack/compass-core.git}
-# export COMPASS_WEB=${COMPASS_WEB:-https://github.com/openstack/compass-web.git}
-# export COMPASS_INSTALL=${COMPASS_INSTALL:-http://github.com/baigk/compass-install.git}
-
-# Compass core packages
-# export COMPASS_PKG=${COMPASS_PKG:-$PACKAGE_URL/centos7-compass-core.tar.gz}
-# export PIP_REPO=${PIP_REPO:-$PACKAGE_URL/pip.tar.gz}
-# export PIP_OPENSTACK_REPO=${PIP_OPENSTACK_REPO:-$PACKAGE_URL/pip-openstack.tar.gz}
-
-# OS ISO for provisioning
-export CENTOS_ISO=${CENTOS_ISO:-$PACKAGE_URL/CentOS-7-x86_64-Minimal-1611.iso} # centos 7.3
-export UBUNTU_ISO=${UBUNTU_ISO:-$PACKAGE_URL/ubuntu-16.04-server-amd64.iso} # ubuntu 16.04
-
-# OpenStack Packages for deployment
-# export UBUNTU_PPA=${UBUNTU_PPA:-$PACKAGE_URL/xenial-ocata-ppa.tar.gz}
-# export CENTOS_PPA=${CENTOS_PPA:-$PACKAGE_URL/centos7-ocata-ppa.tar.gz}
-
-# SDN Packages for integration
-# export APP_PACKAGE=${APP_PACKAGE:-$PACKAGE_URL/packages.tar.gz}
-
-# Other Packages
-# export LOADERS=${LOADERS:-$PACKAGE_URL/loaders.tar.gz}
-# export CIRROS=${CIRROS:-$PACKAGE_URL/cirros-0.3.3-x86_64-disk.img}
-
-# Containerized compass-core docker images
-export COMPASS_DECK=${COMPASS_DECK:-huangxiangyu/compass-deck:v0.2}
-export COMPASS_TASKS=${COMPASS_TASKS:-wtwde/compass-tasks-osa:v0.2}
-export COMPASS_COBBLER=${COMPASS_COBBLER:-huangxiangyu/compass-cobbler:v0.1}
-export COMPASS_DB=${COMPASS_DB:-huangxiangyu/compass-db:v0.1}
-export COMPASS_MQ=${COMPASS_MQ:-huangxiangyu/compass-mq:v0.1}
-
-# Containerized compass-core ansible
-export COMPASS_COMPOSE=${COMPASS_COMPOSE:-https://github.com/hexhxy/compass-docker-compose.git}
diff --git a/build/build.yaml b/build/build.yaml
new file mode 100644
index 00000000..3f684613
--- /dev/null
+++ b/build/build.yaml
@@ -0,0 +1,41 @@
+---
+packages:
+ - name: CentOS-7-x86_64-Minimal-1611.iso
+ description: "Centos ISO of each host for provisioning"
+ get_method: cached
+ url: http://artifacts.opnfv.org/compass4nfv/package/master/CentOS-7-x86_64-Minimal-1611.iso
+
+ - name: ubuntu-16.04-server-amd64.iso
+ description: "Ubuntu ISO of each host for provisioning"
+ get_method: cached
+ url: http://artifacts.opnfv.org/compass4nfv/package/master/ubuntu-16.04-server-amd64.iso
+
+ - name: compass-deck
+ description: "RESTful API and DB Handlers for Compass"
+ get_method: docker
+ url: huangxiangyu/compass-deck:v0.2
+
+ - name: compass-tasks-osa
+ description: "compass task container for openstack deployment via openstack-ansible"
+ get_method: docker
+ url: wtwde/compass-tasks-osa:v0.2
+
+ - name: compass-cobbler
+ description: "cobbler container for compass"
+ get_method: docker
+ url: huangxiangyu/compass-cobbler:v0.1
+
+ - name: compass-db
+ description: "datebase container for compass"
+ get_method: docker
+ url: huangxiangyu/compass-db:v0.1
+
+ - name: compass-mq
+ description: "message queue container for compass"
+ get_method: docker
+ url: huangxiangyu/compass-mq:v0.1
+
+ - name: compass-docker-compose
+ description: "containerized compass compose ansible"
+ get_method: git
+ url: https://github.com/hexhxy/compass-docker-compose.git
diff --git a/build/parser.py b/build/parser.py
new file mode 100644
index 00000000..602d7c21
--- /dev/null
+++ b/build/parser.py
@@ -0,0 +1,104 @@
+##############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import yaml
+import os
+import sys
+
+
+def load_env():
+ cache_dir = os.environ.get('CACHE_DIR')
+ print "Read local Cache dir is %s" % cache_dir
+ return cache_dir
+
+
+def get_from_cache(cache, package):
+ filename = package.get("name")
+ remotefile = package.get("url")
+ localfile = cache + "/" + filename
+ localmd5file = localfile + ".md5"
+ remotemd5file = remotefile + ".md5"
+ print "removing local md5 file...."
+ cmd = "rm -f " + localmd5file
+ os.system(cmd)
+ print "downloading remote md5 file to local...."
+ cmd = "curl --connect-timeout 10 -o " + localmd5file + " " + remotemd5file
+ os.system(cmd)
+ if os.path.exists(localmd5file):
+ print "calculate md5sum of local file"
+ cmd = "md5sum " + localfile + "|cut -d ' ' -f 1"
+ localmd5sum = os.popen(cmd).readlines()
+ cmd = "cat " + localmd5file + "|cut -d ' ' -f 1"
+ remotemd5sum = os.popen(cmd).readlines()
+ print "md5 local %s remote %s" % (localmd5sum, remotemd5sum)
+ if (remotemd5sum == localmd5sum):
+ print "Same with remote, no need to download...."
+ return
+ print "downloading remote file to local...."
+ cmd = "curl --connect-timeout 10 -o " + localfile + " " + remotefile
+ print cmd
+ os.system(cmd)
+
+
+def get_from_git(cache, package):
+ localfile = cache + "/" + package.get("name")
+ cmd = "rm -rf " + localfile
+ print cmd
+ os.system(cmd)
+ cmd = "git clone " + package.get("url") + " " + localfile
+ print cmd
+ os.system(cmd)
+
+
+def get_from_docker(cache, package):
+ cmd = "sudo docker pull "+package.get("url")
+ os.system(cmd)
+ cmd = "sudo docker save "+package.get("url")+" -o "+cache+"/"
+ cmd += package.get("name")+".tar"
+ os.system(cmd)
+
+
+def get_from_curl(cache, package):
+ cmd = "curl --connect-timeout 10 -o " + cache + "/"
+ cmd += package.get("name") + " " + package.get("url")
+ print cmd
+ os.system(cmd)
+
+
+def usage():
+ print "cached : Download from a cached server"
+ print "git : Download from git url"
+ print "curl : Download from a url link by curl"
+ print "docker : Download from docker hub"
+
+
+def build_parser(build_file_name):
+ cache = load_env()
+ cfg = yaml.load(file(build_file_name, 'r'))
+
+ print "Starting building...."
+ for pkg in cfg.get("packages"):
+ print "processing %s" % pkg.get("description")
+
+ if pkg.get("get_method") == "cached":
+ get_from_cache(cache, pkg)
+ elif pkg.get("get_method") == "git":
+ get_from_git(cache, pkg)
+ elif pkg.get("get_method") == "docker":
+ get_from_docker(cache, pkg)
+ elif pkg.get("get_method") == "curl":
+ get_from_curl(cache, pkg)
+ else:
+ usage
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ print("parameter wrong%d %s" % (len(sys.argv), sys.argv))
+ sys.exit(1)
+ build_parser(sys.argv[1])