@@ -68,19 +68,51 @@ def zone_name
6868 zone . nil? ? nil : zone . split ( "/" ) [ -1 ]
6969 end
7070
71+ # Returns an attached disk configuration hash.
72+ #
73+ # Compute API needs attached disks to be specified in a custom format.
74+ # This provides a handy shortcut for generating a preformatted config.
75+ #
76+ # Example output:
77+ # {:auto_delete=>false,
78+ # :boot=>true,
79+ # :mode=>"READ_WRITE",
80+ # :source=>"https://www.googleapis.com/compute/v1/projects/myproj/zones/us-central1-f/disks/mydisk",
81+ # :type=>"PERSISTENT"}
82+ #
83+ # See Instances.insert API docs for more info:
84+ # https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert
85+ #
86+ # @param [Hash] opts options to attach the disk with.
87+ # @option opts [Boolean] :writable The mode in which to attach this
88+ # disk. (defaults to READ_WRITE)
89+ # @option opts [Boolean] :boot Indicates whether this is a boot disk.
90+ # (defaults to false)
91+ # @option opts [String] :device_name Specifies a unique device name
92+ # of your choice that is reflected into the /dev/disk/by-id/google-*
93+ # tree of a Linux operating system running within the instance.
94+ # @option opts [Object] :encryption_key Encrypts or decrypts a disk
95+ # using a customer-supplied encryption key.
96+ # @option opts [Object] :auto_delete Specifies whether the disk will
97+ # be auto-deleted when the instance is deleted. (defaults to false)
98+ #
99+ # @return [Hash] Attached disk configuration hash
71100 def attached_disk_obj ( opts = { } )
72101 requires :self_link
73102 collection . attached_disk_obj ( self_link , opts )
74103 end
75104
105+ # A legacy shorthand for attached_disk_obj
106+ #
107+ # @param [Object] writable The mode in which to attach this disk.
108+ # (defaults to READ_WRITE)
109+ # @param [Object] auto_delete Specifies whether the disk will be
110+ # auto-deleted when the instance is deleted. (defaults to false)
111+ # @return [Hash]
76112 def get_as_boot_disk ( writable = true , auto_delete = false )
77- {
78- :auto_delete => auto_delete ,
79- :boot => true ,
80- :source => self_link ,
81- :mode => writable ? "READ_WRITE" : "READ_ONLY" ,
82- :type => "PERSISTENT"
83- }
113+ attached_disk_obj ( boot : true ,
114+ writable : writable ,
115+ auto_delete : auto_delete )
84116 end
85117
86118 def ready?
0 commit comments