12.8. Importing a Block Storage Domain
12.8.1. Importing a Block Storage Domain
An existing block storage domain with
type
set to iscsi
or fcp
can be imported to the engine using the REST API. The ability to import storage domains allows you to recover data in the event of a failure in the engine database, and to migrate data from one data center or environment to another.
This procedure assumes the storage domain is not attached to a data center or host in any environment. Moreover, to import and attach an existing block storage domain to a data center, the target data center must be initialized, and must have a compatibility level of 3.5 or higher.
Procedure 12.1. Importing a block storage domain
- Discover the targets on your iSCSI storage server:
POST /api/hosts/052a880a-53e0-4fe3-9ed5-01f939d1df66/iscsidiscover Accept: application/xml Content-Type: application/xml <action> <iscsi> <address>192.0.2.0</address> <port>3260</port> </iscsi> </action>
- Get a list of storage domains that are candidates to be imported, using the iSCSI targets discovered in the previous step:
POST /api/hosts/052a880a-53e0-4fe3-9ed5-01f939d1df66/unregisteredstoragedomainsdiscover HTTP/1.1 Accept: application/xml Content-type: application/xml <action> <iscsi> <address>192.0.2.0</address> </iscsi> <iscsi_target>iqn.name1.120.01</iscsi_target> <iscsi_target>iqn.name2.120.02</iscsi_target> <iscsi_target>iqn.name3.120.03</iscsi_target> </action>
The response shows a list of storage domains not associated with a host, similar to the following:<action> <iscsi> <address>192.0.2.0</address> </iscsi> <storage_domains> <storage_domain id="6ab65b16-0f03-4b93-85a7-5bc3b8d52be0"> <name>scsi4</name> <type>data</type> <external_status> <state>ok</state> </external_status> <master>false</master> <storage> <type>iscsi</type> <volume_group id="OLkKwa-VmEM-abW7-hPiv-BGrw-sQ2E-vTdAy1"/> </storage> <available>0</available> <used>0</used> <committed>0</committed> <storage_format>v3</storage_format> </storage_domain> <status> <state>complete</state> </status> <iscsi_target>iqn.name1.120.01</iscsi_target> <iscsi_target>iqn.name2.120.02</iscsi_target> <iscsi_target>iqn.name3.120.03</iscsi_target> </action>
- Import the iSCSI storage domains to the host:
POST /api/storagedomains/ HTTP/1.1 Accept: application/xml Content-type: application/xml <storage_domain id="6ab65b16-0f03-4b93-85a7-5bc3b8d52be0"> <import>true</import> <host id="052a880a-53e0-4fe3-9ed5-01f939d1df66" /> <type>data</type> <storage> <type>iscsi</type> </storage> </storage_domain>
You have now imported the block storage domain to your host.
You may now wish to attach the storage domain to the host, and find any unregistered disks. Attach the storage domain and associated disks with the following steps:
Procedure 12.2. Attaching a block storage domain
- Attach the storage domain to your data center:
POST /api/datacenters/01a45ff0-915a-45e0-8d56-5253234ac988/storagedomains Accept: application/xml Content-Type: application/xml <storage_domain> <name>scsi4</name> </storage_domain>
- Find the unregistered disks on the storage domain:
GET /api/storagedomains/6ab65b16-0f03-4b93-85a7-5bc3b8d52be0/disks;unregistered Accept: application/xml Content-Type: application/xml
This will return information about any unregistered disks on the storage domain, with a response similar to:<disk href= "/api/storagedomains/6ab65b16-0f03-4b93-85a7-5bc3b8d52be0/disks/b662f6da-3e97-4bb6-8a50-bda9980a6e83" id="b662f6da-3e97-4bb6-8a50-bda9980a6e83"> <actions> <link href= "/api/storagedomains/6ab65b16-0f03-4b93-85a7-5bc3b8d52be0/disks/b662f6da-3e97-4bb6-8a50-bda9980a6e83/export" rel="export"/> </actions> <name>disk1</name> <description/> <link href= "/api/storagedomains/6ab65b16-0f03-4b93-85a7-5bc3b8d52be0/disks/b662f6da-3e97-4bb6-8a50-bda9980a6e83/permissions" rel="permissions"/> <link href= "/api/storagedomains/6ab65b16-0f03-4b93-85a7-5bc3b8d52be0/disks/b662f6da-3e97-4bb6-8a50-bda9980a6e83/statistics" rel="statistics"/> <alias>disk1</alias> <image_id>930d653e-2a11-45ce-8042-9935584a3f87</image_id> <storage_domain href= "/api/storagedomains/6ab65b16-0f03-4b93-85a7-5bc3b8d52be0" id="8ac10ec5-7cc9-4b1c-9c97-f121a9e4679a"/> <storage_domains> <storage_domain id="6ab65b16-0f03-4b93-85a7-5bc3b8d52be0"/> </storage_domains> <size>10737418240</size> <provisioned_size>10737418240</provisioned_size> <actual_size>10737418240</actual_size> <status> <state>ok</state> </status> <interface>ide</interface> <format>raw</format> <sparse>false</sparse> <bootable>false</bootable> <shareable>false</shareable> <wipe_after_delete>false</wipe_after_delete> <propagate_errors>false</propagate_errors> <storage_type>image</storage_type> </disk>
- Attach the disk to the storage domain:
POST /api/storagedomains/6ab65b16-0f03-4b93-85a7-5bc3b8d52be0/disks;unregistered Accept: application/xml Content-Type: application/xml <disk id='b662f6da-3e97-4bb6-8a50-bda9980a6e83'></disk>
The disk is now attached to the imported block storage domain.