예제 #1
0
    def s3_bucket_list(namespace, projectname, uid, secret):
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        # use projectname if the api supports it
        # check this below line
        _headers = common.s3_hmac_base64_sig(
            'GET',
            None,
            None,
            uid,
            secret,
            'application/json',
            _headers,
            None)

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "GET",
                                             self.URI_S3_SERVICE_BASE, None,
                                             None, False,
                                             'application/json',
                                             None, _headers)

        o = common.json_decode(s)

        return o
예제 #2
0
    def s3_key_list_versions(namespace, bucket, key, uid, secret ):
	'''
        Makes a REST API call to list versions of a S3 key value pair
        Parameters:           
            key:  label of the key
            bucket:  label of the bucket
	    uid:	user id
	    secret:	secret
 	    namespace:	namespace
        Returns:
            JSON payload of key list
	'''
	_headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

	qparms = {'versions': None}

	_headers = common.s3_hmac_base64_sig('GET', bucket, None , uid, secret , 'application/json' , _headers, qparms )
	
	uri = URI_S3_KEY_INSTANCE.format(bucket, key)

	if (qparms):
            for qk in qparms.iterkeys():
                if (qparms[qk] != None):
                    uri += '&' if ('?' in uri) else '?'
                    uri += qk + '=' + qparms[qk]

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT , "GET",
                                             uri , None , None, False ,
                                             'application/octet-stream', None, _headers), 's3'

	o = json_decode(s)

	return o
예제 #3
0
    def s3_bucket_create(self,
                         namespace,
                         bucket,
                         projecturi,
                         vpooluri,
                         uid,
                         secret):
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        if _headers.get("x-amz-date") is None:
            _headers['Date'] = formatdate()

        _headers = common.s3_hmac_base64_sig(
            'PUT',
            bucket,
            None,
            uid,
            secret,
            'application/json',
            _headers,
            None)

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "PUT",
                                             self.URI_S3_BUCKET_INSTANCE.
                                             format(bucket), None, None, False,
                                             'application/json',
                                             None, _headers)

        o = common.json_decode(s)

        return o
예제 #4
0
    def s3_bucket_update(self, namespace, bucket, versioning, uid, secret):
        headers = dict()

        # chekc this
        qparms = {'versioning': None}

        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        _headers = common.s3_hmac_base64_sig(
            'PUT',
            bucket,
            None,
            uid,
            secret,
            'application/json',
            _headers,
            qparms)

        root = ET.Element('VersioningConfiguration')
        root.set('xmlns', S3_XML_NS)
        ET.SubElement(root, 'Status').text = versioning
        parms = ET.tostring(root)

        uri = URI_S3_BUCKET_INSTANCE.format(bucket)

        body = None

        if(parms):
            body = cjson.encode(parms)

        if (qparms):
            uri += "?"
            first = True
            for qk in qparms.iterkeys():
                if (not first):
                    uri += '&'
                    uri += qk
                else:
                    first = False
                    uri += qk

                if (qparms[qk] is not None):
                    uri += '=' + qparms[qk]

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "PUT",
                                             uri, body, None, False,
                                             'application/json',
                                             None, _headers)

        o = common.json_decode(s)
예제 #5
0
    def s3_key_list(namespace, bucket, uid, secret ):
	_headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

	_headers = common.s3_hmac_base64_sig('GET', bucket, None , uid, secret , 'application/json' , _headers, qparms )
	
	uri = URI_S3_BUCKET_INSTANCE.format(bucket)

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT , "GET",
                                             uri , None , None, False ,
                                             'application/json', None, _headers, 's3')

	o = json_decode(s)

	return o
예제 #6
0
    def s3_bucket_delete(namespace, bucket, uid, secret):
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        _headers = common.s3_hmac_base64_sig('DELETE', bucket, None, uid,
                                             secret, 'application/json',
                                             _headers, None)

        (s, h) = common.service_json_request(
            self.__ipAddr, S3_PORT, "DELETE",
            URI_S3_BUCKET_INSTANCE.format(bucket), None, None, False,
            'application/json', None, _headers)

        o = common.json_decode(s)

        return o
