def cluster_update(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster resize operation. Validate data before actual resize is delegated to cluster service. :return: Defined entity of the native cluster :rtype: container_service_extension.def_.models.DefEntity """ # TODO Reject request if rde_in_use is less than 2.0.0 # TODO find out the RDE version from the request spec # TODO Insert RDE converters and validators cluster_id = data[RequestKey.CLUSTER_ID] rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) NativeEntityClass = rde_factory.get_rde_model(rde_in_use) cluster_entity_spec: AbstractNativeEntity = \ NativeEntityClass(**data[RequestKey.INPUT_SPEC]) # noqa: E501 curr_entity = svc.entity_svc.get_entity(cluster_id) is_upgrade_operation = \ request_utils.validate_cluster_update_request_and_check_cluster_upgrade( # noqa: E501 asdict(cluster_entity_spec.spec), asdict(curr_entity.entity.spec)) if is_upgrade_operation: return asdict(svc.upgrade_cluster(cluster_id, cluster_entity_spec)) return asdict(svc.resize_cluster(cluster_id, cluster_entity_spec))
def cluster_update(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster update operation. :return: Defined entity of the native cluster :rtype: container_service_extension.def_.models.DefEntity """ cluster_id = data[RequestKey.CLUSTER_ID] input_entity: dict = data[RequestKey.INPUT_SPEC] # Validate the input # ToDo: Should the validation be done using a v36 client? rde_validator_factory.get_validator( rde_version=rde_constants.RDEVersion.RDE_2_0_0). \ validate(cloudapi_client=op_ctx.cloudapi_client, entity_id=cluster_id, entity=input_entity, operation=BehaviorOperation.UPDATE_CLUSTER) # TODO Insert RDE converter if needed. # Call the backend to initiate the cluster update operation. rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) NativeEntityClass: Type[AbstractNativeEntity] = rde_factory.get_rde_model( rde_in_use) # noqa: E501 cluster_entity: AbstractNativeEntity = \ NativeEntityClass.from_dict(input_entity) return svc.update_cluster(cluster_id, cluster_entity).to_dict()
def cluster_upgrade_plan(data, op_ctx: ctx.OperationContext): """Request handler for cluster upgrade-plan operation. :return: List[Tuple(str, str)] """ svc = cluster_service_factory.ClusterServiceFactory(op_ctx).get_cluster_service() # noqa: E501 return svc.get_cluster_upgrade_plan(data[RequestKey.CLUSTER_ID])
def create_cluster(behavior_ctx: BehaviorRequestContext): entity_id: str = behavior_ctx.entity_id input_entity: dict = behavior_ctx.entity cloudapi_client: CloudApiClient = behavior_ctx.op_ctx.cloudapi_client payload_version: str = input_entity.get( rde_constants.PayloadKey.PAYLOAD_VERSION) # noqa: E501 rde_utils.raise_error_if_unsupported_payload_version(payload_version) # Validate the Input payload based on the (Operation, payload_version). # Get the validator based on the payload_version input_rde_version = rde_constants.MAP_INPUT_PAYLOAD_VERSION_TO_RDE_VERSION[ payload_version] # noqa: E501 rde_validator_factory.get_validator( rde_version=input_rde_version). \ validate(cloudapi_client=cloudapi_client, entity=input_entity) # Convert the input entity to runtime rde format. # Based on the runtime rde, call the appropriate backend method. converted_input_entity = rde_utils.convert_input_rde_to_runtime_rde_format( input_entity) # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory( behavior_ctx).get_cluster_service() # noqa: E501 return svc.create_cluster( entity_id=entity_id, input_native_entity=converted_input_entity) # noqa: E501
def cluster_acl_info(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster acl list operation.""" rde_in_use = server_utils.get_rde_version_in_use() # Redirect to generic handler if the backend supports RDE-2.0 if semantic_version.Version(rde_in_use) >= semantic_version.Version( rde_constants.RDEVersion.RDE_2_0_0.value): # noqa: E501 return cluster_handler.cluster_acl_info(data=data, op_ctx=op_ctx) svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) cluster_id = data[RequestKey.CLUSTER_ID] 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 result: dict = svc.get_cluster_acl_info(cluster_id, page, page_size) 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_upgrade(data, op_ctx: ctx.OperationContext): """Request handler for cluster upgrade operation. Validate data before actual upgrade is delegated to cluster service. :return: Dict """ rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) # TODO find out the RDE version from the request spec # TODO Insert RDE converters and validators NativeEntityClass = rde_factory.get_rde_model(rde_in_use) cluster_entity_spec: AbstractNativeEntity = \ NativeEntityClass(**data[RequestKey.INPUT_SPEC]) cluster_id = data[RequestKey.CLUSTER_ID] curr_entity = svc.entity_svc.get_entity(cluster_id) request_utils.validate_request_payload( asdict(cluster_entity_spec.spec), asdict(curr_entity.entity.spec), exclude_fields=[ FlattenedClusterSpecKey.TEMPLATE_NAME.value, FlattenedClusterSpecKey.TEMPLATE_REVISION.value ]) return asdict(svc.upgrade_cluster(cluster_id, cluster_entity_spec))
def cluster_resize(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster resize operation. Validate data before actual resize is delegated to cluster service. :return: Defined entity of the native cluster :rtype: container_service_extension.def_.models.DefEntity """ rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) cluster_id = data[RequestKey.CLUSTER_ID] # TODO find out the RDE version from the request spec # TODO Insert RDE converters and validators NativeEntityClass = rde_factory.get_rde_model(rde_in_use) cluster_entity_spec: AbstractNativeEntity = \ NativeEntityClass(**data[RequestKey.INPUT_SPEC]) # noqa: E501 curr_entity = svc.entity_svc.get_entity(cluster_id) request_utils.validate_request_payload( asdict(cluster_entity_spec.spec), asdict(curr_entity.entity.spec), exclude_fields=[ FlattenedClusterSpecKey.WORKERS_COUNT.value, FlattenedClusterSpecKey.NFS_COUNT.value ]) return asdict(svc.resize_cluster(cluster_id, cluster_entity_spec))
def cluster_create(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster create operation. :return: Defined entity of the native cluster :rtype: container_service_extension.def_.models.DefEntity """ rde_in_use = server_utils.get_rde_version_in_use() input_entity: dict = data[RequestKey.INPUT_SPEC] payload_version = input_entity.get( rde_constants.PayloadKey.PAYLOAD_VERSION_RDE_1_0.value) # noqa: E501 # Reject request >= 2.0 _raise_error_if_unsupported_payload_version(payload_version) # Convert the input entity to runtime rde format converted_native_entity: AbstractNativeEntity = rde_utils.convert_input_rde_to_runtime_rde_format( input_entity) # noqa: E501 # Redirect to generic handler if the backend supports RDE-2.0 if semantic_version.Version(rde_in_use) >= semantic_version.Version( rde_constants.RDEVersion.RDE_2_0_0.value): # noqa: E501 rde_data: dict = cluster_handler.cluster_create( data={RequestKey.INPUT_SPEC: converted_native_entity.to_dict()}, op_ctx=op_ctx) new_rde = common_models.DefEntity(**rde_data) else: # Based on the runtime rde, call the appropriate backend method. svc = cluster_service_factory.ClusterServiceFactory( op_ctx).get_cluster_service() # noqa: E501 new_rde: common_models.DefEntity = svc.create_cluster( converted_native_entity) # noqa: E501 # convert the created rde back to input rde version return _convert_rde_to_1_0_format(new_rde.to_dict())
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_create(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster create operation. :return: Defined entity of the native cluster :rtype: container_service_extension.def_.models.DefEntity """ input_entity: dict = data[RequestKey.INPUT_SPEC] payload_version = input_entity.get(rde_constants.PayloadKey.PAYLOAD_VERSION) # noqa: E501 rde_utils.raise_error_if_unsupported_payload_version(payload_version) # Validate the Input payload based on the (Operation, payload_version). # Get the validator based on the payload_version # ToDo : Don't use default cloudapi_client. Use the specific versioned one rde_validator_factory.get_validator( rde_version=rde_constants.MAP_INPUT_PAYLOAD_VERSION_TO_RDE_VERSION[ payload_version]).validate(cloudapi_client=op_ctx.cloudapi_client, entity=input_entity) # Convert the input entity to runtime rde format. # Based on the runtime rde, call the appropriate backend method. converted_native_entity = rde_utils.convert_input_rde_to_runtime_rde_format(input_entity) # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory(op_ctx).get_cluster_service() # noqa: E501 # TODO: Response RDE must be compatible with the request RDE. # Conversions may be needed especially if there is a major version # difference in the input RDE and runtime RDE. return svc.create_cluster(converted_native_entity).to_dict()
def cluster_resize(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster resize operation. Validate data before actual resize is delegated to cluster service. :return: Defined entity of the native cluster :rtype: container_service_extension.def_.models.DefEntity """ input_entity: dict = data[RequestKey.INPUT_SPEC] # Convert the input entity to runtime rde format. # Based on the runtime rde, call the appropriate backend method. converted_native_entity: AbstractNativeEntity = rde_utils.convert_input_rde_to_runtime_rde_format( input_entity) # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory( op_ctx).get_cluster_service() # noqa: E501 cluster_id = data[RequestKey.CLUSTER_ID] curr_entity = svc.entity_svc.get_entity(cluster_id) request_utils.validate_request_payload( converted_native_entity.spec.to_dict(), curr_entity.entity.spec.to_dict(), # noqa: E501 exclude_fields=[ FlattenedClusterSpecKey1X.WORKERS_COUNT.value, FlattenedClusterSpecKey1X.NFS_COUNT.value ]) new_rde: common_models.DefEntity = svc.resize_cluster( cluster_id, converted_native_entity) # noqa: E501 # convert the resized rde back to input rde version new_native_entity: AbstractNativeEntity = rde_utils.convert_runtime_rde_to_input_rde_version_format( # noqa: E501 new_rde.entity, rde_constants.RDEVersion.RDE_1_0_0) new_rde.entity = new_native_entity return new_rde.to_dict()
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 update_cluster(behavior_ctx: RequestContext): entity_id: str = behavior_ctx.entity_id input_entity: dict = behavior_ctx.entity cloudapi_client: CloudApiClient = behavior_ctx.op_ctx.cloudapi_client payload_version: str = input_entity.get( rde_constants.PayloadKey.PAYLOAD_VERSION) # noqa: E501 rde_utils.raise_error_if_unsupported_payload_version( payload_version=payload_version) # Validate the Input payload based on the (Operation, payload_version). # Get the validator based on the payload_version kind = input_entity['kind'] is_tkgm_cluster = (kind == ClusterEntityKind.TKG_M.value) sysadmin_client = behavior_ctx.op_ctx.sysadmin_client input_rde_version = rde_constants.MAP_INPUT_PAYLOAD_VERSION_TO_RDE_VERSION[ payload_version] # noqa: E501 rde_validator_factory.get_validator( rde_version=input_rde_version). \ validate(cloudapi_client=cloudapi_client, sysadmin_client=sysadmin_client, operation=BehaviorOperation.UPDATE_CLUSTER, entity_id=entity_id, entity=input_entity, is_tkgm_cluster=is_tkgm_cluster) # Convert the input entity to runtime rde format. # Based on the runtime rde, call the appropriate backend method. converted_input_entity = rde_utils.convert_input_rde_to_runtime_rde_format( input_entity) # noqa: E501 svc = cluster_service_factory.ClusterServiceFactory( behavior_ctx).get_cluster_service() # noqa: E501 return svc.update_cluster( entity_id, input_native_entity=converted_input_entity) # noqa: E501
def delete_cluster(behavior_ctx: RequestContext): entity_id: str = behavior_ctx.entity_id svc = cluster_service_factory.ClusterServiceFactory( behavior_ctx).get_cluster_service() # noqa: E501 return svc.delete_cluster(entity_id)
def native_cluster_list(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster list operation. :return: List """ svc = cluster_service_factory.ClusterServiceFactory(op_ctx).get_cluster_service() # noqa: E501 filters = data.get(RequestKey.QUERY_PARAMS, {}) page_number = int(filters.get(PaginationKey.PAGE_NUMBER, CSE_PAGINATION_FIRST_PAGE_NUMBER)) page_size = int(filters.get(PaginationKey.PAGE_SIZE, CSE_PAGINATION_DEFAULT_PAGE_SIZE)) # remove page number and page size from the filters as it is treated # differently from other filters if PaginationKey.PAGE_NUMBER in filters: del filters[PaginationKey.PAGE_NUMBER] if PaginationKey.PAGE_SIZE in filters: del filters[PaginationKey.PAGE_SIZE] # response needs to paginated result = svc.get_clusters_by_page(filters=filters) clusters = [def_entity.to_dict() for def_entity in result[PaginationKey.VALUES]] # noqa: E501 uri = data['url'] return server_utils.create_links_and_construct_paginated_result( uri, clusters, result_total=result[PaginationKey.RESULT_TOTAL], page_number=page_number, page_size=page_size, query_params=filters)
def nfs_node_delete(data, op_ctx: ctx.OperationContext): """Request handler for node delete operation. Required data: cluster_name, node_names_list Optional data and default values: org_name=None, ovdc_name=None (data validation handled in broker) :return: Dict """ rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) cluster_id = data[RequestKey.CLUSTER_ID] node_name = data[RequestKey.NODE_NAME] telemetry_handler.record_user_action_details( cse_operation=telemetry_constants.CseOperation.V36_NODE_DELETE, cse_params={ telemetry_constants.PayloadKey.CLUSTER_ID: cluster_id, telemetry_constants.PayloadKey.NODE_NAME: node_name, telemetry_constants.PayloadKey.SOURCE_DESCRIPTION: thread_local_data.get_thread_local_data( server_constants.ThreadLocalData.USER_AGENT) # noqa: E501 }) return svc.delete_nodes(cluster_id, [node_name]).to_dict()
def cluster_acl_update(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster acl update operation.""" svc = cluster_service_factory.ClusterServiceFactory( op_ctx).get_cluster_service() # noqa: E501 cluster_id = data[RequestKey.CLUSTER_ID] 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_upgrade_plan(data, op_ctx: ctx.OperationContext): """Request handler for cluster upgrade-plan operation. :return: List[Tuple(str, str)] """ rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) return svc.get_cluster_upgrade_plan(data[RequestKey.CLUSTER_ID])
def cluster_list(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster list operation. :return: List """ svc = cluster_service_factory.ClusterServiceFactory(op_ctx).get_cluster_service() # noqa: E501 # response should not be paginated return [def_entity.to_dict() for def_entity in svc.list_clusters(data.get(RequestKey.QUERY_PARAMS, {}))]
def cluster_config(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster config operation. Required data: cluster_id :return: Dict """ svc = cluster_service_factory.ClusterServiceFactory(op_ctx).get_cluster_service() # noqa: E501 cluster_id = data[RequestKey.CLUSTER_ID] return svc.get_cluster_config(cluster_id)
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_config(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster config operation. Required data: cluster_id :return: Dict """ rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) cluster_id = data[RequestKey.CLUSTER_ID] return svc.get_cluster_config(cluster_id)
def cluster_delete(data: dict, op_ctx: ctx.OperationContext): """Request handler for 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 """ svc = cluster_service_factory.ClusterServiceFactory(op_ctx).get_cluster_service() # noqa: E501 cluster_id = data[RequestKey.CLUSTER_ID] return svc.delete_cluster(cluster_id).to_dict()
def cluster_list(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster list operation. :return: List """ rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) # response should not be paginated return [ asdict(def_entity) for def_entity in svc.list_clusters( data.get(RequestKey.QUERY_PARAMS, {})) ]
def native_cluster_list(data: dict, op_ctx: ctx.OperationContext): """Request handler for cluster list operation. :return: List """ rde_in_use = server_utils.get_rde_version_in_use() # Redirect to generic handler if the backend supports RDE-2.0 if semantic_version.Version(rde_in_use) >= semantic_version.Version( rde_constants.RDEVersion.RDE_2_0_0.value): # noqa: E501 response_data: dict = cluster_handler.native_cluster_list( data=data, op_ctx=op_ctx) # noqa: E501 rde_list: list[dict] = response_data[PaginationKey.VALUES] formatted_rde_list = [ _convert_rde_to_1_0_format(rde_data) for rde_data in rde_list ] # noqa: E501 response_data[PaginationKey.VALUES] = formatted_rde_list return response_data svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) filters = data.get(RequestKey.QUERY_PARAMS, {}) page_number = int( filters.get(PaginationKey.PAGE_NUMBER, CSE_PAGINATION_FIRST_PAGE_NUMBER)) page_size = int( filters.get(PaginationKey.PAGE_SIZE, CSE_PAGINATION_DEFAULT_PAGE_SIZE)) # remove page number and page size from the filters as it is treated # differently from other filters if PaginationKey.PAGE_NUMBER in filters: del filters[PaginationKey.PAGE_NUMBER] if PaginationKey.PAGE_SIZE in filters: del filters[PaginationKey.PAGE_SIZE] # response needs to paginated result = svc.get_clusters_by_page(filters=filters) clusters = [ def_entity.to_dict() for def_entity in result[PaginationKey.VALUES] ] # noqa: E501 # 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( uri, clusters, result_total=result[PaginationKey.RESULT_TOTAL], page_number=page_number, page_size=page_size, query_params=filters)
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_upgrade_plan(data, op_ctx: ctx.OperationContext): """Request handler for cluster upgrade-plan operation. :return: List[Tuple(str, str)] """ rde_in_use = server_utils.get_rde_version_in_use() # Redirect to generic handler if the backend supports RDE-2.0 if semantic_version.Version(rde_in_use) >= semantic_version.Version( rde_constants.RDEVersion.RDE_2_0_0.value): # noqa: E501 return cluster_handler.cluster_upgrade_plan(data=data, op_ctx=op_ctx) svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) 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.""" rde_in_use = server_utils.get_rde_version_in_use() # Redirect to generic handler if the backend supports RDE-2.0 if semantic_version.Version(rde_in_use) >= semantic_version.Version( rde_constants.RDEVersion.RDE_2_0_0.value): # noqa: E501 return cluster_handler.cluster_acl_update(data=data, op_ctx=op_ctx) svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) cluster_id = data[RequestKey.CLUSTER_ID] 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 """ rde_in_use = server_utils.get_rde_version_in_use() svc = cluster_service_factory.ClusterServiceFactory(op_ctx). \ get_cluster_service(rde_in_use) cluster_id = data[RequestKey.CLUSTER_ID] return svc.get_cluster_info(cluster_id).to_dict()
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()