openstack_activeresource 0.1.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 (47) hide show
  1. data/.document +5 -0
  2. data/Gemfile +15 -0
  3. data/Gemfile.lock +49 -0
  4. data/LICENSE.txt +14 -0
  5. data/README.rdoc +427 -0
  6. data/Rakefile +44 -0
  7. data/VERSION +1 -0
  8. data/lib/hot_fixes.rb +55 -0
  9. data/lib/locales/en.yml +5 -0
  10. data/lib/open_stack/base.rb +88 -0
  11. data/lib/open_stack/common.rb +56 -0
  12. data/lib/open_stack/glance/base.rb +39 -0
  13. data/lib/open_stack/glance/image.rb +33 -0
  14. data/lib/open_stack/glance.rb +27 -0
  15. data/lib/open_stack/keystone/admin/base.rb +41 -0
  16. data/lib/open_stack/keystone/admin/role.rb +35 -0
  17. data/lib/open_stack/keystone/admin/tenant.rb +104 -0
  18. data/lib/open_stack/keystone/admin/user.rb +98 -0
  19. data/lib/open_stack/keystone/admin/user_role.rb +34 -0
  20. data/lib/open_stack/keystone/admin.rb +32 -0
  21. data/lib/open_stack/keystone/public/auth.rb +141 -0
  22. data/lib/open_stack/keystone/public/base.rb +41 -0
  23. data/lib/open_stack/keystone/public/tenant.rb +64 -0
  24. data/lib/open_stack/keystone/public.rb +31 -0
  25. data/lib/open_stack/keystone.rb +27 -0
  26. data/lib/open_stack/nova/compute/base.rb +41 -0
  27. data/lib/open_stack/nova/compute/base_detail.rb +59 -0
  28. data/lib/open_stack/nova/compute/flavor.rb +56 -0
  29. data/lib/open_stack/nova/compute/floating_ip.rb +61 -0
  30. data/lib/open_stack/nova/compute/floating_ip_pool.rb +36 -0
  31. data/lib/open_stack/nova/compute/image.rb +76 -0
  32. data/lib/open_stack/nova/compute/key_pair.rb +47 -0
  33. data/lib/open_stack/nova/compute/network.rb +45 -0
  34. data/lib/open_stack/nova/compute/security_group.rb +117 -0
  35. data/lib/open_stack/nova/compute/server.rb +313 -0
  36. data/lib/open_stack/nova/compute/simple_tenant_usage.rb +128 -0
  37. data/lib/open_stack/nova/compute/volume_attachment.rb +98 -0
  38. data/lib/open_stack/nova/compute.rb +39 -0
  39. data/lib/open_stack/nova/volume/base.rb +41 -0
  40. data/lib/open_stack/nova/volume/volume.rb +77 -0
  41. data/lib/open_stack/nova/volume.rb +29 -0
  42. data/lib/open_stack/nova.rb +27 -0
  43. data/lib/open_stack.rb +40 -0
  44. data/lib/openstack_activeresource.rb +1 -0
  45. data/test/helper.rb +18 -0
  46. data/test/test_openstack-activeresource.rb +7 -0
  47. metadata +190 -0