예제 #7
0
    def s3_bucket_update(self, namespace, bucket, versioning, uid, secret):
        headers = dict()

        # chekc this
        qparms = {'versioning': None}

        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        _headers = common.s3_hmac_base64_sig('PUT', bucket, None, uid, secret,
                                             'application/json', _headers,
                                             qparms)

        root = ET.Element('VersioningConfiguration')
        root.set('xmlns', S3_XML_NS)
        ET.SubElement(root, 'Status').text = versioning
        parms = ET.tostring(root)

        uri = URI_S3_BUCKET_INSTANCE.format(bucket)

        body = None

        if (parms):
            body = cjson.encode(parms)

        if (qparms):
            uri += "?"
            first = True
            for qk in qparms.iterkeys():
                if (not first):
                    uri += '&'
                    uri += qk
                else:
                    first = False
                    uri += qk

                if (qparms[qk] is not None):
                    uri += '=' + qparms[qk]

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "PUT",
                                             uri, body, None, False,
                                             'application/json', None,
                                             _headers)

        o = common.json_decode(s)
예제 #8
0
    def s3_key_list(namespace, bucket, uid, secret):
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        _headers = common.s3_hmac_base64_sig('GET', bucket, None, uid, secret,
                                             'application/json', _headers,
                                             qparms)

        uri = URI_S3_BUCKET_INSTANCE.format(bucket)

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "GET",
                                             uri, None, None, False,
                                             'application/json', None,
                                             _headers, 's3')

        o = json_decode(s)

        return o
예제 #9
0
    def s3_bucket_list(namespace, projectname, uid, secret):
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        # use projectname if the api supports it
        # check this below line
        _headers = common.s3_hmac_base64_sig('GET', None, None, uid, secret,
                                             'application/json', _headers,
                                             None)

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "GET",
                                             self.URI_S3_SERVICE_BASE, None,
                                             None, False, 'application/json',
                                             None, _headers)

        o = common.json_decode(s)

        return o
예제 #10
0
    def s3_bucket_create(self, namespace, bucket, projecturi, vpooluri, uid,
                         secret):
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        if _headers.get("x-amz-date") is None:
            _headers['Date'] = formatdate()

        _headers = common.s3_hmac_base64_sig('PUT', bucket, None, uid, secret,
                                             'application/json', _headers,
                                             None)

        (s, h) = common.service_json_request(
            self.__ipAddr, S3_PORT, "PUT",
            self.URI_S3_BUCKET_INSTANCE.format(bucket), None, None, False,
            'application/json', None, _headers)

        o = common.json_decode(s)

        return o
예제 #11
0
    def s3_key_list_versions(namespace, bucket, key, uid, secret):
        '''
        Makes a REST API call to list versions of a S3 key value pair
        Parameters:           
            key:  label of the key
            bucket:  label of the bucket
	    uid:	user id
	    secret:	secret
 	    namespace:	namespace
        Returns:
            JSON payload of key list
	'''
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        qparms = {'versions': None}

        _headers = common.s3_hmac_base64_sig('GET', bucket, None, uid, secret,
                                             'application/json', _headers,
                                             qparms)

        uri = URI_S3_KEY_INSTANCE.format(bucket, key)

        if (qparms):
            for qk in qparms.iterkeys():
                if (qparms[qk] != None):
                    uri += '&' if ('?' in uri) else '?'
                    uri += qk + '=' + qparms[qk]

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "GET",
                                             uri, None, None, False,
                                             'application/octet-stream', None,
                                             _headers), 's3'

        o = json_decode(s)

        return o
예제 #12
0
    def s3_bucket_delete(namespace, bucket, uid, secret):
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        _headers = common.s3_hmac_base64_sig(
            'DELETE',
            bucket,
            None,
            uid,
            secret,
            'application/json',
            _headers,
            None)

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "DELETE",
                                             URI_S3_BUCKET_INSTANCE.format(
                                                 bucket), None, None, False,
                                             'application/json',
                                             None, _headers)

        o = common.json_decode(s)

        return o