Example #1
0
 def _validateParameters(self):
     Util.printStep('Validating parameters')
     if not self.registrationLdapScheme:
         raise ValidationException('registration_ldap_scheme is not defined')
     if not self.registrationLdapHost:
         raise ValidationException('registration_ldap_host is not defined')
     if not self.registrationLdapPort:
         raise ValidationException('registration_ldap_port is not defined')
     if not self.registrationLdapManagerDn:
         raise ValidationException('registration_ldap_manager_dn is not defined')
     if not self.registrationLdapManagerPassword:
         raise ValidationException('registration_ldap_manager_password is not defined')
     if not self.registrationAdminEmail:
         raise ValidationException('registration_admin_email is not defined')
     if not self.registrationMailHost:
         raise ValidationException('registration_mail_host is not defined')
     if not self.registrationMailPort:
         raise ValidationException('registration_mail_port is not defined')
     if not self.registrationMailUser:
         raise ValidationException('registration_mail_user is not defined')
     if not self.registrationMailPassword:
         raise ValidationException('registration_mail_password is not defined')
     if not self.registrationMailSsl:
         raise ValidationException('registration_mail_ssl is not defined')
     if not self.registrationMailDebug:
         raise ValidationException('registration_mail_debug is not defined')
     if not self.registrationSslTruststore:
         self.registrationSslTruststore = ''
Example #2
0
    def _installPackages(self):
        Util.printStep('Removing CIMI server package')
        cmd = 'yum erase -y %s' % self._package
        self._executeExitOnError(cmd)

        Util.printStep('Installing CIMI server package')
        cmd = 'yum install --nogpgcheck -y %s' % self._package
        self._executeExitOnError(cmd)
Example #3
0
    def configureDhcpServer(self):

        def _dhcpDefined():
            return Util.isTrueConfVal(getattr(self, 'dhcp', 'False'))
        def _dhcpNetTypesDefined():
            return any([Util.isTrueConfVal(getattr(self, self._assembleDhcpAttributeName(v), 'False'))
                                                for v in self.NET_TYPES_DHCP])

        if not _dhcpDefined():
            return
        elif not _dhcpNetTypesDefined():
            return

        Util.printStep('Configuring DHCP service')
        self._installDhcp()
        self._confgureDhcp()
        self._startDhcp()
Example #4
0
    def _setupFrontend(self):
        self._cleanConfiguration()
        self._checkConfiguration()

        Util.printStep('configure firewall')
        self._configureFirewall()

        Util.printStep('configure sudo')
        self._configureSudo()

        Util.printStep('configure cloud')
        self._configureCloud()
Example #5
0
 def _restartService(self):
     Util.printStep('Adding %s to chkconfig and restarting' % self._serviceName)
     cmd = 'chkconfig --add %s' % self._serviceName
     Util.execute(cmd.split(' '))
     cmd = 'service %s restart' % self._serviceName
     Util.execute(cmd.split(' '))
Example #6
0
    def _installPackagesOnNode(self):
        Util.printStep('Setting up Couchbase yum repository on node')
        cmd = 'curl --output %s %s' % (self._repofile, self._repourl)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep('Removing Couchbase python client')
        try:
            cmd = 'pip uninstall -y couchbase'
            rc, output = self.system._nodeShell(cmd.split(' '),
                                      withOutput=True,
				      shell=True)	
            if rc != 0:
                Util.printInfo('Couchbase python client NOT removed')
            else:
                Util.printInfo('Couchbase python client removed')
        except:
            Util.printInfo("Couchbase python client NOT removed")

        Util.printStep('Removing Couchbase C client')
        cmd = 'yum erase -y %s' % ' '.join(self._pkgs)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep('Installing Couchbase C client')
        cmd = 'yum install -y %s' % ' '.join(self._pkgs)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep('Installing Couchbase python client dependencies')
        cmd = 'yum install --nogpgcheck -y %s' % ' '.join(self._deps)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep('Installing Couchbase python client')
        cmd = 'pip install couchbase'
        self._executeOnNodeExitOnError(cmd)
