Class: OvirtSDK4::GlusterBricksService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::GlusterBricksService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Object) activate(opts = {})
Executes the
activate
method. -
- (Array<GlusterBrick>) add(bricks, opts = {})
Adds given list of bricks to the volume, and updates the database accordingly.
-
- (GlusterBrickService) brick_service(id)
Locates the
brick
service. -
- (Array<GlusterBrick>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (Object) migrate(opts = {})
Executes the
migrate
method. -
- (Object) remove(opts = {})
Removes the given list of bricks brick from the volume and deletes them from the database.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (Object) stop_migrate(opts = {})
Executes the
stop_migrate
method. -
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (Object) activate(opts = {})
Executes the activate
method.
8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 |
# File 'lib/ovirtsdk4/services.rb', line 8418 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 |
- (Array<GlusterBrick>) add(bricks, opts = {})
Adds given list of bricks to the volume, and updates the database accordingly. The properties serverId
and
`brickDir`are required.
8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 |
# File 'lib/ovirtsdk4/services.rb', line 8446 def add(bricks, opts = {}) if bricks.is_a?(Array) bricks = List.new(bricks) bricks.each_with_index do |value, index| if value.is_a?(Hash) bricks[index] = OvirtSDK4::GlusterBrick.new(value) end end end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) GlusterBrickWriter.write_many(bricks, writer, 'bricks') 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 GlusterBrickReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (GlusterBrickService) brick_service(id)
Locates the brick
service.
8588 8589 8590 |
# File 'lib/ovirtsdk4/services.rb', line 8588 def brick_service(id) return GlusterBrickService.new(@connection, "#{@path}/#{id}") end |
- (Array<GlusterBrick>) list(opts = {})
Returns the representation of the object managed by this service.
8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 |
# File 'lib/ovirtsdk4/services.rb', line 8486 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 GlusterBrickReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Object) migrate(opts = {})
Executes the migrate
method.
8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 |
# File 'lib/ovirtsdk4/services.rb', line 8511 def migrate(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}/migrate", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (Object) remove(opts = {})
Removes the given list of bricks brick from the volume and deletes them from the database.
8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 |
# File 'lib/ovirtsdk4/services.rb', line 8540 def remove(opts = {}) query = {} value = opts[:async] unless value.nil? value = Writer.render_boolean(value) query['async'] = value end value = opts[:bricks] unless value.nil? query['bricks'] = 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.
8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 |
# File 'lib/ovirtsdk4/services.rb', line 8599 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return brick_service(path) end return brick_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (Object) stop_migrate(opts = {})
Executes the stop_migrate
method.
8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 |
# File 'lib/ovirtsdk4/services.rb', line 8561 def stop_migrate(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}/stopmigrate", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (String) to_s
Returns an string representation of this service.
8615 8616 8617 |
# File 'lib/ovirtsdk4/services.rb', line 8615 def to_s return "#<#{GlusterBricksService}:#{@path}>" end |