diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e56810a --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +*.py[cod] +*.sqlite + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +.venv +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject +.idea +.DS_Store +etc/*.conf +tools/lintstack.head.py +tools/pylint_exceptions + +#Linux swap file +*.swp diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..1337a94 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=gerrit.mirantis.com +port=29418 +project=open-paas/open-paas.git diff --git a/murano-apps/Gerrit/package/Classes/Gerrit.yaml b/murano-apps/Gerrit/package/Classes/Gerrit.yaml new file mode 100644 index 0000000..b2531e8 --- /dev/null +++ b/murano-apps/Gerrit/package/Classes/Gerrit.yaml @@ -0,0 +1,99 @@ +Namespaces: + =: io.murano.apps + std: io.murano + res: io.murano.resources + sys: io.murano.system + +Name: Gerrit + +Extends: std:Application + +Properties: + name: + Contract: $.string().notNull() + warUrl: + Contract: $.string().notNull() + ldap: + Contract: $.class(OpenLDAP) + instance: + Contract: $.class(res:Instance).notNull() + +Methods: + initialize: + Body: + - $._environment: $.find(std:Environment).require() + + deploy: + Body: + - If: not $.getAttr(deployed, false) + Then: + - $securityGroupIngress: + - ToPort: 8080 + FromPort: 8080 + IpProtocol: tcp + External: true + - ToPort: 29418 + FromPort: 29418 + IpProtocol: tcp + External: true + - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress) + - $._environment.reporter.report($this, 'Creating VM for Gerrit') + - $.instance.deploy() + - $resources: new(sys:Resources) + - $template: $resources.yaml('DeployGerrit.template').bind(dict( + warUrl => $.warUrl + )) + - $._environment.reporter.report($this, 'Deploying Gerrit') + - $.instance.agent.call($template, $resources) + - If: $.ldap != null + Then: + - $._environment.reporter.report($this, 'Gerrit waits OpenLDAP to be deployed...') + - $.ldap.deploy() + - $.connectLDAP() + + - $._environment.reporter.report($this, 'Gerrit is deployed!') + - $.setAttr(deployed, true) + + connectLDAP: + Body: + - $._environment.reporter.report($this, 'Connecting Gerrit to OpenLDAP server') + - $ldapInstance: $.ldap.instance + - If: $ldapInstance.assignFloatingIp + Then: + - $ldapHost: $ldapInstance.floatingIpAddress + Else: + - $ldapHost: $ldapInstance.ipAddresses[0] + + - $host: "localhost" + - If: $.instance.assignFloatingIp + Then: + - $host: $.instance.floatingIpAddress + Else: + - $host: $.instance.ipAddresses[0] + + - $resources: new(sys:Resources) + - $template: $resources.yaml('ConnectLDAP.template').bind(dict( + openLDAPip => $ldapHost, + host => $host, + domain => $.ldap.domain + )) + - $.instance.agent.call($template, $resources) + - $._environment.reporter.report($this, format('Gerrit is available at {0}:8080', $host)) + + putKey: + Arguments: + - sshKey: + Contract: $.string().notNull() + + Body: + - $._environment.reporter.report($this, 'Put SSH key to Gerrit server') + - $resources: new(sys:Resources) + - $template: $resources.yaml('PutKey.template').bind(dict( + sshKey => $sshKey + )) + - $.instance.agent.call($template, $resources) + + destroy: + Body: + - $.reportDestroyed() + - $.setAttr(deployed, false) diff --git a/murano-apps/Gerrit/package/Resources/ConnectLDAP.template b/murano-apps/Gerrit/package/Resources/ConnectLDAP.template new file mode 100644 index 0000000..fbf38a4 --- /dev/null +++ b/murano-apps/Gerrit/package/Resources/ConnectLDAP.template @@ -0,0 +1,22 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Connect LDAP + +Parameters: + openLDAPip: $openLDAPip + host: $host + domain: $domain + +Body: | + return configure('{0} {1} {2}'.format(args.openLDAPip, args.host, args.domain)).stdout + +Scripts: + configure: + Type: Application + Version: 1.0.0 + EntryPoint: connectLDAP.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false diff --git a/murano-apps/Gerrit/package/Resources/DeployGerrit.template b/murano-apps/Gerrit/package/Resources/DeployGerrit.template new file mode 100644 index 0000000..0fb7267 --- /dev/null +++ b/murano-apps/Gerrit/package/Resources/DeployGerrit.template @@ -0,0 +1,20 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Deploy Gerrit + +Parameters: + warUrl: $warUrl + +Body: | + return deploy('{0}'.format(args.warUrl)).stdout + +Scripts: + deploy: + Type: Application + Version: 1.0.0 + EntryPoint: deployGerrit.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false diff --git a/murano-apps/Gerrit/package/Resources/PutKey.template b/murano-apps/Gerrit/package/Resources/PutKey.template new file mode 100644 index 0000000..79393c2 --- /dev/null +++ b/murano-apps/Gerrit/package/Resources/PutKey.template @@ -0,0 +1,19 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Put sshKey + +Parameters: + sshKey: $sshKey + +Body: | + return configure('{0}'.format(args.sshKey)).stdout + +Scripts: + configure: + Type: Application + Version: 1.0.0 + EntryPoint: putKey.sh + Files: [] + Options: + captureStdout: true + captureStderr: true diff --git a/murano-apps/Gerrit/package/Resources/scripts/connectLDAP.sh b/murano-apps/Gerrit/package/Resources/scripts/connectLDAP.sh new file mode 100644 index 0000000..22c7c23 --- /dev/null +++ b/murano-apps/Gerrit/package/Resources/scripts/connectLDAP.sh @@ -0,0 +1,25 @@ +#!/bin/bash +OPENLDAP_IP="$1" +HOST="$2" +DOMAIN="$3" + +# parse tld +NAME="`echo "$DOMAIN" | cut -d. -f1`" +TLD="`echo "$DOMAIN" | cut -d. -f2`" + + +# setup gerrit to authenticate from OpenLDAP +sed -e "s/type = OPENID/type = ldap/" -i /home/gerrit/gerrit_testsite/etc/gerrit.config +sed -e "s,canonicalWebUrl.*,canonicalWebUrl = http://${HOST}:8080," -i /home/gerrit/gerrit_testsite/etc/gerrit.config + +cat << EOF >> /home/gerrit/gerrit_testsite/etc/gerrit.config +[ldap] + server = ldap://${OPENLDAP_IP} + accountBase = OU=users,DC=${NAME},DC=${TLD} + username = CN=admin,DC=${NAME},DC=${TLD} + password = openstack + accountFullName = cn +EOF + +# restart gerrit +sudo -u gerrit /home/gerrit/gerrit_testsite/bin/gerrit.sh restart diff --git a/murano-apps/Gerrit/package/Resources/scripts/deployGerrit.sh b/murano-apps/Gerrit/package/Resources/scripts/deployGerrit.sh new file mode 100644 index 0000000..00d4cdb --- /dev/null +++ b/murano-apps/Gerrit/package/Resources/scripts/deployGerrit.sh @@ -0,0 +1,22 @@ +#!/bin/bash +WAR="$1" + +# Update the packages and install git and java +apt-get update +apt-get install -y git openjdk-7-jdk git-review + +# Create a user, gerrit2, to run gerrit +useradd -d/home/gerrit gerrit +mkdir /home/gerrit +chown -R gerrit:gerrit /home/gerrit + +# Allow firewall holes for Gerrit +iptables -I INPUT 1 -p tcp -m tcp --dport 8080 -j ACCEPT -m comment --comment "by murano, Gerrit server access on HTTP on port 8080" +iptables -I INPUT 1 -p tcp -m tcp --dport 29418 -j ACCEPT -m comment --comment "by murano, server Apache server access via sshd on port 29418" + +# Download latest stable code, install and remove war file. +cd /tmp +wget ${WAR} +filename=$(basename ${WAR}) +sudo -u gerrit java -jar /tmp/$filename init --batch -d /home/gerrit/gerrit_testsite +rm /tmp/$filename diff --git a/murano-apps/Gerrit/package/Resources/scripts/putKey.sh b/murano-apps/Gerrit/package/Resources/scripts/putKey.sh new file mode 100644 index 0000000..aacbab1 --- /dev/null +++ b/murano-apps/Gerrit/package/Resources/scripts/putKey.sh @@ -0,0 +1,9 @@ +#!/bin/bash +SSHKEY="$1 $2" + +mkdir /home/gerrit/.ssh +echo $SSHKEY > /home/gerrit/.ssh/authorized_keys +echo $SSHKEY > /home/gerrit/.ssh/jenkins-id_rsa.pub +chmod 700 /home/gerrit/.ssh +chmod 600 /home/gerrit/.ssh/authorized_keys /home/gerrit/.ssh/jenkins-id_rsa.pub +chown -R gerrit:gerrit /home/gerrit/.ssh diff --git a/murano-apps/Gerrit/package/UI/ui.yaml b/murano-apps/Gerrit/package/UI/ui.yaml new file mode 100644 index 0000000..2ed2304 --- /dev/null +++ b/murano-apps/Gerrit/package/UI/ui.yaml @@ -0,0 +1,93 @@ +Version: 2 + +Application: + ?: + type: io.murano.apps.Gerrit + name: $.appConfiguration.name + warUrl: $.appConfiguration.warUrl + ldap: $.appConfiguration.OpenLDAP + instance: + ?: + type: io.murano.resources.LinuxMuranoInstance + name: generateHostname($.instanceConfiguration.unitNamingPattern, 1) + flavor: $.instanceConfiguration.flavor + image: $.instanceConfiguration.osImage + keyname: $.instanceConfiguration.keyPair + availabilityZone: $.instanceConfiguration.availabilityZone + assignFloatingIp: $.appConfiguration.assignFloatingIP + +Forms: + - appConfiguration: + fields: + - name: name + type: string + label: Application Name + initial: Gerrit + description: >- + Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and + underline are allowed + - name: assignFloatingIP + type: boolean + label: Assign Floating IP + description: >- + Select to true to assign floating IP automatically + initial: true + required: false + - name: warUrl + type: string + label: URL for war + initial: http://gerrit-releases.storage.googleapis.com/gerrit-2.11.2.war + description: >- + Enter the war version from Gerrit's site + http://gerrit-releases.storage.googleapis.com/index.html + - name: OpenLDAP + type: io.murano.apps.OpenLDAP + required: false + description: >- + Specify OpenLDAP domain for authentication. + - instanceConfiguration: + fields: + - name: title + type: string + required: false + hidden: true + description: Specify some instance parameters on which the application would be created + - name: flavor + type: flavor + label: Instance flavor + description: >- + Select registered in Openstack flavor. Consider that application performance + depends on this parameter. + initial: m1.tiny + required: false + - name: osImage + type: image + imageType: linux + label: Instance image + description: >- + Select a valid image for the application. Image should already be prepared and + registered in glance. + - name: keyPair + type: keypair + label: Key Pair + description: >- + Select a Key Pair to control access to instances. You can login to + instances using this KeyPair after the deployment of application. + required: false + - name: availabilityZone + type: azone + label: Availability zone + description: Select availability zone where the application would be installed. + required: false + - name: unitNamingPattern + type: string + label: Instance Naming Pattern + required: false + maxLength: 200 + regexpValidator: '^[-_\w]+$' + errorMessages: + invalid: Just letters, numbers, underscores and hyphens are allowed. + helpText: Just letters, numbers, underscores and hyphens are allowed. + description: >- + Specify a string, that will be used in instance hostname. + Just A-Z, a-z, 0-9, dash and underline are allowed. diff --git a/murano-apps/Gerrit/package/logo.png b/murano-apps/Gerrit/package/logo.png new file mode 100644 index 0000000..7d709dd Binary files /dev/null and b/murano-apps/Gerrit/package/logo.png differ diff --git a/murano-apps/Gerrit/package/manifest.yaml b/murano-apps/Gerrit/package/manifest.yaml new file mode 100644 index 0000000..f62c7b2 --- /dev/null +++ b/murano-apps/Gerrit/package/manifest.yaml @@ -0,0 +1,13 @@ +Format: 1.0 +Type: Application +FullName: io.murano.apps.Gerrit +Name: Gerrit +Description: | + Gerrit is a web based code review system, facilitating online code reviews + for projects using the Git version control system. +Author: 'Mirantis, Inc' +Tags: [Server, Java, Gerrit, CI] +Classes: + io.murano.apps.Gerrit: Gerrit.yaml +UI: ui.yaml +Logo: logo.png diff --git a/murano-apps/Jenkins/package/Classes/Jenkins.yaml b/murano-apps/Jenkins/package/Classes/Jenkins.yaml new file mode 100644 index 0000000..4fa34d9 --- /dev/null +++ b/murano-apps/Jenkins/package/Classes/Jenkins.yaml @@ -0,0 +1,155 @@ +Namespaces: + =: io.murano.apps + std: io.murano + res: io.murano.resources + sys: io.murano.system + +Name: Jenkins + +Extends: std:Application + +Properties: + name: + Contract: $.string().notNull() + ldap: + Contract: $.class(OpenLDAP) + gerrit: + Contract: $.class(Gerrit) + instance: + Contract: $.class(res:Instance).notNull() + +Methods: + initialize: + Body: + - $._environment: $.find(std:Environment).require() + + deploy: + Body: + - If: not $.getAttr(deployed, false) + Then: + - $._environment.reporter.report($this, 'Creating VM for Jenkins') + - $securityGroupIngress: + - ToPort: 8080 + FromPort: 8080 + IpProtocol: tcp + External: true + - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress) + - $.instance.deploy() + - $resources: new(sys:Resources) + - $template: $resources.yaml('DeployJenkins.template') + - $._environment.reporter.report($this, 'Jenkins deploying') + - $.instance.agent.call($template, $resources) + + - If: $.ldap != null + Then: + - $._environment.reporter.report($this, 'Jenkins waits OpenLDAP to be deployed...') + - $.ldap.deploy() + - $.connectLDAP() + + - If: $.gerrit != null and $.ldap != null + Then: + - $._environment.reporter.report($this, 'Jenkins waits Gerrit to be deployed...') + - $.gerrit.deploy() + - $.connectGerrit() + - $sshKey: $.getKey() + - $.gerrit.putKey($sshKey) + + - $.installJJB() + - $.configureJJB() + - $.createTestJob() + + - If: $.instance.assignFloatingIp + Then: + - $host: $.instance.floatingIpAddress + Else: + - $host: $.instance.ipAddresses[0] + - $._environment.reporter.report($this, 'Jenkins is available at {0}:8080'.format($host)) + - $.setAttr(deployed, true) + + installJJB: + Body: + - $resources: new(sys:Resources) + - $._environment.reporter.report($this, 'Installing Jenkins Job Builder') + - $template: $resources.yaml('InstallJJB.template') + - $.instance.agent.call($template, $resources) + + configureJJB: + Body: + - $resources: new(sys:Resources) + - $._environment.reporter.report($this, 'Configuring Jenkins Job Builder') + + - If: $.ldap != null + Then: + - If: $.ldap.ldapUser != '' and $.ldap.ldapUser != null + Then: + - $user: $.ldap.ldapUser + - $password: $.ldap.ldapPass + Else: + - $user: 'jenkins' + - $password: 'openstack' + Else: + - $user: '' + - $password: '' + + - $template: $resources.yaml('ConfigureJJB.template').bind(dict( + jenkinsip => $.instance.ipAddresses[0], + user => $user, + password => $password + )) + - $.instance.agent.call($template, $resources) + - $._environment.reporter.report($this, 'Jenkins Job Builder is configured!') + + createTestJob: + Body: + - $resources: new(sys:Resources) + - $._environment.reporter.report($this, 'Creating test job via Jenkins Job Builder') + - $template: $resources.yaml('CreateTestJob.template') + - $.instance.agent.call($template, $resources) + + connectLDAP: + Body: + - $.ldap.configureOpenLDAPUser($.ldap.domain, 'jenkins', 'openstack') + - $ldapInstance: $.ldap.instance + - If: $ldapInstance.assignFloatingIp + Then: + - $ldapHost: $ldapInstance.floatingIpAddress + Else: + - $ldapHost: $ldapInstance.ipAddresses[0] + - $resources: new(sys:Resources) + - $._environment.reporter.report($this, 'Connecting Jenkins to OpenLDAP server') + - $template: $resources.yaml('ConnectLDAP.template').bind(dict( + openLDAPip => $ldapHost, + domain => $.ldap.domain + )) + - $.instance.agent.call($template, $resources) + - $._environment.reporter.report($this, 'Jenkins is connected to OpenLDAP server!') + + connectGerrit: + Body: + - $._environment.reporter.report($this, 'Connecting Jenkins with Gerrit') + - $gerritInstance: $.gerrit.instance + - If: $gerritInstance.assignFloatingIp + Then: + - $gerritHost: $gerritInstance.floatingIpAddress + Else: + - $gerritHost: $gerritInstance.ipAddresses[0] + - $resources: new(sys:Resources) + - $template: $resources.yaml('ConnectGerrit.template').bind(dict( + gerritIp => $gerritHost, + domain => $.ldap.domain + )) + - $.instance.agent.call($template, $resources) + - $._environment.reporter.report($this, 'Jenkins is connected with Gerrit!') + + getKey: + Body: + - $._environment.reporter.report($this, 'Get SSH key from Jenkins') + - $resources: new(sys:Resources) + - $template: $resources.yaml('GetKey.template') + - $sshKey: $.instance.agent.call($template, $resources) + - Return: format('{0}', $sshKey) + + destroy: + Body: + - $.reportDestroyed() + - $.setAttr(deployed, false) diff --git a/murano-apps/Jenkins/package/Resources/ConfigureJJB.template b/murano-apps/Jenkins/package/Resources/ConfigureJJB.template new file mode 100644 index 0000000..e5a375b --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/ConfigureJJB.template @@ -0,0 +1,22 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Configure Jenkins Job Builder + +Parameters: + jenkinsip: $jenkinsip + user: $user + password: $password + +Body: | + return configure('{0} {1} {2}'.format(args.jenkinsip, args.user, args.password)).stdout + +Scripts: + configure: + Type: Application + Version: 1.0.0 + EntryPoint: configureJJB.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/ConnectGerrit.template b/murano-apps/Jenkins/package/Resources/ConnectGerrit.template new file mode 100644 index 0000000..3c97add --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/ConnectGerrit.template @@ -0,0 +1,21 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Connect LDAP + +Parameters: + gerritIp: $gerritIp + domain: $domain + +Body: | + return configure('{0} {1}'.format(args.gerritIp, args.domain)).stdout + +Scripts: + configure: + Type: Application + Version: 1.0.0 + EntryPoint: connectGerrit.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false diff --git a/murano-apps/Jenkins/package/Resources/ConnectLDAP.template b/murano-apps/Jenkins/package/Resources/ConnectLDAP.template new file mode 100644 index 0000000..0c1c525 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/ConnectLDAP.template @@ -0,0 +1,21 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Connect LDAP + +Parameters: + openLDAPip: $openLDAPip + domain: $domain + +Body: | + return configure('{0} {1}'.format(args.openLDAPip, args.domain)).stdout + +Scripts: + configure: + Type: Application + Version: 1.0.0 + EntryPoint: connectLDAP.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false diff --git a/murano-apps/Jenkins/package/Resources/CreateTestJob.template b/murano-apps/Jenkins/package/Resources/CreateTestJob.template new file mode 100644 index 0000000..b4297fe --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/CreateTestJob.template @@ -0,0 +1,17 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Create Test Job using Jenkins Job Builder + +Body: | + return create().stdout + +Scripts: + create: + Type: Application + Version: 1.0.0 + EntryPoint: createTestJob.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/DeployJenkins.template b/murano-apps/Jenkins/package/Resources/DeployJenkins.template new file mode 100644 index 0000000..009e018 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/DeployJenkins.template @@ -0,0 +1,20 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Deploy Jenkins + +Parameters: + appName: $appName + +Body: | + return deploy(args.appName).stdout + +Scripts: + deploy: + Type: Application + Version: 1.0.0 + EntryPoint: deployJenkins.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false diff --git a/murano-apps/Jenkins/package/Resources/GetKey.template b/murano-apps/Jenkins/package/Resources/GetKey.template new file mode 100644 index 0000000..0e2fae8 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/GetKey.template @@ -0,0 +1,22 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Get ssh key + +Parameters: + sshKey: $sshKey + +Body: | + key = '' + with open('/var/lib/jenkins/.ssh/jenkins-id_rsa.pub','r') as f: + key = f.read() + return key + +Scripts: + noop: + Type: Application + Version: 1.0.0 + EntryPoint: noop.sh + Files: [] + Options: + captureStdout: true + captureStderr: true diff --git a/murano-apps/Jenkins/package/Resources/InstallJJB.template b/murano-apps/Jenkins/package/Resources/InstallJJB.template new file mode 100644 index 0000000..310065c --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/InstallJJB.template @@ -0,0 +1,17 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Install Jenkins Job Builder + +Body: | + return deploy().stdout + +Scripts: + deploy: + Type: Application + Version: 1.0.0 + EntryPoint: installJJB.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + verifyExitcode: false \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configureJJB.sh b/murano-apps/Jenkins/package/Resources/scripts/configureJJB.sh new file mode 100644 index 0000000..0bfa1d6 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configureJJB.sh @@ -0,0 +1,18 @@ +#!/bin/bash +JENKINS_IP="$1" +USER="$2" +PASSWORD="$3" + +cd ~/jenkins-job-builder +cp etc/jenkins_jobs.ini-sample etc/jenkins_jobs.ini + +sed -i "s/https:\/\/jenkins.example.com/http:\/\/$JENKINS_IP:8080\//g" etc/jenkins_jobs.ini + +if [ -n "$USER" ]; + then + sed -i "s/user=jenkins/user=$USER/g" etc/jenkins_jobs.ini; + sed -i "s/password=1234567890abcdef1234567890abcdef/password=$PASSWORD/g" etc/jenkins_jobs.ini; +fi + + + diff --git a/murano-apps/Jenkins/package/Resources/scripts/connectGerrit.sh b/murano-apps/Jenkins/package/Resources/scripts/connectGerrit.sh new file mode 100644 index 0000000..25c321e --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/connectGerrit.sh @@ -0,0 +1,117 @@ +#!/bin/bash +GERRIT_IP="$1" +DOMAIN="$2" + +cat << CONFIG >> /var/lib/jenkins/credentials.xml + + + + + + + + + + GLOBAL + 10055155-5c33-4318-8161-96a3ccd270a8 + + jenkins + aE53R1jYUuH1K2BgkbGqfw== + + /var/lib/jenkins/.ssh/jenkins-id_rsa + + + + + + +CONFIG + +cat << CONFIG >> /var/lib/jenkins/gerrit-trigger.xml + + + + + Gerrit + false + + ${GERRIT_IP} + 29418 + + jenkins + jenkins@${DOMAIN} + /var/lib/jenkins/.ssh/jenkins-id_rsa + aE53R1jYUuH1K2BgkbGqfw== + false + false + false + false + gerrit review <CHANGE>,<PATCHSET> --message 'Build Successful <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'Build Unstable <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'Build Failed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'Build Started <BUILDURL> <STARTED_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'No Builds Executed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + http://${GERRIT_IP}:8080/ + 0 + 0 + 1 + 0 + -1 + 0 + 0 + -1 + 0 + 0 + true + true + 3 + 30 + + + Code-Review + Code Review + + + Verified + Verified + + + + false + + false + + 0 + + + + + ALL + + + + + 3 + 1 + 360 + + +CONFIG + +cat << CONFIG >> /var/lib/jenkins/hudson.plugins.git.GitTool.xml + + + + + Default + git + + + + +CONFIG + +# Restart jenkins +service jenkins restart + +# Grab jenkins key from gerrit diff --git a/murano-apps/Jenkins/package/Resources/scripts/connectLDAP.sh b/murano-apps/Jenkins/package/Resources/scripts/connectLDAP.sh new file mode 100644 index 0000000..f0b98ae --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/connectLDAP.sh @@ -0,0 +1,54 @@ +#!/bin/bash +OPENLDAP_IP="$1" +DOMAIN="$2" + +NAME="`echo "$DOMAIN" | cut -d. -f1`" +TLD="`echo "$DOMAIN" | cut -d. -f2`" + +cat << CONFIG >> /var/lib/jenkins/config.xml + + + + 1.0 + 2 + NORMAL + true + + + ldap://${OPENLDAP_IP} + dc=${NAME},dc=${TLD} + false + + uid={0} + cn=admin,dc=${NAME},dc=${TLD} + b3BlbnN0YWNr + false + + false + + \${JENKINS_HOME}/workspace/\${ITEM_FULLNAME} + \${ITEM_ROOTDIR}/builds + + + + + + 0 + + + + All + false + false + + + + All + 0 + + + + +CONFIG + +service jenkins restart diff --git a/murano-apps/Jenkins/package/Resources/scripts/createTestJob.sh b/murano-apps/Jenkins/package/Resources/scripts/createTestJob.sh new file mode 100644 index 0000000..6c723a7 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/createTestJob.sh @@ -0,0 +1,6 @@ +cd ~/jenkins-job-builder + +jenkins-jobs test -o output tests/yamlparser/fixtures/templates002.yaml +cat etc/jenkins_jobs.ini +ping -c 5 `grep 'url' etc/jenkins_jobs.ini | awk '{split($0,a,"/"); split(a[3],a,":"); print a[1]}'` +jenkins-jobs --conf etc/jenkins_jobs.ini update tests/yamlparser/fixtures/templates002.yaml diff --git a/murano-apps/Jenkins/package/Resources/scripts/deployJenkins.sh b/murano-apps/Jenkins/package/Resources/scripts/deployJenkins.sh new file mode 100644 index 0000000..d21e7b9 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/deployJenkins.sh @@ -0,0 +1,20 @@ +#!/bin/bash +export DEBIAN_FRONTEND=noninteractive + +# Install prerequisites +wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - +sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list' +apt-get update + +# Jenkins +apt-get -y install jenkins + +# Open firewall for jenkins +iptables -I INPUT 1 -p tcp -m tcp --dport 8080 -j ACCEPT -m comment --comment "by Murano, Jenkins" +service jenkins restart + +# Create an ssh-key that can be used between Gerrit and Jenkins +sudo -u jenkins ssh-keygen -t rsa -N "" -f /var/lib/jenkins/.ssh/jenkins-id_rsa +chmod 400 /var/lib/jenkins/.ssh/jenkins-id_rsa +chmod 600 /var/lib/jenkins/.ssh/jenkins-id_rsa.pub + diff --git a/murano-apps/Jenkins/package/Resources/scripts/installJJB.sh b/murano-apps/Jenkins/package/Resources/scripts/installJJB.sh new file mode 100644 index 0000000..a03d04c --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/installJJB.sh @@ -0,0 +1,8 @@ +cd ~ +git clone https://git.openstack.org/openstack-infra/jenkins-job-builder +cd jenkins-job-builder + +sudo apt-get install python-tox --assume-yes +tox -e venv -- sudo python setup.py install +tox -e venv -- sudo pip install -r requirements.txt + diff --git a/murano-apps/Jenkins/package/Resources/scripts/noop.sh b/murano-apps/Jenkins/package/Resources/scripts/noop.sh new file mode 100644 index 0000000..cb99fc5 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/noop.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Ok" diff --git a/murano-apps/Jenkins/package/UI/ui.yaml b/murano-apps/Jenkins/package/UI/ui.yaml new file mode 100644 index 0000000..d89b7c2 --- /dev/null +++ b/murano-apps/Jenkins/package/UI/ui.yaml @@ -0,0 +1,91 @@ +Version: 2 + +Application: + ?: + type: io.murano.apps.Jenkins + name: $.appConfiguration.name + ldap: $.appConfiguration.OpenLDAP + gerrit: $.appConfiguration.GerritServer + instance: + ?: + type: io.murano.resources.LinuxMuranoInstance + name: generateHostname($.instanceConfiguration.unitNamingPattern, 1) + flavor: $.instanceConfiguration.flavor + image: $.instanceConfiguration.osImage + keyname: $.instanceConfiguration.keyPair + availabilityZone: $.instanceConfiguration.availabilityZone + assignFloatingIp: $.appConfiguration.assignFloatingIP + +Forms: + - appConfiguration: + fields: + - name: name + type: string + label: Application Name + initial: Jenkins + description: >- + Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and + underline are allowed + - name: assignFloatingIP + type: boolean + label: Assign Floating IP + description: >- + Select to true to assign floating IP automatically + initial: true + required: false + - name: OpenLDAP + type: io.murano.apps.OpenLDAP + required: false + description: >- + Specify OpenLDAP domain for authentication + - name: GerritServer + type: io.murano.apps.Gerrit + required: false + description: >- + Specify Gerrit server + - instanceConfiguration: + fields: + - name: title + type: string + required: false + hidden: true + description: Specify some instance parameters on which the application would be created + - name: flavor + type: flavor + label: Instance flavor + description: >- + Select registered in Openstack flavor. Consider that application performance + depends on this parameter. + initial: m1.tiny + required: false + - name: osImage + type: image + imageType: linux + label: Instance image + description: >- + Select a valid image for the application. Image should already be prepared and + registered in glance. + - name: keyPair + type: keypair + label: Key Pair + description: >- + Select a Key Pair to control access to instances. You can login to + instances using this KeyPair after the deployment of application. + required: false + - name: availabilityZone + type: azone + label: Availability zone + description: Select availability zone where the application would be installed. + required: false + - name: unitNamingPattern + type: string + label: Instance Naming Pattern + required: false + maxLength: 200 + regexpValidator: '^[-_\w]+$' + errorMessages: + invalid: Just letters, numbers, underscores and hyphens are allowed. + helpText: Just letters, numbers, underscores and hyphens are allowed. + description: >- + Specify a string, that will be used in instance hostname. + Just A-Z, a-z, 0-9, dash and underline are allowed. diff --git a/murano-apps/Jenkins/package/logo.png b/murano-apps/Jenkins/package/logo.png new file mode 100644 index 0000000..b851bdd Binary files /dev/null and b/murano-apps/Jenkins/package/logo.png differ diff --git a/murano-apps/Jenkins/package/manifest.yaml b/murano-apps/Jenkins/package/manifest.yaml new file mode 100644 index 0000000..79339a4 --- /dev/null +++ b/murano-apps/Jenkins/package/manifest.yaml @@ -0,0 +1,12 @@ +Format: 1.0 +Type: Application +FullName: io.murano.apps.Jenkins +Name: Jenkins +Description: | + Jenkins is an open source continuous integration tool written in Java. +Author: 'Mirantis, Inc' +Tags: [Server, Java, CI, Jenkins] +Classes: + io.murano.apps.Jenkins: Jenkins.yaml +UI: ui.yaml +Logo: logo.png diff --git a/murano-apps/OpenLDAP/package/Classes/OpenLDAP.yaml b/murano-apps/OpenLDAP/package/Classes/OpenLDAP.yaml new file mode 100644 index 0000000..46bcc6f --- /dev/null +++ b/murano-apps/OpenLDAP/package/Classes/OpenLDAP.yaml @@ -0,0 +1,90 @@ +Namespaces: + =: io.murano.apps + std: io.murano + res: io.murano.resources + sys: io.murano.system + +Name: OpenLDAP + +Extends: std:Application + +Properties: + instance: + Contract: $.class(res:Instance).notNull() + name: + Contract: $.string().notNull() + domain: + Contract: $.string() + ldapUser: + Contract: $.string() + ldapPass: + Contract: $.string() + +Methods: + initialize: + Body: + - $._environment: $.find(std:Environment).require() + + deploy: + Body: + - If: not $.getAttr(deployed, false) + Then: + - $securityGroupIngress: + - ToPort: 389 + FromPort: 389 + IpProtocol: tcp + External: true + - ToPort: 636 + FromPort: 636 + IpProtocol: tcp + External: true + - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress) + - $._environment.reporter.report($this, 'Creating VM for OpenLDAP') + - $.instance.deploy() + - $resources: new(sys:Resources) + - $template: $resources.yaml('DeployOpenLDAP.template') + - $._environment.reporter.report($this, 'OpenLDAP deploying') + - $.instance.agent.call($template, $resources) + - $._environment.reporter.report($this, format('OpenLDAP is available at {0}', $.instance.floatingIpAddress)) + - If: $.domain != '' and $.domain != null + Then: + - $.configureOpenLDAPDomain() + - If: $.ldapUser != '' and $.ldapUser != null + Then: + - $.configureOpenLDAPUser($.domain, $.ldapUser, $.ldapPass) + - $.setAttr(deployed, true) + - $._environment.reporter.report($this, 'OpenLDAP is deployed!') + + configureOpenLDAPDomain: + Body: + - If: not $.getAttr(domainConfigured, false) + Then: + - $resources: new(sys:Resources) + - $template: $resources.yaml('ConfigureOpenLDAPDomain.template').bind(dict(domain => $.domain)) + - $.instance.agent.call($template, $resources) + - $._environment.reporter.report($this, 'OpenLDAP domain is configured') + - $.setAttr(domainConfigured, true) + + configureOpenLDAPUser: + Arguments: + - domain: + Contract: $.string().notNull() + - ldapUser: + Contract: $.string().notNull() + - ldapPass: + Contract: $.string().notNull() + Body: + - $.configureOpenLDAPDomain() + - $resources: new(sys:Resources) + - $template: $resources.yaml('ConfigureOpenLDAPUser.template').bind(dict( + domain => $domain, + ldapUser => $ldapUser, + ldapPass => $ldapPass + )) + - $.instance.agent.call($template, $resources) + - $._environment.reporter.report($this, 'OpenLDAP user {0} is added'.format($ldapUser)) + + destroy: + Body: + - $.reportDestroyed() + - $.setAttr(deployed, false) diff --git a/murano-apps/OpenLDAP/package/Resources/ConfigureOpenLDAPDomain.template b/murano-apps/OpenLDAP/package/Resources/ConfigureOpenLDAPDomain.template new file mode 100644 index 0000000..673d64a --- /dev/null +++ b/murano-apps/OpenLDAP/package/Resources/ConfigureOpenLDAPDomain.template @@ -0,0 +1,19 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Configure OpenLDAP + +Parameters: + domain: $domain + +Body: | + return configure('{0}'.format(args.domain)).stdout + +Scripts: + configure: + Type: Application + Version: 1.0.0 + EntryPoint: configureOpenLDAPDomain.sh + Files: [] + Options: + captureStdout: true + captureStderr: true diff --git a/murano-apps/OpenLDAP/package/Resources/ConfigureOpenLDAPUser.template b/murano-apps/OpenLDAP/package/Resources/ConfigureOpenLDAPUser.template new file mode 100644 index 0000000..b91e88e --- /dev/null +++ b/murano-apps/OpenLDAP/package/Resources/ConfigureOpenLDAPUser.template @@ -0,0 +1,21 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Configure OpenLDAP + +Parameters: + domain: $domain + ldapUser: $ldapUser + ldapPass: $ldapPass + +Body: | + return configure('{0} {1} {2}'.format(args.domain, args.ldapUser, args.ldapPass)).stdout + +Scripts: + configure: + Type: Application + Version: 1.0.0 + EntryPoint: configureOpenLDAPUser.sh + Files: [] + Options: + captureStdout: true + captureStderr: true diff --git a/murano-apps/OpenLDAP/package/Resources/DeployOpenLDAP.template b/murano-apps/OpenLDAP/package/Resources/DeployOpenLDAP.template new file mode 100644 index 0000000..888a7d9 --- /dev/null +++ b/murano-apps/OpenLDAP/package/Resources/DeployOpenLDAP.template @@ -0,0 +1,19 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Deploy OpenLDAP + +Parameters: + appName: $appName + +Body: | + return deploy(args.appName).stdout + +Scripts: + deploy: + Type: Application + Version: 1.0.0 + EntryPoint: deployOpenLDAP.sh + Files: [] + Options: + captureStdout: true + captureStderr: true diff --git a/murano-apps/OpenLDAP/package/Resources/scripts/configureOpenLDAPDomain.sh b/murano-apps/OpenLDAP/package/Resources/scripts/configureOpenLDAPDomain.sh new file mode 100644 index 0000000..5db1ee0 --- /dev/null +++ b/murano-apps/OpenLDAP/package/Resources/scripts/configureOpenLDAPDomain.sh @@ -0,0 +1,13 @@ +#!/bin/bash +DOMAIN="$1" + +echo "slapd slapd/no_configuration boolean false" | debconf-set-selections +echo "slapd slapd/domain string ${DOMAIN}" | debconf-set-selections +echo "slapd shared/organization string '${DOMAIN}'" | debconf-set-selections +echo "slapd slapd/password1 password openstack" | debconf-set-selections +echo "slapd slapd/password2 password openstack" | debconf-set-selections +echo "slapd slapd/backend select HDB" | debconf-set-selections +echo "slapd slapd/purge_database boolean true" | debconf-set-selections +echo "slapd slapd/allow_ldap_v2 boolean false" | debconf-set-selections +echo "slapd slapd/move_old_database boolean true" | debconf-set-selections +dpkg-reconfigure -f noninteractive slapd diff --git a/murano-apps/OpenLDAP/package/Resources/scripts/configureOpenLDAPUser.sh b/murano-apps/OpenLDAP/package/Resources/scripts/configureOpenLDAPUser.sh new file mode 100644 index 0000000..69249a8 --- /dev/null +++ b/murano-apps/OpenLDAP/package/Resources/scripts/configureOpenLDAPUser.sh @@ -0,0 +1,38 @@ +#!/bin/bash +DOMAIN="$1" +USERNAME="$2" +PASSWORD="$3" + +NAME="`echo "$DOMAIN" | cut -d. -f1`" +TLD="`echo "$DOMAIN" | cut -d. -f2`" + + +# Create group.ldif and user.ldif +cat << GROUP > /tmp/group.ldif +dn: ou=users,dc=${NAME},dc=${TLD} +objectClass: top +objectClass: organizationalUnit +GROUP + +cat << USER > /tmp/user.ldif +dn: uid=${USERNAME},ou=users,dc=${NAME},dc=${TLD} +objectClass: top +objectClass: account +objectClass: posixAccount +objectClass: shadowAccount +cn: ${USERNAME} +uid: ${USERNAME} +uidNumber: 1001 +gidNumber: 1001 +homeDirectory: /home/${USERNAME} +loginShell: /bin/bash +gecos: ${USERNAME}@${DOMAIN} +userPassword: {crypt}x +shadowLastChange: 0 +shadowMax: 0 +shadowWarning: 0 +USER + +ldapadd -x -w openstack -D "cn=admin,dc=${NAME},dc=${TLD}" -f /tmp/group.ldif +ldapadd -x -w openstack -D "cn=admin,dc=${NAME},dc=${TLD}" -f /tmp/user.ldif +ldappasswd -s ${PASSWORD} -D "cn=admin,dc=${NAME},dc=${TLD}" -w openstack -x uid=${USERNAME},ou=users,dc=${NAME},dc=${TLD} diff --git a/murano-apps/OpenLDAP/package/Resources/scripts/deployOpenLDAP.sh b/murano-apps/OpenLDAP/package/Resources/scripts/deployOpenLDAP.sh new file mode 100644 index 0000000..3873667 --- /dev/null +++ b/murano-apps/OpenLDAP/package/Resources/scripts/deployOpenLDAP.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +apt-get update +apt-get install -y debconf + +echo "slapd slapd/root_password password openstack" | debconf-set-selections +echo "slapd slapd/root_password_again password openstack" | debconf-set-selections +DEBIAN_FRONTEND=noninteractive apt-get install -y slapd ldap-utils + +# Open firewall for ldap/ldaps +iptables -I INPUT 1 -p tcp -m tcp --dport 389 -j ACCEPT -m comment --comment "by murano, OpenLDAP server access on port 389" +iptables -I INPUT 1 -p tcp -m tcp --dport 636 -j ACCEPT -m comment --comment "by murano, OpenLDAP server access on port 636" diff --git a/murano-apps/OpenLDAP/package/UI/ui.yaml b/murano-apps/OpenLDAP/package/UI/ui.yaml new file mode 100644 index 0000000..50da7f3 --- /dev/null +++ b/murano-apps/OpenLDAP/package/UI/ui.yaml @@ -0,0 +1,104 @@ +Version: 2 + +Application: + ?: + type: io.murano.apps.OpenLDAP + name: $.appConfiguration.name + domain: $.appConfiguration.domain + ldapUser: $.appConfiguration.ldapUser + ldapPass: $.appConfiguration.ldapPass + instance: + ?: + type: io.murano.resources.LinuxMuranoInstance + name: generateHostname($.instanceConfiguration.unitNamingPattern, 1) + flavor: $.instanceConfiguration.flavor + image: $.instanceConfiguration.osImage + keyname: $.instanceConfiguration.keyPair + availabilityZone: $.instanceConfiguration.availabilityZone + assignFloatingIp: $.appConfiguration.assignFloatingIP + +Forms: + - appConfiguration: + fields: + - name: name + type: string + label: Application Name + initial: OpenLDAP + description: >- + Enter a desired name for the application. Just A-Z, a-z, 0-9, dash + and underline are allowed + - name: domain + type: string + label: Domain + initial: domain.tld + required: false + descriptionTitle: Domain + description: >- + Please, provide domain for the OpenLDAP instance + - name: ldapUser + type: string + label: Username + required: false + descriptionTitle: LDAP User + description: >- + Please, provide username + - name: ldapPass + type: password + label: Password + required: false + descriptionTitle: LDAP Password + description: >- + Please, provide password + - name: assignFloatingIP + type: boolean + label: Assign Floating IP + description: >- + Select to true to assign floating IP automatically + initial: true + required: false + - instanceConfiguration: + fields: + - name: title + type: string + required: false + hidden: true + description: Specify some instance parameters on which the application would be created + - name: flavor + type: flavor + label: Instance flavor + description: >- + Select registered in Openstack flavor. Consider that application performance + depends on this parameter. + initial: m1.tiny + required: false + - name: osImage + type: image + imageType: linux + label: Instance image + description: >- + Select a valid image for the application. Image should already be prepared and + registered in glance. + - name: keyPair + type: keypair + label: Key Pair + description: >- + Select a Key Pair to control access to instances. You can login to + instances using this KeyPair after the deployment of application. + required: false + - name: availabilityZone + type: azone + label: Availability zone + description: Select availability zone where the application would be installed. + required: false + - name: unitNamingPattern + type: string + label: Instance Naming Pattern + required: false + maxLength: 200 + regexpValidator: '^[-_\w]+$' + errorMessages: + invalid: Just letters, numbers, underscores and hyphens are allowed. + helpText: Just letters, numbers, underscores and hyphens are allowed. + description: >- + Specify a string, that will be used in instance hostname. + Just A-Z, a-z, 0-9, dash and underline are allowed. diff --git a/murano-apps/OpenLDAP/package/logo.png b/murano-apps/OpenLDAP/package/logo.png new file mode 100644 index 0000000..411a332 Binary files /dev/null and b/murano-apps/OpenLDAP/package/logo.png differ diff --git a/murano-apps/OpenLDAP/package/manifest.yaml b/murano-apps/OpenLDAP/package/manifest.yaml new file mode 100644 index 0000000..29e344b --- /dev/null +++ b/murano-apps/OpenLDAP/package/manifest.yaml @@ -0,0 +1,12 @@ +Format: 1.0 +Type: Application +FullName: io.murano.apps.OpenLDAP +Name: OpenLDAP +Description: | + OpenLDAP is an open source implementation of the Lightweight Directory Access Protocol. +Author: 'Mirantis, Inc' +Tags: [Server, LDAP] +Classes: + io.murano.apps.OpenLDAP: OpenLDAP.yaml +UI: ui.yaml +Logo: logo.png