Example #7
0
    def _installPackages(self):
        Util.printStep('Setting up Couchbase yum repository')
        cmd = 'curl --output %s %s' % (self._repofile, self._repourl)
        self._executeExitOnError(cmd)

        Util.printStep('Removing Couchbase python client')
        try:
            cmd = 'pip uninstall -y couchbase'
            rc, output = Util.execute(cmd.split(' '),
                                      withOutput=True,
                                      verboseLevel=self.verboseLevel,
                                      verboseThreshold=Util.VERBOSE_LEVEL_DETAILED)
            if rc != 0:
                Util.printInfo('Couchbase python client NOT removed')
            else:
                Util.printInfo('Couchbase python client removed')
        except:
            Util.printInfo("Couchbase python client NOT removed")

        Util.printStep('Removing Couchbase C client')
        cmd = 'yum erase -y %s' % ' '.join(self._pkgs)
        self._executeExitOnError(cmd)

        Util.printStep('Installing Couchbase C client')
        cmd = 'yum install -y %s' % ' '.join(self._pkgs)
        self._executeExitOnError(cmd)

        Util.printStep('Installing Couchbase python client dependencies')
        cmd = 'yum install -y %s' % ' '.join(self._deps)
        self._executeExitOnError(cmd)

        Util.printStep('Upgrading pip for Couchbase python client')
        cmd = 'pip install --upgrade pip'
        self._executeExitOnError(cmd)

        Util.printStep('Installing Couchbase python client')
        cmd = 'pip install couchbase'
        self._executeExitOnError(cmd)
Example #8
0
 def _restartService(self, service):
     Util.printStep("Adding registration service to chkconfig and restarting")
     cmd = 'chkconfig --add %s' % service
     Util.execute(cmd.split(' '))
     cmd = 'service %s restart' % service
     Util.execute(cmd.split(' '))
Example #9
0
    def _installPackages(self):
        Util.printStep("Setting up Couchbase yum repository")
        cmd = "curl --output %s %s" % (self._repofile, self._repourl)
        self._executeExitOnError(cmd)

        Util.printStep("Removing Couchbase python client")
        try:
            cmd = "pip uninstall -y couchbase"
            rc, output = Util.execute(
                cmd.split(" "),
                withOutput=True,
                verboseLevel=self.verboseLevel,
                verboseThreshold=Util.VERBOSE_LEVEL_DETAILED,
            )
            if rc != 0:
                Util.printInfo("Couchbase python client NOT removed")
            else:
                Util.printInfo("Couchbase python client removed")
        except:
            Util.printInfo("Couchbase python client NOT removed")

        Util.printStep("Removing Couchbase C client")
        cmd = "yum erase -y %s" % " ".join(self._pkgs)
        self._executeExitOnError(cmd)

        Util.printStep("Installing Couchbase C client")
        cmd = "yum install -y %s" % " ".join(self._pkgs)
        self._executeExitOnError(cmd)

        Util.printStep("Installing Couchbase python client dependencies")
        cmd = "yum install -y %s" % " ".join(self._deps)
        self._executeExitOnError(cmd)

        Util.printStep("Installing Couchbase python client")
        cmd = "pip install couchbase"
        self._executeExitOnError(cmd)
Example #10
0
    def _configure(self):
        Util.printStep('(Re-)starting Couchbase')
        cmd = 'service %s restart' % self._serviceName
        self._executeExitOnError(cmd)

        time.sleep(5)

        Util.printStep('Set Couchbase data location')
        options = ['--node-init-data-path=/opt/couchbase/var/lib/couchbase/data']
        cmd = CouchbaseServer._cb_cmd('node-init', self.frontendIp, options)
        self._executeExitOnError(cmd)

        Util.printStep('Create default Couchbase bucket')
        options = ['--bucket=default',
                   '--bucket-type=couchbase',
                   '--bucket-ramsize=400',
                   '--bucket-replica=1']
        cmd = CouchbaseServer._cb_cmd('bucket-create', self.frontendIp, options)
        self._executeExitOnError(cmd)

        Util.printStep('Initialize Couchbase admin account')
        options = ['--cluster-init-username=%s' % self._cb_cluster_username,
                   '--cluster-init-password=%s' % self._cb_cluster_password]
        cmd = CouchbaseServer._cb_cmd('cluster-init', self.frontendIp, options)
        self._executeExitOnError(cmd)

        Util.printStep('Saving cluster password in %s' % self._cb_cluster_password_path)
        with open(self._cb_cluster_password_path, 'w') as f:
            f.write(self._cb_cluster_password + "\n")

        Util.printStep('Reducing read access to password file')
        os.chmod(self._cb_cluster_password_path, 0400)
Example #11
0
 def _installCAs(self):
     Util.printStep('Installing CAs and VOMS configuration')
     self.system.installCAs()
