fog-terremark 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rubocop.yml +20 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +17 -0
  7. data/CONTRIBUTING.md +18 -0
  8. data/CONTRIBUTORS.md +10 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.md +20 -0
  11. data/README.md +36 -0
  12. data/Rakefile +11 -0
  13. data/fog-terremark.gemspec +34 -0
  14. data/gemfiles/Gemfile.1.9.2- +8 -0
  15. data/gemfiles/Gemfile.1.9.3+ +7 -0
  16. data/lib/fog/compute/terremark.rb +62 -0
  17. data/lib/fog/compute/terremark/common.rb +18 -0
  18. data/lib/fog/compute/terremark/mock.rb +144 -0
  19. data/lib/fog/compute/terremark/models/address.rb +23 -0
  20. data/lib/fog/compute/terremark/models/addresses.rb +33 -0
  21. data/lib/fog/compute/terremark/models/image.rb +17 -0
  22. data/lib/fog/compute/terremark/models/images.rb +26 -0
  23. data/lib/fog/compute/terremark/models/internetservice.rb +60 -0
  24. data/lib/fog/compute/terremark/models/internetservices.rb +24 -0
  25. data/lib/fog/compute/terremark/models/network.rb +29 -0
  26. data/lib/fog/compute/terremark/models/networks.rb +37 -0
  27. data/lib/fog/compute/terremark/models/nodeservice.rb +44 -0
  28. data/lib/fog/compute/terremark/models/nodeservices.rb +14 -0
  29. data/lib/fog/compute/terremark/models/server.rb +201 -0
  30. data/lib/fog/compute/terremark/models/servers.rb +35 -0
  31. data/lib/fog/compute/terremark/models/task.rb +44 -0
  32. data/lib/fog/compute/terremark/models/tasks.rb +41 -0
  33. data/lib/fog/compute/terremark/models/vdc.rb +39 -0
  34. data/lib/fog/compute/terremark/models/vdcs.rb +36 -0
  35. data/lib/fog/compute/terremark/parser.rb +16 -0
  36. data/lib/fog/compute/terremark/real.rb +67 -0
  37. data/lib/fog/compute/terremark/requests/add_internet_service.rb +54 -0
  38. data/lib/fog/compute/terremark/requests/add_node_service.rb +51 -0
  39. data/lib/fog/compute/terremark/requests/configure_vapp.rb +58 -0
  40. data/lib/fog/compute/terremark/requests/create_internet_service.rb +57 -0
  41. data/lib/fog/compute/terremark/requests/delete_internet_service.rb +21 -0
  42. data/lib/fog/compute/terremark/requests/delete_node_service.rb +21 -0
  43. data/lib/fog/compute/terremark/requests/delete_public_ip.rb +21 -0
  44. data/lib/fog/compute/terremark/requests/delete_vapp.rb +20 -0
  45. data/lib/fog/compute/terremark/requests/deploy_vapp.rb +33 -0
  46. data/lib/fog/compute/terremark/requests/get_catalog.rb +30 -0
  47. data/lib/fog/compute/terremark/requests/get_catalog_item.rb +33 -0
  48. data/lib/fog/compute/terremark/requests/get_internet_services.rb +32 -0
  49. data/lib/fog/compute/terremark/requests/get_keys_list.rb +32 -0
  50. data/lib/fog/compute/terremark/requests/get_network.rb +70 -0
  51. data/lib/fog/compute/terremark/requests/get_network_ips.rb +29 -0
  52. data/lib/fog/compute/terremark/requests/get_node_services.rb +29 -0
  53. data/lib/fog/compute/terremark/requests/get_organization.rb +89 -0
  54. data/lib/fog/compute/terremark/requests/get_organizations.rb +45 -0
  55. data/lib/fog/compute/terremark/requests/get_public_ip.rb +31 -0
  56. data/lib/fog/compute/terremark/requests/get_public_ips.rb +69 -0
  57. data/lib/fog/compute/terremark/requests/get_task.rb +37 -0
  58. data/lib/fog/compute/terremark/requests/get_tasks_list.rb +30 -0
  59. data/lib/fog/compute/terremark/requests/get_vapp.rb +40 -0
  60. data/lib/fog/compute/terremark/requests/get_vapp_template.rb +33 -0
  61. data/lib/fog/compute/terremark/requests/get_vdc.rb +153 -0
  62. data/lib/fog/compute/terremark/requests/instantiate_vapp_template.rb +75 -0
  63. data/lib/fog/compute/terremark/requests/power_off.rb +33 -0
  64. data/lib/fog/compute/terremark/requests/power_on.rb +33 -0
  65. data/lib/fog/compute/terremark/requests/power_reset.rb +33 -0
  66. data/lib/fog/compute/terremark/requests/power_shutdown.rb +22 -0
  67. data/lib/fog/parsers/terremark.rb +26 -0
  68. data/lib/fog/parsers/terremark/base.rb +23 -0
  69. data/lib/fog/parsers/terremark/get_catalog.rb +31 -0
  70. data/lib/fog/parsers/terremark/get_catalog_item.rb +30 -0
  71. data/lib/fog/parsers/terremark/get_internet_services.rb +55 -0
  72. data/lib/fog/parsers/terremark/get_keys_list.rb +36 -0
  73. data/lib/fog/parsers/terremark/get_network_ips.rb +22 -0
  74. data/lib/fog/parsers/terremark/get_node_services.rb +30 -0
  75. data/lib/fog/parsers/terremark/get_organization.rb +46 -0
  76. data/lib/fog/parsers/terremark/get_organizations.rb +27 -0
  77. data/lib/fog/parsers/terremark/get_public_ips.rb +24 -0
  78. data/lib/fog/parsers/terremark/get_tasks_list.rb +33 -0
  79. data/lib/fog/parsers/terremark/get_vapp_template.rb +29 -0
  80. data/lib/fog/parsers/terremark/get_vdc.rb +85 -0
  81. data/lib/fog/parsers/terremark/instantiate_vapp_template.rb +24 -0
  82. data/lib/fog/parsers/terremark/internet_service.rb +56 -0
  83. data/lib/fog/parsers/terremark/network.rb +37 -0
  84. data/lib/fog/parsers/terremark/node_service.rb +26 -0
  85. data/lib/fog/parsers/terremark/public_ip.rb +20 -0
  86. data/lib/fog/parsers/terremark/task.rb +23 -0
  87. data/lib/fog/parsers/terremark/vapp.rb +59 -0
  88. data/lib/fog/terremark.rb +17 -0
  89. data/lib/fog/terremark/vcloud.rb +27 -0
  90. data/lib/fog/terremark/vcloud/mock.rb +24 -0
  91. data/lib/fog/terremark/vcloud/real.rb +66 -0
  92. data/lib/fog/terremark/version.rb +5 -0
  93. data/spec/minitest_helper.rb +31 -0
  94. metadata +251 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f9ca0d1a12c5d7fc206448f03779d81cedf0d7c0
