def create_bucket(self, bucket_params={}):
        log.info("Connecting Cluster")
        self.connectCluster()
        try:
            bucketSettings = DefaultBucketSettings.builder()

            if bucket_params.get('type') == "memcached":
                bucketSettings.type(BucketType.MEMCACHED)
            elif bucket_params.get('type') == "ephemeral":
                bucketSettings.type(BucketType.EPHEMERAL)
            else:
                bucketSettings.type(BucketType.COUCHBASE)

            bucketSettings.replicas(bucket_params.get('replicas'))
            bucketSettings.name(bucket_params.get('name'))
            bucketSettings.quota(bucket_params.get('size'))
            bucketSettings.enableFlush(bucket_params.get('flushEnabled'))
            bucketSettings.indexReplicas(
                bucket_params.get('enable_replica_index'))
            bucketSettings.build()
            self.clusterManager.insertBucket(bucketSettings)
            log.info("Disconnecting Cluster")
            self.disconnectCluster()
            return True
        except BucketDoesNotExistException as e:
            log.info(e)
            log.info("Disconnecting Cluster")
            self.disconnectCluster()
            return False
        except AuthenticationException as e:
            log.info(e)
            log.info("Disconnecting Cluster")
            self.disconnectCluster()
            return False
Esempio n. 2
0
    def create_bucket(self, bucket_params=dict()):
        self.log.debug("Connecting Cluster")
        self.connectCluster()
        try:
            bucketSettings = DefaultBucketSettings.builder()

            if bucket_params.get('bucketType') == "memcached":
                bucketSettings.type(BucketType.MEMCACHED)
            elif bucket_params.get('bucketType') == "ephemeral":
                bucketSettings.type(BucketType.EPHEMERAL)
            else:
                bucketSettings.type(BucketType.COUCHBASE)

            bucketSettings.replicas(bucket_params.get('replicaNumber'))
            bucketSettings.name(bucket_params.get('name'))
            bucketSettings.quota(bucket_params.get('ramQuotaMB'))
            bucketSettings.enableFlush(bucket_params.get('flushEnabled'))
            bucketSettings.indexReplicas(bucket_params.get('replicaIndex'))
            bucketSettings.build()
            self.clusterManager.insertBucket(bucketSettings)
            self.log.debug("Disconnecting Cluster")
            self.disconnectCluster()
            return True
        except BucketDoesNotExistException as e:
            self.log.error(e)
            self.log.debug("Disconnecting Cluster")
            self.disconnectCluster()
            return False
        except AuthenticationException as e:
            self.log.fatal(e)
            self.log.debug("Disconnecting Cluster")
            self.disconnectCluster()
            return False
    def create_bucket(self,
                      bucket='',
                      ramQuotaMB=1,
                      authType='none',
                      saslPassword='',
                      replicaNumber=1,
                      proxyPort=11211,
                      bucketType='membase',
                      replica_index=1,
                      threadsNumber=3,
                      flushEnabled=1,
                      evictionPolicy='valueOnly',
                      lww=False,
                      maxTTL=None,
                      compressionMode=None,
                      storageBackend="couchstore"):
        log.info("Connecting Cluster")
        self.connectCluster()
        try:
            bucketSettings = DefaultBucketSettings.builder()

            if bucketType == "memcached":
                bucketSettings.type(BucketType.MEMCACHED)
            elif bucketType == "ephemeral":
                bucketSettings.type(BucketType.EPHEMERAL)
            else:
                bucketSettings.type(BucketType.COUCHBASE)

            bucketSettings.password(saslPassword)
            bucketSettings.replicas(replicaNumber)
            bucketSettings.name(bucket)
            bucketSettings.quota(ramQuotaMB)
            bucketSettings.enableFlush(flushEnabled)
            bucketSettings.indexReplicas(replica_index)
            bucketSettings.build()
            self.clusterManager.insertBucket(bucketSettings)
            log.info("Disconnecting Cluster")
            self.disconnectCluster()
            return True
        except BucketDoesNotExistException as e:
            log.info(e)
            log.info("Disconnecting Cluster")
            self.disconnectCluster()
            return False
        except AuthenticationException as e:
            log.info(e)
            log.info("Disconnecting Cluster")
            self.disconnectCluster()
            return False