fog-joyent 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rubocop.yml +20 -0
  4. data/.rubocop_todo.yml +436 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +26 -0
  8. data/CONTRIBUTING.md +18 -0
  9. data/CONTRIBUTORS.md +17 -0
  10. data/Gemfile +4 -0
  11. data/LICENSE.md +10 -0
  12. data/README.md +29 -0
  13. data/Rakefile +12 -0
  14. data/fog-joyent.gemspec +29 -0
  15. data/lib/fog/bin/joyent.rb +33 -0
  16. data/lib/fog/joyent.rb +16 -0
  17. data/lib/fog/joyent/analytics.rb +310 -0
  18. data/lib/fog/joyent/compute.rb +272 -0
  19. data/lib/fog/joyent/core.rb +10 -0
  20. data/lib/fog/joyent/errors.rb +91 -0
  21. data/lib/fog/joyent/models/analytics/field.rb +13 -0
  22. data/lib/fog/joyent/models/analytics/fields.rb +24 -0
  23. data/lib/fog/joyent/models/analytics/instrumentation.rb +82 -0
  24. data/lib/fog/joyent/models/analytics/instrumentations.rb +23 -0
  25. data/lib/fog/joyent/models/analytics/joyent_module.rb +13 -0
  26. data/lib/fog/joyent/models/analytics/joyent_modules.rb +24 -0
  27. data/lib/fog/joyent/models/analytics/metric.rb +17 -0
  28. data/lib/fog/joyent/models/analytics/metrics.rb +16 -0
  29. data/lib/fog/joyent/models/analytics/transformation.rb +13 -0
  30. data/lib/fog/joyent/models/analytics/transformations.rb +24 -0
  31. data/lib/fog/joyent/models/analytics/type.rb +16 -0
  32. data/lib/fog/joyent/models/analytics/types.rb +24 -0
  33. data/lib/fog/joyent/models/analytics/value.rb +20 -0
  34. data/lib/fog/joyent/models/compute/datacenter.rb +11 -0
  35. data/lib/fog/joyent/models/compute/datacenters.rb +21 -0
  36. data/lib/fog/joyent/models/compute/flavor.rb +19 -0
  37. data/lib/fog/joyent/models/compute/flavors.rb +21 -0
  38. data/lib/fog/joyent/models/compute/image.rb +26 -0
  39. data/lib/fog/joyent/models/compute/images.rb +30 -0
  40. data/lib/fog/joyent/models/compute/key.rb +19 -0
  41. data/lib/fog/joyent/models/compute/keys.rb +32 -0
  42. data/lib/fog/joyent/models/compute/network.rb +12 -0
  43. data/lib/fog/joyent/models/compute/networks.rb +14 -0
  44. data/lib/fog/joyent/models/compute/server.rb +124 -0
  45. data/lib/fog/joyent/models/compute/servers.rb +35 -0
  46. data/lib/fog/joyent/models/compute/snapshot.rb +44 -0
  47. data/lib/fog/joyent/models/compute/snapshots.rb +35 -0
  48. data/lib/fog/joyent/requests/analytics/create_instrumentation.rb +25 -0
  49. data/lib/fog/joyent/requests/analytics/delete_instrumentation.rb +23 -0
  50. data/lib/fog/joyent/requests/analytics/describe_analytics.rb +26 -0
  51. data/lib/fog/joyent/requests/analytics/get_instrumentation.rb +26 -0
  52. data/lib/fog/joyent/requests/analytics/get_instrumentation_value.rb +30 -0
  53. data/lib/fog/joyent/requests/analytics/list_instrumentations.rb +25 -0
  54. data/lib/fog/joyent/requests/compute/add_machine_tags.rb +19 -0
  55. data/lib/fog/joyent/requests/compute/create_key.rb +54 -0
  56. data/lib/fog/joyent/requests/compute/create_machine.rb +16 -0
  57. data/lib/fog/joyent/requests/compute/create_machine_snapshot.rb +16 -0
  58. data/lib/fog/joyent/requests/compute/delete_all_machine_metadata.rb +16 -0
  59. data/lib/fog/joyent/requests/compute/delete_all_machine_tags.rb +15 -0
  60. data/lib/fog/joyent/requests/compute/delete_key.rb +27 -0
  61. data/lib/fog/joyent/requests/compute/delete_machine.rb +15 -0
  62. data/lib/fog/joyent/requests/compute/delete_machine_metadata.rb +16 -0
  63. data/lib/fog/joyent/requests/compute/delete_machine_snapshot.rb +18 -0
  64. data/lib/fog/joyent/requests/compute/delete_machine_tag.rb +15 -0
  65. data/lib/fog/joyent/requests/compute/get_dataset.rb +27 -0
  66. data/lib/fog/joyent/requests/compute/get_image.rb +28 -0
  67. data/lib/fog/joyent/requests/compute/get_key.rb +29 -0
  68. data/lib/fog/joyent/requests/compute/get_machine.rb +29 -0
  69. data/lib/fog/joyent/requests/compute/get_machine_metadata.rb +24 -0
  70. data/lib/fog/joyent/requests/compute/get_machine_snapshot.rb +15 -0
  71. data/lib/fog/joyent/requests/compute/get_machine_tag.rb +18 -0
  72. data/lib/fog/joyent/requests/compute/get_package.rb +32 -0
  73. data/lib/fog/joyent/requests/compute/list_datacenters.rb +16 -0
  74. data/lib/fog/joyent/requests/compute/list_datasets.rb +24 -0
  75. data/lib/fog/joyent/requests/compute/list_images.rb +25 -0
  76. data/lib/fog/joyent/requests/compute/list_keys.rb +25 -0
  77. data/lib/fog/joyent/requests/compute/list_machine_snapshots.rb +15 -0
  78. data/lib/fog/joyent/requests/compute/list_machine_tags.rb +20 -0
  79. data/lib/fog/joyent/requests/compute/list_machines.rb +26 -0
  80. data/lib/fog/joyent/requests/compute/list_networks.rb +26 -0
  81. data/lib/fog/joyent/requests/compute/list_packages.rb +34 -0
  82. data/lib/fog/joyent/requests/compute/reboot_machine.rb +15 -0
  83. data/lib/fog/joyent/requests/compute/resize_machine.rb +16 -0
  84. data/lib/fog/joyent/requests/compute/start_machine.rb +16 -0
  85. data/lib/fog/joyent/requests/compute/start_machine_from_snapshot.rb +15 -0
  86. data/lib/fog/joyent/requests/compute/stop_machine.rb +16 -0
  87. data/lib/fog/joyent/requests/compute/update_machine_metadata.rb +15 -0
  88. data/lib/fog/joyent/version.rb +5 -0
  89. data/tests/helper.rb +18 -0
  90. data/tests/helpers/mock_helper.rb +16 -0
  91. data/tests/helpers/succeeds_helper.rb +9 -0
  92. data/tests/joyent/models/analytics/field_tests.rb +10 -0
  93. data/tests/joyent/models/analytics/fields_tests.rb +13 -0
  94. data/tests/joyent/models/analytics/instrumentation_tests.rb +13 -0
  95. data/tests/joyent/models/analytics/instrumentations_tests.rb +3 -0
  96. data/tests/joyent/models/analytics/joyent_module_tests.rb +10 -0
  97. data/tests/joyent/models/analytics/joyent_modules_tests.rb +13 -0
  98. data/tests/joyent/models/analytics/metric_tests.rb +10 -0
  99. data/tests/joyent/models/analytics/metrics_tests.rb +20 -0
  100. data/tests/joyent/models/analytics/transformation_tests.rb +10 -0
  101. data/tests/joyent/models/analytics/transformations_tests.rb +13 -0
  102. data/tests/joyent/models/analytics/type_tests.rb +10 -0
  103. data/tests/joyent/models/analytics/types_tests.rb +13 -0
  104. data/tests/joyent/requests/analytics/instrumentation_tests.rb +44 -0
  105. data/tests/joyent/requests/compute/datasets_tests.rb +58 -0
  106. data/tests/joyent/requests/compute/keys_tests.rb +47 -0
  107. data/tests/joyent/requests/compute/machines_tests.rb +66 -0
  108. data/tests/joyent/requests/compute/networks_tests.rb +39 -0
  109. data/tests/joyent/requests/compute/packages_tests.rb +68 -0
  110. 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,13 @@
