Class: OvirtSDK4::HostService
- Inherits:
-
MeasurableService
- Object
- Service
- MeasurableService
- OvirtSDK4::HostService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Object) activate(opts = {})
Executes the
activate
method. -
- (AssignedAffinityLabelsService) affinity_labels_service
List of scheduling labels assigned to this host.
-
- (Object) approve(opts = {})
Executes the
approve
method. -
- (Object) commit_net_config(opts = {})
Executes the
commit_net_config
method. -
- (Object) deactivate(opts = {})
Executes the
deactivate
method. -
- (HostDevicesService) devices_service
Locates the
devices
service. -
- (Object) enroll_certificate(opts = {})
Executes the
enroll_certificate
method. -
- (Object) fence(opts = {})
Executes the
fence
method. -
- (FenceAgentsService) fence_agents_service
Locates the
fence_agents
service. -
- (Object) force_select_spm(opts = {})
Executes the
force_select_spm
method. -
- (Host) get(opts = {})
Returns the representation of the object managed by this service.
-
- (HostHooksService) hooks_service
Locates the
hooks
service. -
- (Object) install(opts = {})
Executes the
install
method. -
- (Object) iscsi_discover(opts = {})
Executes the
iscsi_discover
method. -
- (Object) iscsi_login(opts = {})
Executes the
iscsi_login
method. -
- (KatelloErrataService) katello_errata_service
Locates the
katello_errata
service. -
- (NetworkAttachmentsService) network_attachments_service
Locates the
network_attachments
service. -
- (HostNicsService) nics_service
Locates the
nics
service. -
- (HostNumaNodesService) numa_nodes_service
Locates the
numa_nodes
service. -
- (AssignedPermissionsService) permissions_service
Locates the
permissions
service. -
- (Object) refresh(opts = {})
Executes the
refresh
method. -
- (Object) remove(opts = {})
Deletes the object managed by this service.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (Object) setup_networks(opts = {})
This method is used to change the configuration of the network interfaces of a host.
-
- (StatisticsService) statistics_service
Locates the
statistics
service. -
- (StorageServerConnectionExtensionsService) storage_connection_extensions_service
Locates the
storage_connection_extensions
service. -
- (HostStorageService) storage_service
Locates the
storage
service. -
- (AssignedTagsService) tags_service
Locates the
tags
service. -
- (String) to_s
Returns an string representation of this service.
-
- (UnmanagedNetworksService) unmanaged_networks_service
Locates the
unmanaged_networks
service. -
- (Object) unregistered_storage_domains_discover(opts = {})
Executes the
unregistered_storage_domains_discover
method. -
- (Object) update(host)
Updates the object managed by this service.
-
- (Object) upgrade(opts = {})
Executes the
upgrade
method.
Instance Method Details
- (Object) activate(opts = {})
Executes the activate
method.
28416 28417 28418 28419 28420 28421 28422 28423 28424 28425 28426 28427 28428 28429 28430 28431 28432 28433 28434 |
# File 'lib/ovirtsdk4/services.rb', line 28416 def activate(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/activate", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (AssignedAffinityLabelsService) affinity_labels_service
List of scheduling labels assigned to this host.
28954 28955 28956 |
# File 'lib/ovirtsdk4/services.rb', line 28954 def affinity_labels_service return AssignedAffinityLabelsService.new(@connection, "#{@path}/affinitylabels") end |
- (Object) approve(opts = {})
Executes the approve
method.
28439 28440 28441 28442 28443 28444 28445 28446 28447 28448 28449 28450 28451 28452 28453 28454 28455 28456 28457 |
# File 'lib/ovirtsdk4/services.rb', line 28439 def approve(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/approve", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (Object) commit_net_config(opts = {})
Executes the commit_net_config
method.
28462 28463 28464 28465 28466 28467 28468 28469 28470 28471 28472 28473 28474 28475 28476 28477 28478 28479 28480 |
# File 'lib/ovirtsdk4/services.rb', line 28462 def commit_net_config(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/commitnetconfig", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (Object) deactivate(opts = {})
Executes the deactivate
method.
28485 28486 28487 28488 28489 28490 28491 28492 28493 28494 28495 28496 28497 28498 28499 28500 28501 28502 28503 |
# File 'lib/ovirtsdk4/services.rb', line 28485 def deactivate(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/deactivate", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (HostDevicesService) devices_service
Locates the devices
service.
28962 28963 28964 |
# File 'lib/ovirtsdk4/services.rb', line 28962 def devices_service return HostDevicesService.new(@connection, "#{@path}/devices") end |
- (Object) enroll_certificate(opts = {})
Executes the enroll_certificate
method.
28508 28509 28510 28511 28512 28513 28514 28515 28516 28517 28518 28519 28520 28521 28522 28523 28524 28525 28526 |
# File 'lib/ovirtsdk4/services.rb', line 28508 def enroll_certificate(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/enrollcertificate", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (Object) fence(opts = {})
Executes the fence
method.
28531 28532 28533 28534 28535 28536 28537 28538 28539 28540 28541 28542 28543 28544 28545 28546 28547 28548 28549 28550 |
# File 'lib/ovirtsdk4/services.rb', line 28531 def fence(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/fence", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) return action.power_management else check_fault(response) end end |
- (FenceAgentsService) fence_agents_service
Locates the fence_agents
service.
28970 28971 28972 |
# File 'lib/ovirtsdk4/services.rb', line 28970 def fence_agents_service return FenceAgentsService.new(@connection, "#{@path}/fenceagents") end |
- (Object) force_select_spm(opts = {})
Executes the force_select_spm
method.
28555 28556 28557 28558 28559 28560 28561 28562 28563 28564 28565 28566 28567 28568 28569 28570 28571 28572 28573 |
# File 'lib/ovirtsdk4/services.rb', line 28555 def force_select_spm(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/forceselectspm", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (Host) get(opts = {})
Returns the representation of the object managed by this service.
28584 28585 28586 28587 28588 28589 28590 28591 28592 28593 28594 28595 28596 28597 28598 28599 28600 28601 28602 28603 28604 |
# File 'lib/ovirtsdk4/services.rb', line 28584 def get(opts = {}) query = {} value = opts[:filter] unless value.nil? value = Writer.render_boolean(value) query['filter'] = value end request = Request.new(:method => :GET, :path => @path, :query => query) response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return HostReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (HostHooksService) hooks_service
Locates the hooks
service.
28978 28979 28980 |
# File 'lib/ovirtsdk4/services.rb', line 28978 def hooks_service return HostHooksService.new(@connection, "#{@path}/hooks") end |
- (Object) install(opts = {})
Executes the install
method.
28609 28610 28611 28612 28613 28614 28615 28616 28617 28618 28619 28620 28621 28622 28623 28624 28625 28626 28627 |
# File 'lib/ovirtsdk4/services.rb', line 28609 def install(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/install", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (Object) iscsi_discover(opts = {})
Executes the iscsi_discover
method.
28632 28633 28634 28635 28636 28637 28638 28639 28640 28641 28642 28643 28644 28645 28646 28647 28648 28649 28650 28651 |
# File 'lib/ovirtsdk4/services.rb', line 28632 def iscsi_discover(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/iscsidiscover", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) return action.iscsi_targets else check_fault(response) end end |
- (Object) iscsi_login(opts = {})
Executes the iscsi_login
method.
28656 28657 28658 28659 28660 28661 28662 28663 28664 28665 28666 28667 28668 28669 28670 28671 28672 28673 28674 |
# File 'lib/ovirtsdk4/services.rb', line 28656 def iscsi_login(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/iscsilogin", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (KatelloErrataService) katello_errata_service
Locates the katello_errata
service.
28986 28987 28988 |
# File 'lib/ovirtsdk4/services.rb', line 28986 def katello_errata_service return KatelloErrataService.new(@connection, "#{@path}/katelloerrata") end |
- (NetworkAttachmentsService) network_attachments_service
Locates the network_attachments
service.
28994 28995 28996 |
# File 'lib/ovirtsdk4/services.rb', line 28994 def return NetworkAttachmentsService.new(@connection, "#{@path}/networkattachments") end |
- (HostNicsService) nics_service
Locates the nics
service.
29002 29003 29004 |
# File 'lib/ovirtsdk4/services.rb', line 29002 def nics_service return HostNicsService.new(@connection, "#{@path}/nics") end |
- (HostNumaNodesService) numa_nodes_service
Locates the numa_nodes
service.
29010 29011 29012 |
# File 'lib/ovirtsdk4/services.rb', line 29010 def numa_nodes_service return HostNumaNodesService.new(@connection, "#{@path}/numanodes") end |
- (AssignedPermissionsService) permissions_service
Locates the permissions
service.
29018 29019 29020 |
# File 'lib/ovirtsdk4/services.rb', line 29018 def return AssignedPermissionsService.new(@connection, "#{@path}/permissions") end |
- (Object) refresh(opts = {})
Executes the refresh
method.
28679 28680 28681 28682 28683 28684 28685 28686 28687 28688 28689 28690 28691 28692 28693 28694 28695 28696 28697 |
# File 'lib/ovirtsdk4/services.rb', line 28679 def refresh(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/refresh", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (Object) remove(opts = {})
Deletes the object managed by this service.
28706 28707 28708 28709 28710 28711 28712 28713 28714 28715 28716 28717 28718 |
# File 'lib/ovirtsdk4/services.rb', line 28706 def remove(opts = {}) query = {} value = opts[:async] unless value.nil? value = Writer.render_boolean(value) query['async'] = value end request = Request.new(:method => :DELETE, :path => @path, :query => query) response = @connection.send(request) unless response.code == 200 check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
29069 29070 29071 29072 29073 29074 29075 29076 29077 29078 29079 29080 29081 29082 29083 29084 29085 29086 29087 29088 29089 29090 29091 29092 29093 29094 29095 29096 29097 29098 29099 29100 29101 29102 29103 29104 29105 29106 29107 29108 29109 29110 29111 29112 29113 29114 29115 29116 29117 29118 29119 29120 29121 29122 29123 29124 29125 29126 29127 29128 29129 29130 29131 29132 29133 29134 29135 29136 29137 29138 29139 29140 29141 29142 29143 29144 29145 29146 29147 29148 29149 29150 29151 29152 29153 29154 29155 29156 29157 29158 |
# File 'lib/ovirtsdk4/services.rb', line 29069 def service(path) if path.nil? || path == '' return self end if path == 'affinitylabels' return affinity_labels_service end if path.start_with?('affinitylabels/') return affinity_labels_service.service(path[15..-1]) end if path == 'devices' return devices_service end if path.start_with?('devices/') return devices_service.service(path[8..-1]) end if path == 'fenceagents' return fence_agents_service end if path.start_with?('fenceagents/') return fence_agents_service.service(path[12..-1]) end if path == 'hooks' return hooks_service end if path.start_with?('hooks/') return hooks_service.service(path[6..-1]) end if path == 'katelloerrata' return katello_errata_service end if path.start_with?('katelloerrata/') return katello_errata_service.service(path[14..-1]) end if path == 'networkattachments' return end if path.start_with?('networkattachments/') return .service(path[19..-1]) end if path == 'nics' return nics_service end if path.start_with?('nics/') return nics_service.service(path[5..-1]) end if path == 'numanodes' return numa_nodes_service end if path.start_with?('numanodes/') return numa_nodes_service.service(path[10..-1]) end if path == 'permissions' return end if path.start_with?('permissions/') return .service(path[12..-1]) end if path == 'statistics' return statistics_service end if path.start_with?('statistics/') return statistics_service.service(path[11..-1]) end if path == 'storage' return storage_service end if path.start_with?('storage/') return storage_service.service(path[8..-1]) end if path == 'storageconnectionextensions' return storage_connection_extensions_service end if path.start_with?('storageconnectionextensions/') return storage_connection_extensions_service.service(path[28..-1]) end if path == 'tags' return end if path.start_with?('tags/') return .service(path[5..-1]) end if path == 'unmanagednetworks' return unmanaged_networks_service end if path.start_with?('unmanagednetworks/') return unmanaged_networks_service.service(path[18..-1]) end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end |
- (Object) setup_networks(opts = {})
This method is used to change the configuration of the network interfaces of a host.
For example, lets assume that you have a host with three network interfaces eth0
, eth1
and eth2
and that
you want to configure a new bond using eth0
and eth1
, and put a VLAN on top of it. Using a simple shell
script and the curl
command line HTTP client that can be done as follows:
#!/bin/sh -ex
url="https://engine.example.com/ovirt-engine/api"
user="admin@internal"
password="..."
curl \
--verbose \
--cacert /etc/pki/ovirt-engine/ca.pem \
--user "${user}:${password}" \
--request POST \
--header "Content-Type: application/xml" \
--header "Accept: application/xml" \
--data '
<action>
<modified_bonds>
<host_nic>
<name>bond0</name>
<bonding>
<options>
<option>
<name>mode</name>
<value>4</value>
</option>
<option>
<name>miimon</name>
<value>100</value>
</option>
</options>
<slaves>
<host_nic>
<name>eth1</name>
</host_nic>
<host_nic>
<name>eth2</name>
</host_nic>
</slaves>
</bonding>
</host_nic>
</modified_bonds>
<modified_network_attachments>
<network_attachment>
<network>
<name>myvlan</name>
</network>
<host_nic>
<name>bond0</name>
</host_nic>
<ip_address_assignments>
<assignment_method>static</assignment_method>
<ip_address_assignment>
<ip>
<address>192.168.122.10</address>
<netmask>255.255.255.0</netmask>
</ip>
</ip_address_assignment>
</ip_address_assignments>
</network_attachment>
</modified_network_attachments>
</action>
' \
"${url}/hosts/1ff7a191-2f3b-4eff-812b-9f91a30c3acc/setupnetworks"
Note that this is valid for version 4 of the API. In previous versions some elements were represented as XML
attributes instead of XML elements. In particular the options
and ip
elements were represented as follows:
<options name="mode" value="4"/>
<options name="miimon" value="100"/>
<ip address="192.168.122.10" netmask="255.255.255.0"/>
Using the Python SDK the same can be done with the following code:
host.setupnetworks(
params.Action(
modified_bonds=params.HostNics(
host_nic=[
params.HostNIC(
name="bond0",
bonding=params.Bonding(
options=params.Options(
option=[
params.Option(name="mode", value="4"),
params.Option(name="miimon", value="100"),
],
),
slaves=params.Slaves(
host_nic=[
params.HostNIC(name="eth1"),
params.HostNIC(name="eth2"),
],
),
),
),
],
),
modified_network_attachments=params.NetworkAttachments(
network_attachment=[
params.NetworkAttachment(
network=params.Network(name="myvlan"),
host_nic=params.HostNIC(name="bond0"),
ip_address_assignments=params.IpAddressAssignments(
ip_address_assignment=[
params.IpAddressAssignment(
assignment_method="static",
ip=params.IP(
address="192.168.122.10",
netmask="255.255.255.0",
),
),
],
),
),
],
),
),
)
28853 28854 28855 28856 28857 28858 28859 28860 28861 28862 28863 28864 28865 28866 28867 28868 28869 28870 28871 |
# File 'lib/ovirtsdk4/services.rb', line 28853 def setup_networks(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/setupnetworks", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (StatisticsService) statistics_service
Locates the statistics
service.
29026 29027 29028 |
# File 'lib/ovirtsdk4/services.rb', line 29026 def statistics_service return StatisticsService.new(@connection, "#{@path}/statistics") end |
- (StorageServerConnectionExtensionsService) storage_connection_extensions_service
Locates the storage_connection_extensions
service.
29042 29043 29044 |
# File 'lib/ovirtsdk4/services.rb', line 29042 def storage_connection_extensions_service return StorageServerConnectionExtensionsService.new(@connection, "#{@path}/storageconnectionextensions") end |
- (HostStorageService) storage_service
Locates the storage
service.
29034 29035 29036 |
# File 'lib/ovirtsdk4/services.rb', line 29034 def storage_service return HostStorageService.new(@connection, "#{@path}/storage") end |
- (AssignedTagsService) tags_service
Locates the tags
service.
29050 29051 29052 |
# File 'lib/ovirtsdk4/services.rb', line 29050 def return AssignedTagsService.new(@connection, "#{@path}/tags") end |
- (String) to_s
Returns an string representation of this service.
29165 29166 29167 |
# File 'lib/ovirtsdk4/services.rb', line 29165 def to_s return "#<#{HostService}:#{@path}>" end |
- (UnmanagedNetworksService) unmanaged_networks_service
Locates the unmanaged_networks
service.
29058 29059 29060 |
# File 'lib/ovirtsdk4/services.rb', line 29058 def unmanaged_networks_service return UnmanagedNetworksService.new(@connection, "#{@path}/unmanagednetworks") end |
- (Object) unregistered_storage_domains_discover(opts = {})
Executes the unregistered_storage_domains_discover
method.
28876 28877 28878 28879 28880 28881 28882 28883 28884 28885 28886 28887 28888 28889 28890 28891 28892 28893 28894 28895 |
# File 'lib/ovirtsdk4/services.rb', line 28876 def unregistered_storage_domains_discover(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/unregisteredstoragedomainsdiscover", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) return action.storage_domains else check_fault(response) end end |
- (Object) update(host)
Updates the object managed by this service.
28900 28901 28902 28903 28904 28905 28906 28907 28908 28909 28910 28911 28912 28913 28914 28915 28916 28917 28918 28919 28920 28921 28922 28923 28924 28925 |
# File 'lib/ovirtsdk4/services.rb', line 28900 def update(host) if host.is_a?(Hash) host = OvirtSDK4::Host.new(host) end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) HostWriter.write_one(host, writer, 'host') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return HostReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end |
- (Object) upgrade(opts = {})
Executes the upgrade
method.
28930 28931 28932 28933 28934 28935 28936 28937 28938 28939 28940 28941 28942 28943 28944 28945 28946 28947 28948 |
# File 'lib/ovirtsdk4/services.rb', line 28930 def upgrade(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/upgrade", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |