k8s_client.views¶
Subpackages¶
Submodules¶
Package Contents¶
Functions¶
|
|
|
Get pods list |
|
|
|
Get nodes list |
|
|
Get contexts list |
|
|
Get the context info |
|
Get the info of the busy jobs of the provided context |
|
|
|
Get roles list |
|
|
|
Get groups list |
Create a new group |
|
|
Delete a group |
|
updates a group |
|
|
|
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 |
|
|
Get clusters list from k8s config |
|
|
Use the provided cluster |
Save k8s config cluster |
|
|
Update k8s config cluster |
|
Deletes the provided cluster |
Get kube_users list from k8s config |
|
|
Use the provided kube_user |
Save k8s config kube_user |
|
|
Update k8s config kube_user |
|
Deletes the provided kube_user |
Get contexts list from k8s config |
|
|
Use the provided context |
Save k8s config context |
|
|
Update k8s config context |
|
Deletes the provided context |
Get servers list from k8s config |
|
|
Use the provided server |
Save k8s config server |
|
|
Update k8s config server |
|
Deletes the provided server |
Used to check if the website is alive |
|
|
Returns the site map endpoints list |
|
Attributes¶
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.get_pods(context_name=None, node_name=None)¶
Get pods list
Parameters¶
"context_name": string (optional)The name of the context of which showing the pods. if
valueis None the default context name will be used."node_name": string (optional)The name of the node inside the context of which showing the pods.
Returns¶
JSON containing the full list of pods of the default context if
context_nameis None andnode_nameis NoneJSON containing the full list of pods of the specified context if
context_nameis a <valid value> andnode_nameis NoneJSON containing the full list of pods of the node of the specified context if
context_nameis a <valid value> andnode_nameis a <valid value>Error message with return code 500 if
context_nameis NOT a <valid value>JSON containing empty pods list if
node_nameis NOT a <valid value>
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.get_nodes(context_name=None)¶
Get nodes list
Parameters¶
"context_name": string (optional)The name of the context of which showing the nodes. if
valueis None the default context name will be used.
Returns¶
[code: 200]JSON containing the full list of nodes of the default context ifcontext_nameis None `[code: 200]JSON containing the full list of nodes of the specified context ifcontext_nameis a <valid value>[code: 500]Error message ifcontext_nameis NOT a <valid value>
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.get_contexts()¶
Get contexts list
Parameters¶
NONE
Returns¶
[code: 200]list [dict]JSON containing the full contexts
- k8s_client.views.get_context(context_name)¶
Get the context info
Parameters¶
"context_name": string (optional)The name of the context of which having the data.
Returns¶
[code: 200]dictJSON containing the data of the default context if
context_nameis a <valid value> `
[code: 404]stringError message if
context_nameis NOT a <valid value>
- k8s_client.views.get_context_busy_jobs(context_name)¶
Get the info of the busy jobs of the provided context
Parameters¶
"context_name": string (optional)The name of the context of which having the data.
Returns¶
[code: 200]dictJSON containing the data of the default context if
context_nameis a <valid value> `
[code: 404]stringError message if
context_nameis NOT a <valid value>
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.get_roles(name=None)¶
Get roles list
Parameters¶
"name": string (optional)The name of the role to search.
Returns¶
JSON containing the full list of roles if
nameis NoneJSON containing the details of the specified role if
nameis a <valid name>Error message with return code 404 if
nameis NOT a <valid name>
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.get_groups(name=None)¶
Get groups list
Parameters¶
"name"string (optional)The name of the group of which showing the details.
Returns¶
[code: 200]JSON containing the full list of groups if_nameis None[code: 200]JSON containing the detail of the specified group ifnameis a <valid value>[code: 404]Error message ifnameis NOT a <valid value>
Notes¶
To each returned group will be added the context details
Examples¶
>>> [ { "contexts": [ { "cluster_id": 1, "cost": 0, "id": 1, "kubeuser_id": 1, "max_cores_for_single_job": 105, "name": "context.dev.k8s.master.dafni.hydra.org.uk", "namespace": "default" } ], "id": 1, "name": "umwrg" } ]
- k8s_client.views.post_group()¶
Create a new group
Parameters¶
- Request Bodyjson
- JSON containing data for the group:
"name"stringThe name of the group to create
"contexts"list [dict]List of dictionaries of the contexts to attach to the group, eventually empty It can contain the name or the id of the contexts. The name has higher priority, meaning if it is defined, the id is ignored If the context is not found, the group will be inserted anyway without contexts
Returns¶
[code: 409]Error message ifnameis already inside the DB[code: 406]Error message ifINPUTis NOT a <valid json>[code: 200]Empty array ifINPUTis valid
Examples¶
>>> Body = { "name": "test5", "contexts": [{"id":1}] }
>>> Body = { "name": "test15", "contexts": [{"name":"context-test"}] }
- k8s_client.views.delete_group(id=None)¶
Delete a group
Parameters¶
"id": intThe id of the group to delete
Returns¶
Error message with return code 409 if there is an integrity error
Error message with return code 404 if
idis NOT a <valid value>JSON containing the deleted group id with return code 200 if
INPUTis valid
- k8s_client.views.update_group(id=None)¶
updates a group
Parameters¶
"id"intThe id of the group to update
- Request Bodyjson
- JSON containing data for the group:
"name": stringThe name of the group to update
"contexts"list [dict]List of dictionaries of the contexts to attach to the group, eventually empty It can contain the name or the id of the contexts. The name has higher priority, meaning if it is defined, the id is ignored If the context is not found, the group will be inserted anyway without contexts
Returns¶
[code: 404]Error message ifidis not inside the DB[code: 406]Error message ifINPUTis NOT a <valid json>[code: 409]Error message if there is an integrity error[code: 200]Empty array ifINPUTis valid
Examples¶
>>> Body = { "name": "test5", "contexts": [{"id":1}] }
>>> Body = { "name": "test15", "contexts": [{"name":"context-test"}] }
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.get_users(username=None)¶
Get users list
- k8s_client.views.post_user()¶
Create a new user
- k8s_client.views.delete_user(username=None)¶
Delete an user
- k8s_client.views.update_user(username=None)¶
updates an user
- k8s_client.views.update_user_password(username=None)¶
updates an user
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.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.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.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.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.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.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.upload_file_for_user_full(username=None)¶
Upload a file for a user
NOT USED
- k8s_client.views.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.get_user_logs(username=None, cluster_uri=None, filename=None, lines_count=None)¶
Get user logs list
- k8s_client.views.get_user_logs_size(username=None, cluster_uri=None, filename=None)¶
Get user log file size
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶
- k8s_client.views.get_k8s_config_clusters()¶
Get clusters list from k8s config
- k8s_client.views.get_k8s_config_cluster(cluster_name)¶
Use the provided cluster
- k8s_client.views.post_k8s_config_cluster()¶
Save k8s config cluster
- k8s_client.views.put_k8s_config_cluster(cluster_name)¶
Update k8s config cluster
- k8s_client.views.delete_k8s_config_cluster(cluster_id)¶
Deletes the provided cluster
- k8s_client.views.get_k8s_config_kube_users()¶
Get kube_users list from k8s config
- k8s_client.views.get_k8s_config_kube_user(kube_user_name)¶
Use the provided kube_user
- k8s_client.views.post_k8s_config_kube_user()¶
Save k8s config kube_user
- k8s_client.views.put_k8s_config_kube_user(kube_user_name)¶
Update k8s config kube_user
- k8s_client.views.delete_k8s_config_kube_user(kube_user_id)¶
Deletes the provided kube_user
- k8s_client.views.get_k8s_config_contexts()¶
Get contexts list from k8s config
- k8s_client.views.get_k8s_config_context(context_name)¶
Use the provided context
- k8s_client.views.post_k8s_config_context()¶
Save k8s config context
- k8s_client.views.put_k8s_config_context(context_name)¶
Update k8s config context
- k8s_client.views.delete_k8s_config_context(context_id)¶
Deletes the provided context
- k8s_client.views.get_k8s_config_servers()¶
Get servers list from k8s config
- k8s_client.views.get_k8s_config_server(server_name)¶
Use the provided server
- k8s_client.views.post_k8s_config_server()¶
Save k8s config server
- k8s_client.views.put_k8s_config_server(server_name)¶
Update k8s config server
- k8s_client.views.delete_k8s_config_server(server_id)¶
Deletes the provided server
- k8s_client.views.get_is_alive()¶
Used to check if the website is alive
Parameters¶
NONE
Returns¶
[code: 200]{“status”: “alive”}
- k8s_client.views.site_map()¶
Returns the site map endpoints list
Parameters¶
NONE
Returns¶
[code: 200]JSON containing the full list of API REST endpoints
- k8s_client.views.file_folder¶
- k8s_client.views.resource_managers¶
- k8s_client.views.log¶
- k8s_client.views.resource_not_found(e)¶
- k8s_client.views.is_json(myjson)¶