summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jjb/global/slave-params.yml14
-rw-r--r--jjb/kvmfornfv/kvmfornfv.yml32
-rw-r--r--jjb/multisite/multisite-daily-jobs.yml3
-rw-r--r--modules/opnfv/installer_adapters/InstallerHandler.py10
-rw-r--r--modules/opnfv/installer_adapters/apex/ApexAdapter.py146
-rw-r--r--modules/opnfv/installer_adapters/apex/example.py16
-rw-r--r--modules/opnfv/utils/SSHUtils.py22
-rwxr-xr-xprototypes/bifrost/scripts/destroy-env.sh18
8 files changed, 216 insertions, 45 deletions
diff --git a/jjb/global/slave-params.yml b/jjb/global/slave-params.yml
index 57bb8bda3..c87fc289c 100644
--- a/jjb/global/slave-params.yml
+++ b/jjb/global/slave-params.yml
@@ -378,6 +378,20 @@
default: https://gerrit.opnfv.org/gerrit/$PROJECT
description: 'Git URL to use on this Jenkins Slave'
- parameter:
+ name: 'intel-pod10-defaults'
+ parameters:
+ - node:
+ name: SLAVE_NAME
+ description: 'Slave name on Jenkins'
+ allowed-slaves:
+ - intel-pod10
+ default-slaves:
+ - intel-pod10
+ - string:
+ name: GIT_BASE
+ default: https://gerrit.opnfv.org/gerrit/$PROJECT
+ description: 'Git URL to use on this Jenkins Slave'
+- parameter:
name: 'intel-pod3-defaults'
parameters:
- node:
diff --git a/jjb/kvmfornfv/kvmfornfv.yml b/jjb/kvmfornfv/kvmfornfv.yml
index fdce301a4..2d1ab5779 100644
--- a/jjb/kvmfornfv/kvmfornfv.yml
+++ b/jjb/kvmfornfv/kvmfornfv.yml
@@ -19,7 +19,7 @@
- 'build':
slave-label: 'opnfv-build-ubuntu'
- 'test':
- slave-label: 'intel-pod1'
+ slave-label: 'intel-pod10'
#####################################
# patch verification phases
#####################################
@@ -97,19 +97,19 @@
node-parameters: false
kill-phase-on: FAILURE
abort-all-job: true
-# - multijob:
-# name: test
-# condition: SUCCESSFUL
-# projects:
-# - name: 'kvmfornfv-verify-test-{stream}'
-# current-parameters: false
-# predefined-parameters: |
-# GERRIT_BRANCH=$GERRIT_BRANCH
-# GERRIT_REFSPEC=$GERRIT_REFSPEC
-# GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
-# node-parameters: false
-# kill-phase-on: FAILURE
-# abort-all-job: true
+ - multijob:
+ name: test
+ condition: SUCCESSFUL
+ projects:
+ - name: 'kvmfornfv-verify-test-{stream}'
+ current-parameters: false
+ predefined-parameters: |
+ GERRIT_BRANCH=$GERRIT_BRANCH
+ GERRIT_REFSPEC=$GERRIT_REFSPEC
+ GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+ node-parameters: false
+ kill-phase-on: FAILURE
+ abort-all-job: true
- job-template:
name: 'kvmfornfv-verify-{phase}-{stream}'
@@ -195,8 +195,8 @@
scm:
- git-scm
-# triggers:
-# - timed: '@midnight'
+ triggers:
+ - timed: '@midnight'
builders:
- description-setter:
diff --git a/jjb/multisite/multisite-daily-jobs.yml b/jjb/multisite/multisite-daily-jobs.yml
index 132391c7d..fda2e682e 100644
--- a/jjb/multisite/multisite-daily-jobs.yml
+++ b/jjb/multisite/multisite-daily-jobs.yml
@@ -250,7 +250,8 @@
#!/bin/bash
echo "This is where we install kingbird"
- $WORKSPACE/tools/kingbird/deploy.sh
+ cd $WORKSPACE/tools/kingbird
+ ./deploy.sh
########################
# publisher macros
########################
diff --git a/modules/opnfv/installer_adapters/InstallerHandler.py b/modules/opnfv/installer_adapters/InstallerHandler.py
index dc5bdb9d6..6c43a46f0 100644
--- a/modules/opnfv/installer_adapters/InstallerHandler.py
+++ b/modules/opnfv/installer_adapters/InstallerHandler.py
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
+# Copyright (c) 2017 Ericsson AB and others.
# Author: Jose Lausuch (jose.lausuch@ericsson.com)
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -23,18 +23,22 @@ class InstallerHandler:
installer,
installer_ip,
installer_user,
- installer_pwd=None):
+ installer_pwd=None,
+ private_key_file=None):
self.installer = installer.lower()
self.installer_ip = installer_ip
self.installer_user = installer_user
self.installer_pwd = installer_pwd
+ self.private_key_file = private_key_file
if self.installer == INSTALLERS[0]:
self.InstallerAdapter = FuelAdapter(self.installer_ip,
self.installer_user,
self.installer_pwd)
elif self.installer == INSTALLERS[1]:
- self.InstallerAdapter = ApexAdapter(self.installer_ip)
+ self.InstallerAdapter = ApexAdapter(installer_ip=self.installer_ip,
+ user=self.installer_user,
+ pkey_file=self.private_key_file)
elif self.installer == INSTALLERS[2]:
self.InstallerAdapter = CompassAdapter(self.installer_ip)
elif self.installer == INSTALLERS[3]:
diff --git a/modules/opnfv/installer_adapters/apex/ApexAdapter.py b/modules/opnfv/installer_adapters/apex/ApexAdapter.py
index 17a27b10a..29637d700 100644
--- a/modules/opnfv/installer_adapters/apex/ApexAdapter.py
+++ b/modules/opnfv/installer_adapters/apex/ApexAdapter.py
@@ -7,26 +7,148 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import os
+import re
+
+import opnfv.utils.SSHUtils as ssh_utils
+import opnfv.utils.OPNFVLogger as logger
+
class ApexAdapter:
- def __init__(self, installer_ip):
+ def __init__(self, installer_ip, pkey_file, user="stack"):
self.installer_ip = installer_ip
+ self.installer_user = user
+ self.pkey_file = pkey_file
+ self.installer_connection = ssh_utils.get_ssh_client(
+ self.installer_ip,
+ self.installer_user,
+ pkey_file=self.pkey_file)
+ self.logger = logger.Logger("ApexHandler").getLogger()
- def get_deployment_info(self):
- pass
+ def runcmd_apex_installer(self, cmd):
+ _, stdout, stderr = (self.installer_connection.exec_command(cmd))
+ error = stderr.readlines()
+ if len(error) > 0:
+ self.logger.error("error %s" % ''.join(error))
+ return error
+ output = ''.join(stdout.readlines())
+ return output
def get_nodes(self):
- pass
+ nodes = []
+ output = self.runcmd_apex_installer(
+ "source /home/stack/stackrc;nova list")
+ lines = output.rsplit('\n')
+ if len(lines) < 4:
+ self.logger.info("No nodes found in the deployment.")
+ return None
+
+ for line in lines:
+ if 'controller' in line:
+ roles = "controller"
+ elif 'compute' in line:
+ roles = "compute"
+ else:
+ continue
+ if 'Daylight' in line:
+ roles = + ", OpenDaylight"
+ fields = line.split('|')
+ dict = {"id": re.sub('[!| ]', '', fields[1]),
+ "roles": roles,
+ "name": re.sub('[!| ]', '', fields[2]),
+ "status": re.sub('[!| ]', '', fields[3]),
+ "ip": re.sub('[!| ctlplane=]', '', fields[6])}
+ nodes.append(dict)
+
+ return nodes
+
+ def get_deployment_info(self):
+ str = "Deployment details:\n"
+ str += "\tINSTALLER: Apex\n"
+ str += ("\tSCENARIO: %s\n" %
+ os.getenv('DEPLOY_SCENARIO', 'Unknown'))
+ sdn = "None"
+
+ nodes = self.get_nodes()
+ if nodes is None:
+ self.logger.info("No nodes found in the deployment.")
+ return
+ num_nodes = len(nodes)
+ num_controllers = 0
+ num_computes = 0
+ for node in nodes:
+ if 'controller' in node['roles']:
+ num_controllers += 1
+ if 'compute' in node['roles']:
+ num_computes += 1
+ if 'Daylight' in node['name']:
+ sdn = 'OpenDaylight'
+
+ ha = str(num_controllers >= 3)
+
+ str += "\tHA: %s\n" % ha
+ str += "\tNUM.NODES: %s\n" % num_nodes
+ str += "\tCONTROLLERS: %s\n" % num_controllers
+ str += "\tCOMPUTES: %s\n" % num_computes
+ str += "\tSDN CONTR.: %s\n\n" % sdn
+
+ str += "\tNODES:\n"
+ for node in nodes:
+ str += ("\t ID: %s\n" % node['id'])
+ str += ("\t Name: %s\n" % node['name'])
+ str += ("\t Roles: %s\n" % node['roles'])
+ str += ("\t Status: %s\n" % node['status'])
+ str += ("\t IP: %s\n\n" % node['ip'])
+
+ return str
+
+ def get_controller_ips(self, options=None):
+ nodes = self.get_nodes()
+ controllers = []
+ for node in nodes:
+ if "controller" in node["roles"]:
+ controllers.append(node['ip'])
+ return controllers
+
+ def get_compute_ips(self, options=None):
+ nodes = self.get_nodes()
+ computes = []
+ for node in nodes:
+ if "compute" in node["roles"]:
+ computes.append(node['ip'])
+ return computes
- def get_controller_ips(self):
- pass
+ def get_file_from_installer(self, remote_path, local_path, options=None):
+ self.logger.debug("Fetching %s from Undercloud %s" %
+ (remote_path, self.installer_ip))
+ get_file_result = ssh_utils.get_file(self.installer_connection,
+ remote_path,
+ local_path)
+ if get_file_result is None:
+ self.logger.error("SFTP failed to retrieve the file.")
+ return 1
+ self.logger.info("%s successfully copied from Undercloud to %s" %
+ (remote_path, local_path))
- def get_compute_ips(self):
- pass
+ def get_file_from_controller(self,
+ remote_path,
+ local_path,
+ ip=None,
+ options=None):
+ if ip is None:
+ controllers = self.get_controller_ips()
+ ip = controllers[0]
- def get_file_from_installer(self, origin, target, options=None):
- pass
+ connection = ssh_utils.get_ssh_client(ip,
+ 'heat-admin',
+ pkey_file=self.pkey_file)
- def get_file_from_controller(self, origin, target, ip=None, options=None):
- pass
+ get_file_result = ssh_utils.get_file(connection,
+ remote_path,
+ local_path)
+ if get_file_result is None:
+ self.logger.error("SFTP failed to retrieve the file.")
+ return 1
+ self.logger.info("%s successfully copied from %s to %s" %
+ (remote_path, ip, local_path))
diff --git a/modules/opnfv/installer_adapters/apex/example.py b/modules/opnfv/installer_adapters/apex/example.py
new file mode 100644
index 000000000..c8c473727
--- /dev/null
+++ b/modules/opnfv/installer_adapters/apex/example.py
@@ -0,0 +1,16 @@
+# This is an example of usage of this Tool
+# Author: Jose Lausuch (jose.lausuch@ericsson.com)
+
+import opnfv.installer_adapters.InstallerHandler as ins_handler
+
+apex_handler = ins_handler.InstallerHandler(installer='apex',
+ installer_ip='192.168.122.135',
+ installer_user='stack',
+ private_key_file='/root/.ssh/id_rsa')
+apex_handler.get_file_from_installer(
+ '/home/stack/overcloudrc', './overcloudrc')
+
+print("\n%s\n" % apex_handler.get_deployment_info())
+
+apex_handler.get_file_from_controller(
+ '/etc/resolv.conf', './resolv.conf')
diff --git a/modules/opnfv/utils/SSHUtils.py b/modules/opnfv/utils/SSHUtils.py
index 16e34c3e5..e0a830caa 100644
--- a/modules/opnfv/utils/SSHUtils.py
+++ b/modules/opnfv/utils/SSHUtils.py
@@ -16,7 +16,11 @@ import os
logger = OPNFVLogger.Logger('SSHUtils').getLogger()
-def get_ssh_client(hostname, username, password=None, proxy=None):
+def get_ssh_client(hostname,
+ username,
+ password=None,
+ proxy=None,
+ pkey_file=None):
client = None
try:
if proxy is None:
@@ -26,14 +30,21 @@ def get_ssh_client(hostname, username, password=None, proxy=None):
client.configure_jump_host(proxy['ip'],
proxy['username'],
proxy['password'])
-
if client is None:
raise Exception('Could not connect to client')
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(hostname,
- username=username,
- password=password)
+ if pkey_file is not None:
+ key = paramiko.RSAKey.from_private_key_file(pkey_file)
+ client.load_system_host_keys()
+ client.connect(hostname,
+ username=username,
+ pkey=key)
+ else:
+ client.connect(hostname,
+ username=username,
+ password=password)
+
return client
except Exception, e:
logger.error(e)
@@ -66,6 +77,7 @@ class ProxyHopClient(paramiko.SSHClient):
'''
Connect to a remote server using a proxy hop
'''
+
def __init__(self, *args, **kwargs):
self.logger = OPNFVLogger.Logger("ProxyHopClient").getLogger()
self.proxy_ssh = None
diff --git a/prototypes/bifrost/scripts/destroy-env.sh b/prototypes/bifrost/scripts/destroy-env.sh
index cdc55df1b..9920046e1 100755
--- a/prototypes/bifrost/scripts/destroy-env.sh
+++ b/prototypes/bifrost/scripts/destroy-env.sh
@@ -21,13 +21,15 @@ virsh undefine jumphost.opnfvlocal || true
virsh undefine controller00.opnfvlocal || true
virsh undefine compute00.opnfvlocal || true
-service ironic-conductor stop
+service ironic-conductor stop || true
echo "removing from database"
-mysql -u root ironic --execute "truncate table ports;"
-mysql -u root ironic --execute "delete from node_tags;"
-mysql -u root ironic --execute "delete from nodes;"
-mysql -u root ironic --execute "delete from conductors;"
+if $(which mysql &> /dev/null); then
+ mysql -u root ironic --execute "truncate table ports;"
+ mysql -u root ironic --execute "delete from node_tags;"
+ mysql -u root ironic --execute "delete from nodes;"
+ mysql -u root ironic --execute "delete from conductors;"
+fi
echo "removing leases"
[[ -e /var/lib/misc/dnsmasq/dnsmasq.leases ]] && > /var/lib/misc/dnsmasq/dnsmasq.leases
echo "removing logs"
@@ -48,6 +50,6 @@ rm -rf /var/lib/libvirt/images/*.qcow2
echo "restarting services"
service dnsmasq restart || true
service libvirtd restart
-service ironic-api restart
-service ironic-conductor start
-service ironic-inspector restart
+service ironic-api restart || true
+service ironic-conductor start || true
+service ironic-inspector restart || true