Skip to content

Commit

Permalink
Provide optional discard_local_ssd argument for stopping an instance …
Browse files Browse the repository at this point in the history
…with local SSD
  • Loading branch information
Rob Chekaluk committed Dec 9, 2023
1 parent 4b3c638 commit 3b0f848
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/fog/compute/google/models/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ def start(async = true)
operation
end

def stop(async = true)
def stop(async = true, discard_local_ssd=false)
requires :identity, :zone

data = service.stop_server(identity, zone_name)
data = service.stop_server(identity, zone_name, discard_local_ssd)
operation = Fog::Compute::Google::Operations
.new(:service => service)
.get(data.name, data.zone)
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/compute/google/requests/stop_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def stop_server(_identity, _zone)
end

class Real
def stop_server(identity, zone)
@compute.stop_instance(@project, zone.split("/")[-1], identity)
def stop_server(identity, zone, discard_local_ssd=false)
@compute.stop_instance(@project, zone.split("/")[-1], identity, discard_local_ssd: discard_local_ssd)
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/integration/compute/core_compute/test_servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ def test_start_stop_reboot
assert server.ready?
end

def test_start_stop_discard_local_ssd
server = @factory.create

async = true
discard_local_ssd = true

server.stop(async, discard_local_ssd)
server.wait_for { stopped? }

assert server.stopped?
end

def test_attach_disk
# Creating server
server = @factory.create
Expand Down

0 comments on commit 3b0f848

Please sign in to comment.