diff options
-rw-r--r-- | docker/Dockerfile | 55 | ||||
-rwxr-xr-x | functest/utils/openstack_clean.py | 121 | ||||
-rwxr-xr-x | functest/utils/openstack_snapshot.py | 53 |
3 files changed, 202 insertions, 27 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index dc772c5b8..6bdfe5ce6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -52,40 +52,39 @@ ENV creds ${FUNCTEST_CONF_DIR}/openstack.creds ENV TERM xterm ENV COLORTERM gnome-terminal - WORKDIR ${HOME} # Packaged dependencies RUN apt-get update && apt-get install -y \ -ssh \ -sshpass \ +build-essential \ +bundler \ +crudini \ curl \ -git \ gcc \ -wget \ +git \ +libffi-dev \ +libgmp3-dev \ +libpq-dev \ +libssl-dev \ +libxml2-dev \ +libxslt-dev \ python-dev \ python-mock \ python-pip \ -bundler \ postgresql \ -build-essential \ -libpq-dev \ -libxslt-dev \ -libssl-dev \ -libgmp3-dev \ -libxml2-dev \ -libffi-dev \ -crudini \ ruby1.9.1-dev \ +ssh \ +sshpass \ +wget \ --no-install-recommends RUN pip install --upgrade pip -RUN mkdir -p ${REPOS_DIR} -RUN mkdir -p ${FUNCTEST_BASE_DIR}/results -RUN mkdir -p ${FUNCTEST_BASE_DIR}/conf -RUN mkdir -p /root/.ssh -RUN chmod 700 /root/.ssh +RUN mkdir -p ${REPOS_DIR} \ + && mkdir -p ${FUNCTEST_BASE_DIR}/results \ + && mkdir -p ${FUNCTEST_BASE_DIR}/conf \ + && mkdir -p /root/.ssh \ + && chmod 700 /root/.ssh RUN git config --global http.sslVerify false @@ -114,14 +113,16 @@ RUN git clone --depth 1 -b $ODL_TAG https://git.opendaylight.org/gerrit/p/integr RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test ${REPOS_DIR}/vims-test RUN git clone --depth 1 https://github.com/wuwenbin2/OnosSystemTest.git ${REPOS_DIR}/onos -RUN pip install -r ${FUNCTEST_REPO_DIR}/requirements.txt -RUN cd ${FUNCTEST_REPO_DIR} && pip install . +RUN cd ${FUNCTEST_REPO_DIR} \ + && pip install -r requirements.txt \ + && pip install . + RUN pip install -r ${REPOS_DIR}/rally/requirements.txt RUN pip install -r ${REPOS_DIR}/tempest/requirements.txt RUN find ${FUNCTEST_REPO_DIR} -name "*.py" \ - -not -path *unit_tests* |xargs grep __main__ |cut -d\: -f 1 |xargs chmod -c 755 -RUN find ${FUNCTEST_REPO_DIR} -name "*.sh" |xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755 + -not -path *unit_tests* |xargs grep __main__ |cut -d\: -f 1 |xargs chmod -c 755 \ + && find ${FUNCTEST_REPO_DIR} -name "*.sh" |xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755 RUN /bin/bash ${REPOS_DIR}/parser/tests/parser_install.sh ${REPOS_DIR} RUN ${REPOS_DIR}/rally/install_rally.sh --yes @@ -155,10 +156,10 @@ RUN /bin/bash -c ". /etc/profile.d/rvm.sh \ && cd ${REPOS_DIR}/vims-test \ && bundle install" -RUN sh -c 'curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -' -RUN sudo apt-get install -y nodejs -RUN cd ${REPOS_DIR}/promise && sudo npm -g install npm@latest -RUN cd ${REPOS_DIR}/promise/source && npm install +RUN sh -c 'curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -' \ + && sudo apt-get install -y nodejs \ + && cd ${REPOS_DIR}/promise && sudo npm -g install npm@latest \ + && cd ${REPOS_DIR}/promise/source && npm install RUN echo "set nocompatible \n\ set backspace=2" \ diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py index 949eee90f..0c3ae3e32 100755 --- a/functest/utils/openstack_clean.py +++ b/functest/utils/openstack_clean.py @@ -9,6 +9,8 @@ # - Neutron networks, subnets and ports # - Routers # - Users and tenants +# - Tacker VNFDs and VNFs +# - Tacker SFCs and SFC classifiers # # Author: # jose.lausuch@ericsson.com @@ -23,6 +25,7 @@ import time import functest.utils.functest_logger as ft_logger import functest.utils.openstack_utils as os_utils +import functest.utils.openstack_tacker as os_tacker import yaml import functest.utils.functest_constants as ft_constants @@ -369,6 +372,109 @@ def remove_tenants(keystone_client, default_tenants): "NOT be deleted.") +def remove_tacker_vnfds(tacker_client, default_vnfds): + logger.debug("Removing Tacker VNFDs...") + vnfds = os_tacker.list_vnfds(tacker_client, verbose=True)['vnfds'] + if vnfds is None: + logger.debug("There are no Tacker VNFDs in the deployment. ") + return + + for vnfd in vnfds: + vnfd_name = vnfd['name'] + vnfd_id = vnfd['id'] + logger.debug("'%s', ID=%s " % (vnfd_name, vnfd_id)) + if (vnfd_id not in default_vnfds and + vnfd_name not in default_vnfds.values()): + logger.debug(" Removing '%s'..." % vnfd_name) + deleted = os_tacker.delete_vnfd(tacker_client, vnfd_id=vnfd_id) + if deleted is not None: + logger.debug(" > Done!") + else: + logger.error("There has been a problem removing the " + "VNFD '%s'(%s)..." % (vnfd_name, vnfd_id)) + else: + logger.debug(" > this is a default VNFD and will " + "NOT be deleted.") + + +def remove_tacker_vnfs(tacker_client, default_vnfs): + logger.debug("Removing Tacker VNFs...") + vnfs = os_tacker.list_vnfs(tacker_client, verbose=True)['vnfs'] + if vnfs is None: + logger.debug("There are no Tacker VNFs in the deployment. ") + return + + for vnf in vnfs: + vnf_name = vnf['name'] + vnf_id = vnf['id'] + logger.debug("'%s', ID=%s " % (vnf_name, vnf_id)) + if (vnf_id not in default_vnfs and + vnf_name not in default_vnfs.values()): + logger.debug(" Removing '%s'..." % vnf_name) + deleted = os_tacker.delete_vnf(tacker_client, vnf_id=vnf_id) + if deleted is not None: + logger.debug(" > Done!") + else: + logger.error("There has been a problem removing the " + "VNF '%s'(%s)..." % (vnf_name, vnf_id)) + else: + logger.debug(" > this is a default VNF and will " + "NOT be deleted.") + + +def remove_tacker_sfcs(tacker_client, default_sfcs): + logger.debug("Removing Tacker SFCs...") + sfcs = os_tacker.list_sfcs(tacker_client, verbose=True)['sfcs'] + if sfcs is None: + logger.debug("There are no Tacker SFCs in the deployment. ") + return + + for sfc in sfcs: + sfc_name = sfc['name'] + sfc_id = sfc['id'] + logger.debug("'%s', ID=%s " % (sfc_name, sfc_id)) + if (sfc_id not in default_sfcs and + sfc_name not in default_sfcs.values()): + logger.debug(" Removing '%s'..." % sfc_name) + deleted = os_tacker.delete_sfc(tacker_client, sfc_id=sfc_id) + if deleted is not None: + logger.debug(" > Done!") + else: + logger.error("There has been a problem removing the " + "SFC '%s'(%s)..." % (sfc_name, sfc_id)) + else: + logger.debug(" > this is a default SFC and will " + "NOT be deleted.") + + +def remove_tacker_sfc_classifiers(tacker_client, default_sfc_classifiers): + logger.debug("Removing Tacker SFC classifiers...") + sfc_clfs = os_tacker.list_sfc_classifiers( + tacker_client, verbose=True)['sfc_classfiers'] + if sfc_clfs is None: + logger.debug("There are no Tacker SFC classifiers in the deployment.") + return + + for sfc_clf in sfc_clfs: + sfc_clf_name = sfc_clf['name'] + sfc_clf_id = sfc_clf['id'] + logger.debug("'%s', ID=%s " % (sfc_clf_name, sfc_clf_id)) + if (sfc_clf_id not in default_sfc_classifiers and + sfc_clf_name not in default_sfc_classifiers.values()): + logger.debug(" Removing '%s'..." % sfc_clf_name) + deleted = os_tacker.delete_sfc_classifier( + tacker_client, sfc_clf_id=sfc_clf_id) + if deleted is not None: + logger.debug(" > Done!") + else: + logger.error("There has been a problem removing the " + "SFC classifier '%s'(%s)..." + % (sfc_clf_name, sfc_clf_id)) + else: + logger.debug(" > this is a default SFC classifier and will " + "NOT be deleted.") + + def main(): logger.info("Cleaning OpenStack resources...") @@ -376,6 +482,7 @@ def main(): neutron_client = os_utils.get_neutron_client() keystone_client = os_utils.get_keystone_client() cinder_client = os_utils.get_cinder_client() + tacker_client = os_tacker.get_tacker_client() try: with open(OS_SNAPSHOT_FILE) as f: @@ -394,6 +501,10 @@ def main(): default_floatingips = snapshot_yaml.get('floatingips') default_users = snapshot_yaml.get('users') default_tenants = snapshot_yaml.get('tenants') + default_vnfds = snapshot_yaml.get('vnfds') + default_vnfs = snapshot_yaml.get('vnfs') + default_sfcs = snapshot_yaml.get('sfcs') + default_sfc_classifiers = snapshot_yaml.get('sfc_classifiers') if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run " @@ -416,6 +527,16 @@ def main(): separator() remove_tenants(keystone_client, default_tenants) separator() + # Note: Delete in this order + # 1. Classifiers, 2. SFCs, 3. VNFs, 4. VNFDs + remove_tacker_sfc_classifiers(tacker_client, default_sfc_classifiers) + separator() + remove_tacker_sfcs(tacker_client, default_sfcs) + separator() + remove_tacker_vnfs(tacker_client, default_vnfs) + separator() + remove_tacker_vnfds(tacker_client, default_vnfds) + separator() if __name__ == '__main__': diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py index 4be1af443..d6e7fe006 100755 --- a/functest/utils/openstack_snapshot.py +++ b/functest/utils/openstack_snapshot.py @@ -9,6 +9,8 @@ # - Neutron networks, subnets and ports # - Routers # - Users and tenants +# - Tacker VNFDs and VNFs +# - Tacker SFCs and SFC classifiers # # Author: # jose.lausuch@ericsson.com @@ -22,6 +24,7 @@ import functest.utils.functest_logger as ft_logger import functest.utils.openstack_utils as os_utils +import functest.utils.openstack_tacker as os_tacker import yaml import functest.utils.functest_constants as ft_constants @@ -127,6 +130,51 @@ def get_tenants(keystone_client): return {'tenants': dic_tenants} +def get_tacker_vnfds(tacker_client): + logger.debug("Getting Tacker VNFDs...") + dic_vnfds = {} + vnfds = os_tacker.list_vnfds(tacker_client, verbose=True)['vnfds'] + if not (vnfds is None or len(vnfds) == 0): + for vnfd in vnfds: + dic_vnfds.update({vnfd['id']: + vnfd['name']}) + return {'vnfds': dic_vnfds} + + +def get_tacker_vnfs(tacker_client): + logger.debug("Getting Tacker VNFs...") + dic_vnfs = {} + vnfs = os_tacker.list_vnfs(tacker_client, verbose=True)['vnfs'] + if not (vnfs is None or len(vnfs) == 0): + for vnf in vnfs: + dic_vnfs.update({vnf['id']: + vnf['name']}) + return {'vnfs': dic_vnfs} + + +def get_tacker_sfcs(tacker_client): + logger.debug("Getting Tacker SFCs...") + dic_sfcs = {} + sfcs = os_tacker.list_sfcs(tacker_client, verbose=True)['sfcs'] + if not (sfcs is None or len(sfcs) == 0): + for sfc in sfcs: + dic_sfcs.update({sfc['id']: + sfc['name']}) + return {'sfcs': dic_sfcs} + + +def get_tacker_sfc_classifiers(tacker_client): + logger.debug("Getting Tacker SFC classifiers...") + dic_sfc_clfs = {} + sfc_clfs = os_tacker.list_sfc_clasifiers( + tacker_client, verbose=True)['sfc_classifiers'] + if not (sfc_clfs is None or len(sfc_clfs) == 0): + for sfc_clf in sfc_clfs: + dic_sfc_clfs.update({sfc_clf['id']: + sfc_clf['name']}) + return {'sfc_classifiers': dic_sfc_clfs} + + def main(): logger.info("Generating OpenStack snapshot...") @@ -134,6 +182,7 @@ def main(): neutron_client = os_utils.get_neutron_client() keystone_client = os_utils.get_keystone_client() cinder_client = os_utils.get_cinder_client() + tacker_client = os_tacker.get_tacker_client() if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run the" + @@ -150,6 +199,10 @@ def main(): snapshot.update(get_floatinips(nova_client)) snapshot.update(get_users(keystone_client)) snapshot.update(get_tenants(keystone_client)) + snapshot.update(get_tacker_vnfds(tacker_client)) + snapshot.update(get_tacker_vnfs(tacker_client)) + snapshot.update(get_tacker_sfcs(tacker_client)) + snapshot.update(get_tacker_sfc_classifiers(tacker_client)) with open(OS_SNAPSHOT_FILE, 'w+') as yaml_file: yaml_file.write(yaml.safe_dump(snapshot, default_flow_style=False)) |