k8s_client.views.users

Submodules

Package Contents

Functions

get_users([username])

Get users list

post_user()

Create a new user

delete_user([username])

Delete an user

update_user([username])

updates an user

update_user_password([username])

updates an user

resource_not_found(e)

is_json(myjson)

login_user()

Login an user

resource_not_found(e)

is_json(myjson)

uninstall_completed_charts_for_user([username])

DEPRECATED!

get_user_contexts([username])

Get user contexts list

resource_not_found(e)

is_json(myjson)

get_user_files([username, filename])

Get user files list

get_user_file_content([username, filename])

Get user file content

get_user_folder_content([username, foldername])

Get user folder content

upload_file_for_user_full([username])

Upload a file for a user

upload_file_part_for_user([username])

Upload a part of a file for a user

delete_file_for_user([username, file_full_path])

Delete a file for an user

delete_folder_for_user([username, file_full_path])

Delete a folder for an user

resource_not_found(e)

is_json(myjson)

get_user_image_tags([username, image_id])

Get user image tags list from the Docker registry

get_user_images([username, id])

Get user images list from the DB

post_user_image([username])

Create a new user image

put_user_image([username, image_id])

Updates an existing user image

delete_user_image([username, image_id])

Delete Image for user

resource_not_found(e)

is_json(myjson)

upload_file_for_job([username, job_uuid])

Upload a file for a reserved job

start_job([username, job_uuid])

Start a reserved job

kill_job([username, job_uuid])

Kills a running job

cancel_job([username, job_uuid])

Cancel a pending job

delete_job([username, job_uuid])

Deletes a job

get_jobs([username, limit, offset])

Get user jobs list

get_jobs_count([username])

Get user jobs count

post_jobs([username])

Creates a new job

resource_not_found(e)

is_json(myjson)

get_user_logs([username, cluster_uri, filename, ...])

Get user logs list

get_user_logs_size([username, cluster_uri, filename])

Get user log file size

resource_not_found(e)

is_json(myjson)

Attributes

file_folder

resource_managers

log

file_folder

resource_managers

log

file_folder

resource_managers

log

file_folder

resource_managers

log

file_folder

resource_managers

log

file_folder

resource_managers

log

file_folder

resource_managers

log

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:
    • username is NOT inside the DB

    • password is NOT valid for the username

  • [code: 200] dict

    if INPUT is 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, optional

Name of the owner user for which to upload the file

Body parameters

"force_restart_errored_pods": boolean

Force the system to restart the pods in error

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

  • [code: 200] OK

    if the job is in reserved status

k8s_client.views.users.get_user_contexts(username=None)

Get user contexts list

Parameters

"username": string, optional

Name of the owner user for which to get the contexts

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

  • [code: 200] list [dict], otherwise

    Each dict items contains:

    "cluster_id": int

    ID of the kube config cluster

    "cost": int

    Contains the cost for CPU for second of the cluster

    "id": int

    ID of the kube config context

    "kubeuser_id": int

    ID of the kube config user

    "max_cores_for_single_job": int

    Max number of cores usable for a job in MPI inside the cluster

    "name": string

    Name of the context

    "namespace": string

    Name 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": string

Name of the owner user for which to get the files list

Query line parameters

  • "cluster_uri"string

    Name 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, optional

    The relative path from the root folder of the cluster to be used

  • "filename"string

    The name of the file to view the details

  • "foldername"string

    The name of the folder to list the details

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

  • [code: 406] Error message if:
    • cluster_uri is NOT provided

  • [code: 200] list [dict], otherwise

    Each dict items contains: - "name" : string

    Name of the item of the dir list

    • "is_dir"boolean

      Indicates if the path refers to a file or to a folder

    • "size"int

      Indicates the size if the item is a file. If the item is a folder it is always 0.

    • "content"int

      Always 0.

    • "creation_time"datetime

      Datetime of file/folder creation

    • "modified_time"datetime

      Datetime of file/folder update

k8s_client.views.users.get_user_file_content(username=None, filename=None)

Get user file content

Parameters

"username": string

Name of the owner user for which to get the file content

Query line parameters

  • "cluster_uri"string

    Name 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, optional

    The relative path from the root folder of the cluster to be used

  • "filename"string

    The name of the file to download

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

    • The file has not been found

  • [code: 406] Error message if:
    • cluster_uri is NOT provided

    • relative_path is NOT provided

    • filename is NOT provided or contains not allowed chars

  • [code: 200] bytes otherwise

    the content of the file

k8s_client.views.users.get_user_folder_content(username=None, foldername=None)

Get user folder content

Parameters

"username": string

Name of the owner user

Query line parameters

  • "cluster_uri"string

    Name of the cluster from where download the folder. It corresponds to a folder on the main machine where file are synchronized

  • "relative_path"string, optional

    The relative path from the root folder of the cluster to be used

  • "foldername"string

    The name of the folder to download

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

  • [code: 406] Error message if:
    • cluster_uri is NOT provided

    • relative_path is NOT provided

    • foldername is NOT provided or contains not allowed chars

  • [code: 200] bytes otherwise

    the 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": string

Name of the owner user

Body payload parameters

The endpoint is used for 3 cases:

1) speed-test "command" : speed-test "data" : blob

Data to be sent

"cluster-uri"string

Name of the cluster on which upload the data

2) Upload part "command" : upload-part "relative-path" : string

The path where to upload the file

"file-name"string

Name of the uploading file

"chunk-number": int

Counter of the chunk to be uploaded

"chunk-size"int

Size of the chunk

"chunk-data"blob

Data to be sent

"cluster-uri"string

