ironik.openstack_handler package

Submodules

ironik.openstack_handler.openstack_api_caller module

author

Jonathan Decker

ironik.openstack_handler.openstack_api_caller.associate_openstack_floating_ip_with_port_id(conn, public_network_id, target_port)[source]

Makes API calls to openstack to delete unattached floating IPs and create a new one and attach it to the given port. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :param public_network_id: Id of the public network from which the floating IP should come. :type public_network_id: str :param target_port: Id of the port, the new floating IP should be attached to. :type target_port: str :return: Dictionary or munch representing the newly assigned floating IP. :rtype: dict

Parameters
  • conn (openstack.connection.Connection) –

  • public_network_id (str) –

  • target_port (str) –

Return type

dict

ironik.openstack_handler.openstack_api_caller.create_and_test_openstack_connection(openstack_credentials, openstack_config)[source]

Call create openstack connection and communicates possible errors. :param openstack_credentials: :param openstack_config:

Parameters
Return type

openstack.connection.Connection

ironik.openstack_handler.openstack_api_caller.create_openstack_connection(username, password, project_id, auth_url, region_name, user_domain_name, project_domain_name)[source]

Creates an openstack.connection.Connection object based on the given credentials and further information from gwdg_defaults. This alone does not validate any of the credentials. This is the base object for all API calls to Openstack using the openstacksdk. Docs can be found here: https://docs.openstack.org/openstacksdk/latest/user/connection.html :param username: Openstack username. :type username: str :param password: Openstack password. :type password: str :param project_id: Openstack project id for which this tool should run. :type project_id: str :param auth_url: Openstack authentication url, which should be the identity service url followed by /v3. :type auth_url: str :return: A connection object from the openstacksdk. :rtype: openstack.connection.Connection :param region_name: :param user_domain_name: :param project_domain_name:

Parameters
  • username (str) –

  • password (str) –

  • project_id (str) –

  • auth_url (str) –

  • region_name (str) –

  • user_domain_name (str) –

  • project_domain_name (str) –

Return type

openstack.connection.Connection

ironik.openstack_handler.openstack_api_caller.create_openstack_security_group(conn, openstack_config, network_config, cluster_name)[source]

Checks whether a security group with the given name already exists and if yes, tries to delete and recreate it. Finally, returns the name of the newly created security group. :param conn: Valid openstack connection :type conn: openstack.connection.Connection :param openstack_config: :param network_config: :param cluster_name: :return: :rtype: bool

Parameters
Return type

bool

ironik.openstack_handler.openstack_api_caller.find_floating_ip_for_internal_ip(conn, internal_ip)[source]
Parameters
  • conn (openstack.connection.Connection) – A connection object initialized by create_openstack_connection.

  • internal_ip (str) – The internal IP inside OpenStack of an instance or load balancer.

Returns

The respective floating IP associated with the internal IP or an empty string.

Return type

str

ironik.openstack_handler.openstack_api_caller.find_openstack_load_balancer_port_id_by_ip(conn, openstack_config, load_balancer_internal_ip)[source]

Makes a call to the openstack API to find the id of port belonging to a load balancer with the given ip. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :param openstack_config: :param load_balancer_internal_ip: Ip of the load balancer device. :type load_balancer_internal_ip: str :return: Id of the target port. :rtype: str

Parameters
Return type

str

ironik.openstack_handler.openstack_api_caller.find_out_openstack_floating_ip_is_free(conn)[source]

Make a call to the openstack API to get the current floating IPs and check whether an IP is not attached. It further tries to claim another floating IP to check whether quota is still left for additional floating IPs in case all listed floating IPs are already attached. Returns a tuple with the number of attached IPs and a bool than indicates whether at least one floating IP is free. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: A tuple with an int that represents the number of attached IPs and a bool that indicates whether at least one floating IP is free :rtype: (int, bool)

Parameters

conn (openstack.connection.Connection) –

Return type

Tuple[int, bool]

ironik.openstack_handler.openstack_api_caller.get_openstack_compute_limits(conn)[source]

Makes a call to the openstack API for the compute limits, converts it into a dictionary and returns it. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: A dictionary containing the compute limits of the openstack account. :rtype: dict

Parameters

conn (openstack.connection.Connection) –