1
+ require 'fog/core/model'
2
+
3
+ # named 'JoyentModule' to avoid name conflicts with ruby's 'Module'
4
+ module Fog
5
+ module Joyent
6
+ class Analytics
7
+ class JoyentModule < Fog::Model
8
+ attribute :name
9
+ attribute :label
10
+ end
11
+ end
12
+ end
13
+ 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,13 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Joyent
5
+ class Analytics
6
+ class Transformation < Fog::Model
7
+ attribute :name
8
+ attribute :label
9
+ attribute :fields
10
+ end
11
+ end
12
+ end
13
+ 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,16 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Joyent
5
+ class Analytics
6
+ class Type < Fog::Model
7
+ attribute :name
8
+ attribute :arity
9
+ attribute :unit
10
+ attribute :abbr
11
+ attribute :base
12
+ attribute :power
13
+ end
14
+ end
15
+ end
16
+ 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,11 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Datacenter < Fog::Model
5
+ identity :name
6
+
7
+ attribute :url
8
+ end
9
+ end
10
+ end
11
+ 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,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Network < Fog::Model
5
+ identity :id
6
+
7
+ attribute :name
8
+ attribute :public
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ require 'fog/joyent/models/compute/network'
2
+ module Fog
3
+ module Compute
4
+ class Joyent
5
+ class Networks < Fog::Collection
6
+ model Fog::Compute::Joyent::Network
7
+
8
+ def all
9
+ load(service.list_networks.body)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ 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