Class: OvirtSDK4::DataCenterService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#clean_finished_tasks(opts = {}) ⇒ Object

Currently, the storage pool manager (SPM) fails to switch to another host if the SPM has uncleared tasks. Clearing all finished tasks enables the SPM switching.

For example, to clean all the finished tasks on a data center with ID 123 send a request like this:

POST /ovirt-engine/api/datacenters/123/cleanfinishedtasks

With a request body like this:

<action/>

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the action should be performed asynchronously.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.


6299
6300
6301
# File 'lib/ovirtsdk4/services.rb', line 6299

def clean_finished_tasks(opts = {})
  internal_action(:cleanfinishedtasks, nil, CLEAN_FINISHED_TASKS, opts)
end

#clusters_serviceClustersService

Locates the clusters service.

Returns:


6514
6515
6516
# File 'lib/ovirtsdk4/services.rb', line 6514

def clusters_service
  @clusters_service ||= ClustersService.new(self, 'clusters')
end

#get(opts = {}) ⇒ DataCenter

Get a data center.

An example of getting a data center:

GET /ovirt-engine/api/datacenters/123
<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/clusters" rel="clusters"/>
  <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/networks" rel="networks"/>
  <link href="/ovirt-engine/api/datacenters/123/quotas" rel="quotas"/>
  <link href="/ovirt-engine/api/datacenters/123/qoss" rel="qoss"/>
  <link href="/ovirt-engine/api/datacenters/123/iscsibonds" rel="iscsibonds"/>
  <local>false</local>
  <quota_mode>disabled</quota_mode>
  <status>up</status>
  <storage_format>v3</storage_format>
  <supported_versions>
    <version>
      <major>4</major>
      <minor>0</minor>
   </version>
  </supported_versions>
  <version>
    <major>4</major>
    <minor>0</minor>
  </version>
  <mac_pool href="/ovirt-engine/api/macpools/456" id="456"/>
</data_center>

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:


6368
6369
6370
# File 'lib/ovirtsdk4/services.rb', line 6368

def get(opts = {})
  internal_get(GET, opts)
end

#iscsi_bonds_serviceIscsiBondsService

Reference to the iSCSI bonds service.

Returns:


6523
6524
6525
# File 'lib/ovirtsdk4/services.rb', line 6523

def iscsi_bonds_service
  @iscsi_bonds_service ||= IscsiBondsService.new(self, 'iscsibonds')
end

#networks_serviceDataCenterNetworksService

Returns a reference to the service, that manages the networks, that are associated with the data center.

Returns:


6532
6533
6534
# File 'lib/ovirtsdk4/services.rb', line 6532

def networks_service
  @networks_service ||= DataCenterNetworksService.new(self, 'networks')
end

#permissions_serviceAssignedPermissionsService

Reference to the permissions service.

Returns:


6541
6542
6543
# File 'lib/ovirtsdk4/services.rb', line 6541

def permissions_service
  @permissions_service ||= AssignedPermissionsService.new(self, 'permissions')
end

#qoss_serviceQossService

Reference to the QOSs service.

Returns:


6550
6551
6552
# File 'lib/ovirtsdk4/services.rb', line 6550

def qoss_service
  @qoss_service ||= QossService.new(self, 'qoss')
end

#quotas_serviceQuotasService

Reference to the quotas service.

Returns:


6559
6560
6561
# File 'lib/ovirtsdk4/services.rb', line 6559

def quotas_service
  @quotas_service ||= QuotasService.new(self, 'quotas')
end

#remove(opts = {}) ⇒ Object

Removes the data center.

DELETE /ovirt-engine/api/datacenters/123

Without any special parameters, the storage domains attached to the data center are detached and then removed from the storage. If something fails when performing this operation, for example if there is no host available to remove the storage domains from the storage, the complete operation will fail.

If the force parameter is true then the operation will always succeed, even if something fails while removing one storage domain, for example. The failure is just ignored and the data center is removed from the database anyway.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.

  • :force (Boolean)

    Indicates if the operation should succeed, and the storage domain removed from the database, even if something fails during the operation.

    This parameter is optional, and the default value is false.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.


6411
6412
6413
# File 'lib/ovirtsdk4/services.rb', line 6411

def remove(opts = {})
  internal_remove(REMOVE, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.

Raises:


6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
# File 'lib/ovirtsdk4/services.rb', line 6602

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'clusters'
    return clusters_service
  end
  if path.start_with?('clusters/')
    return clusters_service.service(path[9..-1])
  end
  if path == 'iscsibonds'
    return iscsi_bonds_service
  end
  if path.start_with?('iscsibonds/')
    return iscsi_bonds_service.service(path[11..-1])
  end
  if path == 'networks'
    return networks_service
  end
  if path.start_with?('networks/')
    return networks_service.service(path[9..-1])
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'qoss'
    return qoss_service
  end
  if path.start_with?('qoss/')
    return qoss_service.service(path[5..-1])
  end
  if path == 'quotas'
    return quotas_service
  end
  if path.start_with?('quotas/')
    return quotas_service.service(path[7..-1])
  end
  if path == 'storagedomains'
    return storage_domains_service
  end
  if path.start_with?('storagedomains/')
    return storage_domains_service.service(path[15..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

#set_master(opts = {}) ⇒ Object

Used for manually setting a storage domain in the data center as a master. For example, for setting a storage domain with ID '456' as a master on a data center with ID '123', send a request like this:

POST /ovirt-engine/api/datacenters/123/setmaster

With a request body like this:

<action>
  <storage_domain id="456"/>
</action>

The new master storage domain can be also specified by its name.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the action should be performed asynchronously.

  • :storage_domain (StorageDomain)

    The new master storage domain for the data center.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.


6458
6459
6460
# File 'lib/ovirtsdk4/services.rb', line 6458

def set_master(opts = {})
  internal_action(:setmaster, nil, SET_MASTER, opts)
end

#storage_domains_serviceAttachedStorageDomainsService

Attach and detach storage domains to and from a data center.

For attaching a single storage domain we should use the following POST request:

POST /ovirt-engine/api/datacenters/123/storagedomains

With a request body like this:

<storage_domain>
  <name>data1</name>
</storage_domain>

For detaching a single storage domain we should use the following DELETE request:

DELETE /ovirt-engine/api/datacenters/123/storagedomains/123

Returns:


6591
6592
6593
# File 'lib/ovirtsdk4/services.rb', line 6591

def storage_domains_service
  @storage_domains_service ||= AttachedStorageDomainsService.new(self, 'storagedomains')
end

#update(data_center, opts = {}) ⇒ DataCenter

Updates the data center.

The name, description, storage_type, version, storage_format and mac_pool elements are updatable post-creation. For example, to change the name and description of data center 123 send a request like this:

PUT /ovirt-engine/api/datacenters/123

With a request body like this:

<data_center>
  <name>myupdatedname</name>
  <description>An updated description for the data center</description>
</data_center>

Parameters:

  • data_center (DataCenter)

    The data center that is being updated.

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the update should be performed asynchronously.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:


6505
6506
6507
# File 'lib/ovirtsdk4/services.rb', line 6505

def update(data_center, opts = {})
  internal_update(data_center, DataCenter, UPDATE, opts)
end