@@ -0,0 +1,39 @@
1
+ # This file is part of the OpenStack-ActiveResource
2
+ #
3
+ # Copyright (C) 2012 Unidata S.p.A. (Davide Guerri - d.guerri@unidata.it)
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ module OpenStack
19
+ module Nova
20
+
21
+ module Compute
22
+ extend ActiveSupport::Autoload
23
+
24
+ autoload :Base
25
+ autoload :BaseDetail
26
+ autoload :Flavor
27
+ autoload :FloatingIp
28
+ autoload :FloatingIpPool
29
+ autoload :Network
30
+ autoload :Image
31
+ autoload :KeyPair
32
+ autoload :SecurityGroup
33
+ autoload :Server
34
+ autoload :SimpleTenantUsage
35
+ autoload :VolumeAttachment
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ # This file is part of the OpenStack-ActiveResource
2
+ #
3
+ # Copyright (C) 2012 Unidata S.p.A. (Davide Guerri - d.guerri@unidata.it)
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ module OpenStack
19
+ module Nova
20
+ module Volume
21
+
22
+ class Base < OpenStack::Common
23
+
24
+ def self.site
25
+ if self == OpenStack::Nova::Volume::Base
26
+ Thread.current[:open_stack_nova_volume_site]
27
+ else
28
+ super
29
+ end
30
+ end
31
+
32
+ def self.site=(site)
33
+ super(site)
34
+ Thread.current[:open_stack_nova_volume_site] = @site
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,77 @@
1
+ # This file is part of the OpenStack-ActiveResource
2
+ #
3
+ # Copyright (C) 2012 Unidata S.p.A. (Davide Guerri - d.guerri@unidata.it)
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ module OpenStack
19
+ module Nova
20
+ module Volume
21
+
22
+ class Volume < Base
23
+ schema do
24
+ attribute :display_name, :string
25
+ attribute :display_description, :text
26
+ attribute :volume_type, :string
27
+ attribute :size, :integer
28
+ attribute :availability_zone, :string
29
+ attribute :created_at, :datetime
30
+ attribute :snapshot_id, :string
31
+ attribute :status, :string
32
+ end
33
+
34
+ alias_attribute :name, :display_name
35
+
36
+ validates :display_name, :presence => true, :format => {:with => /\A[\w\.\-]+\Z/}, :length => {:minimum => 2, :maximum => 255}
37
+ validates :size, :presence => true, :numericality => { :greater_than_or_equal_to => 1, :only_integer => true }
38
+
39
+ def initialize(attributes = {}, persisted = false)
40
+ attributes = attributes.with_indifferent_access
41
+ new_attributes = {
42
+ :id => attributes[:id],
43
+ :display_name => attributes[:display_name],
44
+ :display_description => attributes[:display_description],
45
+ :volume_type => attributes[:volume_type],
46
+ :size => attributes[:size],
47
+ :status => attributes[:status],
48
+ :snapshot_id => attributes[:snapshot_id],
49
+ :availability_zone => attributes[:availability_zone],
50
+ :attachments => attributes[:attachments] || [],
51
+ :created_at => attributes[:created].present? ? DateTime.strptime(attributes[:created], OpenStack::DATETIME_FORMAT) : nil,
52
+ }
53
+
54
+ super(new_attributes, persisted)
55
+ end
56
+
57
+
58
+ # True if the image is a snapshot
59
+ def snapshot?
60
+ persisted? and snapshot_id.present?
61
+ end
62
+
63
+ # True if the volume is attached
64
+ def attached?
65
+ !attachments.empty?
66
+ end
67
+
68
+ # Gets the first server this volume is attached to (if any)
69
+ def server
70
+ Compute::Server.find(attachments[0].server_id) if attached?
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,29 @@
1
+ # This file is part of the OpenStack-ActiveResource
2
+ #
3
+ # Copyright (C) 2012 Unidata S.p.A. (Davide Guerri - d.guerri@unidata.it)
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ module OpenStack
19
+ module Nova
20
+
21
+ module Volume
22
+ extend ActiveSupport::Autoload
23
+
24
+ autoload :Base
25
+ autoload :Volume
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ # This file is part of the OpenStack-ActiveResource
2
+ #
3
+ # Copyright (C) 2012 Unidata S.p.A. (Davide Guerri - d.guerri@unidata.it)
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ module OpenStack
19
+
20
+ module Nova
21
+ extend ActiveSupport::Autoload
22
+
23
+ autoload :Compute
24
+ autoload :Volume
25
+ end
26
+
27
+ end
data/lib/open_stack.rb ADDED
@@ -0,0 +1,40 @@
1
+ # This file is part of the OpenStack-ActiveResource
2
+ #
3
+ # Copyright (C) 2012 Unidata S.p.A. (Davide Guerri - d.guerri@unidata.it)
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ require 'bundler'
20
+
21
+ Bundler.setup
22
+ Bundler.require :default
23
+
24
+ open_stack_path = File.expand_path('..', __FILE__)
25
+ $:.unshift(open_stack_path) if File.directory?(open_stack_path) && !$:.include?(open_stack_path)
26
+
27
+ # Load locales for countries from +locale+ directory
28
+ I18n.load_path += Dir[ File.join(File.dirname(__FILE__), 'locale', '*.{rb,yml}') ]
29
+
30
+ module OpenStack
31
+ extend ActiveSupport::Autoload
32
+
33
+ load 'hot_fixes.rb'
34
+
35
+ autoload :Base
36
+ autoload :Common
37
+ autoload :Keystone
38
+ autoload :Glance
39
+ autoload :Nova
40
+ end
@@ -0,0 +1 @@
1
+ require 'open_stack'
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'openstack_activeresource'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestOpenStackActiveResource < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openstack_activeresource
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.1
6
+ platform: ruby
7
+ authors:
8
+ - Davide Guerri
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-11-29 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activemodel
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: activeresource
28
+ requirement: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: oj
39
+ requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.2.9
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: shoulda
50
+ requirement: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rdoc
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: "3.12"
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: bundler
72
+ requirement: &id006 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.0
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *id006
81
+ - !ruby/object:Gem::Dependency
82
+ name: jeweler
83
+ requirement: &id007 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 1.8.4
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *id007
92
+ - !ruby/object:Gem::Dependency
93
+ name: simplecov
94
+ requirement: &id008 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *id008
103
+ description: OpenStack Ruby and RoR bindings implemented with ActiveResource
104
+ email: d.guerri@rd.unidata.it
105
+ executables: []
106
+
107
+ extensions: []
108
+
109
+ extra_rdoc_files:
110
+ - LICENSE.txt
111
+ - README.rdoc
112
+ files:
113
+ - .document
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - LICENSE.txt
117
+ - README.rdoc
118
+ - Rakefile
119
+ - VERSION
120
+ - lib/hot_fixes.rb
121
+ - lib/locales/en.yml
122
+ - lib/open_stack.rb
123
+ - lib/open_stack/base.rb
124
+ - lib/open_stack/common.rb
125
+ - lib/open_stack/glance.rb
126
+ - lib/open_stack/glance/base.rb
127
+ - lib/open_stack/glance/image.rb
128
+ - lib/open_stack/keystone.rb
129
+ - lib/open_stack/keystone/admin.rb
130
+ - lib/open_stack/keystone/admin/base.rb
131
+ - lib/open_stack/keystone/admin/role.rb
132
+ - lib/open_stack/keystone/admin/tenant.rb
133
+ - lib/open_stack/keystone/admin/user.rb
134
+ - lib/open_stack/keystone/admin/user_role.rb
135
+ - lib/open_stack/keystone/public.rb
136
+ - lib/open_stack/keystone/public/auth.rb
137
+ - lib/open_stack/keystone/public/base.rb
138
+ - lib/open_stack/keystone/public/tenant.rb
139
+ - lib/open_stack/nova.rb
140
+ - lib/open_stack/nova/compute.rb
141
+ - lib/open_stack/nova/compute/base.rb
142
+ - lib/open_stack/nova/compute/base_detail.rb
143
+ - lib/open_stack/nova/compute/flavor.rb
144
+ - lib/open_stack/nova/compute/floating_ip.rb
145
+ - lib/open_stack/nova/compute/floating_ip_pool.rb
146
+ - lib/open_stack/nova/compute/image.rb
147
+ - lib/open_stack/nova/compute/key_pair.rb
148
+ - lib/open_stack/nova/compute/network.rb
149
+ - lib/open_stack/nova/compute/security_group.rb
150
+ - lib/open_stack/nova/compute/server.rb
151
+ - lib/open_stack/nova/compute/simple_tenant_usage.rb
152
+ - lib/open_stack/nova/compute/volume_attachment.rb
153
+ - lib/open_stack/nova/volume.rb
154
+ - lib/open_stack/nova/volume/base.rb
155
+ - lib/open_stack/nova/volume/volume.rb
156
+ - lib/openstack_activeresource.rb
157
+ - test/helper.rb
158
+ - test/test_openstack-activeresource.rb
159
+ homepage: http://github.com/dguerri/openstack_activeresource
160
+ licenses:
161
+ - GPLv3
162
+ post_install_message:
163
+ rdoc_options: []
164
+
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ hash: -3293439597705789089
173
+ segments:
174
+ - 0
175
+ version: "0"
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: "0"
182
+ requirements: []
183
+
184
+ rubyforge_project:
185
+ rubygems_version: 1.8.24
186
+ signing_key:
187
+ specification_version: 3
188
+ summary: OpenStack Ruby and RoR bindings implemented with ActiveResource
189
+ test_files: []
190
+