Class: OCI::Core::Models::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/core/models/instance.rb

Overview

A compute host. The image used to launch the instance determines its operating system and other software. The shape specified during the launch process determines the number of CPUs and memory allocated to the instance. For more information, see [Overview of the Compute Service](docs.us-phoenix-1.oraclecloud.com/Content/Compute/Concepts/computeoverview.htm).

To use any of the API operations, you must be authorized in an IAM policy. If you’re not authorized, talk to an administrator. If you’re an administrator who needs to write policies to give users access, see [Getting Started with Policies](docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/policygetstarted.htm).

Constant Summary collapse

LAUNCH_MODE_ENUM =

rubocop:disable Metrics/LineLength

[
  LAUNCH_MODE_NATIVE = 'NATIVE'.freeze,
  LAUNCH_MODE_EMULATED = 'EMULATED'.freeze,
  LAUNCH_MODE_CUSTOM = 'CUSTOM'.freeze,
  LAUNCH_MODE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
LIFECYCLE_STATE_ENUM =
[
  LIFECYCLE_STATE_PROVISIONING = 'PROVISIONING'.freeze,
  LIFECYCLE_STATE_RUNNING = 'RUNNING'.freeze,
  LIFECYCLE_STATE_STARTING = 'STARTING'.freeze,
  LIFECYCLE_STATE_STOPPING = 'STOPPING'.freeze,
  LIFECYCLE_STATE_STOPPED = 'STOPPED'.freeze,
  LIFECYCLE_STATE_CREATING_IMAGE = 'CREATING_IMAGE'.freeze,
  LIFECYCLE_STATE_TERMINATING = 'TERMINATING'.freeze,
  LIFECYCLE_STATE_TERMINATED = 'TERMINATED'.freeze,
  LIFECYCLE_STATE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Instance

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :availability_domain (String)

    The value to assign to the #availability_domain property

  • :compartment_id (String)

    The value to assign to the #compartment_id property

  • :defined_tags (Hash<String, Hash<String, Object>>)

    The value to assign to the #defined_tags property

  • :display_name (String)

    The value to assign to the #display_name property

  • :extended_metadata (Hash<String, Object>)

    The value to assign to the #extended_metadata property

  • :freeform_tags (Hash<String, String>)

    The value to assign to the #freeform_tags property

  • :id (String)

    The value to assign to the #id property

  • :image_id (String)

    The value to assign to the #image_id property

  • :ipxe_script (String)

    The value to assign to the #ipxe_script property

  • :launch_mode (String)

    The value to assign to the #launch_mode property

  • :launch_options (OCI::Core::Models::LaunchOptions)

    The value to assign to the #launch_options property

  • :lifecycle_state (String)

    The value to assign to the #lifecycle_state property

  • :metadata (Hash<String, String>)

    The value to assign to the #metadata property

  • :region (String)

    The value to assign to the #region property

  • :shape (String)

    The value to assign to the #shape property

  • :source_details (OCI::Core::Models::InstanceSourceDetails)

    The value to assign to the #source_details property

  • :time_created (DateTime)

    The value to assign to the #time_created property



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
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
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/oci/core/models/instance.rb', line 234

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 }

  self.availability_domain = attributes[:'availabilityDomain'] if attributes[:'availabilityDomain']

  raise 'You cannot provide both :availabilityDomain and :availability_domain' if attributes.key?(:'availabilityDomain') && attributes.key?(:'availability_domain')

  self.availability_domain = attributes[:'availability_domain'] if attributes[:'availability_domain']

  self.compartment_id = attributes[:'compartmentId'] if attributes[:'compartmentId']

  raise 'You cannot provide both :compartmentId and :compartment_id' if attributes.key?(:'compartmentId') && attributes.key?(:'compartment_id')

  self.compartment_id = attributes[:'compartment_id'] if attributes[:'compartment_id']

  self.defined_tags = attributes[:'definedTags'] if attributes[:'definedTags']

  raise 'You cannot provide both :definedTags and :defined_tags' if attributes.key?(:'definedTags') && attributes.key?(:'defined_tags')

  self.defined_tags = attributes[:'defined_tags'] if attributes[:'defined_tags']

  self.display_name = attributes[:'displayName'] if attributes[:'displayName']

  raise 'You cannot provide both :displayName and :display_name' if attributes.key?(:'displayName') && attributes.key?(:'display_name')

  self.display_name = attributes[:'display_name'] if attributes[:'display_name']

  self. = attributes[:'extendedMetadata'] if attributes[:'extendedMetadata']

  raise 'You cannot provide both :extendedMetadata and :extended_metadata' if attributes.key?(:'extendedMetadata') && attributes.key?(:'extended_metadata')

  self. = attributes[:'extended_metadata'] if attributes[:'extended_metadata']

  self.freeform_tags = attributes[:'freeformTags'] if attributes[:'freeformTags']

  raise 'You cannot provide both :freeformTags and :freeform_tags' if attributes.key?(:'freeformTags') && attributes.key?(:'freeform_tags')

  self.freeform_tags = attributes[:'freeform_tags'] if attributes[:'freeform_tags']

  self.id = attributes[:'id'] if attributes[:'id']

  self.image_id = attributes[:'imageId'] if attributes[:'imageId']

  raise 'You cannot provide both :imageId and :image_id' if attributes.key?(:'imageId') && attributes.key?(:'image_id')

  self.image_id = attributes[:'image_id'] if attributes[:'image_id']

  self.ipxe_script = attributes[:'ipxeScript'] if attributes[:'ipxeScript']

  raise 'You cannot provide both :ipxeScript and :ipxe_script' if attributes.key?(:'ipxeScript') && attributes.key?(:'ipxe_script')

  self.ipxe_script = attributes[:'ipxe_script'] if attributes[:'ipxe_script']

  self.launch_mode = attributes[:'launchMode'] if attributes[:'launchMode']

  raise 'You cannot provide both :launchMode and :launch_mode' if attributes.key?(:'launchMode') && attributes.key?(:'launch_mode')

  self.launch_mode = attributes[:'launch_mode'] if attributes[:'launch_mode']

  self.launch_options = attributes[:'launchOptions'] if attributes[:'launchOptions']

  raise 'You cannot provide both :launchOptions and :launch_options' if attributes.key?(:'launchOptions') && attributes.key?(:'launch_options')

  self.launch_options = attributes[:'launch_options'] if attributes[:'launch_options']

  self.lifecycle_state = attributes[:'lifecycleState'] if attributes[:'lifecycleState']

  raise 'You cannot provide both :lifecycleState and :lifecycle_state' if attributes.key?(:'lifecycleState') && attributes.key?(:'lifecycle_state')

  self.lifecycle_state = attributes[:'lifecycle_state'] if attributes[:'lifecycle_state']

  self. = attributes[:'metadata'] if attributes[:'metadata']

  self.region = attributes[:'region'] if attributes[:'region']

  self.shape = attributes[:'shape'] if attributes[:'shape']

  self.source_details = attributes[:'sourceDetails'] if attributes[:'sourceDetails']

  raise 'You cannot provide both :sourceDetails and :source_details' if attributes.key?(:'sourceDetails') && attributes.key?(:'source_details')

  self.source_details = attributes[:'source_details'] if attributes[:'source_details']

  self.time_created = attributes[:'timeCreated'] if attributes[:'timeCreated']

  raise 'You cannot provide both :timeCreated and :time_created' if attributes.key?(:'timeCreated') && attributes.key?(:'time_created')

  self.time_created = attributes[:'time_created'] if attributes[:'time_created']
end

Instance Attribute Details

#availability_domainString

[Required] The Availability Domain the instance is running in.

Example: ‘Uocm:PHX-AD-1`

Returns:

  • (String)


42
43
44
# File 'lib/oci/core/models/instance.rb', line 42

def availability_domain
  @availability_domain
end

#compartment_idString

[Required] The OCID of the compartment that contains the instance.

Returns:

  • (String)


46
47
48
# File 'lib/oci/core/models/instance.rb', line 46

def compartment_id
  @compartment_id
end

#defined_tagsHash<String, Hash<String, Object>>

Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).

Example: ‘{"CostCenter": "42"}`

Returns:

  • (Hash<String, Hash<String, Object>>)


54
55
56
# File 'lib/oci/core/models/instance.rb', line 54

def defined_tags
  @defined_tags
end

#display_nameString

A user-friendly name. Does not have to be unique, and it’s changeable. Avoid entering confidential information.

Example: ‘My bare metal instance`

Returns:

  • (String)


62
63
64
# File 'lib/oci/core/models/instance.rb', line 62

def display_name
  @display_name
end

#extended_metadataHash<String, Object>

Additional metadata key/value pairs that you provide. They serve a similar purpose and functionality from fields in the ‘metadata’ object.

They are distinguished from ‘metadata’ fields in that these can be nested JSON objects (whereas ‘metadata’ fields are string/string maps only).

If you don’t need nested metadata values, it is strongly advised to avoid using this object and use the Metadata object instead.

Returns:

  • (Hash<String, Object>)


71
72
73
# File 'lib/oci/core/models/instance.rb', line 71

def 
  @extended_metadata
end

#freeform_tagsHash<String, String>

Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).

Example: ‘"Finance"`

Returns:

  • (Hash<String, String>)


80
81
82
# File 'lib/oci/core/models/instance.rb', line 80

def freeform_tags
  @freeform_tags
end

#idString

[Required] The OCID of the instance.

Returns:

  • (String)


84
85
86
# File 'lib/oci/core/models/instance.rb', line 84

def id
  @id
end

#image_idString

Deprecated. Use ‘sourceDetails` instead.

Returns:

  • (String)


89
90
91
# File 'lib/oci/core/models/instance.rb', line 89

def image_id
  @image_id
end

#ipxe_scriptString

When a bare metal or virtual machine instance boots, the iPXE firmware that runs on the instance is configured to run an iPXE script to continue the boot process.

If you want more control over the boot process, you can provide your own custom iPXE script that will run when the instance boots; however, you should be aware that the same iPXE script will run every time an instance boots; not only after the initial LaunchInstance call.

The default iPXE script connects to the instance’s local boot volume over iSCSI and performs a network boot. If you use a custom iPXE script and want to network-boot from the instance’s local boot volume over iSCSI the same way as the default iPXE script, you should use the following iSCSI IP address: 169.254.0.2, and boot volume IQN: iqn.2015-02.oracle.boot.

For more information about the Bring Your Own Image feature of Oracle Cloud Infrastructure, see [Bring Your Own Image](docs.us-phoenix-1.oraclecloud.com/Content/Compute/References/bringyourownimage.htm).

For more information about iPXE, see ipxe.org.

Returns:

  • (String)


115
116
117
# File 'lib/oci/core/models/instance.rb', line 115

def ipxe_script
  @ipxe_script
end

#launch_modeString

Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are:

  • ‘NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for Oracle-provided images.

  • ‘EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller.

  • ‘CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter.

Returns:

  • (String)


123
124
125
# File 'lib/oci/core/models/instance.rb', line 123

def launch_mode
  @launch_mode
end

#launch_optionsOCI::Core::Models::LaunchOptions



126
127
128
# File 'lib/oci/core/models/instance.rb', line 126

def launch_options
  @launch_options
end

#lifecycle_stateString

[Required] The current state of the instance.

Returns:

  • (String)


130
131
132
# File 'lib/oci/core/models/instance.rb', line 130

def lifecycle_state
  @lifecycle_state
end

#metadataHash<String, String>

Custom metadata that you provide.

Returns:

  • (Hash<String, String>)


134
135
136
# File 'lib/oci/core/models/instance.rb', line 134

def 
  @metadata
end

#regionString

[Required] The region that contains the Availability Domain the instance is running in.

Example: ‘phx`

Returns:

  • (String)


141
142
143
# File 'lib/oci/core/models/instance.rb', line 141

def region
  @region
end

#shapeString

[Required] The shape of the instance. The shape determines the number of CPUs and the amount of memory allocated to the instance. You can enumerate all available shapes by calling list_shapes.

Returns:

  • (String)


148
149
150
# File 'lib/oci/core/models/instance.rb', line 148

def shape
  @shape
end

#source_detailsOCI::Core::Models::InstanceSourceDetails

Details for creating an instance



152
153
154
# File 'lib/oci/core/models/instance.rb', line 152

def source_details
  @source_details
end

#time_createdDateTime

[Required] The date and time the instance was created, in the format defined by RFC3339.

Example: ‘2016-08-25T21:10:29.600Z`

Returns:

  • (DateTime)


159
160
161
# File 'lib/oci/core/models/instance.rb', line 159

def time_created
  @time_created
end

Class Method Details

.attribute_mapObject

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



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/oci/core/models/instance.rb', line 162

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'availability_domain': :'availabilityDomain',
    'compartment_id': :'compartmentId',
    'defined_tags': :'definedTags',
    'display_name': :'displayName',
    'extended_metadata': :'extendedMetadata',
    'freeform_tags': :'freeformTags',
    'id': :'id',
    'image_id': :'imageId',
    'ipxe_script': :'ipxeScript',
    'launch_mode': :'launchMode',
    'launch_options': :'launchOptions',
    'lifecycle_state': :'lifecycleState',
    'metadata': :'metadata',
    'region': :'region',
    'shape': :'shape',
    'source_details': :'sourceDetails',
    'time_created': :'timeCreated'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/oci/core/models/instance.rb', line 187

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'availability_domain': :'String',
    'compartment_id': :'String',
    'defined_tags': :'Hash<String, Hash<String, Object>>',
    'display_name': :'String',
    'extended_metadata': :'Hash<String, Object>',
    'freeform_tags': :'Hash<String, String>',
    'id': :'String',
    'image_id': :'String',
    'ipxe_script': :'String',
    'launch_mode': :'String',
    'launch_options': :'OCI::Core::Models::LaunchOptions',
    'lifecycle_state': :'String',
    'metadata': :'Hash<String, String>',
    'region': :'String',
    'shape': :'String',
    'source_details': :'OCI::Core::Models::InstanceSourceDetails',
    'time_created': :'DateTime'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/oci/core/models/instance.rb', line 364

def ==(other)
  return true if equal?(other)
  self.class == other.class &&
    availability_domain == other.availability_domain &&
    compartment_id == other.compartment_id &&
    defined_tags == other.defined_tags &&
    display_name == other.display_name &&
     == other. &&
    freeform_tags == other.freeform_tags &&
    id == other.id &&
    image_id == other.image_id &&
    ipxe_script == other.ipxe_script &&
    launch_mode == other.launch_mode &&
    launch_options == other.launch_options &&
    lifecycle_state == other.lifecycle_state &&
     == other. &&
    region == other.region &&
    shape == other.shape &&
    source_details == other.source_details &&
    time_created == other.time_created
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



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/oci/core/models/instance.rb', line 409

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/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)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(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?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


389
390
391
# File 'lib/oci/core/models/instance.rb', line 389

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



398
399
400
# File 'lib/oci/core/models/instance.rb', line 398

def hash
  [availability_domain, compartment_id, defined_tags, display_name, , freeform_tags, id, image_id, ipxe_script, launch_mode, launch_options, lifecycle_state, , region, shape, source_details, time_created].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



441
442
443
444
445
446
447
448
449
# File 'lib/oci/core/models/instance.rb', line 441

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



435
436
437
# File 'lib/oci/core/models/instance.rb', line 435

def to_s
  to_hash.to_s
end