Class: VSphereAutomation::VCenter::VcenterVMCreateSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ VcenterVMCreateSpec

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 106

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'guest_OS')
    self.guest_os = attributes[:'guest_OS']
  end

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'placement')
    self.placement = attributes[:'placement']
  end

  if attributes.has_key?(:'hardware_version')
    self.hardware_version = attributes[:'hardware_version']
  end

  if attributes.has_key?(:'boot')
    self.boot = attributes[:'boot']
  end

  if attributes.has_key?(:'boot_devices')
    if (value = attributes[:'boot_devices']).is_a?(Array)
      self.boot_devices = value
    end
  end

  if attributes.has_key?(:'cpu')
    self.cpu = attributes[:'cpu']
  end

  if attributes.has_key?(:'memory')
    self.memory = attributes[:'memory']
  end

  if attributes.has_key?(:'disks')
    if (value = attributes[:'disks']).is_a?(Array)
      self.disks = value
    end
  end

  if attributes.has_key?(:'nics')
    if (value = attributes[:'nics']).is_a?(Array)
      self.nics = value
    end
  end

  if attributes.has_key?(:'cdroms')
    if (value = attributes[:'cdroms']).is_a?(Array)
      self.cdroms = value
    end
  end

  if attributes.has_key?(:'floppies')
    if (value = attributes[:'floppies']).is_a?(Array)
      self.floppies = value
    end
  end

  if attributes.has_key?(:'parallel_ports')
    if (value = attributes[:'parallel_ports']).is_a?(Array)
      self.parallel_ports = value
    end
  end

  if attributes.has_key?(:'serial_ports')
    if (value = attributes[:'serial_ports']).is_a?(Array)
      self.serial_ports = value
    end
  end

  if attributes.has_key?(:'sata_adapters')
    if (value = attributes[:'sata_adapters']).is_a?(Array)
      self.sata_adapters = value
    end
  end

  if attributes.has_key?(:'scsi_adapters')
    if (value = attributes[:'scsi_adapters']).is_a?(Array)
      self.scsi_adapters = value
    end
  end

  if attributes.has_key?(:'storage_policy')
    self.storage_policy = attributes[:'storage_policy']
  end
end

Instance Attribute Details

#bootObject

Returns the value of attribute boot.



23
24
25
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 23

def boot
  @boot
end

#boot_devicesObject

Boot device configuration. If unset, a server-specific boot sequence will be used.



26
27
28
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 26

def boot_devices
  @boot_devices
end

#cdromsObject

List of CD-ROMs. If unset, no CD-ROM devices will be created.



39
40
41
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 39

def cdroms
  @cdroms
end

#cpuObject

Returns the value of attribute cpu.



28
29
30
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 28

def cpu
  @cpu
end

#disksObject

List of disks. If unset, a single blank virtual disk of a guest-specific size will be created on the same storage as the virtual machine configuration, and will use a guest-specific host bus adapter type. If the guest-specific size is 0, no virtual disk will be created.



33
34
35
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 33

def disks
  @disks
end

#floppiesObject

List of floppy drives. If unset, no floppy drives will be created.



42
43
44
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 42

def floppies
  @floppies
end

#guest_osObject

Returns the value of attribute guest_os.



14
15
16
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 14

def guest_os
  @guest_os
end

#hardware_versionObject

Returns the value of attribute hardware_version.



21
22
23
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 21

def hardware_version
  @hardware_version
end

#memoryObject

Returns the value of attribute memory.



30
31
32
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 30

def memory
  @memory
end

#nameObject

Virtual machine name. If unset, a default name will be generated by the server.



17
18
19
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 17

def name
  @name
end

#nicsObject

List of Ethernet adapters. If unset, no Ethernet adapters will be created.



36
37
38
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 36

def nics
  @nics
end

#parallel_portsObject

List of parallel ports. If unset, no parallel ports will be created.



45
46
47
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 45

def parallel_ports
  @parallel_ports
end

#placementObject

Returns the value of attribute placement.



19
20
21
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 19

def placement
  @placement
end

#sata_adaptersObject

List of SATA adapters. If unset, any adapters necessary to connect the virtual machine’s storage devices will be created; this includes any devices that explicitly specify a SATA host bus adapter, as well as any devices that do not specify a host bus adapter if the guest’s preferred adapter type is SATA.



51
52
53
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 51

def sata_adapters
  @sata_adapters
end

#scsi_adaptersObject