Example #12
0
    def _configure(self):
        Util.printStep('Configuring OpenLDAP server')

        Util.printStep('Updating sysconfig')
        shutil.copyfile(self._sysconfigLdapTemplate, self._sysconfigLdap)
        Util.appendOrReplaceInFile(self._sysconfigLdap, 'SLAPD_LDAP=', 'SLAPD_LDAP=yes')

        Util.printStep('Setting root account access')
        Util.appendOrReplaceMultilineBlockInFile(self._openLdapConfig, 
                                                 self._accessValue, 
                                                 start='olcAccess: {0}to *', 
                                                 until='olcAddContentAcl:')

        Util.printStep('(Re-)starting slapd')
        cmd = 'service %s restart' % self._serviceName
        self._executeExitOnError(cmd)

        Util.printStep('Generating test certificate and moving into place')
        self._executeExitOnError(self._testCertCmd)

        self._executeExitOnError('mkdir -p /etc/openldap/cacerts')
        self._executeExitOnError('mv -f cacrt.jks /etc/openldap/cacerts/cacrt.jks')
        self._executeExitOnError('mv -f cacrt.pem /etc/openldap/cacerts/cacrt.pem')
        self._executeExitOnError('mv -f serverkey.pem /etc/openldap/serverkey.pem')
        self._executeExitOnError('mv -f servercrt.pem /etc/openldap/servercrt.pem')

        os.chmod('/etc/openldap/serverkey.pem', stat.S_IRUSR | stat.S_IWUSR)
        self._executeExitOnError('chown ldap:ldap /etc/openldap/serverkey.pem')

        Util.printStep('Updating server config. for generated certs')
        cmd = "ldapmodify -Y EXTERNAL -H ldapi:/// -f %s" % self._certConfigLdif
        Util.execute(cmd.split(' '))

        Util.printStep('Updating client config. for generated certs')
        Util.appendOrReplaceInFile(self._ldapClientConfig,
                                   'TLS_CACERT', 
                                   'TLS_CACERT /etc/openldap/cacerts/cacrt.pem')

        Util.printStep('Creating o=cloud database')
        Util.filePutContent(self._completeDatabaseTemplate,
                            Util.fileGetContent(self._databaseTemplate) % self.__dict__)

        cmd = "ldapadd -Y EXTERNAL -H ldapi:/// -f %s" % self._completeDatabaseTemplate
        Util.execute(cmd.split(' '))

        Util.printStep('Adding cloud database entries')
        cmd = "ldapadd -x -H ldaps://%s -D %s -w %s -f %s" % (self._nodename,
                                                              self._openLdapAdminDn, 
                                                              self.openldapPassword, 
                                                              self._cloudDatabaseSkeleton)
        self._executeExitOnError(cmd)
Example #13
0
 def _startServicesFrontend(self):
     Util.printStep('restart cloud system')
     self.system.startCloudSystem()
Example #14
0
    def _installPackagesOnNode(self):
        Util.printStep("Setting up Couchbase yum repository on node")
        cmd = "curl --output %s %s" % (self._repofile, self._repourl)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep("Removing Couchbase python client")
        try:
            cmd = "pip uninstall -y couchbase"
            rc, output = self.system._nodeShell(cmd.split(" "), withOutput=True, shell=True)
            if rc != 0:
                Util.printInfo("Couchbase python client NOT removed")
            else:
                Util.printInfo("Couchbase python client removed")
        except:
            Util.printInfo("Couchbase python client NOT removed")

        Util.printStep("Removing Couchbase C client")
        cmd = "yum erase -y %s" % " ".join(self._pkgs)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep("Installing Couchbase C client")
        cmd = "yum install -y %s" % " ".join(self._pkgs)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep("Installing Couchbase python client dependencies")
        cmd = "yum install --nogpgcheck -y %s" % " ".join(self._deps)
        self._executeOnNodeExitOnError(cmd)

        Util.printStep("Installing Couchbase python client")
        cmd = "pip install couchbase"
        self._executeOnNodeExitOnError(cmd)
Example #15
0
 def _setupFrontend(self):
     if os.path.exists(self._cb_cluster_password_path):
         Util.printStep('%s exists; skipping Couchbase configuration' % self._cb_cluster_password_path)
     else:
         self._configure()
Example #16
0
 def _installPackages(self):
     Util.printStep('Installing Couchbase packages')
     self.system.installPackages(self._packages)
Example #17
0
 def printStep(self, msg):
     Util.printStep(msg)
Example #18
0
 def _printStep(self, msg):
     Util.printStep(msg)
     self._notifyOnStep(msg)
Example #19
0
    def start(self):
        Util.printAction('Starting image upload')

        Util.printStep('Compressing image')
        self._compressImage()

        Util.printStep('Uploading image')
        self._uploadImage()

        if not self.imageOnly:
            Util.printAction('Starting manifest upload')

            Util.printStep('Parsing manifest')
            self._parseManifest()

            Util.printStep('Updating manifest')
            self._updateManifest()

            Util.printStep('Signing manifest')
            self._signManifest()

            Util.printStep('Uploading manifest')
            self._uploadMarketplaceManifest()