Class: OvirtSDK4::DataCentersService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary collapse
-
#add(data_center, opts = {}) ⇒ DataCenter
Creates a new data center.
-
#data_center_service(id) ⇒ DataCenterService
Reference to the service that manages a specific data center.
-
#list(opts = {}) ⇒ Array<DataCenter>
Lists the data centers.
-
#service(path) ⇒ Service
Locates the service corresponding to the given path.
Methods inherited from Service
Instance Method Details
#add(data_center, opts = {}) ⇒ DataCenter
Creates a new data center.
Creation of a new data center requires the name
and local
elements. For example, to create a data center
named mydc
that uses shared storage (NFS, iSCSI or fibre channel) send a request like this:
POST /ovirt-engine/api/datacenters
With a request body like this:
<data_center>
<name>mydc</name>
<local>false</local>
</data_center>
6902 6903 6904 |
# File 'lib/ovirtsdk4/services.rb', line 6902 def add(data_center, opts = {}) internal_add(data_center, DataCenter, ADD, opts) end |
#data_center_service(id) ⇒ DataCenterService
Reference to the service that manages a specific data center.
7015 7016 7017 |
# File 'lib/ovirtsdk4/services.rb', line 7015 def data_center_service(id) DataCenterService.new(self, id) end |
#list(opts = {}) ⇒ Array<DataCenter>
Lists the data centers.
The following request retrieves a representation of the data centers:
GET /ovirt-engine/api/datacenters
The above request performed with curl
:
curl \
--request GET \
--cacert /etc/pki/ovirt-engine/ca.pem \
--header "Version: 4" \
--header "Accept: application/xml" \
--user "[email protected]:mypassword" \
https://myengine.example.com/ovirt-engine/api/datacenters
This is what an example response could look like:
<data_center href="/ovirt-engine/api/datacenters/123" id="123">
<name>Default</name>
<description>The default Data Center</description>
<link href="/ovirt-engine/api/datacenters/123/networks" rel="networks"/>
<link href="/ovirt-engine/api/datacenters/123/storagedomains" rel="storagedomains"/>
<link href="/ovirt-engine/api/datacenters/123/permissions" rel="permissions"/>
<link href="/ovirt-engine/api/datacenters/123/clusters" rel="clusters"/>
<link href="/ovirt-engine/api/datacenters/123/qoss" rel="qoss"/>
<link href="/ovirt-engine/api/datacenters/123/iscsibonds" rel="iscsibonds"/>
<link href="/ovirt-engine/api/datacenters/123/quotas" rel="quotas"/>
<local>false</local>
<quota_mode>disabled</quota_mode>
<status>up</status>
<supported_versions>
<version>
<major>4</major>
<minor>0</minor>
</version>
</supported_versions>
<version>
<major>4</major>
<minor>0</minor>
</version>
</data_center>
Note the id
code of your Default
data center. This code identifies this data center in relation to other
resources of your virtual environment.
The data center also contains a link to the storage domains collection. The data center uses this collection to attach storage domains from the storage domains main collection.
The order of the returned list of data centers is guaranteed only if the sortby
clause is included in the
search
parameter.
7004 7005 7006 |
# File 'lib/ovirtsdk4/services.rb', line 7004 def list(opts = {}) internal_get(LIST, opts) end |
#service(path) ⇒ Service
Locates the service corresponding to the given path.
7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 |
# File 'lib/ovirtsdk4/services.rb', line 7026 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return data_center_service(path) end return data_center_service(path[0..(index - 1)]).service(path[(index + 1)..-1]) end |