Class: OracleCloud::InstanceRequest
- Inherits:
-
Object
- Object
- OracleCloud::InstanceRequest
- Defined in:
- lib/oraclecloud/instance_request.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#imagelist ⇒ Object
readonly
Returns the value of attribute imagelist.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#public_ip ⇒ Object
readonly
Returns the value of attribute public_ip.
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
-
#sshkeys ⇒ Object
readonly
Returns the value of attribute sshkeys.
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(client, opts) ⇒ InstanceRequest
constructor
A new instance of InstanceRequest.
- #missing_required_options ⇒ Object
- #nat ⇒ Object
- #networking ⇒ Object
- #to_h ⇒ Object
- #validate_options! ⇒ Object
Constructor Details
#initialize(client, opts) ⇒ InstanceRequest
Returns a new instance of InstanceRequest.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/oraclecloud/instance_request.rb', line 21 def initialize(client, opts) @client = client @opts = opts @name = opts[:name] @shape = opts[:shape] @imagelist = opts[:imagelist] @public_ip = opts[:public_ip] @label = opts.fetch(:label, @name) @sshkeys = opts.fetch(:sshkeys, []) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def client @client end |
#imagelist ⇒ Object (readonly)
Returns the value of attribute imagelist.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def imagelist @imagelist end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def name @name end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def opts @opts end |
#public_ip ⇒ Object (readonly)
Returns the value of attribute public_ip.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def public_ip @public_ip end |
#shape ⇒ Object (readonly)
Returns the value of attribute shape.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def shape @shape end |
#sshkeys ⇒ Object (readonly)
Returns the value of attribute sshkeys.
20 21 22 |
# File 'lib/oraclecloud/instance_request.rb', line 20 def sshkeys @sshkeys end |
Instance Method Details
#full_name ⇒ Object
50 51 52 |
# File 'lib/oraclecloud/instance_request.rb', line 50 def full_name "#{client.full_identity_domain}/#{client.username}/#{name}" end |
#missing_required_options ⇒ Object
44 45 46 47 48 |
# File 'lib/oraclecloud/instance_request.rb', line 44 def [ :name, :shape, :imagelist ].each_with_object([]) do |opt, memo| memo << opt unless opts[opt] end end |
#nat ⇒ Object
54 55 56 57 |
# File 'lib/oraclecloud/instance_request.rb', line 54 def nat return unless public_ip (public_ip == :pool) ? 'ippool:/oracle/public/ippool' : "ipreservation:#{public_ip}" end |
#networking ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/oraclecloud/instance_request.rb', line 59 def networking networking = {} networking['eth0'] = {} networking['eth0']['nat'] = nat unless nat.nil? networking end |
#to_h ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/oraclecloud/instance_request.rb', line 67 def to_h { 'shape' => shape, 'label' => label, 'imagelist' => imagelist, 'name' => full_name, 'sshkeys' => sshkeys, 'networking' => networking } end |
#validate_options! ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/oraclecloud/instance_request.rb', line 35 def raise ArgumentError, "The following required options are missing: #{.join(', ')}" unless .empty? raise ArgumentError, "#{shape} is not a valid shape" unless client.shapes.exist?(shape) raise ArgumentError, "#{imagelist} is not a valid imagelist" unless client.imagelists.exist?(imagelist) raise ArgumentError, 'sshkeys must be an array of key names' unless sshkeys.respond_to?(:each) end |