def order_file_volume(self, storage_type, location, size, os_type, iops=None, tier_level=None, snapshot_size=None): """Places an order for a file volume. :param storage_type: "performance_storage_iscsi" (performance) or "storage_service_enterprise" (endurance) :param location: Datacenter in which to order iSCSI volume :param size: Size of the desired volume, in GB :param os_type: OS Type to use for volume alignment, see help for list :param iops: Number of IOPs for a "Performance" order :param tier_level: Tier level to use for an "Endurance" order :param snapshot_size: The size of optional snapshot space, if snapshot space should also be ordered (None if not ordered) """ try: location_id = storage_utils.get_location_id(self, location) except ValueError: raise exceptions.SoftLayerError( "Invalid datacenter name specified. " "Please provide the lower case short name (e.g.: dal09)") base_type_name = 'SoftLayer_Container_Product_Order_Network_' package = storage_utils.get_package(self, storage_type) if storage_type == 'performance_storage_nfs': complex_type = base_type_name + 'PerformanceStorage_Nfs' prices = [ storage_utils.find_performance_price( package, 'performance_storage_nfs'), storage_utils.find_performance_space_price(package, iops), storage_utils.find_performance_iops_price(package, size, iops), ] elif storage_type == 'storage_service_enterprise': complex_type = base_type_name + 'Storage_Enterprise' prices = [ storage_utils.find_endurance_price(package, 'storage_file'), storage_utils.find_endurance_price( package, 'storage_service_enterprise'), storage_utils.find_endurance_space_price( package, size, tier_level), storage_utils.find_endurance_tier_price(package, tier_level), ] if snapshot_size is not None: prices.append( storage_utils.find_snapshot_space_price( package, snapshot_size, tier_level)) else: raise exceptions.SoftLayerError( "File volume storage_type must be either " "Performance or Endurance") order = { 'complexType': complex_type, 'packageId': package['id'], 'osFormatType': { 'keyName': os_type }, 'prices': prices, 'quantity': 1, 'location': location_id, } return self.client.call('Product_Order', 'placeOrder', order)
def order_block_volume(self, storage_type, location, size, os_type, iops=None, tier_level=None, snapshot_size=None): """Places an order for a block volume. :param storage_type: "performance_storage_iscsi" (performance) or "storage_service_enterprise" (endurance) :param location: Datacenter in which to order iSCSI volume :param size: Size of the desired volume, in GB :param os_type: OS Type to use for volume alignment, see help for list :param iops: Number of IOPs for a "Performance" order :param tier_level: Tier level to use for an "Endurance" order :param snapshot_size: The size of optional snapshot space, if snapshot space should also be ordered (None if not ordered) """ try: location_id = storage_utils.get_location_id(self, location) except ValueError: raise exceptions.SoftLayerError( "Invalid datacenter name specified. " "Please provide the lower case short name (e.g.: dal09)") base_type_name = 'SoftLayer_Container_Product_Order_Network_' package = storage_utils.get_package(self, storage_type) if storage_type == 'performance_storage_iscsi': complex_type = base_type_name + 'PerformanceStorage_Iscsi' prices = [ storage_utils.find_performance_price( package, 'performance_storage_iscsi' ), storage_utils.find_performance_space_price(package, iops), storage_utils.find_performance_iops_price(package, size, iops), ] elif storage_type == 'storage_service_enterprise': complex_type = base_type_name + 'Storage_Enterprise' prices = [ storage_utils.find_endurance_price(package, 'storage_block'), storage_utils.find_endurance_price( package, 'storage_service_enterprise' ), storage_utils.find_endurance_space_price( package, size, tier_level ), storage_utils.find_endurance_tier_price(package, tier_level), ] if snapshot_size is not None: prices.append(storage_utils.find_snapshot_space_price( package, snapshot_size, tier_level)) else: raise exceptions.SoftLayerError( "Block volume storage_type must be either " "Performance or Endurance") order = { 'complexType': complex_type, 'packageId': package['id'], 'osFormatType': {'keyName': os_type}, 'prices': prices, 'quantity': 1, 'location': location_id, } return self.client.call('Product_Order', 'placeOrder', order)