Return type

dict

ironik.openstack_handler.openstack_api_caller.get_openstack_flavors(conn)[source]

Makes a call to the openstack API to receive the available flavors and filters the returned attributes. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: A list of dictionaries each describing a flavor. :rtype: list[dict]

Parameters

conn (openstack.connection.Connection) –

Return type

list[dict]

ironik.openstack_handler.openstack_api_caller.get_openstack_images(conn)[source]

Makes a call to the openstack API to receive the available images and filter the returned attributes. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: A list of dictionaries each describing an image. :rtype: list[dict]

Parameters

conn (openstack.connection.Connection) –

Return type

list[dict]

ironik.openstack_handler.openstack_api_caller.get_openstack_public_and_private_networks(conn)[source]

Makes a request to the openstack API for all networks and finds the public network and declares all other networks as private networks. Returns a tuple with the public network and the list of private networks. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: A tuple with a dictionary for the public network and a list of dictionaries for the private networks. :rtype: (dict, list[dict])

Parameters

conn (openstack.connection.Connection) –

Return type

Tuple[dict, list[dict]]

ironik.openstack_handler.openstack_api_caller.get_openstack_routers(conn)[source]

Make a request to the Openstack API to get all routers, filter some attributes and return a list of dictionaries. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: A list of dictionaries where each entry represents a router. :rtype: list[dict]

Parameters

conn (openstack.connection.Connection) –

Return type

list[dict]

ironik.openstack_handler.openstack_api_caller.get_openstack_subnets(conn)[source]

Makes a request to the openstack API to get all subnets, filter some attributes and return a list of dictionaries. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: A list of dictionaries where each entry represents a subnet. :rtype: list[dict]

Parameters

conn (openstack.connection.Connection) –

Return type

list[dict]

ironik.openstack_handler.openstack_api_caller.get_openstack_volume_limits(conn)[source]

Returns a dict with the volume limits for the given OpenStack connection.

Parameters
  • (conn (conn) – openstack.connection.Connection): A connection object initialized by create_openstack_connection.

  • conn (openstack.connection.Connection) –

Returns

A dictionary containing the volume limits of the openstack account.

Return type

dict

ironik.openstack_handler.openstack_api_caller.match_subnet(conn, network_id)[source]

Calls get openstack subnets and matches the subnet with the given network id or calls ask for subnet if there are multiple subnets. :param conn: Valid openstack connection :type conn: openstack.connection.Connection :param network_id: Network Id of the external network of the GWDG openstack deployment. :type network_id: str :return: Dictionary representing the subnet :rtype: dict

Parameters
  • conn (openstack.connection.Connection) –

  • network_id (str) –

Return type

dict

ironik.openstack_handler.openstack_api_caller.verify_openstack_connection(conn)[source]

Verifies that the openstack connection is valid by making a simple API call. Returns True if it is valid and false otherwise. :param conn: A connection object initialized by create_openstack_connection. :type conn: openstack.connection.Connection :return: True if the connection is valid and false otherwise. :rtype: bool

Parameters

conn (openstack.connection.Connection) –

Return type

bool

ironik.openstack_handler.resource_calculator module

author

Jonathan Decker

ironik.openstack_handler.resource_calculator.calculate_free_resources(conn, flavor_dict, kubernetes_config, openstack_config, check_ip)[source]

Check whether compute limits can satisfy requested deployment and give an overview.

Calls get openstack compute limits, as well as get openstack volume limits and calculates how many resources will be used by deploying the given number of master and worker nodes with the given flavors and volumes. Also displays an overview.

Parameters
  • conn (openstack.connection.Connection) – Valid openstack connection.

  • flavor_dict (dict) – Dictionary of the master flavor as returned by ask for flavor.

  • kubernetes_config (KubernetesConfig) –

  • openstack_config (OpenStackConfig) –

  • check_ip (bool) – Whether to skip checking for free floating IPs, will skip if False.

Returns

A bool that is true if the required resources fit within the maximum allowed compute limits

Return type

bool

ironik.openstack_handler.resource_calculator.preprocess_and_calculate_resource_consumption(openstack_config, deployment_options, kubernetes_config, openstack_connection, flavors, images)[source]
Parameters
Return type

bool

Returns:

Module contents