chef-partners/oracle-cloud-client

Name: oracle-cloud-client

Owner: Chef Partners

Description: Client for interacting with the Oracle Cloud REST API

Created: 2015-09-16 19:21:03.0

Updated: 2016-07-15 18:19:07.0

Pushed: 2018-02-06 01:19:28.0

Homepage: null

Size: 65

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Oracle Cloud API Client

oracle-cloud is a RubyGem for interacting with the Oracle Cloud REST API.

Installation

Add this line to your application's Gemfile:

'oraclecloud'

And then execute:

$ bundle

Or install it yourself as:

$ gem install oraclecloud
Usage

First, load in the gem.

ire 'oraclecloud'
rue

Then, set up your client object.

nt = OracleCloud::Client.new(username: 'user@domain.io', password: 'supersecret', identity_domain: 'mydomain', api_url: 'https://some-api-endpoint.compute.us6.oraclecloud.com')
<OracleCloud::Client:0x000000034c0df8 ... >
Instances

To list all instances:

nt.instances.all
#<OracleCloud::Instance:0x007fd6e4080710
sset_data=

Once you have an instance, you can get additional information about it:

ance.hostname
c799e7.compute-mydomain.oraclecloud.internal."

ance.ip_address
10.1.1.1"

ance.public_ip_addresses
"1.2.3.4"]

ance.shape
oc1m"

ance.state
running"

ance.vcable_id
/Compute-mydomain/user@domain.io/7a46361a-4e69-41ec-bf4f-84d22a2eeab0"

ance.image
/oracle/public/oel_6.6_20GB_x11_RD"
Creating Instances

To create an instance, you must create an orchestration which controls that instance. An orchestration can start multiple instances.

First, build an instance request for each instance you wish to start:

ance1 = client.instance_request(shape: 'oc1m', imagelist: '/oracle/public/oel_6.6_20GB_x11_RD', name: 'test1', sshkeys: ["/path/to/sshkey"], public_ip: :pool)
<OracleCloud::InstanceRequest:0x007fdf0d286880 ...>

See the Shapes and Imagelists sections for help on determining your shape and imagelist options.

Then, build an orchestration:

estration = client.orchestrations.create(name: 'test1', description: 'my first orchestration', instances: [ instance1 ])
<OracleCloud::Orchestration:0x007fdf0a342880

You will see that the orchestration is not yet started, so go ahead and start it!

estration.status
stopped"

estration.start
"relationships"=>[],
atus"=>"starting",

You can refresh the orchestration status. Once it's started, your instances should be available.

estration.refresh && orchestration.status
starting"

estration.refresh && orchestration.status
ready"

ance = orchestration.instances.first
<OracleCloud::Instance:0x007fff0b478aa8 ...>

ance.state
running"

ance.public_ip_addresses
"1.2.3.4"]
Shapes

You can list all available shapes using the client.shapes.all method:

nt.shapes.all
#<OracleCloud::Shape:0x007f823b9cb5e8
hape_data=
"nds_iops_limit"=>0,
"ram"=>122880,
"cpus"=>16.0,
"uri"=>"https://some-api-endpoint.compute.us6.oraclecloud.com/shape/oc4m",
"io"=>800,
"name"=>"oc4m"}>,
racleCloud::Shape:0x007f823b9cb5c0
hape_data=
"nds_iops_limit"=>0,
"ram"=>122880,
"cpus"=>32.0,
"uri"=>"https://some-api-endpoint.compute.us6.oraclecloud.com/shape/oc7",
"io"=>1000,
"name"=>"oc7"}>,

This returns an array of OracleCloud::Shape objects which you can interrogate as needed:

nt.shapes.all.map { |shape| shape.name }.sort
"oc1m", "oc2m", "oc3", "oc3m", "oc4", "oc4m", "oc5", "oc5m", "oc6", "oc7"]
Imagelists

You can list all available imagelists using the client.imagelists.all method:

nt.imagelists.all
#<OracleCloud::ImageList:0x007f823ed69b48
magelist_data=
"default"=>1,
"description"=>"\"OEL 6.4 20 GB image\"",
"entries"=>
 [{"attributes"=>{},
   "version"=>1,
   "machineimages"=>["/oracle/public/oel_6.4_20GB_x11_RD"],
   "uri"=>

This returns an array of OracleCloud::ImageList objects which you can interrogateas needed:

nt.imagelists.all.map { |imagelist| imagelist.name }.sort
"/oracle/public/oel_6.4_20GB_x11_RD", "/oracle/public/oel_6.4_5GB_RD", "/oracle/public/oel_6.6_20GB_x11_RD"]
License and Authors

Author:: Chef Partner Engineering (partnereng@chef.io)

Copyright:: Copyright (c) 2015 Chef Software, Inc.

License:: Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributing
  1. Fork it ( https://github.com/chef-partners/oracle-cloud-client/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.