示例#1
0
 def create_admin_user(self, username, displayname, cluster_name='ceph'):
     try:
         add_io_info = AddIOInfo()
         cmd = 'radosgw-admin user create --uid=%s --display-name=%s --cluster %s' % (
             username, displayname, cluster_name)
         log.info('cmd: %s' % cmd)
         variable = subprocess.Popen(cmd,
                                     stdout=subprocess.PIPE,
                                     shell=True)
         v = variable.stdout.read()
         v_as_json = json.loads(v)
         # log.info(v_as_json)
         user_details = {}
         user_details['user_id'] = v_as_json['user_id']
         user_details['display_name'] = v_as_json['display_name']
         user_details['access_key'] = v_as_json['keys'][0]['access_key']
         user_details['secret_key'] = v_as_json['keys'][0]['secret_key']
         add_io_info.add_user_info(
             **{
                 'user_id': user_details['user_id'],
                 'access_key': user_details['access_key'],
                 'secret_key': user_details['secret_key']
             })
         return user_details
     except subprocess.CalledProcessError as e:
         error = e.output + str(e.returncode)
         log.error(error)
         return False
 def create_admin_user(self, username, displayname, cluster_name="ceph"):
     try:
         add_io_info = AddIOInfo()
         cmd = (
             'radosgw-admin user create --uid="%s" --display-name="%s" --cluster %s'
             % (username, displayname, cluster_name))
         log.info("cmd: %s" % cmd)
         variable = subprocess.Popen(cmd,
                                     stdout=subprocess.PIPE,
                                     shell=True)
         v = variable.stdout.read()
         v_as_json = json.loads(v)
         # log.info(v_as_json)
         user_details = {}
         user_details["user_id"] = v_as_json["user_id"]
         user_details["display_name"] = v_as_json["display_name"]
         user_details["access_key"] = v_as_json["keys"][0]["access_key"]
         user_details["secret_key"] = v_as_json["keys"][0]["secret_key"]
         add_io_info.add_user_info(
             **{
                 "user_id": user_details["user_id"],
                 "access_key": user_details["access_key"],
                 "secret_key": user_details["secret_key"],
             })
         return user_details
     except subprocess.CalledProcessError as e:
         error = e.output + str(e.returncode)
         log.error(error)
         return False
示例#3
0
def test_exec(config):

    test_info = AddTestInfo('create m buckets, n objects and delete')

    try:

        test_info.started_info()
        add_io_info = AddIOInfo()
        read_io_info = ReadIOInfo()
        add_io_info.initialize()

        rgw_service = RGWService()
        quota_mgmt = QuotaMgmt()
        test_config = AddToCephConf()

        if config.shards:
            test_config.set_to_ceph_conf(
                'global', ConfigOpts.rgw_override_bucket_index_max_shards,
                config.shards)

            rgw_service.restart()

            no_of_shards_for_each_bucket = int(config.shards) * int(
                config.bucket_count)

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        for each_user in all_user_details:

            if config.max_objects:
                quota_mgmt.set_bucket_quota(each_user['user_id'],
                                            config.max_objects)
                quota_mgmt.enable_bucket_quota(each_user['user_id'])

            rgw = ObjectOps(config, each_user)

            buckets = rgw.create_bucket()
            rgw.upload(buckets)

        #read_io_info.verify_io()

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo("multipart Upload with cancel and download")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                })

        log.info("multipart upload enabled")

        for each_user in all_user_details:
            config.objects_count = 2

            rgw = ObjectOps(config, each_user)
            buckets = rgw.create_bucket()

            rgw.break_upload_at_part_no = config.break_at_part_no
            rgw.multipart_upload(buckets)

            log.info("starting at part no: %s" % config.break_at_part_no)
            log.info("--------------------------------------------------")

            rgw.break_upload_at_part_no = 0
            rgw.multipart_upload(buckets)
            rgw.download_keys()

        test_info.success_status("test completed")

        sys.exit(0)

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo('multipart Upload with cancel and download')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)


        for each_user in all_user_details:
            add_io_info.add_user_info(**{'user_id': each_user['user_id'],
                                         'access_key': each_user['access_key'],
                                         'secret_key': each_user['secret_key']})


        log.info('multipart upload enabled')

        for each_user in all_user_details:
            config.objects_count = 2

            rgw = ObjectOps(config, each_user)
            buckets = rgw.create_bucket()

            rgw.break_upload_at_part_no = config.break_at_part_no
            rgw.multipart_upload(buckets)

            log.info('starting at part no: %s' % config.break_at_part_no)
            log.info('--------------------------------------------------')

            rgw.break_upload_at_part_no = 0
            rgw.multipart_upload(buckets)
            rgw.download_keys()

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo("create m buckets, n objects and delete")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                }
            )

        for each_user in all_user_details:

            rgw = ObjectOps(config, each_user)
            rgw.bucket_ops.test_op_code = "delete"

            buckets = rgw.create_bucket()
            rgw.upload(buckets, test_op_code="delete")

            rgw.delete_keys()
            time.sleep(15)
            rgw.delete_bucket()

        test_info.success_status("test completed")

        sys.exit(0)

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo(
        "enable versioning on a bucket and upload keys and its versions "
        "and suspend version on the same bucket"
    )

    try:

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                }
            )

        for each_user in all_user_details:

            rgw = ObjectOps(config, each_user)
            rgw.enable_versioning = True
            rgw.version_count = config.version_count
            buckets = rgw.create_bucket()
            rgw.set_bucket_properties()
            rgw.upload(buckets)

            rgw.enable_versioning = False
            rgw.set_bucket_properties()

        test_info.success_status("test completed")

        sys.exit(0)

    except AssertionError as e:
        log.error(e)
        sys.exit(1)