Name of the cluster on which upload the data

3) Join parts "command" : join-parts "relative-path" : string

The path where to upload the file

"file-name"string

Name of the uploading file

"chunks-count": int

Total number the uploaded chunks

"cluster-uri"string

Name of the cluster on which upload the data

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

  • [code: 406] Error message if:
    • cluster_uri is NOT provided

    • relative_path is NOT provided

  • [code: 200] list otherwise

    The 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": string

Name of the owner user

Query line parameters

  • "cluster_uri"string

    Name of the cluster from where delete the file. It corresponds to a folder on the main machine where file are synchronized

  • "file_full_path"string

    The full relative path of the file to delete

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

  • [code: 406] Error message if:
    • cluster_uri is NOT provided

    • file_full_path is NOT provided

  • [code: 200] list otherwise

    Deleted file

k8s_client.views.users.delete_folder_for_user(username=None, file_full_path=None)

Delete a folder for an user

Parameters

"username": string

Name of the owner user

Query line parameters

  • "cluster_uri"string

    Name of the cluster from where delete. It corresponds to a folder on the main machine where file are synchronized

  • "file_full_path"string

    The full relative path of the folder to delete

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

  • [code: 406] Error message if:
    • cluster_uri is NOT provided

    • file_full_path is NOT provided

  • [code: 200] list otherwise

    Deleted 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": string

Name of the owner user for which to get the associated list

"image_id": int

Id of the image

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

    • image_id is NOT inside the DB

  • [code: 200] dict [ string, list ], otherwise

    The dict contains: - "name" : string

    Full 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": string

Name of the owner user for which to get the associated images list

Returns

  • [code: 404] Error message if:
    • username is 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"string

      Full path of the image, composed by docker hub server/group/image

    • "id"int

      Id 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": string

Name of the owner user of the inserted image

Request Bodyjson
JSON containing data for the data:
"full_path": string

Full path of the image containing the docker registry, the group and the name itself

"tag": semver

String 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:
    • username is 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"string

      Full path of the image, composed by docker hub server/group/image

    • "id"int

      Id of the record

    • "tag"semver

      Tag of the image

k8s_client.views.users.put_user_image(username=None, image_id=None)

Updates an existing user image

Parameters

"username": string

Name of the owner user of the image

"image_id": int, optional

Id 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, optional

Id of the image. If it is None, the provided parameter is used instead

"full_path": string

Full 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:
    • username is NOT inside the DB

    • image_id is NOT inside the DB

  • [code: 406] Error message if:
    • image_id not provided

  • [code: 200] otherwise
    A dict contains:
    • "full_path"string

      Full path of the image, composed by docker hub server/group/image

    • "id"int

      Id of the record

k8s_client.views.users.delete_user_image(username=None, image_id=None)

Delete Image for user

Parameters

"username": string

Name of the owner user of the image

Returns

  • [code: 404] Error message if:
    • username is 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, optional

Name of the owner user for which to upload the file

"job_uuid": string

UUID of the job to upload the file

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

    • job_uuid is NOT inside the DB or is not reserved

  • [code: 200] OK

    if the job is in reserved status

k8s_client.views.users.start_job(username=None, job_uuid=None)

Start a reserved job

Parameters

"username": string, optional

Name of the owner user for which to start the job

"job_uuid": string

UUID of the job to start

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

    • job_uuid is NOT inside the DB or is not reserved

  • [code: 200] OK

    if the job is in reserved status

k8s_client.views.users.kill_job(username=None, job_uuid=None)

Kills a running job

Parameters

"username": string, optional

Name of the owner user for which to kill the job

"job_uuid": string

UUID of the job to kill

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

    • job_uuid is NOT inside the DB or is not running

  • [code: 200] OK

    if the job is in running status

k8s_client.views.users.cancel_job(username=None, job_uuid=None)

Cancel a pending job

Parameters

"username": string, optional

Name of the owner user for which to cancel the job

"job_uuid": string

UUID of the job to cancel

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

    • job_uuid is 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, optional

Name of the owner user for which to delete the job

"job_uuid": string

UUID of the job to delete

Returns

  • [code: 404] Error message if:
    • username is NOT inside the DB

    • job_uuid is 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, optional

Name of the owner user for which to get the jobs count

"offset": int, optional

Offset of the jobs list items count. Used for pagination

"limit": int, optional

Limit of the jobs list items count. Used for pagination

Query parameters:

"image_id": int, optional

Image Id for which to get the jobs count

"context_id": int, optional

Context Id for which to get the jobs count

"status": string, optional

Status for which to get the jobs count

"image_tag_id": int, optional

Image tag Id for which to get the jobs count

"node_id": int, optional

Node Id for which to get the jobs count

"node_name": string, optional

Node Name for which to get the jobs count

"paradigm": string, optional

Paradigm for which to get the jobs count

"uuid": string, optional

UUID for which to get the jobs count

Returns

  • [code: 406] Error message if:
    • username is NOT inside the DB

  • [code: 200] int

    Count 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:
    • username is NOT inside the DB

  • [code: 200] int

    Count 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": int

Number of cores to use to run the application

"context_name": string

Name of the context to use to run the application

"docker_image_name": string

Name 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": string

String 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, optional
  • String representing the status of the new job. Default is “pending”

  • Accepted values: pending, reserved

Returns

  • [code: 406] Error message if:
    • context_name is NOT inside the DB

    • paradigm is NOT valid

    • username is NOT inside the DB

    • cores_to_use is a number that overcomes the available cores for the selected context

    • new_job_status is NOT valid

  • [code: 200] dict [str, str]

    if INPUT is 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)