List of SCSI adapters. If unset, any adapters necessary to connect the virtual machine’s storage devices will be created; this includes any devices that explicitly specify a SCSI host bus adapter, as well as any devices that do not specify a host bus adapter if the guest’s preferred adapter type is SCSI. The type of the SCSI adapter will be a guest-specific default type.



54
55
56
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 54

def scsi_adapters
  @scsi_adapters
end

#serial_portsObject

List of serial ports. If unset, no serial ports will be created.



48
49
50
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 48

def serial_ports
  @serial_ports
end

#storage_policyObject

Returns the value of attribute storage_policy.



56
57
58
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 56

def storage_policy
  @storage_policy
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 59

def self.attribute_map
  {
    :'guest_os' => :'guest_OS',
    :'name' => :'name',
    :'placement' => :'placement',
    :'hardware_version' => :'hardware_version',
    :'boot' => :'boot',
    :'boot_devices' => :'boot_devices',
    :'cpu' => :'cpu',
    :'memory' => :'memory',
    :'disks' => :'disks',
    :'nics' => :'nics',
    :'cdroms' => :'cdroms',
    :'floppies' => :'floppies',
    :'parallel_ports' => :'parallel_ports',
    :'serial_ports' => :'serial_ports',
    :'sata_adapters' => :'sata_adapters',
    :'scsi_adapters' => :'scsi_adapters',
    :'storage_policy' => :'storage_policy'
  }
end

.openapi_typesObject

Attribute type mapping.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 82

def self.openapi_types
  {
    :'guest_os' => :'VcenterVmGuestOS',
    :'name' => :'String',
    :'placement' => :'VcenterVMPlacementSpec',
    :'hardware_version' => :'VcenterVmHardwareVersion',
    :'boot' => :'VcenterVmHardwareBootCreateSpec',
    :'boot_devices' => :'Array<VcenterVmHardwareBootDeviceEntryCreateSpec>',
    :'cpu' => :'VcenterVmHardwareCpuUpdateSpec',
    :'memory' => :'VcenterVmHardwareMemoryUpdateSpec',
    :'disks' => :'Array<VcenterVmHardwareDiskCreateSpec>',
    :'nics' => :'Array<VcenterVmHardwareEthernetCreateSpec>',
    :'cdroms' => :'Array<VcenterVmHardwareCdromCreateSpec>',
    :'floppies' => :'Array<VcenterVmHardwareFloppyCreateSpec>',
    :'parallel_ports' => :'Array<VcenterVmHardwareParallelCreateSpec>',
    :'serial_ports' => :'Array<VcenterVmHardwareSerialCreateSpec>',
    :'sata_adapters' => :'Array<VcenterVmHardwareAdapterSataCreateSpec>',
    :'scsi_adapters' => :'Array<VcenterVmHardwareAdapterScsiCreateSpec>',
    :'storage_policy' => :'VcenterVMStoragePolicySpec'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 219

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      guest_os == o.guest_os &&
      name == o.name &&
      placement == o.placement &&
      hardware_version == o.hardware_version &&
      boot == o.boot &&
      boot_devices == o.boot_devices &&
      cpu == o.cpu &&
      memory == o.memory &&
      disks == o.disks &&
      nics == o.nics &&
      cdroms == o.cdroms &&
      floppies == o.floppies &&
      parallel_ports == o.parallel_ports &&
      serial_ports == o.serial_ports &&
      sata_adapters == o.sata_adapters &&
      scsi_adapters == o.scsi_adapters &&
      storage_policy == o.storage_policy
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 277

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN, :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = VSphereAutomation::VCenter.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 343

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 256

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


243
244
245
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 243

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



249
250
251
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 249

def hash
  [guest_os, name, placement, hardware_version, boot, boot_devices, cpu, memory, disks, nics, cdroms, floppies, parallel_ports, serial_ports, sata_adapters, scsi_adapters, storage_policy].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



201
202
203
204
205
206
207
208
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 201

def list_invalid_properties
  invalid_properties = Array.new
  if @guest_os.nil?
    invalid_properties.push('invalid value for "guest_os", guest_os cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



323
324
325
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 323

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



329
330
331
332
333
334
335
336
337
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 329

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



317
318
319
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 317

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



212
213
214
215
# File 'lib/vsphere-automation-vcenter/models/vcenter_vm_create_spec.rb', line 212

def valid?
  return false if @guest_os.nil?
  true
end