Este conteúdo não está disponível no idioma selecionado.
3.8. Attaching a Storage Domain to a Data Center
This Ruby example attaches an existing NFS storage domain, mydata, to an existing data center, mydc. This example is used to attach both data and ISO storage domains.
# Get the reference to the root of the services tree:
system_service = connection.system_service
# Locate the service that manages the storage domains and use it to
search for the storage domain:
sds_service = system_service.storage_domains_service
sd = sds_service.list(search: 'name=mydata')[0]
# Locate the service that manages the data centers and use it to
search for the data center:
dcs_service = system_service.data_centers_service
dc = dcs_service.list(search: 'name=mydc')[0]
# Locate the service that manages the data center where you want to
attach the storage domain:
dc_service = dcs_service.data_center_service(dc.id)
# Locate the service that manages the storage domains that are attached
to the data centers:
attached_sds_service = dc_service.storage_domains_service
# Use the "add" method of service that manages the attached storage
domains to attach it:
attached_sds_service.add(
OvirtSDK4::StorageDomain.new(
id: sd.id
)
)
# Wait until the storage domain is active:
attached_sd_service = attached_sds_service.storage_domain_service(sd.id)
loop do
sleep(5)
sd = attached_sd_service.get
break if sd.status == OvirtSDK4::StorageDomainStatus::ACTIVE
end
# Get the reference to the root of the services tree:
system_service = connection.system_service
# Locate the service that manages the storage domains and use it to
# search for the storage domain:
sds_service = system_service.storage_domains_service
sd = sds_service.list(search: 'name=mydata')[0]
# Locate the service that manages the data centers and use it to
# search for the data center:
dcs_service = system_service.data_centers_service
dc = dcs_service.list(search: 'name=mydc')[0]
# Locate the service that manages the data center where you want to
# attach the storage domain:
dc_service = dcs_service.data_center_service(dc.id)
# Locate the service that manages the storage domains that are attached
# to the data centers:
attached_sds_service = dc_service.storage_domains_service
# Use the "add" method of service that manages the attached storage
# domains to attach it:
attached_sds_service.add(
OvirtSDK4::StorageDomain.new(
id: sd.id
)
)
# Wait until the storage domain is active:
attached_sd_service = attached_sds_service.storage_domain_service(sd.id)
loop do
sleep(5)
sd = attached_sd_service.get
break if sd.status == OvirtSDK4::StorageDomainStatus::ACTIVE
end
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.
Tornando o open source mais inclusivo
A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.
Sobre a Red Hat
Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.