Class: OvirtSDK4::AffinityGroupVmsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::AffinityGroupVmsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Vm) add(vm, opts = {})
Adds a new
vm
. -
- (Array<Vm>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
-
- (AffinityGroupVmService) vm_service(id)
Locates the
vm
service.
Instance Method Details
- (Vm) add(vm, opts = {})
Adds a new vm
.
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
# File 'lib/ovirtsdk4/services.rb', line 943 def add(vm, opts = {}) if vm.is_a?(Hash) vm = OvirtSDK4::Vm.new(vm) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) VmWriter.write_one(vm, writer, 'vm') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 201, 202 begin reader = XmlReader.new(response.body) return VmReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<Vm>) list(opts = {})
Returns the representation of the object managed by this service.
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
# File 'lib/ovirtsdk4/services.rb', line 979 def list(opts = {}) query = {} value = opts[:max] unless value.nil? value = Writer.render_integer(value) query['max'] = 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 VmReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
# File 'lib/ovirtsdk4/services.rb', line 1019 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return vm_service(path) end return vm_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
1035 1036 1037 |
# File 'lib/ovirtsdk4/services.rb', line 1035 def to_s return "#<#{AffinityGroupVmsService}:#{@path}>" end |
- (AffinityGroupVmService) vm_service(id)
Locates the vm
service.
1008 1009 1010 |
# File 'lib/ovirtsdk4/services.rb', line 1008 def vm_service(id) return AffinityGroupVmService.new(@connection, "#{@path}/#{id}") end |