3.10. 데이터 센터에 스토리지 도메인 연결
Red Hat Virtualization에 스토리지 도메인을 추가한 후 이를 데이터 센터에 연결하고 사용할 준비가 되기 전에 활성화해야 합니다.
예 3.8. 데이터 센터에 스토리지 도메인 연결
이 예에서는 기존 NFS 스토리지 도메인 mydata
를 기존 데이터 센터인 Default
에 연결합니다. 연결 작업은 데이터 센터의 storagedomains
컬렉션의 추가
방법으로 원활하게 수행됩니다. 이러한 예는 데이터와 ISO 스토리지 도메인을 모두 연결하는 데 사용할 수 있습니다.
V4
import ovirtsdk4 as sdk import ovirtsdk4.types as types # Create the connection to the server: connection = sdk.Connection( url='https://engine.example.com/ovirt-engine/api', username='admin@internal', password='password', ca_file='ca.pem', ) # Locate the service that manages the storage domains and use it to # search for the storage domain: sds_service = connection.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 = connection.system_service().data_centers_service() dc = dcs_service.list(search='name=Default')[0] # Locate the service that manages the data center where we 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( types.StorageDomain( id=sd.id, ), ) # Wait until the storage domain is active: attached_sd_service = attached_sds_service.storage_domain_service(sd.id) while True: time.sleep(5) sd = attached_sd_service.get() if sd.status == types.StorageDomainStatus.ACTIVE: break print("Attached data storage domain '%s' to data center '%s' (Status: %s)." % (sd.name(), dc.name(), sd.status.state())) # Close the connection to the server: connection.close()
add
메서드 호출이 성공하면 예제에서는 다음 텍스트를 출력합니다.
Attached data storage domain 'data1' to data center 'Default' (Status: maintenance).
상태: 유지
관리는 스토리지 도메인을 계속 활성화해야 함을 나타냅니다.