Merge changes from topic 'stable-branch'
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Thu, 20 Sep 2018 22:21:48 +0000 (22:21 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Thu, 20 Sep 2018 22:21:48 +0000 (22:21 +0000)
* changes:
  [armband] verify: Simplify and move to build hosts
  [fuel] Retire Danube stream
  [fuel] cleanup: remove unused scenarios
  [fuel] cleanup: remove unused job defs & scripts

jjb/dovetail/dovetail-run.sh
jjb/openci/create-cde.sh
jjb/openci/create-clme.sh
jjb/openci/openci-opnfv-daily-jobs.yaml
jjb/releng/releng-release-create-branch.sh
jjb/releng/releng-release-jobs.yaml
jjb/yardstick/yardstick-daily.sh
releases/gambia/sandbox.yaml [new file with mode: 0644]
releases/scripts/create_branch.py [deleted file]
releases/scripts/repos.py

index 739da9e..ed636b8 100755 (executable)
@@ -51,11 +51,6 @@ elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
     # replace the default one by the customized one provided by jenkins config
 fi
 
-# Set iptables rule to allow forwarding return traffic for container
-if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
-    sudo iptables -I FORWARD -j RETURN
-fi
-
 releng_repo=${WORKSPACE}/releng
 [ -d ${releng_repo} ] && sudo rm -rf ${releng_repo}
 git clone https://gerrit.opnfv.org/gerrit/releng ${releng_repo} >/dev/null
index 410db50..8fb9f00 100755 (executable)
@@ -11,17 +11,37 @@ set -o errexit
 set -o nounset
 set -o pipefail
 
+export PS1=${PS1:-}
+
 # This script creates CompositionDefinedEvent
-# The JMS Messaging Plugin doesn't handle the newlines well so the eventBody is
-# constructed on a single line. This is something that needs to be fixed properly
 
-cat << EOF > $WORKSPACE/event.properties
-type=$PUBLISH_EVENT_TYPE
-origin=$PUBLISH_EVENT_ORIGIN
-scenario=$DEPLOY_SCENARIO
-eventBody="{ 'type': '$PUBLISH_EVENT_TYPE', 'id': '$(uuidgen)', 'time': '$(date -u +%Y-%m-%d_%H:%M:%SUTC)', 'origin': '$PUBLISH_EVENT_ORIGIN', 'buildUrl': '$BUILD_URL', 'branch': 'master', 'compositionName': '$DEPLOY_SCENARIO', 'compositionMetadataUrl': '$SCENARIO_METADATA_LOCATION' }"
+git clone https://gitlab.openci.io/openci/prototypes.git
+cd prototypes/federated-cicd
+virtualenv openci_publish
+cd openci_publish
+source bin/activate
+python setup.py install
+
+# generate event body
+cat <<EOF > ./json_body.txt
+{
+    "type": "$PUBLISH_EVENT_TYPE",
+    "id": "$(uuidgen)",
+    "time": "$(date -u +%Y-%m-%d_%H:%M:%SUTC)",
+    "buildUrl": "$BUILD_URL",
+    "branch": "master",
+    "origin": "$PUBLISH_EVENT_ORIGIN",
+    "scenario": "$DEPLOY_SCENARIO",
+    "compositionName": "$DEPLOY_SCENARIO",
+    "compositionMetadataUrl": "$SCENARIO_METADATA_LOCATION"
+}
 EOF
+
+python openci_publish -H 129.192.69.55 -U ${ACTIVEMQ_USER} -p ${ACTIVEMQ_PASSWORD} -n openci.prototype -B ./json_body.txt
+
 echo "Constructed $PUBLISH_EVENT_TYPE"
 echo "--------------------------------------------"
-cat $WORKSPACE/event.properties
+cat  ./json_body.txt
 echo "--------------------------------------------"
+
+deactivate
index 5e8ee10..85c1a80 100755 (executable)
@@ -11,17 +11,36 @@ set -o errexit
 set -o nounset
 set -o pipefail
 
+export PS1=${PS1:-}
+
 # This script creates ConfidenceLevelModifiedEvent
-# The JMS Messaging Plugin doesn't handle the newlines well so the eventBody is
-# constructed on a single line. This is something that needs to be fixed properly
 
-cat << EOF > $WORKSPACE/event.properties
-type=$PUBLISH_EVENT_TYPE
-origin=$PUBLISH_EVENT_ORIGIN
-scenario=$DEPLOY_SCENARIO
-eventBody="{ 'type': '$PUBLISH_EVENT_TYPE', 'id': '$(uuidgen)', 'time': '$(date -u +%Y-%m-%d_%H:%M:%SUTC)', 'origin': '$PUBLISH_EVENT_ORIGIN', 'buildUrl': '$BUILD_URL', 'branch': 'master', 'compositionName': '$DEPLOY_SCENARIO', 'compositionMetadataUrl': '$SCENARIO_METADATA_LOCATION', 'confidenceLevel': { $CONFIDENCE_LEVEL } }"
+git clone https://gitlab.openci.io/openci/prototypes.git
+cd prototypes/federated-cicd
+virtualenv openci_publish
+cd openci_publish
+source bin/activate
+python setup.py install
+
+# generate event body
+cat <<EOF > ./json_body.txt
+{
+    "type": "$PUBLISH_EVENT_TYPE",
+    "id": "$(uuidgen)",
+    "time": "$(date -u +%Y-%m-%d_%H:%M:%SUTC)",
+    "buildUrl": "$BUILD_URL",
+    "branch": "master",
+    "origin": "$PUBLISH_EVENT_ORIGIN",
+    "scenario": "$DEPLOY_SCENARIO",
+    "compositionName": "$DEPLOY_SCENARIO",
+    "compositionMetadataUrl": "$SCENARIO_METADATA_LOCATION",
+    "confidenceLevel": "$CONFIDENCE_LEVEL",
+}
 EOF
+
+python openci_publish -H 129.192.69.55 -U ${ACTIVEMQ_USER} -p ${ACTIVEMQ_PASSWORD} -n openci.prototype -B ./json_body.txt
+
 echo "Constructed $PUBLISH_EVENT_TYPE"
 echo "--------------------------------------------"
-cat $WORKSPACE/event.properties
+cat ./json_body.txt
 echo "--------------------------------------------"
index cb15014..7f48fcc 100644 (file)
           name: SCENARIO_METADATA_LOCATION
           default: https://url/to/scenario/metadata/on/opnfv/artifact/repo/$BUILD_NUMBER
           description: 'The location of the scenario metadata'
-      - 'opnfv-build-defaults'
+      - 'ericsson-build4-defaults'
+
+    wrappers:
+      - credentials-binding:
+          - username-password-separated:
+              credential-id: openci-connect-activemq
+              username: ACTIVEMQ_USER
+              password: ACTIVEMQ_PASSWORD
+      - workspace-cleanup
 
     triggers:
       - jms-messaging:
           provider-name: openci.activemq
-          selector: CI_TYPE = 'custom'
-          checks:
-            - field: origin
-              expected-value: '{origin}'
-            - field: type
-              expected-value: 'ArtifactPublishedEvent'
+          selector: JMSType = 'ArtifactPublishedEvent' and JMSOrigin = 'ODL'
 
     builders:
       - shell: |
           echo "----------------------------------"
       - shell:
           !include-raw-escape: ./create-cde.sh
-      - inject:
-          properties-file: "$WORKSPACE/event.properties"
-
-    publishers:
-      - jms-messaging:
-          provider-name: openci.activemq
-          msg-type: Custom
-          msg-props: |
-            type=$type
-            origin=$origin
-            scenario=$scenario
-          msg-content:
-            $eventBody
 
 - job-template:
     name: 'openci-opnfv-{scenario}-test-daily-{stream}'
           name: CONFIDENCE_LEVEL
           default: "'opnfvdaily': 'SUCCESS'"
           description: 'The confidence level the published artifact gained'
-      - 'opnfv-build-defaults'
+      - 'ericsson-build4-defaults'
+
+    wrappers:
+      - credentials-binding:
+          - username-password-separated:
+              credential-id: openci-connect-activemq
+              username: ACTIVEMQ_USER
+              password: ACTIVEMQ_PASSWORD
+      - workspace-cleanup
 
     triggers:
       - jms-messaging:
           provider-name: openci.activemq
-          selector: CI_TYPE = 'custom'
-          checks:
-            - field: origin
-              expected-value: 'OPNFV'
-            - field: type
-              expected-value: 'CompositionDefinedEvent'
-            - field: scenario
-              expected-value: '{scenario}'
+          selector: JMSType = 'CompositionDefinedEvent' and JMSOrigin = 'OPNFV' and JMSScenario = '{scenario}'
 
     builders:
       - shell: |
           echo "----------------------------------"
       - shell:
           !include-raw-escape: ./create-clme.sh
-      - inject:
-          properties-file: "$WORKSPACE/event.properties"
-
-    publishers:
-      - jms-messaging:
-          provider-name: openci.activemq
-          msg-type: Custom
-          msg-props: |
-            type=$type
-            origin=$origin
-            scenario=$scenario
-          msg-content:
-            $eventBody
index 92be0e6..663ff19 100644 (file)
@@ -26,7 +26,20 @@ STREAM=${STREAM:-'nostream'}
 RELEASE_FILES=$(git diff HEAD^1 --name-only -- "releases/$STREAM")
 
 for release_file in $RELEASE_FILES; do
-    python releases/scripts/create_branch.py -f $release_file
+
+    while read -r repo branch ref; do
+
+        echo "$repo" "$branch" "$ref"
+        branches="$(git ls-remote "https://gerrit.opnfv.org/gerrit/$repo.git" "refs/heads/$branch")"
+
+        if ! [ -z "$branches" ]; then
+            echo "refs/heads/$branch already exists at $ref ($branches)"
+        else
+            ssh -n -f -p 29418 gerrit.opnfv.org gerrit create-branch "$repo" "$branch" "$ref"
+        fi
+
+    done < <(python releases/scripts/repos.py -b -f "$release_file")
+
     python releases/scripts/create_jobs.py -f $release_file
     NEW_FILES=$(git status --porcelain --untracked=no | cut -c4-)
     if [ -n "$NEW_FILES" ]; then
index 89519ae..3136d78 100644 (file)
       - shell: !include-raw-escape:
           - releng-release-create-venv.sh
           - releng-release-tagging.sh
-          - releng-release-create-branch.sh
+          - releng-release-create-branch.sh
 
     publishers:
       - email-jenkins-admins-on-failure
index 783c64e..58d590c 100755 (executable)
@@ -41,10 +41,6 @@ elif [[ ${INSTALLER_TYPE} == 'fuel' ]]; then
     cacert_file_vol="-v ${HOME}/os_cacert:/etc/ssl/certs/mcp_os_cacert"
     sshkey="-v ${SSH_KEY}:/root/.ssh/mcp.rsa"
 fi
-# Set iptables rule to allow forwarding return traffic for container
-if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
-    sudo iptables -I FORWARD -j RETURN
-fi
 
 opts="--privileged=true --rm"
 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
diff --git a/releases/gambia/sandbox.yaml b/releases/gambia/sandbox.yaml
new file mode 100644 (file)
index 0000000..16f2df2
--- /dev/null
@@ -0,0 +1,9 @@
+---
+project: sandbox
+project-type: infra
+release-model: stable
+
+branches:
+  - name: stable/gambia
+    location:
+      sandbox: c2012f5b642f17e6024db631b833414114a329d5
diff --git a/releases/scripts/create_branch.py b/releases/scripts/create_branch.py
deleted file mode 100644 (file)
index fa3c92d..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/usr/bin/env python2
-# SPDX-License-Identifier: Apache-2.0
-##############################################################################
-# Copyright (c) 2018 The Linux Foundation 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
-##############################################################################
-"""
-Create Gerrit Branchs
-"""
-
-import argparse
-
-try:
-    import ConfigParser
-except ImportError:
-    import configparser as ConfigParser
-
-import logging
-import os
-import yaml
-
-from requests.compat import quote
-from requests.exceptions import RequestException
-
-from pygerrit2.rest import GerritRestAPI
-from pygerrit2.rest.auth import HTTPDigestAuthFromNetrc, HTTPBasicAuthFromNetrc
-
-
-logging.basicConfig(level=logging.INFO)
-
-
-def quote_branch(arguments):
-    """
-    Quote is used here to escape the '/' in branch name. By
-    default '/' is listed in 'safe' characters which aren't escaped.
-    quote is not used in the data of the PUT request, as quoting for
-    arguments is handled by the request library
-    """
-    new_args = arguments.copy()
-    new_args['branch'] = quote(new_args['branch'], '')
-    return new_args
-
-
-def create_branch(api, arguments):
-    """
-    Create a branch using the Gerrit REST API
-    """
-    logger = logging.getLogger(__file__)
-
-    branch_data = """
-    {
-      "ref": "%(branch)s"
-      "revision": "%(commit)s"
-    }""" % arguments
-
-    # First verify the commit exists, otherwise the branch will be
-    # created at HEAD
-    try:
-        request = api.get("/projects/%(project)s/commits/%(commit)s" %
-                          arguments)
-        logger.debug(request)
-        logger.debug("Commit exists: %(commit)s", arguments)
-    except RequestException as err:
-        if hasattr(err, 'response') and err.response.status_code in [404]:
-            logger.warn("Commit %(commit)s for %(project)s does"
-                        " not exist. Not creating branch.", arguments)
-            logger.warn(err)
-        else:
-            logger.error("Error: %s", str(err))
-        # Skip trying to create the branch
-        return
-
-    # Try to create the branch and let us know if it already exist.
-    try:
-        request = api.put("/projects/%(project)s/branches/%(branch)s" %
-                          quote_branch(arguments), branch_data)
-        logger.info("Branch %(branch)s for %(project)s successfully created",
-                    arguments)
-    except RequestException as err:
-        if hasattr(err, 'response') and err.response.status_code in [412, 409]:
-            logger.info("Branch %(branch)s already created for %(project)s",
-                        arguments)
-            logger.info(err)
-        else:
-            logger.error("Error: %s", str(err))
-
-
-def main():
-    """Given a yamlfile that follows the release syntax, create branches
-    in Gerrit listed under branches"""
-
-    config = ConfigParser.ConfigParser()
-    config.read(os.path.join(os.path.abspath(os.path.dirname(__file__)),
-                'defaults.cfg'))
-    config.read([os.path.expanduser('~/releases.cfg'), 'releases.cfg'])
-
-    gerrit_url = config.get('gerrit', 'url')
-
-    parser = argparse.ArgumentParser()
-    parser.add_argument('--file', '-f',
-                        type=argparse.FileType('r'),
-                        required=True)
-    parser.add_argument('--basicauth', '-b', action='store_true')
-    args = parser.parse_args()
-
-    GerritAuth = HTTPDigestAuthFromNetrc
-    if args.basicauth:
-        GerritAuth = HTTPBasicAuthFromNetrc
-
-    try:
-        auth = GerritAuth(url=gerrit_url)
-    except ValueError as err:
-        logging.error("%s for %s", err, gerrit_url)
-        quit(1)
-    restapi = GerritRestAPI(url=gerrit_url, auth=auth)
-
-    project = yaml.safe_load(args.file)
-
-    create_branches(restapi, project)
-
-
-def create_branches(restapi, project):
-    """Create branches for a specific project defined in the release
-    file"""
-
-    branches = []
-    for branch in project['branches']:
-        repo, ref = next(iter(branch['location'].items()))
-        branches.append({
-            'project': repo,
-            'branch': branch['name'],
-            'commit': ref
-        })
-
-    for branch in branches:
-        create_branch(restapi, branch)
-
-
-if __name__ == "__main__":
-    main()
index 47ce42d..91c4e93 100644 (file)
@@ -63,20 +63,28 @@ def main():
                         type=str,
                         help="Only print"
                              "SHAs for the specified release")
