def cluster_acl_info(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster acl list operation.""" cluster_id = data[RequestKey.CLUSTER_ID] def_entity_service = entity_service.DefEntityService( op_ctx.cloudapi_client) # noqa: E501 def_entity = def_entity_service.get_entity(cluster_id) rde_utils.raise_error_if_tkgm_cluster_operation( def_entity.entity.kind) # noqa: E501 query = data.get(RequestKey.QUERY_PARAMS, {}) page = int( query.get(PaginationKey.PAGE_NUMBER, CSE_PAGINATION_FIRST_PAGE_NUMBER)) # noqa: E501 page_size = int( query.get(PaginationKey.PAGE_SIZE, CSE_PAGINATION_DEFAULT_PAGE_SIZE)) # noqa: E501 op_ctx.entity_id = data[ RequestKey.CLUSTER_ID] # hack for passing entity id # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory( _get_request_context(op_ctx)).get_cluster_service() # noqa: E501 result: dict = svc.get_cluster_acl_info(cluster_id, page, page_size) # remove duplicate /api path while forming the endpoint url uri = f"{op_ctx.client.get_api_uri().strip('/api')}{data['url']}" return server_utils.create_links_and_construct_paginated_result( base_uri=uri, values=result.get(PaginationKey.VALUES, []), result_total=result.get(PaginationKey.RESULT_TOTAL, 0), page_number=page, page_size=page_size)
def cluster_config(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster config operation. Required data: cluster_id :return: Dict """ cluster_id = data[RequestKey.CLUSTER_ID] def_entity_service = entity_service.DefEntityService( op_ctx.cloudapi_client) # noqa: E501 def_entity: common_models.DefEntity = def_entity_service.get_entity( cluster_id) # noqa: E501 telemetry_handler.record_user_action_details( cse_operation=telemetry_constants.CseOperation.V36_CLUSTER_CONFIG, cse_params={ server_constants.CLUSTER_ENTITY: def_entity, telemetry_constants.PayloadKey.SOURCE_DESCRIPTION: thread_local_data.get_thread_local_data( ThreadLocalData.USER_AGENT) # noqa: E501 }) op_ctx.entity_id = cluster_id # hack for passing entity id svc = cluster_service_factory.ClusterServiceFactory( _get_request_context(op_ctx)).get_cluster_service() # noqa: E501 config_dict = svc.get_cluster_config(cluster_id) config: str = config_dict.get( server_constants.BEHAVIOR_TASK_RESPONSE_RESULT_MESSAGE_KEY, {}).get( server_constants.BEHAVIOR_TASK_RESPONSE_RESULT_CONTENT_MESSAGE_KEY ) # noqa: E501 return_dict = {"message": config} return return_dict
def cluster_upgrade_plan(data, op_ctx: ctx.OperationContext): """Request handler for cluster upgrade-plan operation. :return: List[Tuple(str, str)] """ op_ctx.entity_id = data[ RequestKey.CLUSTER_ID] # hack for passing entity id # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory( _get_request_context(op_ctx)).get_cluster_service() # noqa: E501 return svc.get_cluster_upgrade_plan(data[RequestKey.CLUSTER_ID])
def cluster_acl_update(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster acl update operation.""" cluster_id = data[RequestKey.CLUSTER_ID] def_entity_service = entity_service.DefEntityService( op_ctx.cloudapi_client) # noqa: E501 def_entity = def_entity_service.get_entity(cluster_id) rde_utils.raise_error_if_tkgm_cluster_operation( def_entity.entity.kind) # noqa: E501 op_ctx.entity_id = data[ RequestKey.CLUSTER_ID] # hack for passing entity id # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory( _get_request_context(op_ctx)).get_cluster_service() # noqa: E501 update_acl_entries = data.get(RequestKey.INPUT_SPEC, {}).get( ClusterAclKey.ACCESS_SETTING) # noqa: E501 svc.update_cluster_acl(cluster_id, update_acl_entries)
def cluster_info(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster info operation. Required data: cluster_name Optional data and default values: org_name=None, ovdc_name=None (data validation handled in broker) :return: Dict """ op_ctx.entity_id = data[ RequestKey.CLUSTER_ID] # hack for passing entity id # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory( _get_request_context(op_ctx)).get_cluster_service() # noqa: E501 cluster_id = data[RequestKey.CLUSTER_ID] return svc.get_cluster_info(cluster_id).to_dict()
def cluster_force_delete(data: dict, op_ctx: ctx.OperationContext): """Request handler for force cluster delete operation. Required data: cluster_name Optional data and default values: org_name=None, ovdc_name=None (data validation handled in broker) :return: Dict """ cluster_id = data[RequestKey.CLUSTER_ID] def_entity_service = entity_service.DefEntityService( op_ctx.cloudapi_client) # noqa: E501 def_entity: common_models.DefEntity = def_entity_service.get_entity( cluster_id) # noqa: E501 op_ctx.entity_id = cluster_id svc = cluster_service_factory.ClusterServiceFactory( _get_request_context(op_ctx)).get_cluster_service() # noqa: E501 task_href = svc.force_delete_cluster(cluster_id) def_entity.entity.status.task_href = task_href return def_entity.to_dict()