4
+ data.tar.gz: a95535fdb55c22fa4e638bfc752289db39e80c75
5
+ SHA512:
6
+ metadata.gz: 21e69efd8c5242e6b3ca63361a944e43cb3739349dde7c27cf18a25e66acef57466792ea536c39f8c8ae2d3df0e4ed16edad0fdec6ac027d0cc8d54c31352d53
7
+ data.tar.gz: fd48041dfde926507b7147e1ccc0d9158175a05f9d8390b4ffb94187d6efd1960c6944a5ef64f3d66bee00ccb4626f9701f3bb6661f5f39033875ea351eeb882
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ gemfiles/*.lock
@@ -0,0 +1,20 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+
4
+ Style/EachWithObject:
5
+ Enabled: false
6
+
7
+ Style/Encoding:
8
+ EnforcedStyle: when_needed
9
+
10
+ Style/FormatString:
11
+ Enabled: false
12
+
13
+ Style/HashSyntax:
14
+ EnforcedStyle: hash_rockets
15
+
16
+ Style/SignalException:
17
+ EnforcedStyle: only_raise
18
+
19
+ Style/StringLiterals:
20
+ EnforcedStyle: double_quotes
@@ -0,0 +1 @@
1
+ fog-terremark
@@ -0,0 +1 @@
1
+ 2.1.5
@@ -0,0 +1,17 @@
1
+ matrix:
2
+ include:
3
+ - rvm: 1.8.7
4
+ gemfile: gemfiles/Gemfile.1.9.2-
5
+ - rvm: 1.9.2
6
+ gemfile: gemfiles/Gemfile.1.9.2-
7
+ - rvm: 1.9.3
8
+ gemfile: gemfiles/Gemfile.1.9.3+
9
+ - rvm: 2.0.0
10
+ gemfile: gemfiles/Gemfile.1.9.3+
11
+ - rvm: 2.1.4
12
+ gemfile: gemfiles/Gemfile.1.9.3+
13
+ env: COVERAGE=true
14
+ - rvm: ree
15
+ gemfile: gemfiles/Gemfile.1.9.2-
16
+ - rvm: jruby
17
+ gemfile: gemfiles/Gemfile.1.9.3+
@@ -0,0 +1,18 @@
1
+ ## Getting Involved
2
+
3
+ New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
4
+
5
+ ### Coding
6
+
7
+ * Pick a task:
8
+ * Offer feedback on open [pull requests](https://github.com/fog/fog-terremark/pulls).
9
+ * Review open [issues](https://github.com/fog/fog-terremark/issues) for things to help on.
10
+ * [Create an issue](https://github.com/fog/fog-terremark/issues/new) to start a discussion on additions or features.
11
+ * Fork the project, add your changes and tests to cover them in a topic branch.
12
+ * Commit your changes and rebase against `fog/fog-terremark` to ensure everything is up to date.
13
+ * [Submit a pull request](https://github.com/fog/fog-terremark/compare/)
14
+
15
+ ### Non-Coding
16
+
17
+ * Offer feedback on open [issues](https://github.com/fog/fog-terremark/issues).
18
+ * Organize or volunteer at events.
@@ -0,0 +1,10 @@
1
+ * Athir Nuaimi <anuaimi@devfoundry.com>
2
+ * Chirag Jog <chirag.jog@gmail.com>
3
+ * David Calavera <david.calavera@gmail.com>
4
+ * Edward Muller <emuller@engineyard.com>
5
+ * James Herdman <james.herdman@me.com>
6
+ * Juris Galang <jurisgalang@gmail.com>
7
+ * marios <marios@redhat.com>
8
+ * Paul Thornthwaite <tokengeek@gmail.com>
9
+ * Paulo Henrique Lopes Ribeiro <plribeiro3000@gmail.com>
10
+ * Wesley Beary <geemus@gmail.com>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fog-terremark.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2014 [CONTRIBUTORS.md](https://github.com/fog/fog-terremark/blob/master/CONTRIBUTORS.md)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # Fog::Terremark
2
+
3
+ Module for the 'fog' gem to support Terremark vCloud
4
+
5
+ ## Help Needed
6
+
7
+ This gem needs a maintainer. If you want to work on it, please contact
8
+ [@geemus](mailto:geemus@gmail.com) or [@plribeiro3000](mailto:plribeiro3000@gmail.com)
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'fog-terremark'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install fog-terremark
25
+
26
+ ## Usage
27
+
28
+ TODO: Write usage instructions here
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/fog/fog-terremark/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs.push %w(spec)
6
+ t.test_files = FileList['spec/**/*_spec.rb']
7
+ t.verbose = true
8
+ end
9
+
10
+ desc 'Default Task'
11
+ task :default => :test
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fog/terremark/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fog-terremark"
8
+ spec.version = Fog::Terremark::VERSION
9
+ spec.authors = ["Paulo Henrique Lopes Ribeiro"]
10
+ spec.email = ["plribeiro3000@gmail.com"]
11
+ spec.summary = %q{Module for the 'fog' gem to support Terremark vCloud.}
12
+ spec.description = %q{This library can be used as a module for `fog` or as standalone provider
13
+ to use the Terremark vCloud in applications.}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "fog-core"
23
+ spec.add_dependency "fog-xml"
24
+
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "minitest"
27
+ spec.add_development_dependency "turn"
28
+ spec.add_development_dependency "pry"
29
+
30
+ if RUBY_VERSION.to_f > 1.9
31
+ spec.add_development_dependency "coveralls"
32
+ spec.add_development_dependency "rubocop"
33
+ end
34
+ end
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem 'mime-types', '< 2.0'
4
+ gem 'nokogiri', '< 1.6'
5
+ gem 'rest-client', '~> 1.6.8'
6
+ gem 'fog-core'
7
+
8
+ gemspec :path => '../'
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gem 'activesupport', '>= 3.0', '< 4'
4
+ gem 'mime-types', '< 2.0'
5
+ gem 'fog-core'
6
+
7
+ gemspec :path => '../'
@@ -0,0 +1,62 @@
1
+ module Fog
2
+ module Compute
3
+ class Terremark < Fog::Service
4
+ autoload :Common, 'fog/compute/terremark/common'
5
+ autoload :Parser, 'fog/compute/terremark/parser'
6
+ autoload :Real, 'fog/compute/terremark/real'
7
+ autoload :Mock, 'fog/compute/terremark/mock'
8
+
9
+ requires :terremark_vcloud_username, :terremark_vcloud_password
10
+
11
+ model_path 'fog/compute/terremark/models'
12
+ model :address
13
+ collection :addresses
14
+ model :image
15
+ collection :images
16
+ model :internetservice
17
+ collection :internetservices
18
+ model :network
19
+ collection :networks
20
+ model :nodeservice
21
+ collection :nodeservices
22
+ model :server
23
+ collection :servers
24
+ model :task
25
+ collection :tasks
26
+ model :vdc
27
+ collection :vdcs
28
+
29
+ request_path 'fog/compute/terremark/requests'
30
+ request :add_internet_service
31
+ request :add_node_service
32
+ request :configure_vapp
33
+ request :create_internet_service
34
+ request :delete_internet_service
35
+ request :delete_node_service
36
+ request :delete_public_ip
37
+ request :delete_vapp
38
+ request :deploy_vapp
39
+ request :get_catalog
40
+ request :get_catalog_item
41
+ request :get_internet_services
42
+ request :get_keys_list
43
+ request :get_network
44
+ request :get_network_ips
45
+ request :get_node_services
46
+ request :get_organization
47
+ request :get_organizations
48
+ request :get_public_ip
49
+ request :get_public_ips
50
+ request :get_task
51
+ request :get_tasks_list
52
+ request :get_vapp
53
+ request :get_vapp_template
54
+ request :get_vdc
55
+ request :instantiate_vapp_template
56
+ request :power_off
57
+ request :power_on
58
+ request :power_reset
59
+ request :power_shutdown
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Common
5
+ def default_organization_id
6
+ @default_organization_id ||= begin
7
+ org_list = get_organizations.body['OrgList']
8
+ if org_list.length == 1
9
+ org_list.first['href'].split('/').last.to_i
10
+ else
11
+ nil
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,144 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Mock
5
+ include Common
6
+
7
+ def self.mock_data
8
+ {
9
+ :organizations =>
10
+ [
11
+ {
12
+ :info => {
13
+ :name => "Boom Inc.",
14
+ :id => 1
15
+ },
16
+ :vdcs => [
17
+ { :id => 21,
18
+ :name => "Boomstick",
19
+ :storage => { :used => 105, :allocated => 200 },
20
+ :cpu => { :allocated => 10000 },
21
+ :memory => { :allocated => 20480 },
22
+ :networks => [
23
+ { :id => 31,
24
+ :name => "1.2.3.0/24",
25
+ :subnet => "1.2.3.0/24",
26
+ :gateway => "1.2.3.1",
27
+ :netmask => "255.255.255.0",
28
+ :fencemode => "isolated"
29
+ },
30
+ { :id => 32,
31
+ :name => "4.5.6.0/24",
32
+ :subnet => "4.5.6.0/24",
33
+ :gateway => "4.5.6.1",
34
+ :netmask => "255.255.255.0",
35
+ :fencemode => "isolated"
36
+ },
37
+ ],
38
+ :vms => [
39
+ { :id => 41,
40
+ :name => "Broom 1"
41
+ },
42
+ { :id => 42,
43
+ :name => "Broom 2"
44
+ },
45
+ { :id => 43,
46
+ :name => "Email!"
47
+ }
48
+ ],
49
+ :public_ips => [
50
+ { :id => 51,
51
+ :name => "99.1.2.3"
52
+ },
53
+ { :id => 52,
54
+ :name => "99.1.2.4"
55
+ },
56
+ { :id => 53,
57
+ :name => "99.1.9.7"
58
+ }
59
+ ]
60
+ },
61
+ { :id => 22,
62
+ :storage => { :used => 40, :allocated => 150 },
63
+ :cpu => { :allocated => 1000 },
64
+ :memory => { :allocated => 2048 },
65
+ :name => "Rock-n-Roll",
66
+ :networks => [
67
+ { :id => 33,
68
+ :name => "7.8.9.0/24",
69
+ :subnet => "7.8.9.0/24",
70
+ :gateway => "7.8.9.1",
71
+ :netmask => "255.255.255.0",
72
+ :fencemode => "isolated"
73
+ }
74
+ ],
75
+ :vms => [
76
+ { :id => 44,
77
+ :name => "Master Blaster"
78
+ }
79
+ ],
80
+ :public_ips => [
81
+ { :id => 54,
82
+ :name => "99.99.99.99"
83
+ }
84
+ ]
85
+ }
86
+ ]
87
+ }
88
+ ]
89
+ }
90
+ end
91
+
92
+ def self.error_headers
93
+ {
94
+ "X-Powered-By" => "ASP.NET",
95
+ "Date" => Time.now.to_s,
96
+ "Content-Type" => "text/html",
97
+ "Content-Length" => "0",
98
+ "Server" => "Microsoft-IIS/7.0",
99
+ "Cache-Control" => "private"
100
+ }
101
+ end
102
+
103
+ def self.unathorized_status
104
+ 401
105
+ end
106
+
107
+ def self.headers(body, content_type)
108
+ {
109
+ "X-Powered-By" => "ASP.NET",
110
+ "Date" => Time.now.to_s,
111
+ "Content-Type" => content_type,
112
+ "Content-Length" => body.to_s.length,
113
+ "Server" => "Microsoft-IIS/7.0",
114
+ "Set-Cookie" => "vcloud-token=ecb37bfc-56f0-421d-97e5-bf2gdf789457; path=/",
115
+ "Cache-Control" => "private"
116
+ }
117
+ end
118
+
119
+ def self.status
120
+ 200
121
+ end
122
+
123
+ def initialize(_options={})
124
+ self.class.instance_eval '
125
+ def self.data
126
+ @data ||= Hash.new do |hash, key|
127
+ hash[key] = Fog::Compute::Terremark::Mock.mock_data
128
+ end
129
+ end'
130
+ self.class.instance_eval '
131
+ def self.reset
132
+ @data = nil
133
+ end
134
+
135
+ def self.reset_data(keys=data.keys)
136
+ for key in [*keys]
137
+ data.delete(key)
138
+ end
139
+ end'
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end