def remove_proxy_vcs(session, quantity, return_type=None, **kwargs): """ Removes proxy vcs. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type quantity: int :param quantity: The number of vcs to be removed. 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_capacity(quantity, "quantity") path = '/api/zios/virtual_controllers/remove_proxy_vcs.json' parameters = get_parameters_options([('quantity', quantity)]) return session.delete_api(path=path, parameters=parameters, return_type=return_type, **kwargs)
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)
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 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 add_raid_groups_to_pool(session, pool_id, raid_groups, capacity, return_type=None, **kwargs): """ Adds RAID groups to a storage pool. RAID groups need to be of the same type as the RAID groups already participating in the pool. RAID groups also must not be allocated to another pool. :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 raid_groups: str :param raid_groups: A comma separated string of RAID groups with no spaces around the commas. The value must match RAID groups's 'name' attribute. For example: 'RaidGroup-3,RaidGroup-4'. Required. :type capacity: int :param capacity: The total capacity in GB that will be added for the storage pool. May not exceed the capacity of the combined added RAID groups. 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_pool_id(pool_id) verify_raid_groups(raid_groups) capacity = verify_capacity(capacity, "Storage pool") body_values = { 'raid_groups': raid_groups, 'capacity': '{0}G'.format(capacity) } path = '/api/pools/{0}/expand.json'.format(pool_id) return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def delete_drives_from_policy(session, policy_name, drive_type, quantity, return_type=None, **kwargs): """ Remove drives from storage policy :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type policy_name: str :param policy_name: The Policy name 'name' value as returned by get_all_policies. Required. :type drive_type: str :param drive_type: Type of the drives the user wish to remove from the policy. Required. e.g SAS_300_GB :type quantity: int :param quantity: Quantity of the drives the user wish to remove from the policy. 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. """ path = '/api/zios/policies/{0}/drives.json'.format(policy_name) drive_type = verify_field(drive_type, 'drive_type') quantity = verify_capacity(quantity, 'quantity') body = {"drives": [{"type": drive_type, "quantity": quantity}]} return session.delete_api(path=path, body=body, secure=True, 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)
def create_pool(session, display_name, raid_groups, capacity, pooltype, cache='NO', cowcache='YES', mode='stripe', return_type=None, **kwargs): """ Creates a new storage pool. A storage pool is an abstraction over RAID groups. Multiple RAID groups can, and often do, participate in a single storage pool. Volumes are then created on the storage pool, rather than on the individual RAID groups. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type display_name: str :param display_name: A text label to assign to the pool. For example: 'pool1', 'pool2', etc. May not contain a single quote (') character. Required. :type raid_groups: str :param raid_groups: A comma separated string of RAID groups with no spaces around the commas. The value must match RAID groups's 'name' attribute. For example: 'RaidGroup-1,RaidGroup-2'. Required. :type capacity: int :param capacity: The total capacity in GB that will be created for the storage pool. May not exceed the capacity of the combined underlying RAID groups. Required. :type pooltype: str :param pooltype: Whether the pool should be set to Transactional, Repository, or Archival type. Transactional is useful for more space efficient writes on snapshots, but requires 4x as much memory, therefore is limited to 20TB maximum space. Repository is a good general purpose option that suits all workloads up to 100TB. Archival can be used when >100TB pools are mandatory, but comes with restrictions such as minimum 1 hour snapshot interval (instead of 1 minute). Please see the VSPA User Guide "Pools" section for a more descriptive definition of these types. Must be the string 'Transactional', 'Repository', or 'Archival'. Required. :type cache: str :param cache: If set to 'YES', SSD caching will be enabled for this pool. Optional, set to 'NO' by default. :type cowcache: str :param cowcache: If set to 'YES', the pool's copy on write (CoW) operations will occur on SSD for elevated performance instead of directly on the underlying drives. In certain extreme scenarios, this may be detrimental. It is suggested to leave 'YES' unless instructed by a Zadara Storage representative. Optional, set to 'YES' by default. :type mode: str :param mode: If set to 'stripe', use striping to distribute data across all participating RAID sets in the pool - this should always be used for pools with more than one RAID group, unless you know what you're doing. If set to 'simple', data will fill up one RAID group before moving to the next (worse for performance than stripe). Single RAID group pools will be set to 'simple' below automatically. 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. """ display_name = verify_field(display_name, "display_name") capacity = verify_capacity(capacity, "Storage Pool") verify_raid_groups(raid_groups) verify_pool_type(pooltype) cache = verify_boolean(cache, "cache") mode = verify_mode(mode) # If only one RAID group will be participating in this pool, force the # mode to simple. if len(raid_groups.split(',')) == 1: mode = 'simple' body_values = { 'display_name': display_name, 'capacity': '{0}G'.format(capacity), 'raid_groups': raid_groups, 'cache': cache, 'mode': mode } if pooltype == 'Transactional': pooltype = 'Transactional Workloads' else: pooltype = '{0} Storage'.format(pooltype) body_values['pooltype'] = pooltype # CoW cache can only be enabled or disabled for pools where primary cache # is enabled. if cache == 'YES': cowcache = verify_boolean(cowcache, "cowcache") body_values['cowcache'] = str(cowcache == 'YES').lower() path = '/api/pools.json' return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)