Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def restore_zios(session, cloud_name, zios_id, return_type=None, **kwargs):
    """
    Restore ZIOS.

    :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 zios_id: int
    :param zios_id: The ZIOS 'id' value as returned by get_all_zios_objects. 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.
    """
    zios_id = verify_zios_id(zios_id)
    cloud_name = verify_cloud_name(cloud_name)

    path = "/api/clouds/{0}/zioses/{1}/restore.json".format(cloud_name, zios_id)

    return session.post_api(path=path, return_type=return_type, **kwargs)
Ejemplo n.º 3
0
def upgrade_zios(session, cloud_name, zios_id, image, return_type=None, **kwargs):
    """
    Upgrade a ZIOS software 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 zios_id: int
    :param zios_id: The ZIOS 'id' value as returned by get_all_zios_objects. 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.
    """
    zios_id = verify_zios_id(zios_id)
    cloud_name = verify_cloud_name(cloud_name)
    image = verify_field(image, "image")

    body_values = {'image': image}

    path = "/api/clouds/{0}/zioses/{1}/upgrade.json".format(cloud_name, zios_id)
    return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
Ejemplo n.º 4
0
def get_all_zios_objects(session, cloud_name, per_page=30, page=1, return_type=None, **kwargs):
    """
    Retrieves details for all ZIOSs in the cloud.

    :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 page: int
    :param page: The page number to page from.  Optional.

    :type: per_page: int
    :param per_page: The total number of records to return.  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_cloud_name(cloud_name)

    page = verify_positive_argument(page, 'page')
    per_page = verify_positive_argument(per_page, 'per_page')

    path = "/api/clouds/{0}/zioses.json?per_page={1}&page={2}".format(cloud_name, per_page, page)

    return session.get_api(path=path, return_type=return_type, **kwargs)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
def create_storage_policy_zios(session, cloud_name, zios_id, policy_name, drive_type, drive_quantity,
                               policy_type_id, description=None, return_type=None, **kwargs):
    """
    Creates a new policy to ZIOS.

    :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 zios_id: int
    :param zios_id: The ZIOS 'id' value as returned by get_all_zios_objects. Required.

    :type policy_name: str
    :param policy_name: Policy name.  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_type_id: int
    :param policy_type_id: Storage policy type id.  Required.

    :type description: str
    :param description: Policy description

    :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.
    """
    zios_id = verify_zios_id(zios_id)
    cloud_name = verify_cloud_name(cloud_name)
    drive_type = verify_field(drive_type, 'drive_type')
    drive_quantity = verify_capacity(drive_quantity, 'drive_quantity')
    policy_type_id = verify_capacity(policy_type_id, 'policy_type_id')

    body_values = {"name":policy_name, "drive_type":drive_type,
                   "drive_quantity":drive_quantity, "policy_type_id":policy_type_id}

    if description is not None:
        body_values["description"] = description

    path = "/api/clouds/{0}/zioses/{1}/policy.json".format(cloud_name, zios_id)

    return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
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)