create_stored_iscsi_volume ( $opt )

This operation creates a volume on a specified gateway. This operation is supported only for the gateway-cached volume architecture.

The size of the volume to create is inferred from the disk size. You can choose to preserve existing data on the disk, create volume from an existing snapshot, or create an empty volume. If you choose to create an empty gateway volume, then any existing data on the disk is erased.

In the request you must specify the gateway and the disk information on which you are creating the volume. In response, AWS Storage Gateway creates the volume and returns volume information such as the volume Amazon Resource Name (ARN), its size, and the iSCSI target ARN that initiators can use to connect to the volume target.

Access

public

Parameters

Parameter

Type

Required

Description

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • GatewayARN - string - Required - The Amazon Resource Name (ARN) of the gateway. Use the ListGateways operation to return a list of gateways for your account and region.
  • DiskId - string - Required - The unique identifier for the gateway local disk that is configured as a stored volume. Use ListLocalDisks to list disk IDs for a gateway.
  • SnapshotId - string - Optional - The snapshot ID (e.g. “snap-1122aabb”) of the snapshot to restore as the new stored volume. Specify this field if you want to create the iSCSI storage volume from a snapshot otherwise do not include this field. To list snapshots for your account use DescribeSnapshots in the Amazon Elastic Compute Cloud API Reference. [Constraints: The value must match the following regular expression pattern: \Asnap-[0-9a-fA-F]{8}\z]
  • PreserveExistingData - boolean - Required - Specify this field as true if you want to preserve the data on the local disk. Otherwise, specifying this field as false creates an empty volume. Valid Values: true, false
  • TargetName - string - Required - The name of the iSCSI target used by initiators to connect to the target and as a suffix for the target ARN. For example, specifying TargetName as myvolume results in the target ARN of arn:aws:storagegateway:us-east-1:111122223333:gateway/mygateway/target/iqn.1997-05.com.amazon:myvolume. The target name must be unique across all volumes of a gateway. [Constraints: The value must be between 1 and 200 characters, and must match the following regular expression pattern: ^[-\.;a-z0-9]+$]
  • NetworkInterfaceId - string - Required - The network interface of the gateway on which to expose the iSCSI target. Only IPv4 addresses are accepted. Use DescribeGatewayInformation to get a list of the network interfaces available on a gateway. Valid Values: A valid IP address. [Constraints: The value must match the following regular expression pattern: \A(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\z]
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Volumes and Snapshots

$ec2 = new AmazonEC2();
$sg = new AmazonStorageGateway();

// Get network interface ID
$response = $sg->describe_gateway_information(array('GatewayARN' => $gateway_arn));
var_dump($response->isOK());
$network_interface_id = (string) $response->body->GatewayNetworkInterfaces->Ipv4Address;

// Get local disk
$response = $sg->list_local_disks(array('GatewayARN' => $gateway_arn));
var_dump($response->isOK());
$disks = $response->body->DiskId()->map_string();
$disk_id = $disks[1];

// List iSCSI volumes
$response = $sg->list_volumes(array('GatewayARN' => $gateway_arn));
var_dump($response->isOK());

// Add iSCSI volume
$response = $sg->create_stored_iscsi_volume(array(
	'GatewayARN'           => $gateway_arn,
	'DiskId'               => $disk_id,
	'NetworkInterfaceId'   => $network_interface_id,
	'PreserveExistingData' => true,
	'TargetName'           => 'aws-sdk-php-test-volume-01',
));
var_dump($response->isOK());
$volume_arn = (string) $response->body->VolumeARN;
$target_arn = (string) $response->body->TargetARN;

// Wait until volume is available
do
{
	sleep(20); echo '.';
	$response = $sg->describe_stored_iscsi_volumes(array('VolumeARNs' => array($volume_arn)));
	$status = $response->body->VolumeStatus()->map_string();
	$status = (string) reset($status);
} while ($status !== 'AVAILABLE');

// List iSCSI volumes
$response = $sg->list_volumes(array('GatewayARN' => $gateway_arn));
var_dump($response->isOK());

// Update snapshot schedule
$response = $sg->update_snapshot_schedule(array(
	'VolumeARN'         => $volume_arn,
	'StartAt'           => 0,
	'RecurrenceInHours' => 24,
	"Description"       => 'daily snapshot',
));
var_dump($response->isOK());

// Describe snapshot schedule
$response = $sg->describe_snapshot_schedule(array(
	'VolumeARN' => $volume_arn,
));
var_dump($response->isOK());

// Update chap credentials
$response = $sg->update_chap_credentials(array(
	'TargetARN'                     => $target_arn,
	'SecretToAuthenticateInitiator' => '111111111111',
	'InitiatorName'                 => 'example-initiator',
	'SecretToAuthenticateTarget'    => '222222222222',
));
var_dump($response->isOK());

// Describe chap credentials
$response = $sg->describe_chap_credentials(array(
	'TargetARN' => $target_arn,
));
var_dump($response->isOK());

// Delete chap credentials
$response = $sg->delete_chap_credentials(array(
	'TargetARN'     => $target_arn,
	'InitiatorName' => 'example-initiator',
));
var_dump($response->isOK());

// Delete iSCSI volume
$response = $sg->delete_volume(array(
	'VolumeARN'  => $volume_arn,
));
var_dump($response->isOK());

// List iSCSI volumes
$response = $sg->list_volumes(array('GatewayARN' => $gateway_arn));
var_dump($response->isOK());

Source

Method defined in services/storagegateway.class.php | Toggle source view (6 lines) | View on GitHub

public function create_stored_iscsi_volume($opt = null)
{
    if (!$opt) $opt = array();
    
    return $this->authenticate('CreateStorediSCSIVolume', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback