Class: Capistrano::Gcp::Autoscaling::Core::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/gcp/autoscaling/core/instance.rb

Constant Summary collapse

INSTANCE_PATTERN =
%r{/instances/[\w-]+}.freeze
ZONE_PATTERN =
%r{/zones/[\w-]+}.freeze
SEPARATOR =
'/'.freeze
RUNNING_STATUS =
'RUNNING'.freeze
NONE_ACTION =
'NONE'.freeze
VERIFYING_ACTION =
'VERIFYING'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(compute_service, managed_instance, options = {}) ⇒ Instance

Returns a new instance of Instance.



15
16
17
18
19
# File 'lib/capistrano/gcp/autoscaling/core/instance.rb', line 15

def initialize(compute_service, managed_instance, options = {})
  @compute_service = compute_service
  @managed_instance = managed_instance
  @options = options
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/capistrano/gcp/autoscaling/core/instance.rb', line 29

def available?
  running? && (verifying? || do_nothing?)
end

#created_atObject



25
26
27
# File 'lib/capistrano/gcp/autoscaling/core/instance.rb', line 25

def created_at
  Time.parse(instance.creation_timestamp)
end

#network_ipObject



21
22
23
# File 'lib/capistrano/gcp/autoscaling/core/instance.rb', line 21

def network_ip
  instance.network_interfaces.first.network_ip
end