def resume_upgrade(session, cloud_name, vpsa_id, return_type=None, **kwargs): """ Resume VPSA Upgrade :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vpsa_id: int :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas. For example: '2653'. Required. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_vpsa_id(vpsa_id) path = "/api/clouds/{0}/vpsas/{1}/resume_waiting.json" \ .format(cloud_name, vpsa_id) return session.post_api(path=path, return_type=return_type, **kwargs)
def get_cache(session, cloud_name, vpsa_id, **kwargs): """ Get VPSA cache :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vpsa_id: int :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas. For example: '2653'. Required. :type return_type: int :param return_type: If this is set to the string 'str', this function will return a cache size as a string. Otherwise, it will return an integer. Optional (will return an integer by default). :rtype: int, str :returns: Cache size as Int return_type parameter. """ verify_vpsa_id(vpsa_id) path = "/api/clouds/{0}/vpsas/{1}".format(cloud_name, vpsa_id) result = session.get_api(path=path, **kwargs) return result["vpsa"]["cache"]
def unassign_publicip(session, cloud_name, vsa_id, return_type=None, **kwargs): """ Unassign public IP from VPSAOS. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vsa_id: str :param vsa_id: The 'vsa_id' value as returned by get_all_vpsaoss. For example: 'vsa-000007de'. Required. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_cloud_name(cloud_name) verify_vpsa_id(vsa_id) path = '/api/clouds/{0}/zioses/{1}/public_ip/unassign.json' \ .format(cloud_name, vsa_id) return session.post_api(path=path, return_type=return_type, **kwargs)
def add_drives(session, cloud_name, vsa_id, drive_type, drive_quantity, skip_validation, return_type=None, **kwargs): """ Add drives to a VPSAOS. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vsa_id: str :param vsa_id: The 'vsa_id' value as returned by get_all_vpsaoss. For example: 'vsa-000007de'. Required. :type drive_type: str :param drive_type: Drive type internal name. Required :type drive_quantity: int :param drive_quantity: Number of drives to add. Required. :type skip_validation: bool :param skip_validation: Skips maximum drive validation. Use for admin only. Please notice that exceeding the number of drives allowed will waive the support for the VPSA. Required :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ cloud_name = verify_cloud_name(cloud_name) vsa_id = verify_vpsa_id(vsa_id) drive_type = verify_field(drive_type, 'drive_type') drive_quantity = verify_capacity(drive_quantity, 'drive_quantity') skip_validation = verify_bool_parameter(skip_validation) body_values = { 'drive_type': drive_type, 'quantity': drive_quantity, 'skip_validation': skip_validation } path = '/api/clouds/{0}/vpsas/{1}/drives.json'.format(cloud_name, vsa_id) return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def change_cache(session, cloud_name, vpsa_id, cache, return_type=None, **kwargs): """ Change VPSA cache :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vpsa_id: int :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas. For example: '2653'. Required. :type cache: str :param cache: New cache size :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_vpsa_id(vpsa_id) from zadarapy.provisioning_portal.vpsa import verify_cache_argument verify_cache_argument(cache, 'cache') path = "/api/clouds/{0}/vpsas/{1}/change_cache.json" \ .format(cloud_name, vpsa_id) body_values = {"cache": cache} return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def upgrade_vpsa_version(session, cloud_name, vpsa_id, image, when=None, return_type=None, **kwargs): """ Upgrade a VPSA to a new version. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vpsa_id: int :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas. For example: '2653'. Required. :type image: str :param image: The version to upgrade to. For example: '16.05-sp2-389'. Required. :type when: str :param when: When to trigger the VPSA version upgrade. Can be one of three values: "now" will initiate the upgrade ASAP - and is the default value if "when" parameter isn't passed. "manual" will prepare the standby VC with the new version for a later manually initiated completion. A date can also be passed in "%Y-%m-%d %H:%M" format. For example: "2017-10-20 19:30". This value is relative to the cloud's timezone setting. Optional. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ cloud_name = verify_field(cloud_name, "cloud_name") image = verify_field(image, "image") vpsa_id = verify_vpsa_id(vpsa_id) body_values = {'image': image} if when is not None: body_values['when'] = verify_field(when, "when") path = '/api/clouds/{0}/vpsas/{1}/upgrade.json'.format(cloud_name, vpsa_id) return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def add_drives(session, cloud_name, vsa_id, drive_type, drive_quantity, policy_id, return_type=None, **kwargs): """ Add drives to a VPSAOS. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vsa_id: str :param vsa_id: The 'vsa_id' value as returned by get_all_vpsaoss. For example: 'vsa-000007de'. Required. :type drive_type: str :param drive_type: Drive type internal name. Required :type drive_quantity: int :param drive_quantity: Number of drives to add. Required. :type policy_id: str :param policy_id: Storage policy id or internal name. Required :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ cloud_name = verify_cloud_name(cloud_name) vsa_id = verify_vpsa_id(vsa_id) policy_id = verify_field(policy_id, 'policy_id') drive_type = verify_field(drive_type, 'drive_type') body_values = {'drive_type': drive_type, 'policy_id': policy_id} if drive_quantity is not None: drive_quantity = verify_capacity(drive_quantity, 'drive_quantity') body_values['quantity'] = drive_quantity path = '/api/clouds/{0}/zioses/{1}/drives.json'.format(cloud_name, vsa_id) return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def upgrade_vpsaos_image(session, cloud_name, vsa_id, image, return_type=None, **kwargs): """ Upgrade a VPSAOS to a specified image. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vsa_id: str :param vsa_id: The 'vsa_id' value as returned by get_all_vpsaoss. For example: 'vsa-000007de'. Required. :type image: str :param image: The image 'name' value as returned by get_images. For example: 'zios-00.00-1389.img'. Required. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_cloud_name(cloud_name) verify_vpsa_id(vsa_id) verify_field(image, "image") body_values = {'image': image} path = '/api/clouds/{0}/zioses/{1}/upgrade.json'.format(cloud_name, vsa_id) return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def create_zsnap(session, cloud_name, vsa_id, prefix, return_type=None, **kwargs): """ Create a zsnap. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vsa_id: str :param vsa_id: The 'vsa_id' value as returned by get_all_vpsaoss. For example: 'vsa-000007de'. Required. :type prefix: str :param prefix: Required. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ cloud_name = verify_cloud_name(cloud_name) vsa_id = verify_vpsa_id(vsa_id) prefix = verify_field(prefix, 'prefix') body_values = {'prefix': prefix} path = '/api/clouds/{0}/zioses/{1}/zsnap.json'.format(cloud_name, vsa_id) return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def create_zsnap(session, cloud_name, vpsa_id, prefix, return_type=None, **kwargs): """ Create Zsnap from CC. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vpsa_id: int :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas. For example: '2653'. Required. :type prefix: str :param prefix: Z-Snap prefix :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ vpsa_id = verify_vpsa_id(vpsa_id) path = "/api/clouds/{0}/vpsas/{1}/zsnap.json" \ .format(cloud_name, vpsa_id) body_values = {'prefix': prefix} return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def change_engine_type(session, cloud_name, vpsa_id, when, app_engine_type=None, engine_type=None, image=None, return_type=None, **kwargs): """ Change VPSA engine type :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vpsa_id: int :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas. For example: '2653'. Required. :type image: str :param image: The version to upgrade to. For example: '16.05-sp2-389'. Required. :type when: str :param when: When to trigger the VPSA version upgrade. Can be one of three values: "now" will initiate the upgrade ASAP - and is the default value if "when" parameter isn't passed. "manual" will prepare the standby VC with the new version for a later manually initiated completion. A date can also be passed in "%Y-%m-%d %H:%M" format. For example: "2017-10-20 19:30". This value is relative to the cloud's timezone setting. Optional. :type engine_type: str :param engine_type: CCVM Engine Type :type app_engine_type: str :param app_engine_type: CCVM Application Engine Typ :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_vpsa_id(vpsa_id) path = "/api/clouds/{0}/vpsas/{1}/change_engine_type.json" \ .format(cloud_name, vpsa_id) body_values = {"when": when} if app_engine_type is not None: body_values["app_engine_type"] = app_engine_type if engine_type is not None: body_values["engine_type"] = engine_type if image is not None: body_values["image"] = image return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def add_storage_policy(session, cloud_name, vsa_id, policy_name, policy_desc, drive_type, drive_quantity, policy_type_id, return_type=None, **kwargs): """ Create a new storage policy in VPSAOS. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type cloud_name: str :param cloud_name: The cloud 'name' as returned by get_all_clouds. For example: 'zadaralab01'. Required. :type vsa_id: str :param vsa_id: The 'vsa_id' value as returned by get_all_vpsaoss. For example: 'vsa-000007de'. Required. :type policy_name: str :param policy_name: Storage policy name. Required :type policy_desc: str :param policy_desc: Storage policy description. Optional :type drive_type: str :param drive_type: Drive type internal name. Required :type drive_quantity: int :param drive_quantity: Number of drives to add. Required. :type policy_type_id: int :param policy_type_id: Policy type id as returned by vpsa_zone_group_storage_policy_type. Required. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ cloud_name = verify_cloud_name(cloud_name) vsa_id = verify_vpsa_id(vsa_id) policy_name = verify_field(policy_name, 'policy_name') drive_type = verify_field(drive_type, 'drive_type') body_values = {'name': policy_name, 'drive_type': drive_type} if policy_desc is not None: policy_desc = verify_field(policy_desc, 'policy_desc') body_values['policy_desc'] = policy_desc if drive_quantity is not None: drive_quantity = verify_capacity(drive_quantity, 'drive_quantity') body_values['drive_quantity'] = drive_quantity if policy_type_id is not None: policy_type_id = int(policy_type_id) if policy_type_id < 0: raise ValueError('policy_type_id {0} cannot be negative.'.format( policy_type_id)) body_values['policy_type_id'] = policy_type_id path = '/api/clouds/{0}/zioses/{1}/policy.json'.format(cloud_name, vsa_id) return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)