示例#1
0
def hibernate_vpsa(session, vpsa_id, return_type=None, **kwargs):
    """
    Hibernates a VPSA.  A hibernated VPSA will have all IO and ZCS engines
    shutdown, during which time there is no hourly cost incurred for those
    engines (costs still apply for all attached drives).  This action is
    immediate and does not require a storage cloud administrator's approval.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  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_positive_argument(vpsa_id, 'vpsa_id')
    path = '/api/vpsas/{0}/hibernate.json'.format(vpsa_id)

    return session.post_api(path=path, return_type=return_type, **kwargs)
示例#2
0
def resume_vpsa(session, vpsa_id, return_type=None, **kwargs):
    """
    Resumes a hibernated VPSA.  This action is immediate and does not require
    a storage cloud administrator's approval.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  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_positive_argument(vpsa_id, 'vpsa_id')
    path = '/api/vpsas/{0}/restore.json'.format(vpsa_id)

    return session.post_api(path=path, return_type=return_type, **kwargs)
示例#3
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)
示例#4
0
def remove_vpsa_public_ip(session, vpsa_id, return_type=None, **kwargs):
    """
    Submits a request to remove a public IP from a VPSA.  This must be
    approved by a storage cloud administrator before the public IP is
    assigned.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  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_positive_argument(vpsa_id, 'vpsa_id')
    path = '/api/vpsas/{0}/public_ip.json'.format(vpsa_id)

    return session.delete_api(path=path, return_type=return_type, **kwargs)
示例#5
0
def change_vpsa_engines(session,
                        vpsa_id,
                        io_engine_id,
                        zcs_engine_id,
                        return_type=None,
                        **kwargs):
    """
    Submits a request to create a new VPSA.  This must be approved by a
    storage cloud administrator before the VPSA creation starts.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  Required.

    :type vpsa_id: int
    :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas.  For
        example: '2653'.  Required.

    :type io_engine_id: str
    :param io_engine_id: The IO engine 'key' value as returned by the
        'engine_types' list for cloud_id from get_cloud.  For example:
        'vsa.V2.baby.vf'.  This can be the same value as the existing IO
        engine.  Required.

    :type zcs_engine_id: str
    :param zcs_engine_id: The ZCS engine 'key' value as returned by the
        'app_engine_types' list for cloud_id from get_cloud.  For example:
        'tiny'.  Can also be the string 'None', which will disable the ZCS
        engine for this VPSA.  This can be the same value as the existing ZCS
        engine.  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_positive_argument(vpsa_id, 'vpsa_id')
    verify_io_engine_id(io_engine_id)
    verify_zcs_engine_id(zcs_engine_id)
    body = {'engine': io_engine_id, 'app_engine': zcs_engine_id}
    path = '/api/vpsas/{0}/engine.json'.format(vpsa_id)

    return session.post_api(path=path,
                            body=body,
                            return_type=return_type,
                            **kwargs)
示例#6
0
def change_vpsa_cache(session, vpsa_id, quantity, return_type=None, **kwargs):
    """
    Sets the quantity of additional cache groups for a VPSA.  The quantity of
    cache groups that comes with the base engine is not included in this
    calculation.  For example, if the engine comes with 2 cache groups,
    passing a quantity of 0 will result in 2 total groups, a quantity of 1
    will result in 3 total groups, and so on.  Conversely, in the same
    example, to go from 4 to 2 cache groups, a quantity of 0 would be needed.
    This must be approved by a storage cloud administrator before the cache
    groups are modified.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  Required.

    :type vpsa_id: int
    :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas.  For
        example: '2653'.  Required.

    :type quantity: int
    :param quantity: As described above, the total number of additional cache
        groups needed in addition to the groups that come with the engine.
        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_positive_argument(vpsa_id, 'vpsa_id')
    verify_cache_argument(quantity, 'quantity')

    path = '/api/vpsas/{0}/cache.json'.format(vpsa_id)
    body = {'cache': '{}'.format(quantity)}

    return session.post_api(path=path,
                            body=body,
                            return_type=return_type,
                            **kwargs)
示例#7
0
def get_pool_performance(session,
                         pool_id,
                         interval=1,
                         return_type=None,
                         **kwargs):
    """
    Retrieves metering statistics for the pool for the specified interval.
    Default interval is one second.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  Required.

    :type pool_id: str
    :param pool_id: The pool 'name' value as returned by get_all_pools.  For
        example: 'pool-00000001'.  Required.

    :type interval: int
    :param interval: The interval to collect statistics for, in seconds.

    :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_pool_id(pool_id)
    interval = verify_positive_argument(interval, "interval")

    path = '/api/pools/{0}/performance.json'.format(pool_id)

    parameters = {'interval': interval}

    return session.get_api(path=path,
                           parameters=parameters,
                           return_type=return_type,
                           **kwargs)
