Skip to content

Commit

Permalink
generate gluu-couchabse.properties and couchbase.pkcs12
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Jun 22, 2018
1 parent 77aa32b commit 464a082
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 17 deletions.
74 changes: 57 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,17 @@ def __init__(self, install_dir=None):
self.couchebaseClusterAdmin = 'admin'
self.couchbasePackageFolder = os.path.join(self.distFolder, 'couchbase')
self.couchbaseCli = '/opt/couchbase/bin/couchbase-cli'
self.couchbaseTrustStoreFn = "%s/couchbase.pkcs12" % self.certFolder
self.couchbaseTrustStorePass = 'newsecret'

self.couchebaseBucketClusterPort = 28091
self.couchebaseHost = self.ldap_hostname+':'+ str(self.couchebaseBucketClusterPort)
self.couchebaseIndex = '%s/static/couchebase/index.txt' % self.install_dir
self.couchebaseCbImport = '/opt/couchbase/bin/cbimport'
self.couchebaseCbq = '/opt/couchbase/bin/cbq'
self.couchebaseCert = '/etc/certs/couchbase.pem'

self.couchebaseCert = os.path.join(self.certFolder, 'couchbase.pem')
self.gluuCouchebaseProperties = os.path.join(self.configFolder, 'gluu-couchabse.properties')
self.couchbaseBuckets = []

self.ldif_files = [self.ldif_base,
self.ldif_appliance,
Expand Down Expand Up @@ -1461,6 +1465,7 @@ def encode_passwords(self):
self.encoded_opendj_p12_pass = self.obscure(self.opendj_p12_pass)
self.oxauthClient_pw = self.getPW()
self.oxauthClient_encoded_pw = self.obscure(self.oxauthClient_pw)
self.encoded_couchbaseTrustStorePass = self.obscure(self.couchbaseTrustStorePass)
except:
self.logIt("Error encoding passwords", True)
self.logIt(traceback.format_exc(), True)
Expand Down Expand Up @@ -2081,21 +2086,6 @@ def install_passport(self):
self.installNodeService('passport')


def install_couchebase(self):
self.couchbaseInstall()
self.changeCouchbasePort('rest_port', self.couchebaseBucketClusterPort)
self.restartCouchebase()
self.couchebaseCreateCluster()
self.couchbaseSSL()

#execute this fonctions for 'site' when couchbase is backend
self.couchebaseCreateBucket('gluu')
self.couchebaseCreateIndexes('gluu')

self.import_ldif_couchebase()



def install_gluu_components(self):
if self.installLdap:
progress_bar(27, "Installing Gluu components: LDAP")
Expand Down Expand Up @@ -3496,6 +3486,7 @@ def couchebaseCreateBucket(self, bucketName, bucketType='couchbase', bucketRamsi

self.run(cmd_args)

self.couchbaseBuckets.append(bucketName)

def couchbaseImportJson(self, bucket, jsonFile, keyGen=None):
self.logIt("Importing Couchebase json file %s to bucket %s" % (jsonFile, bucket))
Expand Down Expand Up @@ -3624,6 +3615,55 @@ def couchbaseSSL(self):
self.logIt("Running command: " + ' '.join(cmd_args))
os.system(' '.join(cmd_args))

cmd_args = [self.cmd_keytool, "-import", "-trustcacerts", "-alias", "%s_couchbase" % self.hostname, \
"-file", self.couchebaseCert, "-keystore", self.couchbaseTrustStoreFn, \
"-storepass", self.couchbaseTrustStorePass, "-noprompt"]

self.run(cmd_args)


def couchbaseProperties(self):
prop_file = os.path.basename(self.gluuCouchebaseProperties)
prop = open(os.path.join(self.templateFolder,prop_file)).read()


prop_dict = {
'couchbase_servers': 'localhost',
'couchbase_servers': 'localhost',
'couchbase_buckets': ' '.join(self.couchbaseBuckets),
'default_bucket': 'gluu',
'user_mapping': 'people, groups',
'session_mapping': 'sessions',
'static_mapping': 'statistic',
'site_mapping': 'site',
'encryption_method': 'CRYPT-SHA-256',
'ssl_enabled': 'true',
'couchbaseTrustStoreFn': self.couchbaseTrustStoreFn,
'encoded_couchbaseTrustStorePass': self.encoded_couchbaseTrustStorePass,
}

prop = prop % prop_dict

out_file = os.path.join(self.outputFolder, prop_file)
self.writeFile(out_file, prop)
self.writeFile(self.gluuCouchebaseProperties, prop)



def install_couchebase(self):
self.couchbaseInstall()
self.changeCouchbasePort('rest_port', self.couchebaseBucketClusterPort)
self.restartCouchebase()
self.couchebaseCreateCluster()
self.couchbaseSSL()

#execute this fonctions for 'site' when couchbase is backend
self.couchebaseCreateBucket('gluu')
self.couchebaseCreateIndexes('gluu')

self.import_ldif_couchebase()
self.couchbaseProperties()

############################ Main Loop #################################################

def print_help():
Expand Down
15 changes: 15 additions & 0 deletions templates/gluu-couchabse.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
servers: %(couchbase_servers)s
buckets: %(couchbase_buckets)s

bucket.default: %(default_bucket)s
bucket.gluu_user.mapping: %(user_mapping)s
bucket.gluu_session.mapping: %(session_mapping)s
bucket.gluu_statistic.mapping: %(static_mapping)s
bucket.gluu_site.mapping: %(site_mapping)s

password.encryption.method: %(encryption_method)s

ssl.enable: %(ssl_enabled)s
ssl.trustStoreFile: %(couchbaseTrustStoreFn)s
ssl.trustStorePin: %(encoded_couchbaseTrustStorePass)s
ssl.trustStoreFormat: pkcs12

0 comments on commit 464a082

Please sign in to comment.