Class: CemAcpt::Platform::Gcp::Disk

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/cem_acpt/platform/gcp/compute.rb

Overview

This class represents a GCP VM disk

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#add_cmd, #cmd, #cmd_flag_vars?

Constructor Details

#initialize(project: nil, name: 'disk-1', image_name: '', size: 20, type: 'pd-standard') ⇒ Disk

Returns a new instance of Disk.



65
66
67
68
69
70
71
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 65

def initialize(project: nil, name: 'disk-1', image_name: '', size: 20, type: 'pd-standard')
  @project = project
  @name = name
  @image_name = image_name
  @size = size
  @type = type
end

Instance Attribute Details

#image_nameObject (readonly)

Returns the value of attribute image_name.



63
64
65
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 63

def image_name
  @image_name
end

#nameObject (readonly)

Returns the value of attribute name.



63
64
65
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 63

def name
  @name
end

#projectObject (readonly)

Returns the value of attribute project.



63
64
65
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 63

def project
  @project
end

#sizeObject (readonly)

Returns the value of attribute size.



63
64
65
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 63

def size
  @size
end

Instance Method Details

#cmd_flagObject



73
74
75
76
77
78
79
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 73

def cmd_flag
  return unless cmd_flag_vars?(name, image, size, type)

  '--create-disk=auto-delete=yes,boot=yes,' \
  "device-name=#{name},image=#{image}," \
  "mode=rw,size=#{size},type=#{type}"
end

#imageObject



85
86
87
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 85

def image
  @image ||= image_path(@image_name)
end

#typeObject



81
82
83
# File 'lib/cem_acpt/platform/gcp/compute.rb', line 81

def type
  type_path(@type)
end