+    parser.add_argument('--branches', '-b',
+                        action='store_true',
+                        default=False,
+                        help="Print Branch info")
+
     args = parser.parse_args()
 
     project = yaml.safe_load(args.file)
 
-    list_repos(project, args)
+    if args.branches:
+        list_branches(project, args)
+    else:
+        list_repos(project, args)
 
 
 def list_repos(project, args):
     """List repositories in the project file"""
 
     lookup = project.get('releases', [])
+
     if 'releases' not in project:
         exit(0)
-
     repos = set()
     for item in lookup:
         repo, ref = next(iter(item['location'].items()))
@@ -90,5 +98,24 @@ def list_repos(project, args):
         print(repo)
 
 
+def list_branches(project, args):
+    """List branches in the project file"""
+
+    lookup = project.get('branches', [])
+
+    if 'branches' not in project:
+        exit(0)
+    repos = set()
+    for item in lookup:
+        repo, ref = next(iter(item['location'].items()))
+        if args.names:
+            repos.add(Repo(repo))
+        elif args.release and item['name'] == args.release:
+            repos.add(Repo(repo, ref))
+        elif not args.release:
+            repos.add(Repo(repo, item['name'], ref))
+    for repo in repos:
+        print(repo)
+
 if __name__ == "__main__":
     main()