Backend - OpenShift

class conu.backend.origin.backend.OpenshiftBackend(api_key=None, logging_level=20, logging_kwargs=None)

Bases: conu.backend.k8s.backend.K8sBackend

ContainerClass

alias of conu.apidefs.container.Container

ImageClass

alias of conu.apidefs.image.Image

__init__(api_key=None, logging_level=20, logging_kwargs=None)

This method serves as a configuration interface for conu.

Parameters:
  • api_key – str, Bearer API token
  • logging_level – int, control logger verbosity: see logging.{DEBUG,INFO,ERROR}
  • logging_kwargs – dict, additional keyword arguments for logger set up, for more info see docstring of set_logging function
clean_project(app_name)

Delete all objects in current project in OpenShift cluster :return: None

cleanup_containers()

Remove containers associated with this backend instance

Returns:None
cleanup_deployments()

Delete all deployments created in namespaces associated with this backend :return: None

cleanup_images()

Remove images associated with this backend instance

Returns:None
cleanup_namespaces()

Delete all namespaces created by this backend :return: None

cleanup_pods()

Delete all pods created in namespaces associated with this backend :return: None

cleanup_services()

Delete all services created in namespaces associated with this backend :return: None

cleanup_volumes()

Remove volumes associated with this backend instance

Returns:None
create_namespace()

Create namespace with random name :return: name of new created namespace

delete_namespace(name)

Delete namespace with specific name :param name: str, namespace to delete :return: None

static get_internal_registry_ip()

Search for docker-registry IP :return: str, ip address

http_request(path='/', method='GET', host=None, port=None, json=False, data=None)

perform a HTTP request

Parameters:
  • path – str, path within the reqest, e.g. “/api/version”
  • method – str, HTTP method
  • host – str, if None, set to 127.0.0.1
  • port – str or int, if None, set to 8080
  • json – bool, should we expect json?
  • data – data to send (can be dict, list, str)
Returns:

dict

list_containers()

list all available containers for this backend

Returns:collection of instances of conu.apidefs.container.Container
list_deployments()

List all available deployments.

Returns:collection of instances of conu.backend.k8s.deployment.Deployment
list_images()

list all available images for this backend

Returns:collection of instances of conu.apidefs.image.Image
list_pods()

List all available pods.

Returns:collection of instances of conu.backend.k8s.pod.Pod
list_services()

List all available services.

Returns:collection of instances of conu.backend.k8s.service.Service
static login_to_registry(username)

Login within docker daemon to docker registry running in this OpenShift cluster :return:

new_app(image, project, source=None, template=None, name_in_template=None, other_images=None, oc_new_app_args=None)

Deploy app in OpenShift cluster using ‘oc new-app’ :param image: image to be used as builder image :param project: project where app should be created :param source: source used to extend the image, can be path or url :param template: str, url or local path to a template to use :param name_in_template: dict, {repository:tag} image name used in the template :param other_images: list of dict, some templates need other image to be pushed into the

OpenShift registry, specify them in this parameter as list of dict [{<image>:<tag>}], where “<image>” is DockerImage and “<tag>” is a tag under which the image should be available in the OpenShift registry.
Parameters:oc_new_app_args – additional parameters for the oc new-app
Returns:str, name of app
static push_to_registry(image, repository, tag, project)
Parameters:
  • image – DockerImage, image to push
  • repository – str, new name of image
  • tag – str, new tag of image
  • project – str, oc project
Returns:

DockerImage, new docker image

request_service(app_name, expected_output=None)

Make request on service of app. If there is connection error function return False. :param app_name: str, name of app :param expected_output: str, If not None method will check output returned from request

and try to find matching string.
Returns:bool, True if connection was established False if there was connection error
wait_for_service(app_name, expected_output=None, timeout=100)

Block until service is not ready to accept requests, raises an exc ProbeTimeout if timeout is reached :param app_name: str, name of app :param expected_output: If not None method will check output returned from request

and try to find matching string.
Parameters:timeout – int or float (seconds), time to wait for pod to run
Returns:None