Class: OvirtSDK4::ClusterService

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

Instance Method Summary (collapse)

Instance Method Details

- (AffinityGroupsService) affinity_groups_service

Locates the affinity_groups service.

Returns:



4124
4125
4126
# File 'lib/ovirtsdk4/services.rb', line 4124

def affinity_groups_service
  return AffinityGroupsService.new(@connection, "#{@path}/affinitygroups")
end

- (AssignedCpuProfilesService) cpu_profiles_service

Locates the cpu_profiles service.

Returns:



4132
4133
4134
# File 'lib/ovirtsdk4/services.rb', line 4132

def cpu_profiles_service
  return AssignedCpuProfilesService.new(@connection, "#{@path}/cpuprofiles")
end

- (Cluster) get(opts = {})

Returns the representation of the object managed by this service.

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.

Returns:



4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
# File 'lib/ovirtsdk4/services.rb', line 4024

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 ClusterReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (GlusterHooksService) gluster_hooks_service

Locates the gluster_hooks service.

Returns:



4140
4141
4142
# File 'lib/ovirtsdk4/services.rb', line 4140

def gluster_hooks_service
  return GlusterHooksService.new(@connection, "#{@path}/glusterhooks")
end

- (GlusterVolumesService) gluster_volumes_service

Locates the gluster_volumes service.

Returns:



4148
4149
4150
# File 'lib/ovirtsdk4/services.rb', line 4148

def gluster_volumes_service
  return GlusterVolumesService.new(@connection, "#{@path}/glustervolumes")
end

- (NetworkFiltersService) network_filters_service

A sub collection with all the supported network filters for this cluster.

Returns:



4156
4157
4158
# File 'lib/ovirtsdk4/services.rb', line 4156

def network_filters_service
  return NetworkFiltersService.new(@connection, "#{@path}/networkfilters")
end

- (AssignedNetworksService) networks_service

Locates the networks service.

Returns:



4164
4165
4166
# File 'lib/ovirtsdk4/services.rb', line 4164

def networks_service
  return AssignedNetworksService.new(@connection, "#{@path}/networks")
end

- (AssignedPermissionsService) permissions_service

Locates the permissions service.

Returns:



4172
4173
4174
# File 'lib/ovirtsdk4/services.rb', line 4172

def permissions_service
  return AssignedPermissionsService.new(@connection, "#{@path}/permissions")
end

- (Object) remove(opts = {})

Deletes the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.



4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
# File 'lib/ovirtsdk4/services.rb', line 4053

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

- (Object) reset_emulated_machine(opts = {})

Executes the reset_emulated_machine method.



4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
# File 'lib/ovirtsdk4/services.rb', line 4070

def reset_emulated_machine(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}/resetemulatedmachine",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.

Raises:

  • (Error)


4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
# File 'lib/ovirtsdk4/services.rb', line 4183

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'affinitygroups'
    return affinity_groups_service
  end
  if path.start_with?('affinitygroups/')
    return affinity_groups_service.service(path[15..-1])
  end
  if path == 'cpuprofiles'
    return cpu_profiles_service
  end
  if path.start_with?('cpuprofiles/')
    return cpu_profiles_service.service(path[12..-1])
  end
  if path == 'glusterhooks'
    return gluster_hooks_service
  end
  if path.start_with?('glusterhooks/')
    return gluster_hooks_service.service(path[13..-1])
  end
  if path == 'glustervolumes'
    return gluster_volumes_service
  end
  if path.start_with?('glustervolumes/')
    return gluster_volumes_service.service(path[15..-1])
  end
  if path == 'networkfilters'
    return network_filters_service
  end
  if path.start_with?('networkfilters/')
    return network_filters_service.service(path[15..-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
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


4237
4238
4239
# File 'lib/ovirtsdk4/services.rb', line 4237

def to_s
  return "#<#{ClusterService}:#{@path}>"
end

- (Object) update(cluster)

Updates the object managed by this service.



4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
# File 'lib/ovirtsdk4/services.rb', line 4093

def update(cluster)
  if cluster.is_a?(Hash)
    cluster = OvirtSDK4::Cluster.new(cluster)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    ClusterWriter.write_one(cluster, writer, 'cluster')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return ClusterReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end