Add no_deploy_environment option
authorNikolas Hermanns <nikolas.hermanns@ericsson.com>
Mon, 7 Mar 2016 12:31:16 +0000 (13:31 +0100)
committerJonas Bjurel <jonas.bjurel@ericsson.com>
Sat, 9 Apr 2016 18:58:19 +0000 (20:58 +0200)
For development reason it is useable to
have an option so that everything is done
except the deploy of the openstack
environment.

Change-Id: I1f1b7f9c89ee8c9ceea96353e25a51eee53b955c

Conflicts:
deploy/cloud/deploy.py
deploy/deploy.py
deploy/deploy_env.py

ci/deploy.sh
deploy/cloud/deploy.py
deploy/deploy.py
deploy/deploy_env.py

index 2304d72..7bd180e 100755 (executable)
@@ -38,6 +38,7 @@ OPTIONS:
   -B  PXE Bridge for booting of Fuel master
   -d  Dry-run
   -f  Deploy on existing Fuel master
+  -e  Do not launch environment deployment
   -F  Do only create a Fuel master
   -H  No health check
   -l  Lab-name
@@ -59,6 +60,7 @@ Input parameters to the build script is:
 -d Dry-run - Produces deploy config files (config/dea.yaml and
    config/dha.yaml), but does not execute deploy
 -f Deploy on existing Fuel master
+-e Do not launch environment deployment
 -F Do only create a Fuel master
 -H Do not run fuel built in health-check after successfull deployment
 -l Lab name as defined in the configuration directory, e.g. lf
@@ -104,6 +106,7 @@ PXE_BRIDGE=''
 NO_HEALTH_CHECK=''
 USE_EXISTING_FUEL=''
 FUEL_CREATION_ONLY=''
+NO_DEPLOY_ENVIRONMENT=''
 STORAGE_DIR=''
 DRY_RUN=0
 #
@@ -113,7 +116,7 @@ DRY_RUN=0
 ############################################################################
 # BEGIN of main
 #
-while getopts "b:B:dfFHl:p:s:S:i:h" OPTION
+while getopts "b:B:dfFHl:p:s:S:i:h:e" OPTION
 do
     case $OPTION in
         b)
@@ -139,6 +142,9 @@ do
         F)
             FUEL_CREATION_ONLY='-fo'
             ;;
+        e)
+            NO_DEPLOY_ENVIRONMENT='-nde'
+            ;;
         H)
             NO_HEALTH_CHECK='-nh'
             ;;
@@ -224,8 +230,8 @@ if [ $DRY_RUN -eq 0 ]; then
         ISO=${SCRIPT_PATH}/ISO/image.iso
     fi
     # Start deployment
-    echo "python deploy.py -s $STORAGE_DIR -b $PXE_BRIDGE $USE_EXISTING_FUEL $FUEL_CREATION_ONLY $NO_HEALTH_CHECK -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO"
-    python deploy.py $STORAGE_DIR $PXE_BRIDGE $USE_EXISTING_FUEL $FUEL_CREATION_ONLY $NO_HEALTH_CHECK -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO
+    echo "python deploy.py -s $STORAGE_DIR -b $PXE_BRIDGE $USE_EXISTING_FUEL $FUEL_CREATION_ONLY $NO_HEALTH_CHECK $NO_DEPLOY_ENVIRONMENT -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO"
+    python deploy.py $STORAGE_DIR $PXE_BRIDGE $USE_EXISTING_FUEL $FUEL_CREATION_ONLY $NO_HEALTH_CHECK $NO_DEPLOY_ENVIRONMENT -dea ${SCRIPT_PATH}/config/dea.yaml -dha ${SCRIPT_PATH}/config/dha.yaml -iso $ISO
 fi
 popd > /dev/null
 
index 59f63ff..e00934b 100644 (file)
@@ -22,6 +22,7 @@ from common import (
     check_file_exists,
     commafy,
     ArgParser,
+    log,
 )
 
 YAML_CONF_DIR = '/var/lib/opnfv'
@@ -29,9 +30,12 @@ YAML_CONF_DIR = '/var/lib/opnfv'
 
 class Deploy(object):
 
-    def __init__(self, dea_file, no_health_check):
+    def __init__(self, dea_file, no_health_check, deploy_timeout,
+                 no_deploy_environment):
         self.dea = DeploymentEnvironmentAdapter(dea_file)
         self.no_health_check = no_health_check
+        self.deploy_timeout = deploy_timeout
+        self.no_deploy_environment = no_deploy_environment
         self.macs_per_blade = {}
         self.blades = self.dea.get_node_ids()
         self.blade_node_dict = self.dea.get_blade_node_map()
@@ -59,8 +63,12 @@ class Deploy(object):
 
     def deploy_cloud(self):
         dep = Deployment(self.dea, YAML_CONF_DIR, self.env_id,
-                         self.node_roles_dict, self.no_health_check)
-        dep.deploy()
+                         self.node_roles_dict, self.no_health_check,
+                         self.deploy_timeout)
+        if not self.no_deploy_environment:
+            dep.deploy()
+        else:
+            log('Configuration is done. Deployment is not launched.')
 
     def deploy(self):
 
@@ -76,13 +84,22 @@ def parse_arguments():
     parser.add_argument('-nh', dest='no_health_check', action='store_true',
                         default=False,
                         help='Don\'t run health check after deployment')
+    parser.add_argument('-dt', dest='deploy_timeout', action='store',
+                        default=240, help='Deployment timeout (in minutes) '
+                        '[default: 240]')
+    parser.add_argument('-nde', dest='no_deploy_environment',
+                        action='store_true', default=False,
+                        help=('Do not launch environment deployment'))
     parser.add_argument('dea_file', action='store',
                         help='Deployment Environment Adapter: dea.yaml')
+
     args = parser.parse_args()
     check_file_exists(args.dea_file)
 
     kwargs = {'dea_file': args.dea_file,
-              'no_health_check': args.no_health_check}
+              'no_health_check': args.no_health_check,
+              'deploy_timeout': args.deploy_timeout,
+              'no_deploy_environment': args.no_deploy_environment}
     return kwargs
 
 
index 245e6c0..f86f2be 100755 (executable)
@@ -61,7 +61,7 @@ class AutoDeploy(object):
     def __init__(self, no_fuel, fuel_only, no_health_check, cleanup_only,
                  cleanup, storage_dir, pxe_bridge, iso_file, dea_file,
                  dha_file, fuel_plugins_dir, fuel_plugins_conf_dir,
-                 no_plugins):
+                 no_plugins, deploy_timeout, no_deploy_environment):
         self.no_fuel = no_fuel
         self.fuel_only = fuel_only
         self.no_health_check = no_health_check
@@ -75,6 +75,8 @@ class AutoDeploy(object):
         self.fuel_plugins_dir = fuel_plugins_dir
         self.fuel_plugins_conf_dir = fuel_plugins_conf_dir
         self.no_plugins = no_plugins
+        self.deploy_timeout = deploy_timeout
+        self.no_deploy_environment = no_deploy_environment
         self.dea = (DeploymentEnvironmentAdapter(dea_file)
                     if not cleanup_only else None)
         self.dha = DeploymentHardwareAdapter(dha_file)
@@ -197,7 +199,8 @@ class AutoDeploy(object):
         dep = CloudDeploy(self.dea, self.dha, self.fuel_conf['ip'],
                           self.fuel_username, self.fuel_password,
                           self.dea_file, self.fuel_plugins_conf_dir,
-                          WORK_DIR, self.no_health_check)
+                          WORK_DIR, self.no_health_check, self.deploy_timeout,
+                          self.no_deploy_environment)
         return dep.deploy()
 
     def setup_execution_environment(self):
@@ -238,6 +241,7 @@ class AutoDeploy(object):
         # Exit status
         return 0
 
+
 def check_bridge(pxe_bridge, dha_path):
     with io.open(dha_path) as yaml_file:
         dha_struct = yaml.load(yaml_file)
@@ -315,6 +319,12 @@ def parse_arguments():
                         help='Fuel Plugins Configuration directory')
     parser.add_argument('-np', dest='no_plugins', action='store_true',
                         default=False, help='Do not install Fuel Plugins')
+    parser.add_argument('-dt', dest='deploy_timeout', action='store',
+                        default=240, help='Deployment timeout (in minutes) '
+                        '[default: 240]')
+    parser.add_argument('-nde', dest='no_deploy_environment',
+                        action='store_true', default=False,
+                        help=('Do not launch environment deployment'))
 
     args = parser.parse_args()
     log(args)
@@ -340,7 +350,9 @@ def parse_arguments():
               'dha_file': args.dha_file,
               'fuel_plugins_dir': args.fuel_plugins_dir,
               'fuel_plugins_conf_dir': args.fuel_plugins_conf_dir,
-              'no_plugins': args.no_plugins}
+              'no_plugins': args.no_plugins,
+              'deploy_timeout': args.deploy_timeout,
+              'no_deploy_environment': args.no_deploy_environment}
     return kwargs
 
 
index 735ea66..aa861e1 100644 (file)
@@ -34,7 +34,8 @@ BLADE_RESTART_TIMES = 3
 class CloudDeploy(object):
 
     def __init__(self, dea, dha, fuel_ip, fuel_username, fuel_password,
-                 dea_file, fuel_plugins_conf_dir, work_dir, no_health_check):
+                 dea_file, fuel_plugins_conf_dir, work_dir, no_health_check,
+                 deploy_timeout, no_deploy_environment):
         self.dea = dea
         self.dha = dha
         self.fuel_ip = fuel_ip
@@ -48,6 +49,8 @@ class CloudDeploy(object):
         self.fuel_plugins_conf_dir = fuel_plugins_conf_dir
         self.work_dir = work_dir
         self.no_health_check = no_health_check
+        self.deploy_timeout = deploy_timeout
+        self.no_deploy_environment = no_deploy_environment
         self.file_dir = os.path.dirname(os.path.realpath(__file__))
         self.ssh = SSHClient(self.fuel_ip, self.fuel_username,
                              self.fuel_password)
@@ -103,8 +106,13 @@ class CloudDeploy(object):
         deploy_app = '%s/%s' % (self.work_dir, deploy_app)
         dea_file = '%s/%s' % (self.work_dir, os.path.basename(self.dea_file))
         with self.ssh as s:
-            status = s.run('python %s %s %s' % (
-                deploy_app, ('-nh' if self.no_health_check else ''), dea_file))
+            status = s.run('python %s %s %s %s %s' % (
+                deploy_app,
+                ('-nh' if self.no_health_check else ''),
+                ('-dt %s' %
+                 self.deploy_timeout if self.deploy_timeout else ''),
+                ('-nde' if self.no_deploy_environment else ''),
+                dea_file))
         return status
 
     def check_supported_release(self):