示例#8
0
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    read_io_info = ReadIOInfo()

    test_info = AddTestInfo('create m buckets')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        # write all users details to yaml file.

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        for each_user in all_user_details:
            log.info('User credentials: %s' % each_user)
            rgw = ObjectOps(config, each_user)

            assert rgw.create_bucket()

        #read_io_info.verify_io()

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo('create m buckets, n objects and delete')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        for each_user in all_user_details:

            rgw = ObjectOps(config, each_user)
            rgw.bucket_ops.test_op_code = 'delete'

            buckets = rgw.create_bucket()
            rgw.upload(buckets, test_op_code='delete')

            rgw.delete_keys()
            time.sleep(15)
            rgw.delete_bucket()

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
示例#10
0
def test_exec(config):
    add_io_info = AddIOInfo()
    add_io_info.initialize()

    read_io = ReadIOInfo()

    test_info = AddTestInfo('multipart Upload')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        log.info('multipart upload enabled')

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        for each_user in all_user_details:

            config.objects_count = 1

            rgw = ObjectOps(config, each_user)
            buckets = rgw.create_bucket()

            rgw.multipart_upload(buckets)

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
示例#11
0
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    read_io_info = ReadIOInfo()

    test_info = AddTestInfo("create m buckets")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        # write all users details to yaml file.

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                })

        for each_user in all_user_details:
            log.info("User credentials: %s" % each_user)
            rgw = ObjectOps(config, each_user)

            assert rgw.create_bucket()

        # read_io_info.verify_io()

        test_info.success_status("test completed")

        sys.exit(0)

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
def test_exec(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo('enable versioning on a bucket and upload '
                            'keys and its versions and delete its versions')

    try:

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        for each_user in all_user_details:

            rgw = ObjectOps(config, each_user)
            rgw.enable_versioning = True
            rgw.version_count = config.version_count
            buckets = rgw.create_bucket()
            rgw.set_bucket_properties()
            rgw.upload(buckets)
            rgw.delete_key_version()

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:

        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
示例#13
0
def test_exec_write(config):

    test_info = AddTestInfo(
        'test with write persmission on objects and buckets')

    try:

        # test case starts

        add_io_info = AddIOInfo()
        add_io_info.initialize()

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        user1 = all_user_details[0]
        log.info('user1: %s' % user1)
        user2 = all_user_details[1]
        log.info('user2: %s' % user2)

        u1 = ObjectOps(config, user1)

        u2 = ObjectOps(config, user2)

        u2_canonical_id = u2.canonical_id

        log.info('canonical id of u2: %s' % u2_canonical_id)

        grants = {'permission': 'READ', 'user_id': None, 'recursive': True}

        log.info('write persmission are not set')
        grants['user_id'] = u2_canonical_id

        u1.grants = grants
        u1.create_bucket()

        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created

        u2.json_file_upload = u1.json_file_upload
        u2.json_file_download = u1.json_file_download

        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if not uploaded:
            log.info(
                'no write permission set and hence failing to create object')

        log.info('setting permission to write also')

        grants = {
            'permission': 'WRITE',
            'user_id': u2_canonical_id,
            'recursive': True
        }
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created

        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if uploaded:
            log.info('object created after permission set')

        test_info.success_status('test completed')

    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec_write(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo(
        "give the permission for all the users and then reset it")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:

            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                })

        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        log.info("user1: %s" % user1)

        all_user_details.pop(0)

        for each_user in all_user_details:

            print("iter ------------------>")

            log.info("user2: %s" % each_user)

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info("canonical id of u2: %s" % u2_canonical_id)

            log.info("setting only read permission")

            grants = {"permission": "READ", "user_id": None, "recursive": True}

            log.info("write persmission are not set")
            grants["user_id"] = u2_canonical_id

            u1.grants = grants

            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            u2.create_bucket()
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info(
                    "no write permission set and hence failing to create object"
                )

            elif key_created:
                raise AssertionError("object created even with no permission")

            log.info("setting permission to write also")

            grants = {
                "permission": "WRITE",
                "user_id": u2_canonical_id,
                "recursive": True,
            }
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets,
                                    object_base_name=str(u2.canonical_id) +
                                    ".key")
            if key_created:
                log.info("object created after permission set")

        log.info(
            "***************** removing grants and making the bucket private *****************"
        )
        u1.grants = None
        u1.acls = "private"
        u1.set_bucket_properties()

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            print("iter ------------------>")

            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            buckets = u2.set_bucket_properties()

            if not buckets:
                log.info("bucket init failed: %s" % buckets)
            elif buckets:

                key_created = u2.upload(buckets)
                if not key_created:
                    log.info(
                        "no write permission set and hence failing to create object"
                    )

                elif key_created:
                    raise AssertionError(
                        "object created even with no permission")

        test_info.success_status("test completed")

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
示例#15
0
def test_exec_write(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo(
        'give the permission for all the users and then reset it')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:

            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        log.info('user1: %s' % user1)

        all_user_details.pop(0)

        for each_user in all_user_details:

            print('iter ------------------>')

            log.info('user2: %s' % each_user)

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info('canonical id of u2: %s' % u2_canonical_id)

            log.info('setting only read permission')

            grants = {'permission': 'READ', 'user_id': None, 'recursive': True}

            log.info('write persmission are not set')
            grants['user_id'] = u2_canonical_id

            u1.grants = grants

            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            u2.create_bucket()
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info(
                    'no write permission set and hence failing to create object'
                )

            elif key_created:
                raise AssertionError("object created even with no permission")

            log.info('setting permission to write also')

            grants = {
                'permission': 'WRITE',
                'user_id': u2_canonical_id,
                'recursive': True
            }
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets,
                                    object_base_name=str(u2.canonical_id) +
                                    ".key")
            if key_created:
                log.info('object created after permission set')

        log.info(
            '***************** removing grants and making the bucket private *****************'
        )
        u1.grants = None
        u1.acls = 'private'
        u1.set_bucket_properties()

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            print('iter ------------------>')

            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            buckets = u2.set_bucket_properties()

            if not buckets:
                log.info('bucket init failed: %s' % buckets)
            elif buckets:

                key_created = u2.upload(buckets)
                if not key_created:
                    log.info(
                        'no write permission set and hence failing to create object'
                    )

                elif key_created:
                    raise AssertionError(
                        "object created even with no permission")

        test_info.success_status('test completed')

    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec_write(config):

    test_info = AddTestInfo(
        "test with write persmission on objects and buckets")

    try:

        # test case starts

        add_io_info = AddIOInfo()
        add_io_info.initialize()

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                })

        user1 = all_user_details[0]
        log.info("user1: %s" % user1)
        user2 = all_user_details[1]
        log.info("user2: %s" % user2)

        u1 = ObjectOps(config, user1)

        u2 = ObjectOps(config, user2)

        u2_canonical_id = u2.canonical_id

        log.info("canonical id of u2: %s" % u2_canonical_id)

        grants = {"permission": "READ", "user_id": None, "recursive": True}

        log.info("write persmission are not set")
        grants["user_id"] = u2_canonical_id

        u1.grants = grants
        u1.create_bucket()

        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created

        u2.json_file_upload = u1.json_file_upload
        u2.json_file_download = u1.json_file_download

        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if not uploaded:
            log.info(
                "no write permission set and hence failing to create object")

        log.info("setting permission to write also")

        grants = {
            "permission": "WRITE",
            "user_id": u2_canonical_id,
            "recursive": True
        }
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created

        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if uploaded:
            log.info("object created after permission set")

        test_info.success_status("test completed")

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
示例#17
0
def test_exec_read(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    grants = {'permission': 'READ', 'user_id': None, 'recursive': True}

    test_info = AddTestInfo(
        'Test with read permission on buckets for all users')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        user1 = all_user_details[0]
        log.info('user1: %s' % user1)

        all_user_details.pop(0)

        u1 = ObjectOps(config, user1)

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info('canonical id of u2: %s' % u2_canonical_id)

            grants['user_id'] = u2_canonical_id

            u1.grants = None
            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

            # set permissions and read

            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

        test_info.success_status('test completed')

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
示例#18
0
def test_exec_read(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    grants = {"permission": "READ", "user_id": None, "recursive": True}

    test_info = AddTestInfo("Test with read permission on buckets for all users")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                }
            )

        user1 = all_user_details[0]
        log.info("user1: %s" % user1)

        all_user_details.pop(0)

        u1 = ObjectOps(config, user1)

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info("canonical id of u2: %s" % u2_canonical_id)

            grants["user_id"] = u2_canonical_id

            u1.grants = None
            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

            # set permissions and read

            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

        test_info.success_status("test completed")

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
def test_exec_read(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo('Test with read permission on buckets')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        user1 = all_user_details[0]
        log.info('user1: %s' % user1)
        user2 = all_user_details[1]
        log.info('user2: %s' % user2)

        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)

        u1_grants = {
            'permission': 'READ',
            'user_id': u2.canonical_id,
            'recursive': True
        }
        u2_grants = {
            'permission': 'FULL_CONTROL',
            'user_id': u1.canonical_id,
            'recursive': True
        }

        u1.grants = u1_grants
        u1.create_bucket()
        u1_buckets = u1.set_bucket_properties()
        u1.upload(u1_buckets, object_base_name=u1.canonical_id + '.key')

        all_keys = u1_buckets[0].get_all_keys()

        for key in all_keys:
            log.info('all keys from user 1--------------')
            log.info('name: %s' % key.name)

        u2.grants = u2_grants
        u2.create_bucket()
        u2_buckets = u2.set_bucket_properties()

        bu2 = u1.connection['conn'].get_bucket(u2_buckets[0].name)

        log.info('copying the objects from u1 to u2')

        for each in all_keys:
            bu2.copy_key(each.key, u1_buckets[0].name, each.key)

        all_keys2 = bu2.get_all_keys()

        for key in all_keys2:
            log.info('all keys from user 2--------------')
            log.info('name: %s' % key.name)

        log.info('verifying copied objects--------')

        u2.grants = None
        u2_buckets = u2.set_bucket_properties()

        all_keys3 = u2_buckets[0].get_all_keys()

        for key in all_keys3:
            log.info('all keys from user 2--------------')
            log.info('name: %s' % key.name)

        test_info.success_status('test completed')

    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec_read(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo("Test with read permission on buckets")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                })

        user1 = all_user_details[0]
        log.info("user1: %s" % user1)
        user2 = all_user_details[1]
        log.info("user2: %s" % user2)

        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)

        u1_grants = {
            "permission": "READ",
            "user_id": u2.canonical_id,
            "recursive": True,
        }
        u2_grants = {
            "permission": "FULL_CONTROL",
            "user_id": u1.canonical_id,
            "recursive": True,
        }

        u1.grants = u1_grants
        u1.create_bucket()
        u1_buckets = u1.set_bucket_properties()
        u1.upload(u1_buckets, object_base_name=u1.canonical_id + ".key")

        all_keys = u1_buckets[0].get_all_keys()

        for key in all_keys:
            log.info("all keys from user 1--------------")
            log.info("name: %s" % key.name)

        u2.grants = u2_grants
        u2.create_bucket()
        u2_buckets = u2.set_bucket_properties()

        bu2 = u1.connection["conn"].get_bucket(u2_buckets[0].name)

        log.info("copying the objects from u1 to u2")

        for each in all_keys:
            bu2.copy_key(each.key, u1_buckets[0].name, each.key)

        all_keys2 = bu2.get_all_keys()

        for key in all_keys2:
            log.info("all keys from user 2--------------")
            log.info("name: %s" % key.name)

        log.info("verifying copied objects--------")

        u2.grants = None
        u2_buckets = u2.set_bucket_properties()

        all_keys3 = u2_buckets[0].get_all_keys()

        for key in all_keys3:
            log.info("all keys from user 2--------------")
            log.info("name: %s" % key.name)

        test_info.success_status("test completed")

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)