示例#8
0
def add_drives_to_vpsa(session, vpsa_id, drives, return_type=None, **kwargs):
    """
    Submits a request to add drives to a VPSA.  This must be approved by a
    storage cloud administrator before the drives are added.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  Required.

    :type vpsa_id: int
    :param vpsa_id: The VPSA 'id' value as returned by get_all_vpsas.  For
        example: '2653'.  Required.

    :type drives: list
    :param drives: A Python list of Python dictionaries that defines what type
        and how many of each type of drive to attach to the VPSA.  Each list
        item should contain a dictionary that defines a 'drive_type' key and
        'quantity' key.  The 'drive_type' key is the 'key' value as returned
        by the 'drive_types' list for the cloud_id from get_cloud.  For
        example: 'SATA_2793GB_5940RPM'.  The 'quantity' key is the number of
        drives to add for this type.  Every VPSA must have at least two
        drives.

        For example, to add two SATA 3TB drives and two 600GB SAS drives, use
        the following:

        [{'drive_type':'SATA_2793GB_5940RPM','quantity':2},
         {'drive_type':'SAS_557GB_10500RPM','quantity':2}]

        Please note that the example is not a string, rather a representation
        of what the "pprint" function might return.  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_positive_argument(vpsa_id, "vpsa_id")
    body = {}

    if type(drives) is not list:
        raise ValueError('The passed "drives" parameter is not a Python '
                         'list.')

    for v in drives:
        if type(v) is not dict:
            raise ValueError('Each item in the "drives" list must be a '
                             'Python dictionary.')

        if 'drive_type' not in v:
            raise ValueError('The required "drive_type" key was not found in '
                             'the drive dictionary.')

        if 'quantity' not in v:
            raise ValueError('The required "quantity" key was not found in '
                             'the drive dictionary.')

        body[v['drive_type'] + '_drives'] = v['quantity']

    path = '/api/vpsas/{0}/drives.json'.format(vpsa_id)

    return session.post_api(path=path,
                            body=body,
                            return_type=return_type,
                            **kwargs)
示例#9
0
def update_pool_capacity_alerts(session,
                                pool_id,
                                capacityhistory=None,
                                alertmode=None,
                                protectedmode=None,
                                emergencymode=None,
                                return_type=None,
                                **kwargs):
    """
    Update the pool alerting thresholds.  Alerts are used both to notify
    administrators of pending pool space exhaustion, as well as deleting
    the oldest snapshots in an attempt to free space.  Parameters set to
    'None' will not have their existing values changed.

    :type session: zadarapy.session.Session
    :param session: A valid zadarapy.session.Session object.  Required.

    :type pool_id: str
    :param pool_id: The pool 'name' value as returned by get_all_pools.  For
        example: 'pool-00000001'.  Required.

    :type capacityhistory: int
    :param capacityhistory: The number of minutes used to calculate pool
        exhaustion.  This value is used in conjunction with "alertmode".  For
        example, if "capacityhistory" is 60 minutes, the VPSA will use the
        amount of data written in the last 60 minutes to calculate the write
        rate for the "alertmode" value.  Optional.

    :type alertmode: int
    :param alertmode: The number of minutes before the storage pool is
        predicted to reach space exhaustion.  Works in conjunction with the
        "capacityhistory" value.  If the VPSA predicts the pool will run out
        of space in less than or equal to the amount of minutes defined here,
        an alert will be sent to the VPSA administrator.  Optional.

    :type protectedmode: int
    :param protectedmode: If the number of minutes before the pool is
        predicted to reach space exhaustion is less than this value, the VPSA
        will not allow the creation of new volumes, shares, or snapshots.
        Optional.

    :type emergencymode: int
    :param emergencymode: If the number of GB free on the pool is less than
        this value, the VPSA will start deleting old snapshots in an attempt
        to prevent space exhaustion.  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.
    """
    verify_pool_id(pool_id)
    capacityhistory = verify_positive_argument(capacityhistory,
                                               "capacityhistory")
    alertmode = verify_positive_argument(alertmode, "alertmode")
    protectedmode = verify_positive_argument(protectedmode, "protectedmode")
    emergencymode = verify_positive_argument(emergencymode, "emergencymode")
    body_values = {}

    if capacityhistory is not None:
        body_values['capacityhistory'] = capacityhistory

    if alertmode is not None:
        body_values['alertmode'] = alertmode

    if protectedmode is not None:
        body_values['protectedmode'] = protectedmode

    if emergencymode is not None:
        body_values['emergencymode'] = emergencymode

    if not body_values:
        raise ValueError('At least one of the following must be set: '
                         '"capacityhistory", "alertmode", "protectedmode", '
                         '"emergencymode"')

    path = '/api/pools/{0}/update_protection.json'.format(pool_id)

    return session.post_api(path=path,
                            body=body_values,
                            return_type=return_type,
                            **kwargs)