From 3d62edef397fc5531d89a12739685ef9001a4652 Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Mon, 11 Jul 2016 19:13:15 +0300 Subject: [PATCH] Move system-config url to properties Make system-config url available for configuring by setting it out of the class. Also add property for choosing which branch should be used stable or master. By default it will be "master" branch with url pointing on fuel-infra repository. Also add UI form for SystemConfig package, which will be used later by UI forms of Applications. Change-Id: I52779d9b190ddee1de2243de812e3f7133584b6d --- .../package/Classes/CiCdEnvironment.yaml | 15 +++++-- .../CiCdEnvironment/package/UI/ui.yaml | 9 ++++ .../CiCdEnvironment/package/manifest.yaml | 1 + .../Gerrit/package/Classes/Gerrit.yaml | 9 +++- murano-apps/Gerrit/package/UI/ui.yaml | 8 ++++ .../Jenkins/package/Classes/Jenkins.yaml | 9 +++- murano-apps/Jenkins/package/UI/ui.yaml | 8 ++++ .../Nodepool/package/Classes/Nodepool.yaml | 9 +++- murano-apps/Nodepool/package/UI/ui.yaml | 8 ++++ .../package/Classes/SystemConfig.yaml | 22 ++++++++-- .../package/Resources/SystemConfig.template | 11 ++++- .../package/Resources/scripts/deploy.sh | 35 ++++++++++++--- murano-apps/SystemConfig/package/UI/ui.yaml | 43 +++++++++++++++++++ .../SystemConfig/package/manifest.yaml | 1 + murano-apps/Zuul/package/Classes/Zuul.yaml | 9 +++- murano-apps/Zuul/package/UI/ui.yaml | 8 ++++ 16 files changed, 186 insertions(+), 19 deletions(-) create mode 100644 murano-apps/SystemConfig/package/UI/ui.yaml diff --git a/murano-apps/CiCdEnvironment/package/Classes/CiCdEnvironment.yaml b/murano-apps/CiCdEnvironment/package/Classes/CiCdEnvironment.yaml index efd88cb..e43efc1 100644 --- a/murano-apps/CiCdEnvironment/package/Classes/CiCdEnvironment.yaml +++ b/murano-apps/CiCdEnvironment/package/Classes/CiCdEnvironment.yaml @@ -26,6 +26,9 @@ Properties: Contract: $.class(ci_cd_pipeline_murano_app:Nodepool) Usage: Out + systemConfigRepo: + Contract: $.class(puppet:SystemConfig) + zuulNodepoolHelper: Contract: $.class(ci_cd_pipeline_murano_app:ZuulNodepoolHelper) ldapRootUser: @@ -104,7 +107,8 @@ Methods: name => 'Gerrit', instance => $gerritInstance, ldap => $this.ldap, - userSSH => $this.userSSH) + userSSH => $this.userSSH, + systemConfigRepo => $.systemConfigRepo) # Jenkins # set user and mail for accessing to Gerrit from Jenkins @@ -128,7 +132,8 @@ Methods: gerrit => $this.gerrit, cfplugin => false, gitUser => $.ldapUser, - gitEmail => $.ldapEmail) + gitEmail => $.ldapEmail, + systemConfigRepo => $.systemConfigRepo) # Zuul - If: $this.zuul = null and $this.zuulNodepoolHelper != null @@ -144,7 +149,8 @@ Methods: - $this.zuul: new(ci_cd_pipeline_murano_app:Zuul, $._environment, name => 'Zuul', instance => $zuulInstance, - gerrit => $this.gerrit) + gerrit => $this.gerrit, + systemConfigRepo => $.systemConfigRepo) # Nodepool - If: $this.nodepool = null and $this.zuulNodepoolHelper != null @@ -165,7 +171,8 @@ Methods: authUrl => $this.zuulNodepoolHelper.authUrl, username => $this.zuulNodepoolHelper.username, tenant => $this.zuulNodepoolHelper.tenant, - password => $this.zuulNodepoolHelper.password) + password => $this.zuulNodepoolHelper.password, + systemConfigRepo => $.systemConfigRepo) # Deploy all - $applications: diff --git a/murano-apps/CiCdEnvironment/package/UI/ui.yaml b/murano-apps/CiCdEnvironment/package/UI/ui.yaml index edbcbe5..2973575 100644 --- a/murano-apps/CiCdEnvironment/package/UI/ui.yaml +++ b/murano-apps/CiCdEnvironment/package/UI/ui.yaml @@ -18,6 +18,7 @@ Application: keyname: $.instanceConfiguration.keyPair availabilityZone: $.instanceConfiguration.availabilityZone assignFloatingIp: true + systemConfigRepo: $.appConfiguration.systemConfigRepo Forms: - appConfiguration: @@ -81,6 +82,13 @@ Forms: descriptionTitle: User public ssh key description: > Please, provide user public ssh key. + - name: systemConfigRepo + type: org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig + label: system-config Url + required: false + descriptionTitle: system-config Url + description: > + Please, provide url for system-config repository. - name: zuulNodepoolHelper type: org.openstack.ci_cd_pipeline_murano_app.ZuulNodepoolHelper label: Zuul and Nodepool @@ -88,6 +96,7 @@ Forms: descriptionTitle: Zuul and Nodepool description: > Specify Zuul and Nodepool parameters if needed. + - instanceConfiguration: fields: - name: title diff --git a/murano-apps/CiCdEnvironment/package/manifest.yaml b/murano-apps/CiCdEnvironment/package/manifest.yaml index 56426ff..6cd1c3c 100644 --- a/murano-apps/CiCdEnvironment/package/manifest.yaml +++ b/murano-apps/CiCdEnvironment/package/manifest.yaml @@ -16,6 +16,7 @@ Require: org.openstack.ci_cd_pipeline_murano_app.Jenkins: org.openstack.ci_cd_pipeline_murano_app.Gerrit: org.openstack.ci_cd_pipeline_murano_app.puppet.Puppet: + org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig: org.openstack.ci_cd_pipeline_murano_app.utils.CiCdUtils: org.openstack.ci_cd_pipeline_murano_app.ZuulNodepoolHelper: org.openstack.ci_cd_pipeline_murano_app.Zuul: diff --git a/murano-apps/Gerrit/package/Classes/Gerrit.yaml b/murano-apps/Gerrit/package/Classes/Gerrit.yaml index 31954bb..ad45a9d 100644 --- a/murano-apps/Gerrit/package/Classes/Gerrit.yaml +++ b/murano-apps/Gerrit/package/Classes/Gerrit.yaml @@ -22,6 +22,8 @@ Properties: Contract: $.class(ci_cd_pipeline_murano_app:OpenLDAP) userSSH: Contract: $.string() + systemConfigRepo: + Contract: $.class(puppet:SystemConfig) Methods: initialize: @@ -60,7 +62,12 @@ Methods: - $._environment.reporter.report($this, 'Installing puppet modules...') - - $this.systemConfig: new(puppet:SystemConfig) + # initialize System Config + - If: $.systemConfigRepo = null + Then: + - $this.systemConfig: new(puppet:SystemConfig) + Else: + - $this.systemConfig: $.systemConfigRepo - $this.systemConfig.installOnTheNode($this.instance) - If: $.ldap != null diff --git a/murano-apps/Gerrit/package/UI/ui.yaml b/murano-apps/Gerrit/package/UI/ui.yaml index a692bb3..e4931ff 100644 --- a/murano-apps/Gerrit/package/UI/ui.yaml +++ b/murano-apps/Gerrit/package/UI/ui.yaml @@ -7,6 +7,7 @@ Application: warUrl: $.appConfiguration.warUrl ldap: $.appConfiguration.OpenLDAP userSSH: $.appConfiguration.userSSH + systemConfigRepo: $.appConfiguration.systemConfigRepo instance: ?: type: org.openstack.ci_cd_pipeline_murano_app.puppet.PuppetInstance @@ -54,6 +55,13 @@ Forms: descriptionTitle: User public ssh key description: >- Please, provide user public ssh key + - name: systemConfigRepo + type: org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig + label: system-config Url + required: false + descriptionTitle: system-config Url + description: > + Please, provide url for system-config repository. - instanceConfiguration: fields: - name: title diff --git a/murano-apps/Jenkins/package/Classes/Jenkins.yaml b/murano-apps/Jenkins/package/Classes/Jenkins.yaml index 0e72732..ac91e11 100644 --- a/murano-apps/Jenkins/package/Classes/Jenkins.yaml +++ b/murano-apps/Jenkins/package/Classes/Jenkins.yaml @@ -29,6 +29,8 @@ Properties: Contract: $.string() gitEmail: Contract: $.string() + systemConfigRepo: + Contract: $.class(puppet:SystemConfig) Methods: initialize: @@ -52,7 +54,12 @@ Methods: - $.instance.deploy() - $._environment.reporter.report($this, 'Jenkins VM "{0}" with id {1} created'.format($.instance.name, $.instance.openstackId)) - - $this.systemConfig: new(puppet:SystemConfig) + # initialize System Config + - If: $.systemConfigRepo = null + Then: + - $this.systemConfig: new(puppet:SystemConfig) + Else: + - $this.systemConfig: $.systemConfigRepo - $this.systemConfig.installOnTheNode($this.instance) - $resources: new(sys:Resources) diff --git a/murano-apps/Jenkins/package/UI/ui.yaml b/murano-apps/Jenkins/package/UI/ui.yaml index 97da0c9..1c387a8 100644 --- a/murano-apps/Jenkins/package/UI/ui.yaml +++ b/murano-apps/Jenkins/package/UI/ui.yaml @@ -10,6 +10,7 @@ Application: dockerplugin: $.appConfiguration.dockerplugin gitUser: $.appConfiguration.gitUser gitEmail: $.appConfiguration.gitEmail + systemConfigRepo: $.appConfiguration.systemConfigRepo instance: ?: type: org.openstack.ci_cd_pipeline_murano_app.puppet.PuppetInstance @@ -56,6 +57,13 @@ Forms: required: false description: >- Specify OpenLDAP domain for authentication + - name: systemConfigRepo + type: org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig + label: system-config Url + required: false + descriptionTitle: system-config Url + description: > + Please, provide url for system-config repository. - name: Gerrit type: org.openstack.ci_cd_pipeline_murano_app.Gerrit required: false diff --git a/murano-apps/Nodepool/package/Classes/Nodepool.yaml b/murano-apps/Nodepool/package/Classes/Nodepool.yaml index 0d150bc..dbbe05d 100644 --- a/murano-apps/Nodepool/package/Classes/Nodepool.yaml +++ b/murano-apps/Nodepool/package/Classes/Nodepool.yaml @@ -29,6 +29,8 @@ Properties: Contract: $.string().notNull() password: Contract: $.string().notNull() + systemConfigRepo: + Contract: $.class(puppet:SystemConfig) Methods: .init: @@ -54,7 +56,12 @@ Methods: - $._environment.reporter.report($this, 'Installing needed puppets for Nodepool...') - - $this.systemConfig: new(puppet:SystemConfig) + # initialize System Config + - If: $.systemConfigRepo = null + Then: + - $this.systemConfig: new(puppet:SystemConfig) + Else: + - $this.systemConfig: $.systemConfigRepo - $this.systemConfig.installOnTheNode($this.instance) - $._environment.reporter.report($this, 'Waiting while Jenkins is being deployed...') diff --git a/murano-apps/Nodepool/package/UI/ui.yaml b/murano-apps/Nodepool/package/UI/ui.yaml index b6981c1..3f86703 100644 --- a/murano-apps/Nodepool/package/UI/ui.yaml +++ b/murano-apps/Nodepool/package/UI/ui.yaml @@ -10,6 +10,7 @@ Application: username: $.openstackConfiguration.username tenant: $.openstackConfiguration.tenant password: $.openstackConfiguration.password + systemConfigRepo: $.appConfiguration.systemConfigRepo instance: ?: type: org.openstack.ci_cd_pipeline_murano_app.puppet.PuppetInstance @@ -37,6 +38,13 @@ Forms: Select to true to assign floating IP automatically initial: true required: false + - name: systemConfigRepo + type: org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig + label: system-config Url + required: false + descriptionTitle: system-config Url + description: > + Please, provide url for system-config repository. - name: Jenkins type: org.openstack.ci_cd_pipeline_murano_app.Jenkins label: Jenkins diff --git a/murano-apps/SystemConfig/package/Classes/SystemConfig.yaml b/murano-apps/SystemConfig/package/Classes/SystemConfig.yaml index 5bb7477..9b30872 100644 --- a/murano-apps/SystemConfig/package/Classes/SystemConfig.yaml +++ b/murano-apps/SystemConfig/package/Classes/SystemConfig.yaml @@ -1,13 +1,26 @@ Namespaces: =: org.openstack.ci_cd_pipeline_murano_app.puppet + std: io.murano sys: io.murano.system puppet: org.openstack.ci_cd_pipeline_murano_app.puppet +Extends: std:Application + Name: SystemConfig Properties: - projectConfigRepo: + name: + Contract: $.string().notNull() + Default: 'System Config' + projectConfigUrl: Contract: $.string().notNull() Default: 'https://review.fuel-infra.org/open-paas/project-config' + systemConfigUrl: + Contract: $.string().notNull() + Default: 'https://review.fuel-infra.org/open-paas/system-config' + branchName: + Contract: $.string() + patchId: + Contract: $.string() Methods: installOnTheNode: Arguments: @@ -15,7 +28,10 @@ Methods: Contract: $.class(puppet:PuppetInstance) Body: - $resources: new(sys:Resources) - - $template: $resources.yaml('SystemConfig.template') + - $template: $resources.yaml('SystemConfig.template').bind(dict( + url => $this.systemConfigUrl, + branch => $this.branchName, + patch_id => $this.patchId)) - $instance.agent.call($template, $resources) - - $instance.putHieraData({'project_config_repo' => $this.projectConfigRepo}) + - $instance.putHieraData({'project_config_repo' => $this.projectConfigUrl}) - $instance.installPuppetModule('reidmv/yamlfile') diff --git a/murano-apps/SystemConfig/package/Resources/SystemConfig.template b/murano-apps/SystemConfig/package/Resources/SystemConfig.template index 9a57e36..02fc1dc 100644 --- a/murano-apps/SystemConfig/package/Resources/SystemConfig.template +++ b/murano-apps/SystemConfig/package/Resources/SystemConfig.template @@ -2,8 +2,17 @@ FormatVersion: 2.1.0 Version: 1.0.0 Name: Deploy Project Config +Parameters: + url: $url + branch: $branch + patch_id: $patch_id + Body: | - return deploy().stdout + return deploy( + '"{0}" "{1}" "{2}"'.format( + args.url, + args.branch, + args.patch_id)).stdout Scripts: deploy: diff --git a/murano-apps/SystemConfig/package/Resources/scripts/deploy.sh b/murano-apps/SystemConfig/package/Resources/scripts/deploy.sh index 6f8f543..2906f09 100644 --- a/murano-apps/SystemConfig/package/Resources/scripts/deploy.sh +++ b/murano-apps/SystemConfig/package/Resources/scripts/deploy.sh @@ -1,16 +1,37 @@ #!/bin/bash +URL="$1" +BRANCH="$2" +PATCH_ID="$3" + logger Cloning openstack-ci system-config -git clone https://review.fuel-infra.org/open-paas/system-config +repository_name="$(basename "$URL")" + +if [ -n "$PATCH_ID" ] ; then + git clone $URL + pushd $repository_name + patch_ref=`git ls-remote | grep $PATCH_ID | tail -1 | awk '{print $2}'` + if [ -z "$patch_ref" ] ; then + echo "Patch id $PATCH_ID is not correct." + exit 1 + fi + git fetch $URL $patch_ref && git checkout "FETCH_HEAD" + popd +elif [ -n "$BRANCH" ] ; then + git clone $URL --branch $BRANCH +else + git clone $URL +fi logger Installing openstack-ci system-config -cd system-config -./install_modules.sh +pushd $repository_name + ./install_modules.sh -cp -r modules/ /etc/puppet/ + cp -r modules/ /etc/puppet/ -# Should be installed on the each node to use -# domain2dn function -puppet module install datacentred-ldap \ No newline at end of file + # Should be installed on the each node to use + # domain2dn function + puppet module install datacentred-ldap +popd diff --git a/murano-apps/SystemConfig/package/UI/ui.yaml b/murano-apps/SystemConfig/package/UI/ui.yaml new file mode 100644 index 0000000..b33bc54 --- /dev/null +++ b/murano-apps/SystemConfig/package/UI/ui.yaml @@ -0,0 +1,43 @@ +Version: 2 + +Application: + ?: + type: org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig + name: $.appConfiguration.name + projectConfigUrl: $.appConfiguration.projectConfigUrl + systemConfigUrl: $.appConfiguration.systemConfigUrl + branchName: $.appConfiguration.branchName + patchId: $.appConfiguration.patchId + +Forms: + - appConfiguration: + fields: + - name: name + type: string + label: Application Name + initial: System Config + description: > + Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and + underline are allowed + - name: systemConfigUrl + type: string + label: Url for System Config Repository + description: Provide URL for system config repository. + initial: https://review.fuel-infra.org/open-paas/system-config + required: true + - name: projectConfigUrl + type: string + label: Url for Project Config Repository + description: Provide URL for project config repository. + initial: https://review.fuel-infra.org/open-paas/project-config + required: true + - name: branchName + type: string + label: Branch Name + description: Provide branch, which should be used for for system-config repo. + required: false + - name: patchId + type: string + label: Patch Id + description: Provide Id of patchset, which will be used for system-config repo. + required: false diff --git a/murano-apps/SystemConfig/package/manifest.yaml b/murano-apps/SystemConfig/package/manifest.yaml index d0df736..dfaf668 100644 --- a/murano-apps/SystemConfig/package/manifest.yaml +++ b/murano-apps/SystemConfig/package/manifest.yaml @@ -9,6 +9,7 @@ Author: 'Mirantis, Inc' Tags: [CI] Classes: org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig: SystemConfig.yaml +UI: ui.yaml Logo: logo.png Require: org.openstack.ci_cd_pipeline_murano_app.puppet.Puppet: diff --git a/murano-apps/Zuul/package/Classes/Zuul.yaml b/murano-apps/Zuul/package/Classes/Zuul.yaml index 8900543..22c79c6 100644 --- a/murano-apps/Zuul/package/Classes/Zuul.yaml +++ b/murano-apps/Zuul/package/Classes/Zuul.yaml @@ -17,6 +17,8 @@ Properties: Contract: $.class(puppet:PuppetInstance).notNull() gerrit: Contract: $.class(Gerrit) + systemConfigRepo: + Contract: $.class(puppet:SystemConfig) Methods: .init: Body: @@ -47,7 +49,12 @@ Methods: - $.instance.deploy() - $._environment.reporter.report($this, 'Zuul VM "{0}" with id {1} created'.format($.instance.name, $.instance.openstackId)) - - $this.systemConfig: new(puppet:SystemConfig) + # initialize System Config + - If: $.systemConfigRepo = null + Then: + - $this.systemConfig: new(puppet:SystemConfig) + Else: + - $this.systemConfig: $.systemConfigRepo - $this.systemConfig.installOnTheNode($this.instance) - $._environment.reporter.report($this, 'Zuul is waiting while Gerrit is being deployed...') diff --git a/murano-apps/Zuul/package/UI/ui.yaml b/murano-apps/Zuul/package/UI/ui.yaml index 78588fb..b6e664b 100644 --- a/murano-apps/Zuul/package/UI/ui.yaml +++ b/murano-apps/Zuul/package/UI/ui.yaml @@ -5,6 +5,7 @@ Application: type: org.openstack.ci_cd_pipeline_murano_app.Zuul name: $.appConfiguration.name gerrit: $.appConfiguration.Gerrit + systemConfigRepo: $.appConfiguration.systemConfigRepo instance: ?: type: org.openstack.ci_cd_pipeline_murano_app.puppet.PuppetInstance @@ -22,6 +23,13 @@ Forms: type: string label: Application Name initial: Zuul + - name: systemConfigRepo + type: org.openstack.ci_cd_pipeline_murano_app.puppet.SystemConfig + label: system-config Url + required: false + descriptionTitle: system-config Url + description: > + Please, provide url for system-config repository. - name: Gerrit type: org.openstack.ci_cd_pipeline_murano_app.Gerrit description: Gerrit Server