oraclecloud 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'securerandom'
20
+
21
+ module OracleCloud
22
+ class Orchestrations < Assets
23
+ def local_init
24
+ @asset_type = 'orchestration'
25
+ @asset_klass = OracleCloud::Orchestration
26
+ end
27
+
28
+ def validate_create_options!
29
+ raise ArgumentError, 'instances option must be an array of instance requests to create' unless create_opts[:instances].respond_to?(:each)
30
+ raise ArgumentError, 'orchestration description is required' unless create_opts[:description]
31
+
32
+ create_opts[:name] = SecureRandom.uuid unless create_opts[:name]
33
+ create_opts[:launch_plan_label] = 'launch_plan' unless create_opts[:launch_plan_label]
34
+ end
35
+
36
+ def create_request_payload
37
+ {
38
+ 'name' => "#{client.compute_identity_domain}/#{client.username}/#{create_opts[:name]}",
39
+ 'relationships' => [],
40
+ 'account' => "#{client.compute_identity_domain}/default",
41
+ 'description' => create_opts[:description],
42
+ 'schedule' => { 'start_time' => nil, 'stop_time' => nil },
43
+ 'uri' => nil,
44
+ 'oplans' => [
45
+ {
46
+ 'status' => 'unknown',
47
+ 'info' => {},
48
+ 'obj_type' => 'launchplan',
49
+ 'ha_policy' => 'active',
50
+ 'label' => create_opts[:launch_plan_label],
51
+ 'objects' => [
52
+ {
53
+ 'instances' => create_opts[:instances].map(&:to_h)
54
+ }
55
+ ]
56
+ }
57
+ ]
58
+ }
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,42 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module OracleCloud
19
+ class Shape
20
+ attr_reader :shape_data
21
+
22
+ def initialize(shape_data)
23
+ @shape_data = shape_data
24
+ end
25
+
26
+ def name
27
+ shape_data['name']
28
+ end
29
+
30
+ def ram
31
+ shape_data['ram']
32
+ end
33
+
34
+ def cpus
35
+ shape_data['cpus']
36
+ end
37
+
38
+ def io
39
+ shape_data['io']
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,36 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module OracleCloud
19
+ class Shapes
20
+ attr_reader :client
21
+
22
+ def initialize(client)
23
+ @client = client
24
+ end
25
+
26
+ def all
27
+ client.http_get(:single, '/shape/')['result'].each_with_object([]) do |shape, memo|
28
+ memo << OracleCloud::Shape.new(shape)
29
+ end
30
+ end
31
+
32
+ def exist?(shape_name)
33
+ all.any? { |x| x.name == shape_name }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module OracleCloud
19
+ class SSHKey < Asset
20
+ def local_init
21
+ @asset_type = 'sshkey'
22
+ end
23
+
24
+ def enabled
25
+ asset_data['enabled']
26
+ end
27
+
28
+ def key
29
+ asset_data['key']
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module OracleCloud
19
+ class SSHKeys < Assets
20
+ def local_init
21
+ @asset_type = 'sshkey'
22
+ @asset_klass = OracleCloud::SSHKey
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module OracleCloud
19
+ VERSION = '1.0.0'
20
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'oraclecloud/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'oraclecloud'
8
+ spec.version = OracleCloud::VERSION
9
+ spec.authors = ['Chef Partner Engineering']
10
+ spec.email = ['partnereng@chef.io']
11
+
12
+ spec.summary = 'Client gem for interacting with the Oracle Cloud API.'
13
+ spec.homepage = 'https://github.com/chef-partners/oracle-cloud-client'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'rest-client', '~> 1.8'
20
+ spec.add_dependency 'ffi-yajl', '~> 2.2'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'pry'
26
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oraclecloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Chef Partner Engineering
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ffi-yajl
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - partnereng@chef.io
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - CHANGELOG.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/oraclecloud.rb
113
+ - lib/oraclecloud/asset.rb
114
+ - lib/oraclecloud/assets.rb
115
+ - lib/oraclecloud/client.rb
116
+ - lib/oraclecloud/exceptions.rb
117
+ - lib/oraclecloud/imagelist.rb
118
+ - lib/oraclecloud/imagelists.rb
119
+ - lib/oraclecloud/instance.rb
120
+ - lib/oraclecloud/instance_request.rb
121
+ - lib/oraclecloud/instances.rb
122
+ - lib/oraclecloud/ip_association.rb
123
+ - lib/oraclecloud/ip_associations.rb
124
+ - lib/oraclecloud/orchestration.rb
125
+ - lib/oraclecloud/orchestrations.rb
126
+ - lib/oraclecloud/shape.rb
127
+ - lib/oraclecloud/shapes.rb
128
+ - lib/oraclecloud/sshkey.rb
129
+ - lib/oraclecloud/sshkeys.rb
130
+ - lib/oraclecloud/version.rb
131
+ - oraclecloud.gemspec
132
+ homepage: https://github.com/chef-partners/oracle-cloud-client
133
+ licenses: []
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.4.8
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Client gem for interacting with the Oracle Cloud API.
155
+ test_files: []
156
+ has_rdoc: