src/rgw/setup/rgw.py
def _update_hax_endpoint_and_create_admin(conf: MappedConf):
        """Update motr_ha(hax) endpoint values to rgw config file and create admin."""
        # admin user should be created only on one node.
        # 1. While creating admin user, global lock created in consul kv store.
        # (rgw_consul_index, cortx>rgw>volatile>rgw_lock, machine_id)
        # 2. Before creating admin user.
        #    a. Check for rgw_lock in consul kv store
        #    b. Create user only if lock value is equal to **self** machine_id
        # 3. If user creation attempt failed from this node, delete the lock
        #    so other node can acquire the lock and try user creation.
        # 4. If user creation is successful, update lock value to 'user_created'.

        rgw_consul_idx = f'{const.COMPONENT_NAME}_consul_idx'
        # Get consul url from cortx config.
        consul_url = Rgw._get_consul_url(conf)
        # Check for rgw_lock in consul kv store.
        Log.info('Checking for rgw lock in consul kv store.')
        Rgw._load_rgw_config(rgw_consul_idx, consul_url)
        rgw_lock = Rgw._get_lock(rgw_consul_idx)
        if rgw_lock is True:
            # TODO: Find a way to get current data pod hostname on server node.
            # current_data_node = socket.gethostname().replace('server', 'data')
            # user_status = Rgw._create_admin_on_current_node(conf, current_data_node)

            # if user_status == 0:
            #    Log.info(f'User creation is successful on "{Rgw._machine_id}" node.')
            #    Rgw._set_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY, const.ADMIN_USER_CREATED)
            # else:
            data_pod_hostnames = Rgw._get_data_nodes(conf)
            #    if len(data_pod_hostnames) == 1 and current_data_node == data_pod_hostnames[0]:
            #        Log.error('Admin user creation failed')
            #        Rgw._delete_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY)
            #        raise SetupError(user_status, 'Admin user creation failed on'
            #            f' "{Rgw._machine_id}" node, with all data pods - {data_pod_hostnames}')

            #    data_pod_hostnames.remove(current_data_node)
            for data_pod_hostname in data_pod_hostnames:
                try:
                    Rgw._update_hax_endpoint(conf, data_pod_hostname)
                except SetupError as e:
                    Log.debug(f'Error occured while updating hax endpoints. {e}')
                    continue
                status = Rgw._create_rgw_user(conf)
                if status == 0:
                    Log.info(f'User creation is successful on "{Rgw._machine_id}" node.')
                    Rgw._set_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY, const.ADMIN_USER_CREATED)
                    break
                else:
                    if data_pod_hostname == data_pod_hostnames[-1]:
                        Log.error(f'Admin user creation failed with error code - {status}')
                        Rgw._delete_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY)
                        raise SetupError(status, 'Admin user creation failed on'
                            f' "{Rgw._machine_id}" node, with all data pods - {data_pod_hostnames}')
Update motr_ha(hax) endpoint values to rgw config file and create admin.
Update motr_ha(hax) endpoint values to rgw config file and create admin.
Update motr_ha ( hax ) endpoint values to rgw config file and create admin .
def _update_hax_endpoint_and_create_admin(conf: MappedConf):
        rgw_consul_idx = f'{const.COMPONENT_NAME}_consul_idx'
        consul_url = Rgw._get_consul_url(conf)
        Log.info('Checking for rgw lock in consul kv store.')
        Rgw._load_rgw_config(rgw_consul_idx, consul_url)
        rgw_lock = Rgw._get_lock(rgw_consul_idx)
        if rgw_lock is True:
            data_pod_hostnames = Rgw._get_data_nodes(conf)
            for data_pod_hostname in data_pod_hostnames:
                try:
                    Rgw._update_hax_endpoint(conf, data_pod_hostname)
                except SetupError as e:
                    Log.debug(f'Error occured while updating hax endpoints. {e}')
                    continue
                status = Rgw._create_rgw_user(conf)
                if status == 0:
                    Log.info(f'User creation is successful on "{Rgw._machine_id}" node.')
                    Rgw._set_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY, const.ADMIN_USER_CREATED)
                    break
                else:
                    if data_pod_hostname == data_pod_hostnames[-1]:
                        Log.error(f'Admin user creation failed with error code - {status}')
                        Rgw._delete_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY)
                        raise SetupError(status, 'Admin user creation failed on'
                            f' "{Rgw._machine_id}" node, with all data pods - {data_pod_hostnames}')
def _update_hax_endpoint_and_create_admin ( conf : MappedConf ) : rgw_consul_idx = f'{const.COMPONENT_NAME}_consul_idx' consul_url = Rgw . _get_consul_url ( conf ) Log . info ( 'Checking for rgw lock in consul kv store.' ) Rgw . _load_rgw_config ( rgw_consul_idx , consul_url ) rgw_lock = Rgw . _get_lock ( rgw_consul_idx ) if rgw_lock is True : data_pod_hostnames = Rgw . _get_data_nodes ( conf ) for data_pod_hostname in data_pod_hostnames : try : Rgw . _update_hax_endpoint ( conf , data_pod_hostname ) except SetupError as e : Log . debug ( f'Error occured while updating hax endpoints. {e}' ) continue status = Rgw . _create_rgw_user ( conf ) if status == 0 : Log . info ( f'User creation is successful on "{Rgw._machine_id}" node.' ) Rgw . _set_consul_kv ( rgw_consul_idx , const . CONSUL_LOCK_KEY , const . ADMIN_USER_CREATED ) break else : if data_pod_hostname == data_pod_hostnames [ - 1 ] : Log . error ( f'Admin user creation failed with error code - {status}' ) Rgw . _delete_consul_kv ( rgw_consul_idx , const . CONSUL_LOCK_KEY ) raise SetupError ( status , 'Admin user creation failed on' f' "{Rgw._machine_id}" node, with all data pods - {data_pod_hostnames}' )
Update motr_ha(hax) endpoint values to rgw config file and create admin.
Update motr_ha ( hax ) endpoint values to rgw config file and create admin .
"""Update motr_ha(hax) endpoint values to rgw config file and create admin.""" # admin user should be created only on one node. # 1. While creating admin user, global lock created in consul kv store. # (rgw_consul_index, cortx>rgw>volatile>rgw_lock, machine_id) # 2. Before creating admin user. #    a. Check for rgw_lock in consul kv store #    b. Create user only if lock value is equal to **self** machine_id # 3. If user creation attempt failed from this node, delete the lock #    so other node can acquire the lock and try user creation. # 4. If user creation is successful, update lock value to 'user_created'. # Get consul url from cortx config. # Check for rgw_lock in consul kv store. # TODO: Find a way to get current data pod hostname on server node. # current_data_node = socket.gethostname().replace('server', 'data') # user_status = Rgw._create_admin_on_current_node(conf, current_data_node) # if user_status == 0: #    Log.info(f'User creation is successful on "{Rgw._machine_id}" node.') #    Rgw._set_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY, const.ADMIN_USER_CREATED) # else: #    if len(data_pod_hostnames) == 1 and current_data_node == data_pod_hostnames[0]: #        Log.error('Admin user creation failed') #        Rgw._delete_consul_kv(rgw_consul_idx, const.CONSUL_LOCK_KEY) #        raise SetupError(user_status, 'Admin user creation failed on' #            f' "{Rgw._machine_id}" node, with all data pods - {data_pod_hostnames}') #    data_pod_hostnames.remove(current_data_node)
conf
MappedConf