ironik.rancher package

Submodules

ironik.rancher.kubernetes_api_caller module

author

Jonathan Decker

ironik.rancher.kubernetes_api_caller.apply_controller_manager_manifests(kube_client, openstack_config)[source]
Parameters
Return type

bool

Returns:

ironik.rancher.kubernetes_api_caller.apply_csi_driver_manifests(kube_client)[source]
Parameters

kube_client (kubernetes.client.api.core_v1_api.CoreV1Api) –

Return type

bool

Returns:

ironik.rancher.kubernetes_api_caller.create_cloud_conf_secret(kube_client, cloud_conf_str)[source]
Parameters
  • kube_client (kubernetes.client.api.core_v1_api.CoreV1Api) –

  • cloud_conf_str (str) –

Return type

bool

Returns:

ironik.rancher.kubernetes_api_caller.init_client(kube_config)[source]
Parameters

kube_config (str) –

Returns

Return type

kubernetes.client.api.core_v1_api.CoreV1Api

ironik.rancher.kubernetes_api_caller.verify_client(kube_client)[source]
Parameters

kube_client (kubernetes.client.api.core_v1_api.CoreV1Api) –

Return type

bool

Returns:

ironik.rancher.rancher_api_caller module

author

Jonathan Decker

ironik.rancher.rancher_api_caller.add_rancher_base_binding_to_user(session, rancher_config, user_id)[source]

Makes an API call to rancher to add the user-base role binding to the given user id. :param rancher_config: :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :param user_id: :return: True if it worked and false otherwise. :rtype: bool

Parameters
Return type

bool

ironik.rancher.rancher_api_caller.check_rancher_cluster_ready(session, cluster_id, rancher_config)[source]
Parameters
Returns

Return type

bool

ironik.rancher.rancher_api_caller.check_rancher_nodes_ready(session, cluster_id, rancher_config)[source]

Checks how many nodes for the given cluster are in an active state and returns the number. :param rancher_config: :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :param cluster_id: Id of the cluster to which the nodes should belong. :type cluster_id: str :return: The number of active nodes. :rtype: init

Parameters
Return type

int

ironik.rancher.rancher_api_caller.create_and_test_rancher_session(rancher_credentials, rancher_config)[source]

Calls create rancher session and communicates possible errors. :param rancher_config: :param rancher_credentials: :return: Returns a requests Session which is configured to authenticate with rancher or None if the session is not valid. :rtype: requests.Session or None

Parameters
Return type

requests.sessions.Session

ironik.rancher.rancher_api_caller.create_rancher_cluster(session, rancher_config, cluster_name, iso_time_stamp, rke_config)[source]

Makes an API call to rancher to create a new cluster using the given parameters. :param rancher_config: :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :param cluster_name: The name for the cluster in Rancher. :type cluster_name: str :param iso_time_stamp: Iso time stamp which is written to the description of the new cluster. :type iso_time_stamp: str :param rke_config: Rancher kubernetes engine configuration as produced by rke template. :type rke_config: dict :return: The id of the new cluster in rancher. :rtype: str

Parameters
Return type

str

ironik.rancher.rancher_api_caller.create_rancher_node_pool(session, cluster_name, cluster_id, node_template_id, is_master, kubernetes_config, rancher_config)[source]

Makes an API call the rancher API to create a new node pool for the given cluster with the given node template. Quantity of 0 will be accepted but the new node pool will not show up in the UI. :param rancher_config: :param kubernetes_config: :param cluster_name: Name of the cluster, used to prefix the name of the nodes. :type cluster_name: str :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :param cluster_id: Id of the cluster in rancher. :type cluster_id: str :param node_template_id: Id of the node template to use for the cluster. :type node_template_id: str :param is_master: Indicates whether the nodes are supposed to be master nodes for the kubernetes cluster or just worker nodes. Master nodes also get the roles etcd and controlPlane in addition to worker. Worker only get the worker role. Further the name prefix for master nodes is master and worker for worker. :type is_master: bool :return: Id of the node pool in rancher. :rtype: str

Parameters
Return type

str

ironik.rancher.rancher_api_caller.create_rancher_node_template(session, openstack_credentials, openstack_config, rancher_config, template_name)[source]

Queries rancher API to create a new node template based on the given instructions and returns the id of the template. :param rancher_config: :param openstack_config: :param openstack_credentials: :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :param template_name: The name of the template in rancher. :type template_name: str :return: Id of the node template created in rancher. :rtype: str

Parameters
Return type

str

ironik.rancher.rancher_api_caller.create_rancher_session(rancher_access_key, rancher_secret_key, disable_verify=True)[source]

Creates a requests Session used to access Rancher API. This needs to be forwarded to any function making API calls to Rancher. SSL verification is disabled by default as the test server does not have a valid ssl certificate. :param rancher_access_key: :param rancher_secret_key: :param disable_verify: Determines whether ssl verification and warnings should be disabled. :type disable_verify: bool :return: A Session object used to make API calls to Rancher. :rtype: requests.Session

Parameters
  • rancher_access_key (str) –

  • rancher_secret_key (str) –

  • disable_verify (bool) –

Return type

requests.sessions.Session

ironik.rancher.rancher_api_caller.create_rancher_user(session, rancher_config)[source]

Makes an API call to rancher to create a new user in rancher with the given name and password, setting must change password on first login to true. :param rancher_config: :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :return: Id of the user. :rtype: str

Parameters
Return type

str

ironik.rancher.rancher_api_caller.get_rancher_kubernetes_engine_config(kubernetes_config, network_config)[source]
Parameters
Return type

dict

Returns:

ironik.rancher.rancher_api_caller.get_rancher_user_id(session, rancher_config)[source]

Queries the rancher API to check if a user exists and returns true if it does and false otherwise. :param rancher_config: :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :return: :rtype:

Parameters
Return type

str

ironik.rancher.rancher_api_caller.get_rke_template(kubernetes_config, network_config)[source]
Parameters
Returns

Return type

dict

ironik.rancher.rancher_api_caller.make_rancher_user_cluster_owner(session, cluster_id, rancher_config, user_id)[source]

Makes an API call to rancher to make the given user id owner of the given cluster. :param rancher_config: :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :param cluster_id: Id of the cluster. :type cluster_id: str :param user_id: :return: True if it worked and false otherwise. :rtype: bool

Parameters
Return type

bool

ironik.rancher.rancher_api_caller.request_kubeconfig(session, cluster_id, rancher_config)[source]
Parameters
Returns

Return type

str

ironik.rancher.rancher_api_caller.verify_rancher_token(session, base_url)[source]

Verifies whether a Rancher token is valid by trying to get the given base url using the given Session object. Returns True if everything is fine and False if either the token is invalid or the url is unreachable. :param session: A Session object initialized by create_rancher_session. :type session: requests.Session :param base_url: Base url of the Rancher API, should be the URL of the Rancher server with /v3 attached to it. :type base_url: str :return: True if the token is valid and false if either the token is invalid or the url is unreachable. :rtype: bool

Parameters
  • session (requests.sessions.Session) –

  • base_url (str) –

Return type

bool

Module contents