fog-joyent 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +436 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +26 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +17 -0
- data/Gemfile +4 -0
- data/LICENSE.md +10 -0
- data/README.md +29 -0
- data/Rakefile +12 -0
- data/fog-joyent.gemspec +29 -0
- data/lib/fog/bin/joyent.rb +33 -0
- data/lib/fog/joyent.rb +16 -0
- data/lib/fog/joyent/analytics.rb +310 -0
- data/lib/fog/joyent/compute.rb +272 -0
- data/lib/fog/joyent/core.rb +10 -0
- data/lib/fog/joyent/errors.rb +91 -0
- data/lib/fog/joyent/models/analytics/field.rb +13 -0
- data/lib/fog/joyent/models/analytics/fields.rb +24 -0
- data/lib/fog/joyent/models/analytics/instrumentation.rb +82 -0
- data/lib/fog/joyent/models/analytics/instrumentations.rb +23 -0
- data/lib/fog/joyent/models/analytics/joyent_module.rb +13 -0
- data/lib/fog/joyent/models/analytics/joyent_modules.rb +24 -0
- data/lib/fog/joyent/models/analytics/metric.rb +17 -0
- data/lib/fog/joyent/models/analytics/metrics.rb +16 -0
- data/lib/fog/joyent/models/analytics/transformation.rb +13 -0
- data/lib/fog/joyent/models/analytics/transformations.rb +24 -0
- data/lib/fog/joyent/models/analytics/type.rb +16 -0
- data/lib/fog/joyent/models/analytics/types.rb +24 -0
- data/lib/fog/joyent/models/analytics/value.rb +20 -0
- data/lib/fog/joyent/models/compute/datacenter.rb +11 -0
- data/lib/fog/joyent/models/compute/datacenters.rb +21 -0
- data/lib/fog/joyent/models/compute/flavor.rb +19 -0
- data/lib/fog/joyent/models/compute/flavors.rb +21 -0
- data/lib/fog/joyent/models/compute/image.rb +26 -0
- data/lib/fog/joyent/models/compute/images.rb +30 -0
- data/lib/fog/joyent/models/compute/key.rb +19 -0
- data/lib/fog/joyent/models/compute/keys.rb +32 -0
- data/lib/fog/joyent/models/compute/network.rb +12 -0
- data/lib/fog/joyent/models/compute/networks.rb +14 -0
- data/lib/fog/joyent/models/compute/server.rb +124 -0
- data/lib/fog/joyent/models/compute/servers.rb +35 -0
- data/lib/fog/joyent/models/compute/snapshot.rb +44 -0
- data/lib/fog/joyent/models/compute/snapshots.rb +35 -0
- data/lib/fog/joyent/requests/analytics/create_instrumentation.rb +25 -0
- data/lib/fog/joyent/requests/analytics/delete_instrumentation.rb +23 -0
- data/lib/fog/joyent/requests/analytics/describe_analytics.rb +26 -0
- data/lib/fog/joyent/requests/analytics/get_instrumentation.rb +26 -0
- data/lib/fog/joyent/requests/analytics/get_instrumentation_value.rb +30 -0
- data/lib/fog/joyent/requests/analytics/list_instrumentations.rb +25 -0
- data/lib/fog/joyent/requests/compute/add_machine_tags.rb +19 -0
- data/lib/fog/joyent/requests/compute/create_key.rb +54 -0
- data/lib/fog/joyent/requests/compute/create_machine.rb +16 -0
- data/lib/fog/joyent/requests/compute/create_machine_snapshot.rb +16 -0
- data/lib/fog/joyent/requests/compute/delete_all_machine_metadata.rb +16 -0
- data/lib/fog/joyent/requests/compute/delete_all_machine_tags.rb +15 -0
- data/lib/fog/joyent/requests/compute/delete_key.rb +27 -0
- data/lib/fog/joyent/requests/compute/delete_machine.rb +15 -0
- data/lib/fog/joyent/requests/compute/delete_machine_metadata.rb +16 -0
- data/lib/fog/joyent/requests/compute/delete_machine_snapshot.rb +18 -0
- data/lib/fog/joyent/requests/compute/delete_machine_tag.rb +15 -0
- data/lib/fog/joyent/requests/compute/get_dataset.rb +27 -0
- data/lib/fog/joyent/requests/compute/get_image.rb +28 -0
- data/lib/fog/joyent/requests/compute/get_key.rb +29 -0
- data/lib/fog/joyent/requests/compute/get_machine.rb +29 -0
- data/lib/fog/joyent/requests/compute/get_machine_metadata.rb +24 -0
- data/lib/fog/joyent/requests/compute/get_machine_snapshot.rb +15 -0
- data/lib/fog/joyent/requests/compute/get_machine_tag.rb +18 -0
- data/lib/fog/joyent/requests/compute/get_package.rb +32 -0
- data/lib/fog/joyent/requests/compute/list_datacenters.rb +16 -0
- data/lib/fog/joyent/requests/compute/list_datasets.rb +24 -0
- data/lib/fog/joyent/requests/compute/list_images.rb +25 -0
- data/lib/fog/joyent/requests/compute/list_keys.rb +25 -0
- data/lib/fog/joyent/requests/compute/list_machine_snapshots.rb +15 -0
- data/lib/fog/joyent/requests/compute/list_machine_tags.rb +20 -0
- data/lib/fog/joyent/requests/compute/list_machines.rb +26 -0
- data/lib/fog/joyent/requests/compute/list_networks.rb +26 -0
- data/lib/fog/joyent/requests/compute/list_packages.rb +34 -0
- data/lib/fog/joyent/requests/compute/reboot_machine.rb +15 -0
- data/lib/fog/joyent/requests/compute/resize_machine.rb +16 -0
- data/lib/fog/joyent/requests/compute/start_machine.rb +16 -0
- data/lib/fog/joyent/requests/compute/start_machine_from_snapshot.rb +15 -0
- data/lib/fog/joyent/requests/compute/stop_machine.rb +16 -0
- data/lib/fog/joyent/requests/compute/update_machine_metadata.rb +15 -0
- data/lib/fog/joyent/version.rb +5 -0
- data/tests/helper.rb +18 -0
- data/tests/helpers/mock_helper.rb +16 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- data/tests/joyent/models/analytics/field_tests.rb +10 -0
- data/tests/joyent/models/analytics/fields_tests.rb +13 -0
- data/tests/joyent/models/analytics/instrumentation_tests.rb +13 -0
- data/tests/joyent/models/analytics/instrumentations_tests.rb +3 -0
- data/tests/joyent/models/analytics/joyent_module_tests.rb +10 -0
- data/tests/joyent/models/analytics/joyent_modules_tests.rb +13 -0
- data/tests/joyent/models/analytics/metric_tests.rb +10 -0
- data/tests/joyent/models/analytics/metrics_tests.rb +20 -0
- data/tests/joyent/models/analytics/transformation_tests.rb +10 -0
- data/tests/joyent/models/analytics/transformations_tests.rb +13 -0
- data/tests/joyent/models/analytics/type_tests.rb +10 -0
- data/tests/joyent/models/analytics/types_tests.rb +13 -0
- data/tests/joyent/requests/analytics/instrumentation_tests.rb +44 -0
- data/tests/joyent/requests/compute/datasets_tests.rb +58 -0
- data/tests/joyent/requests/compute/keys_tests.rb +47 -0
- data/tests/joyent/requests/compute/machines_tests.rb +66 -0
- data/tests/joyent/requests/compute/networks_tests.rb +39 -0
- data/tests/joyent/requests/compute/packages_tests.rb +68 -0
- metadata +235 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'fog/joyent/models/analytics/instrumentation'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Joyent
|
5
|
+
class Analytics
|
6
|
+
class Instrumentations < Fog::Collection
|
7
|
+
model Fog::Joyent::Analytics::Instrumentation
|
8
|
+
|
9
|
+
def all
|
10
|
+
data = service.list_instrumentations.body
|
11
|
+
load(data)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
data = service.get_instrumentation(id).body
|
16
|
+
new(data)
|
17
|
+
rescue Fog::Compute::Joyent::Errors::NotFound
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'fog/joyent/models/analytics/joyent_module'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Joyent
|
5
|
+
class Analytics
|
6
|
+
class JoyentModules < Fog::Collection
|
7
|
+
model Fog::Joyent::Analytics::JoyentModule
|
8
|
+
|
9
|
+
def all
|
10
|
+
data = service.describe_analytics.body['modules']
|
11
|
+
load(data)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Joyent returns an odd data structure like this:
|
15
|
+
# { 'apache' => {'label' => 'Apache'}}
|
16
|
+
# where the key is the name of the module
|
17
|
+
def new(attributes = {})
|
18
|
+
name, other_attributes = attributes
|
19
|
+
super(other_attributes.merge('name' => name))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Joyent
|
5
|
+
class Analytics
|
6
|
+
class Metric < Fog::Model
|
7
|
+
attribute :module
|
8
|
+
attribute :stat
|
9
|
+
attribute :label
|
10
|
+
attribute :interval
|
11
|
+
attribute :fields
|
12
|
+
attribute :unit
|
13
|
+
attribute :type
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fog/joyent/models/analytics/metric'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Joyent
|
5
|
+
class Analytics
|
6
|
+
class Metrics < Fog::Collection
|
7
|
+
model Fog::Joyent::Analytics::Metric
|
8
|
+
|
9
|
+
def all
|
10
|
+
data = service.describe_analytics.body['metrics']
|
11
|
+
load(data)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'fog/joyent/models/analytics/transformation'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Joyent
|
5
|
+
class Analytics
|
6
|
+
class Transformations < Fog::Collection
|
7
|
+
model Fog::Joyent::Analytics::Transformation
|
8
|
+
|
9
|
+
def all
|
10
|
+
data = service.describe_analytics.body['transformations']
|
11
|
+
load(data)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Joyent returns an odd data structure like this:
|
15
|
+
# { 'apache' => {'label' => 'Apache'}}
|
16
|
+
# where the key is the name of the module
|
17
|
+
def new(attributes = {})
|
18
|
+
name, other_attributes = attributes
|
19
|
+
super(other_attributes.merge('name' => name))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'fog/joyent/models/analytics/type'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Joyent
|
5
|
+
class Analytics
|
6
|
+
class Types < Fog::Collection
|
7
|
+
model Fog::Joyent::Analytics::Type
|
8
|
+
|
9
|
+
def all
|
10
|
+
data = service.describe_analytics.body['types']
|
11
|
+
load(data)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Joyent returns an odd data structure like this:
|
15
|
+
# { 'apache' => {'label' => 'Apache'}}
|
16
|
+
# where the key is the name of the module
|
17
|
+
def new(attributes = {})
|
18
|
+
name, other_attributes = attributes
|
19
|
+
super(other_attributes.merge('name' => name))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Joyent
|
5
|
+
class Analytics
|
6
|
+
class Value < Fog::Model
|
7
|
+
attribute :value
|
8
|
+
attribute :transformations
|
9
|
+
attribute :start_time, :type => :timestamp
|
10
|
+
attribute :duration
|
11
|
+
attribute :end_time, :type => :timestamp
|
12
|
+
attribute :nsources
|
13
|
+
attribute :minreporting
|
14
|
+
attribute :requested_start_time, :type => :timestamp
|
15
|
+
attribute :requested_duration
|
16
|
+
attribute :requested_end_time, :type => :timestamp
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/joyent/models/compute/datacenter'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Joyent
|
7
|
+
class Datacenters < Fog::Collection
|
8
|
+
model Fog::Compute::Joyent::Datacenter
|
9
|
+
|
10
|
+
def all
|
11
|
+
data = service.list_datacenters().body.map {|k,v| {:name => k, :url => v}}
|
12
|
+
load(data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(id)
|
16
|
+
all[id]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end # Joyent
|
20
|
+
end # Compute
|
21
|
+
end # Fog
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Joyent
|
4
|
+
class Flavor < Fog::Model
|
5
|
+
identity :id
|
6
|
+
|
7
|
+
attribute :name
|
8
|
+
attribute :memory
|
9
|
+
attribute :swap
|
10
|
+
attribute :disk
|
11
|
+
attribute :vcpus
|
12
|
+
attribute :default, :type => :boolean
|
13
|
+
attribute :description
|
14
|
+
attribute :version
|
15
|
+
attribute :group
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/joyent/models/compute/flavor'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Joyent
|
7
|
+
class Flavors < Fog::Collection
|
8
|
+
model Fog::Compute::Joyent::Flavor
|
9
|
+
|
10
|
+
def all
|
11
|
+
load(service.list_packages().body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
data = service.get_package(id).body
|
16
|
+
new(data)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end # Joyent
|
20
|
+
end # Compute
|
21
|
+
end # Fog
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Joyent
|
4
|
+
class Image < Fog::Model
|
5
|
+
identity :id
|
6
|
+
|
7
|
+
attribute :name
|
8
|
+
attribute :os
|
9
|
+
attribute :version
|
10
|
+
attribute :type
|
11
|
+
attribute :description
|
12
|
+
attribute :requirements
|
13
|
+
attribute :homepage
|
14
|
+
attribute :published_at, :type => :time
|
15
|
+
attribute :public, :type => :boolean
|
16
|
+
attribute :owner
|
17
|
+
attribute :state
|
18
|
+
attribute :tags
|
19
|
+
attribute :eula
|
20
|
+
attribute :acl
|
21
|
+
attribute :created, :type => :time
|
22
|
+
attribute :default, :type => :boolean
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/joyent/models/compute/image'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Joyent
|
7
|
+
class Images < Fog::Collection
|
8
|
+
model Fog::Compute::Joyent::Image
|
9
|
+
|
10
|
+
def all
|
11
|
+
# the API call for getting images changed from 6.5 to 7.0. Joyent seems to still support the old url, but no idea for how long
|
12
|
+
if service.joyent_version.gsub(/[^0-9.]/,'').to_f < 7.0
|
13
|
+
load(service.list_datasets.body)
|
14
|
+
else
|
15
|
+
load(service.list_images.body)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(id)
|
20
|
+
data = if service.joyent_version.gsub(/[^0-9.]/,'').to_f < 7.0
|
21
|
+
service.get_dataset(id).body
|
22
|
+
else
|
23
|
+
service.get_image(id).body
|
24
|
+
end
|
25
|
+
new(data)
|
26
|
+
end
|
27
|
+
end # Images
|
28
|
+
end # Joyent
|
29
|
+
end # Compute
|
30
|
+
end # Fog
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Joyent
|
4
|
+
class Key < Fog::Model
|
5
|
+
identity :name
|
6
|
+
|
7
|
+
attribute :name
|
8
|
+
attribute :key
|
9
|
+
|
10
|
+
attribute :created, :type => :time
|
11
|
+
|
12
|
+
def destroy
|
13
|
+
requires :name
|
14
|
+
service.delete_key(name)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/joyent/models/compute/key'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Joyent
|
6
|
+
class Keys < Fog::Collection
|
7
|
+
model Fog::Compute::Joyent::Key
|
8
|
+
|
9
|
+
def all
|
10
|
+
data = service.list_keys.body
|
11
|
+
load(data)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(keyname)
|
15
|
+
data = service.get_key(keyname).body
|
16
|
+
if data
|
17
|
+
new(data)
|
18
|
+
else
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(params = {})
|
24
|
+
raise ArgumentError, "option [name] required" unless params.key?(:name)
|
25
|
+
raise ArgumentError, "option [key] required" unless params.key?(:key)
|
26
|
+
|
27
|
+
service.create_key(params)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'fog/compute/models/server'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Joyent
|
5
|
+
class Server < Fog::Compute::Server
|
6
|
+
identity :id
|
7
|
+
|
8
|
+
attribute :name
|
9
|
+
attribute :state
|
10
|
+
attribute :type
|
11
|
+
attribute :dataset
|
12
|
+
attribute :compute_node
|
13
|
+
attribute :networks
|
14
|
+
attribute :ips
|
15
|
+
attribute :memory
|
16
|
+
attribute :disk
|
17
|
+
attribute :metadata
|
18
|
+
attribute :tags
|
19
|
+
attribute :package
|
20
|
+
attribute :image
|
21
|
+
attribute :primary_ip, :aliases => 'primaryIp'
|
22
|
+
|
23
|
+
attribute :created, :type => :time
|
24
|
+
attribute :updated, :type => :time
|
25
|
+
|
26
|
+
def public_ip_address
|
27
|
+
ips.empty? ? nil : ips.first
|
28
|
+
end
|
29
|
+
|
30
|
+
def ready?
|
31
|
+
self.state == 'running'
|
32
|
+
end
|
33
|
+
|
34
|
+
def stopped?
|
35
|
+
requires :id
|
36
|
+
self.state == 'stopped'
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
requires :id
|
41
|
+
service.delete_machine(id)
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def start
|
46
|
+
requires :id
|
47
|
+
service.start_machine(id)
|
48
|
+
self.wait_for { ready? }
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
def stop
|
53
|
+
requires :id
|
54
|
+
service.stop_machine(id)
|
55
|
+
self.wait_for { stopped? }
|
56
|
+
true
|
57
|
+
end
|
58
|
+
|
59
|
+
def resize(flavor)
|
60
|
+
requires :id
|
61
|
+
service.resize_machine(id, flavor.name)
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
65
|
+
def reboot
|
66
|
+
requires :id
|
67
|
+
service.reboot_machine(id)
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
def snapshots
|
72
|
+
requires :id
|
73
|
+
service.snapshots.all(id)
|
74
|
+
end
|
75
|
+
|
76
|
+
def update_metadata(data = {})
|
77
|
+
requires :id
|
78
|
+
service.update_machine_metadata(self.id, data)
|
79
|
+
self.reload
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
def delete_metadata(keyname)
|
84
|
+
raise ArgumentError, "Must provide a key name to delete" if keyname.nil? || keyname.empty?
|
85
|
+
requires :id
|
86
|
+
|
87
|
+
service.delete_machine_metadata(self.id, keyname)
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
def delete_all_metadata
|
92
|
+
requires :id
|
93
|
+
service.delete_all_machine_metadata(self.id)
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
def list_tags
|
98
|
+
requires :id
|
99
|
+
service.list_machine_tags(id).body
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_tags(tags_hash = {})
|
103
|
+
requires :id
|
104
|
+
service.add_machine_tags(self.id, tags_hash).body
|
105
|
+
end
|
106
|
+
|
107
|
+
def delete_tag(tagname)
|
108
|
+
requires :id
|
109
|
+
|
110
|
+
raise ArgumentError, "Must provide a tag name to delete" if tagname.nil? || tagname.empty?
|
111
|
+
service.delete_machine_tag(self.id, tagname)
|
112
|
+
true
|
113
|
+
end
|
114
|
+
|
115
|
+
def delete_all_tags
|
116
|
+
requires :id
|
117
|
+
|
118
|
+
service.delete_all_machine_tags(self.id)
|
119
|
+
true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|