k8s_client.views.users¶
Submodules¶
Package Contents¶
Functions¶
|
Get users list |
Create a new user |
|
|
Delete an user |
|
updates an user |
|
updates an user |
|
|
Login an user |
|
|
|
|
DEPRECATED! |
|
Get user contexts list |
|
|
|
Get user files list |
|
Get user file content |
|
Get user folder content |
|
Upload a file for a user |
|
Upload a part of a file for a user |
|
Delete a file for an user |
|
Delete a folder for an user |
|
|
|
Get user image tags list from the Docker registry |
|
Get user images list from the DB |
|
Create a new user image |
|
Updates an existing user image |
|
Delete Image for user |
|
|
|
Upload a file for a reserved job |
|
Start a reserved job |
|
Kills a running job |
|
Cancel a pending job |
|
Deletes a job |
|
Get user jobs list |
|
Get user jobs count |
|
Creates a new job |
|
|
|
Get user logs list |
|
Get user log file size |
|
Attributes¶
- k8s_client.views.users.get_users(username=None)¶
Get users list
- k8s_client.views.users.post_user()¶
Create a new user
- k8s_client.views.users.delete_user(username=None)¶
Delete an user
- k8s_client.views.users.update_user(username=None)¶
updates an user
- k8s_client.views.users.update_user_password(username=None)¶
updates an user
- k8s_client.views.users.file_folder¶
- k8s_client.views.users.resource_managers¶
- k8s_client.views.users.log¶
- k8s_client.views.users.resource_not_found(e)¶
- k8s_client.views.users.is_json(myjson)¶
- k8s_client.views.users.login_user()¶
Login an user
Parameters¶
- Request Bodyjson
- JSON containing data for the data:
"username": string,Name of the owner user to login
"password": string,Password of the user
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBpasswordis NOT valid for the username
[code: 200]dictif
INPUTis valid, with keys:"email"User email (str)
"first_name"User first name (str)
"groups"User groups list (list [dict [
"id"(str),"name"(str) ] ])"id"User id (int)
"last_name"User last name (str)
"roles"User roles list (list [dict [
"id"(str),"name"(str) ] ])"tokens"User tokens (` dict` [
"access"(str),"refresh"(str) ] )"username"User username (str)
- k8s_client.views.users.file_folder¶
- k8s_client.views.users.resource_managers¶
- k8s_client.views.users.log¶
- k8s_client.views.users.resource_not_found(e)¶
- k8s_client.views.users.is_json(myjson)¶
- k8s_client.views.users.uninstall_completed_charts_for_user(username=None)¶
DEPRECATED!
Uninstalls the completed charts
Parameters¶
"username": string, optionalName of the owner user for which to upload the file
Body parameters¶
"force_restart_errored_pods": booleanForce the system to restart the pods in error
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 200]OKif the job is in reserved status
- k8s_client.views.users.get_user_contexts(username=None)¶
Get user contexts list
Parameters¶
"username": string, optionalName of the owner user for which to get the contexts
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 200]list [dict], otherwiseEach dict items contains:
"cluster_id": intID of the kube config cluster
"cost": intContains the cost for CPU for second of the cluster
"id": intID of the kube config context
"kubeuser_id": intID of the kube config user
"max_cores_for_single_job": intMax number of cores usable for a job in MPI inside the cluster
"name": stringName of the context
"namespace": stringName of the namespace to use
- k8s_client.views.users.file_folder¶
- k8s_client.views.users.resource_managers¶
- k8s_client.views.users.log¶
- k8s_client.views.users.resource_not_found(e)¶
- k8s_client.views.users.is_json(myjson)¶
- k8s_client.views.users.get_user_files(username=None, filename=None)¶
Get user files list
Parameters¶
"username": stringName of the owner user for which to get the files list
Query line parameters¶
"cluster_uri"stringName of the cluster where to look for the files. It corresponds to a folder on the main machine where file are synchronized
"relative_path"string, optionalThe relative path from the root folder of the cluster to be used
"filename"stringThe name of the file to view the details
"foldername"stringThe name of the folder to list the details
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 406]Error message if:cluster_uriis NOT provided
[code: 200]list [dict], otherwiseEach dict items contains: -
"name": stringName of the item of the dir list
"is_dir"booleanIndicates if the path refers to a file or to a folder
"size"intIndicates the size if the item is a file. If the item is a folder it is always 0.
"content"intAlways 0.
"creation_time"datetimeDatetime of file/folder creation
"modified_time"datetimeDatetime of file/folder update
- k8s_client.views.users.get_user_file_content(username=None, filename=None)¶
Get user file content
Parameters¶
"username": stringName of the owner user for which to get the file content
Query line parameters¶
"cluster_uri"stringName of the cluster from where download the files content It corresponds to a folder on the main machine where file are synchronized
"relative_path"string, optionalThe relative path from the root folder of the cluster to be used
"filename"stringThe name of the file to download
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBThe file has not been found
[code: 406]Error message if:cluster_uriis NOT providedrelative_pathis NOT providedfilenameis NOT provided or contains not allowed chars
[code: 200]bytes otherwisethe content of the file
- k8s_client.views.users.get_user_folder_content(username=None, foldername=None)¶
Get user folder content
Parameters¶
"username": stringName of the owner user
Query line parameters¶
"cluster_uri"stringName of the cluster from where download the folder. It corresponds to a folder on the main machine where file are synchronized
"relative_path"string, optionalThe relative path from the root folder of the cluster to be used
"foldername"stringThe name of the folder to download
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 406]Error message if:cluster_uriis NOT providedrelative_pathis NOT providedfoldernameis NOT provided or contains not allowed chars
[code: 200]bytes otherwisethe zipped content of the folder
- k8s_client.views.users.upload_file_for_user_full(username=None)¶
Upload a file for a user
NOT USED
- k8s_client.views.users.upload_file_part_for_user(username=None)¶
Upload a part of a file for a user
Parameters¶
"username": stringName of the owner user
Body payload parameters¶
The endpoint is used for 3 cases:
1) speed-test
"command": speed-test"data": blobData to be sent
"cluster-uri"stringName of the cluster on which upload the data
2) Upload part
"command": upload-part"relative-path": stringThe path where to upload the file
"file-name"stringName of the uploading file
"chunk-number": intCounter of the chunk to be uploaded
"chunk-size"intSize of the chunk
"chunk-data"blobData to be sent
"cluster-uri"stringName of the cluster on which upload the data
3) Join parts
"command": join-parts"relative-path": stringThe path where to upload the file
"file-name"stringName of the uploading file
"chunks-count": intTotal number the uploaded chunks
"cluster-uri"stringName of the cluster on which upload the data
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 406]Error message if:cluster_uriis NOT providedrelative_pathis NOT provided
[code: 200]list otherwiseThe result of the command
- k8s_client.views.users.delete_file_for_user(username=None, file_full_path=None)¶
Delete a file for an user
Parameters¶
"username": stringName of the owner user
Query line parameters¶
"cluster_uri"stringName of the cluster from where delete the file. It corresponds to a folder on the main machine where file are synchronized
"file_full_path"stringThe full relative path of the file to delete
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 406]Error message if:cluster_uriis NOT providedfile_full_pathis NOT provided
[code: 200]list otherwiseDeleted file
- k8s_client.views.users.delete_folder_for_user(username=None, file_full_path=None)¶
Delete a folder for an user
Parameters¶
"username": stringName of the owner user
Query line parameters¶
"cluster_uri"stringName of the cluster from where delete. It corresponds to a folder on the main machine where file are synchronized
"file_full_path"stringThe full relative path of the folder to delete
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 406]Error message if:cluster_uriis NOT providedfile_full_pathis NOT provided
[code: 200]list otherwiseDeleted folder
- k8s_client.views.users.file_folder¶
- k8s_client.views.users.resource_managers¶
- k8s_client.views.users.log¶
- k8s_client.views.users.resource_not_found(e)¶
- k8s_client.views.users.is_json(myjson)¶
- k8s_client.views.users.get_user_image_tags(username=None, image_id=None)¶
Get user image tags list from the Docker registry
Parameters¶
"username": stringName of the owner user for which to get the associated list
"image_id": intId of the image
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBimage_idis NOT inside the DB
[code: 200]dict [ string, list ], otherwiseThe dict contains: -
"name": stringFull path of the image, composed by docker hub server/group/image
"tags"list [ string ]Each item contains a semver string representing an image version
- k8s_client.views.users.get_user_images(username=None, id=None)¶
Get user images list from the DB
Parameters¶
"username": stringName of the owner user for which to get the associated images list
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 200]otherwise- format:
- list [dict]
if id is None
- dict
if id is not None
- Each dict items contains:
"full_path"stringFull path of the image, composed by docker hub server/group/image
"id"intId of the record
"tags_list": list [ semver ]"wide_tags_list": list [ dict [ id: int, image_id: int, tag: semver ] ]
- k8s_client.views.users.post_user_image(username=None)¶
Create a new user image
Parameters¶
"username": stringName of the owner user of the inserted image
- Request Bodyjson
- JSON containing data for the data:
"full_path": stringFull path of the image containing the docker registry, the group and the name itself
"tag": semverString representing the version of the image
Returns¶
[code: 401]Error message if:The Bearer token is not correctly provided or it is expired
[code: 404]Error message if:usernameis NOT inside the DB
[code: 409]Error message if:The couple (full_path, tag) are already inside the DB
[code: 200]otherwise- A dict contains:
"full_path"stringFull path of the image, composed by docker hub server/group/image
"id"intId of the record
"tag"semverTag of the image
- k8s_client.views.users.put_user_image(username=None, image_id=None)¶
Updates an existing user image
Parameters¶
"username": stringName of the owner user of the image
"image_id": int, optionalId of the image. Optional if the id is contained inside the request json body
- Request Bodyjson
- JSON containing data for the data:
"image_id": int, optionalId of the image. If it is None, the provided parameter is used instead
"full_path": stringFull path of the image containing the docker registry, the group and the name itself
Returns¶
[code: 401]Error message if:The Bearer token is not correctly provided or it is expired
[code: 404]Error message if:usernameis NOT inside the DBimage_idis NOT inside the DB
[code: 406]Error message if:image_id not provided
[code: 200]otherwise- A dict contains:
"full_path"stringFull path of the image, composed by docker hub server/group/image
"id"intId of the record
- k8s_client.views.users.delete_user_image(username=None, image_id=None)¶
Delete Image for user
Parameters¶
"username": stringName of the owner user of the image
Returns¶
[code: 404]Error message if:usernameis NOT inside the DB
[code: 406]Error message if:image_id not provided
[code: 200]dict [ image_id: int ] otherwise
- k8s_client.views.users.file_folder¶
- k8s_client.views.users.resource_managers¶
- k8s_client.views.users.log¶
- k8s_client.views.users.resource_not_found(e)¶
- k8s_client.views.users.is_json(myjson)¶
- k8s_client.views.users.upload_file_for_job(username=None, job_uuid=None)¶
Upload a file for a reserved job
Parameters¶
"username": string, optionalName of the owner user for which to upload the file
"job_uuid": stringUUID of the job to upload the file
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBjob_uuidis NOT inside the DB or is not reserved
[code: 200]OKif the job is in reserved status
- k8s_client.views.users.start_job(username=None, job_uuid=None)¶
Start a reserved job
Parameters¶
"username": string, optionalName of the owner user for which to start the job
"job_uuid": stringUUID of the job to start
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBjob_uuidis NOT inside the DB or is not reserved
[code: 200]OKif the job is in reserved status
- k8s_client.views.users.kill_job(username=None, job_uuid=None)¶
Kills a running job
Parameters¶
"username": string, optionalName of the owner user for which to kill the job
"job_uuid": stringUUID of the job to kill
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBjob_uuidis NOT inside the DB or is not running
[code: 200]OKif the job is in running status
- k8s_client.views.users.cancel_job(username=None, job_uuid=None)¶
Cancel a pending job
Parameters¶
"username": string, optionalName of the owner user for which to cancel the job
"job_uuid": stringUUID of the job to cancel
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBjob_uuidis NOT inside the DB or is not in a pending status
[code: 200]list [string]Array containing the cancelled job if the job is in pending or reserved status
[code: 200]list []empty list otherwise
- k8s_client.views.users.delete_job(username=None, job_uuid=None)¶
Deletes a job
Parameters¶
"username": string, optionalName of the owner user for which to delete the job
"job_uuid": stringUUID of the job to delete
Returns¶
[code: 404]Error message if:usernameis NOT inside the DBjob_uuidis NOT inside the DB
[code: 200]list [string]Array containing the deleted job
- k8s_client.views.users.get_jobs(username=None, limit=None, offset=0)¶
Get user jobs list
Parameters¶
"username": string, optionalName of the owner user for which to get the jobs count
"offset": int, optionalOffset of the jobs list items count. Used for pagination
"limit": int, optionalLimit of the jobs list items count. Used for pagination
Query parameters:¶
"image_id": int, optionalImage Id for which to get the jobs count
"context_id": int, optionalContext Id for which to get the jobs count
"status": string, optionalStatus for which to get the jobs count
"image_tag_id": int, optionalImage tag Id for which to get the jobs count
"node_id": int, optionalNode Id for which to get the jobs count
"node_name": string, optionalNode Name for which to get the jobs count
"paradigm": string, optionalParadigm for which to get the jobs count
"uuid": string, optionalUUID for which to get the jobs count
Returns¶
[code: 406]Error message if:usernameis NOT inside the DB
[code: 200]intCount of user jobs otherwise
- k8s_client.views.users.get_jobs_count(username=None)¶
Get user jobs count
Parameters¶
"username": string,Name of the owner user for which to get the jobs count
Returns¶
[code: 406]Error message if:usernameis NOT inside the DB
[code: 200]intCount of user jobs otherwise
- k8s_client.views.users.post_jobs(username=None)¶
Creates a new job
Parameters¶
- Request Bodyjson
- JSON containing data for the data:
"cores_to_use": intNumber of cores to use to run the application
"context_name": stringName of the context to use to run the application
"docker_image_name": stringName of the image representing the application to run
"docker_image_tag"string,Version of the image representing the application to run. Semver
"username": string,Name of the owner user to use to run the application
"paradigm": string,Paradigm to use. Values allowed: mpi | openmp
"env_variables": stringString representing the list of variables to pass to the application. The list will be of the form “name1=value1, …, nameK=valueK” All the variables will be instanced inside the environment where the application runs
"new_job_status"string, optionalString representing the status of the new job. Default is “pending”
Accepted values: pending, reserved
Returns¶
[code: 406]Error message if:context_nameis NOT inside the DBparadigmis NOT validusernameis NOT inside the DBcores_to_useis a number that overcomes the available cores for the selected contextnew_job_statusis NOT valid
[code: 200]dict [str, str]if
INPUTis valid
Examples¶
>>> Body = { "cores_to_use": 30, "context_name": "context.dev.k8s.master.dafni.hydra.org.uk", "docker_image_name": "umwrg/openmp-test-2022", "docker_image_tag" : "0.0.12", "username": "a86302gb", "paradigm": "openmp", "env_variables": "API_USER=pippo, NP=75" } Returns { "job_uuid": "187fe2b9-5003-406f-8bd5-7a7931752e7d", "log_file_name": "a86302gb.187fe2b9-5003-406f-8bd5-7a7931752e7d.log" }
- k8s_client.views.users.file_folder¶
- k8s_client.views.users.resource_managers¶
- k8s_client.views.users.log¶
- k8s_client.views.users.resource_not_found(e)¶
- k8s_client.views.users.is_json(myjson)¶
- k8s_client.views.users.get_user_logs(username=None, cluster_uri=None, filename=None, lines_count=None)¶
Get user logs list
- k8s_client.views.users.get_user_logs_size(username=None, cluster_uri=None, filename=None)¶
Get user log file size
- k8s_client.views.users.file_folder¶
- k8s_client.views.users.resource_managers¶
- k8s_client.views.users.log¶
- k8s_client.views.users.resource_not_found(e)¶
- k8s_client.views.users.is_json(myjson)¶