openstack_activeresource 0.2.1 → 0.3.0
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.
- data/VERSION +1 -1
- data/lib/hot_fixes.rb +4 -1
- data/lib/open_stack/base.rb +5 -0
- data/lib/open_stack/keystone/admin/role.rb +10 -3
- data/lib/open_stack/keystone/admin/tenant.rb +44 -13
- data/lib/open_stack/keystone/admin/user.rb +33 -6
- data/lib/open_stack/keystone/admin/user_role.rb +15 -0
- data/lib/open_stack/keystone/public/auth.rb +22 -7
- data/lib/open_stack/keystone/public/base.rb +2 -0
- data/lib/open_stack/keystone/public/tenant.rb +17 -3
- data/lib/open_stack/nova/compute/base.rb +2 -0
- data/lib/open_stack/nova/compute/base_detail.rb +1 -1
- data/lib/open_stack/nova/compute/flavor.rb +35 -7
- data/lib/open_stack/nova/compute/floating_ip.rb +28 -9
- data/lib/open_stack/nova/compute/floating_ip_pool.rb +5 -0
- data/lib/open_stack/nova/compute/image.rb +34 -4
- data/lib/open_stack/nova/compute/key_pair.rb +17 -4
- data/lib/open_stack/nova/compute/network.rb +10 -0
- data/lib/open_stack/nova/compute/security_group.rb +31 -6
- data/lib/open_stack/nova/compute/server.rb +118 -43
- data/lib/open_stack/nova/compute/simple_tenant_usage.rb +49 -13
- data/lib/open_stack/nova/compute/volume_attachment.rb +20 -6
- data/lib/open_stack/nova/volume/volume.rb +14 -5
- data/openstack_activeresource.gemspec +2 -2
- data/test/test_openstack-activeresource.rb +3 -5
- metadata +3 -3
|
@@ -19,6 +19,13 @@ module OpenStack
|
|
|
19
19
|
module Nova
|
|
20
20
|
module Compute
|
|
21
21
|
|
|
22
|
+
# Server usages for a tenant
|
|
23
|
+
#
|
|
24
|
+
# ==== Attributes
|
|
25
|
+
# * +total_hours+ - Amount of hour the SimpleTenantUsage instance is related to
|
|
26
|
+
# * +total_vcpus_usage+ - Aggregated virtual cpu usage
|
|
27
|
+
# * +total_memory_mb_usage+ - Aggregated memory usage (MBytes)
|
|
28
|
+
# * +total_local_gb_usage+ - Aggregated storage usage (GBytes)
|
|
22
29
|
class SimpleTenantUsage < Base
|
|
23
30
|
self.element_name = "os-simple-tenant-usage"
|
|
24
31
|
self.collection_name = "os-simple-tenant-usage"
|
|
@@ -32,7 +39,8 @@ module OpenStack
|
|
|
32
39
|
attribute :start, :datetime
|
|
33
40
|
end
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
# Redefine the find method to add the detailed flag
|
|
43
|
+
def self.find(*arguments) #:nodoc:
|
|
36
44
|
scope = arguments.slice!(0)
|
|
37
45
|
options = arguments.slice!(0) || {}
|
|
38
46
|
|
|
@@ -64,18 +72,11 @@ module OpenStack
|
|
|
64
72
|
end
|
|
65
73
|
end
|
|
66
74
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
DateTime.parse(@attributes[:start] + ' UTC')
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def stop
|
|
76
|
-
DateTime.parse(@attributes[:stop] + ' UTC')
|
|
77
|
-
end
|
|
78
|
-
|
|
75
|
+
# Find all server usage from a given date to the current one
|
|
76
|
+
#
|
|
77
|
+
# ==== Attributes
|
|
78
|
+
# * +scope+ - ActiveResource scope (:all, :first, :last, :one or an id)
|
|
79
|
+
# * +from_date+ - Initial date
|
|
79
80
|
def self.find_from_date(scope, from_date)
|
|
80
81
|
now = Time.now.utc
|
|
81
82
|
|
|
@@ -86,6 +87,12 @@ module OpenStack
|
|
|
86
87
|
|
|
87
88
|
end
|
|
88
89
|
|
|
90
|
+
# Find all server usage between the given dates
|
|
91
|
+
#
|
|
92
|
+
# ==== Attributes
|
|
93
|
+
# * +scope+ - ActiveResource scope (:all, :first, :last, :one or an id)
|
|
94
|
+
# * +from_date+ - Initial date
|
|
95
|
+
# * +to_date+ - Final date
|
|
89
96
|
def self.find_between_dates(scope, from_date, to_date)
|
|
90
97
|
find(scope, :params => {
|
|
91
98
|
:start => from_date.utc.strftime(OpenStack::DATETIME_FORMAT),
|
|
@@ -94,8 +101,35 @@ module OpenStack
|
|
|
94
101
|
|
|
95
102
|
end
|
|
96
103
|
|
|
104
|
+
# OpenStack::Nova::Compute::ServerUsage instances
|
|
105
|
+
def server_usages
|
|
106
|
+
@attributes[:server_usages].present? ? @attributes[:server_usages] : []
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# The start date for the ServerUsage set
|
|
110
|
+
def start
|
|
111
|
+
DateTime.parse(@attributes[:start] + ' UTC')
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# The stop date for the ServerUsage set
|
|
115
|
+
def stop
|
|
116
|
+
DateTime.parse(@attributes[:stop] + ' UTC')
|
|
117
|
+
end
|
|
118
|
+
|
|
97
119
|
end
|
|
98
120
|
|
|
121
|
+
# A server usage entry
|
|
122
|
+
#
|
|
123
|
+
# ==== Attributes
|
|
124
|
+
# * +name+ - The name of the server this entry is related
|
|
125
|
+
# * +vcpus+ - Virtual CPU used by the server in the timespan (+started_at+ - +ended_at+ or +uptime+) for this entry
|
|
126
|
+
# * +memory_mb+ - Memory (MBytes) used by the server in the timespan (+started_at+ - +ended_at+ or +uptime+) for this entry
|
|
127
|
+
# * +local_gb+ - The amount of storage used over the uptime ()GBytes)
|
|
128
|
+
# * +flavor+ - The flavor id used by the server in this server usage entry
|
|
129
|
+
# * +state+ - Current state for the server in this server usage entry
|
|
130
|
+
# * +uptime+ - The uptime of this server in seconds
|
|
131
|
+
# * +hours+ - The uptime of this server in hours
|
|
132
|
+
# * +tenant_id+ - The tenant id for this server usage entry
|
|
99
133
|
class ServerUsage < Base
|
|
100
134
|
|
|
101
135
|
schema do
|
|
@@ -112,10 +146,12 @@ module OpenStack
|
|
|
112
146
|
attribute :ended_at, :datetime
|
|
113
147
|
end
|
|
114
148
|
|
|
149
|
+
# The initial date for this server usage entry
|
|
115
150
|
def started_at
|
|
116
151
|
DateTime.parse(@attributes[:started_at] + ' UTC')
|
|
117
152
|
end
|
|
118
153
|
|
|
154
|
+
# The final date for this server usage entry (can be nil if the server is still alive)
|
|
119
155
|
def ended_at
|
|
120
156
|
return nil if @attributes[:ended_at].blank?
|
|
121
157
|
DateTime.parse(@attributes[:ended_at] + ' UTC')
|
|
@@ -19,6 +19,10 @@ module OpenStack
|
|
|
19
19
|
module Nova
|
|
20
20
|
module Compute
|
|
21
21
|
|
|
22
|
+
# A Volume attachment (this class describes an attachment of a volume to a server)
|
|
23
|
+
#
|
|
24
|
+
# ==== Attributes
|
|
25
|
+
# * +device+ - The volume (unique) name (e.g. /dev/vdc)
|
|
22
26
|
class VolumeAttachment < Base
|
|
23
27
|
self.element_name = "volumeAttachment"
|
|
24
28
|
self.collection_name = "os-volume_attachments"
|
|
@@ -34,7 +38,7 @@ module OpenStack
|
|
|
34
38
|
validates :volume, :presence => true
|
|
35
39
|
validates :server, :presence => true
|
|
36
40
|
|
|
37
|
-
def initialize(attributes = {}, persisted = false)
|
|
41
|
+
def initialize(attributes = {}, persisted = false) #:notnew:
|
|
38
42
|
attributes = attributes.with_indifferent_access
|
|
39
43
|
new_attributes = {
|
|
40
44
|
:device => attributes[:device],
|
|
@@ -59,9 +63,9 @@ module OpenStack
|
|
|
59
63
|
new_attachment
|
|
60
64
|
end
|
|
61
65
|
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
# Overloads ActiveRecord::encode method
|
|
67
|
+
def encode(options={}) #:nodoc:
|
|
68
|
+
# Custom encoding to deal with openstack API
|
|
65
69
|
to_encode = {
|
|
66
70
|
VolumeAttachment.element_name => {
|
|
67
71
|
:device => device,
|
|
@@ -72,20 +76,30 @@ module OpenStack
|
|
|
72
76
|
to_encode.send("to_#{self.class.format.extension}", options)
|
|
73
77
|
end
|
|
74
78
|
|
|
79
|
+
# Return the server to which this volume_attachment is related (if any)
|
|
75
80
|
def server
|
|
76
81
|
Server.find(server_id) if server_id.present?
|
|
77
82
|
end
|
|
78
83
|
|
|
84
|
+
# Bind the volume_attachment to a sever
|
|
85
|
+
#
|
|
86
|
+
# ==== Attributes
|
|
87
|
+
# * +server+ - an OpenStack::Nova::Compute::Server instance
|
|
79
88
|
def server=(server)
|
|
80
|
-
@attributes[:server_id] = server.id
|
|
89
|
+
@attributes[:server_id] = server.id if !persisted?
|
|
81
90
|
end
|
|
82
91
|
|
|
92
|
+
# Return the volume to which this volume_attachment is related (if any)
|
|
83
93
|
def volume
|
|
84
94
|
Volume::Volume.find(volume_id) if volume_id.present?
|
|
85
95
|
end
|
|
86
96
|
|
|
97
|
+
# Bind the volume_attachment to a volume
|
|
98
|
+
#
|
|
99
|
+
# ==== Attributes
|
|
100
|
+
# * +volume+ - an OpenStack::Nova::Compute::Volume instance
|
|
87
101
|
def volume=(volume)
|
|
88
|
-
@attributes[:volume_id] = volume.id
|
|
102
|
+
@attributes[:volume_id] = volume.id if !persisted?
|
|
89
103
|
end
|
|
90
104
|
|
|
91
105
|
end
|
|
@@ -19,6 +19,17 @@ module OpenStack
|
|
|
19
19
|
module Nova
|
|
20
20
|
module Volume
|
|
21
21
|
|
|
22
|
+
# An OpenStack Volume
|
|
23
|
+
#
|
|
24
|
+
# ==== Attributes
|
|
25
|
+
# * +display_name+ - Volume name
|
|
26
|
+
# * +display_description+ - Volume description
|
|
27
|
+
# * +volume_type+ - Volume type identifier
|
|
28
|
+
# * +size+ - Volume size (GBytes)
|
|
29
|
+
# * +availability_zone+ - The availability zone for the volume
|
|
30
|
+
# * +created_at+ - Creation date for the volume
|
|
31
|
+
# * +snapshot_id+ - The snapshot id for the volume (not nil if this volume is a snapshot)
|
|
32
|
+
# * +status+ - If the volume is a snapshot, this is the status of the snapshot (i.e. available)
|
|
22
33
|
class Volume < Base
|
|
23
34
|
schema do
|
|
24
35
|
attribute :display_name, :string
|
|
@@ -28,15 +39,14 @@ module OpenStack
|
|
|
28
39
|
attribute :availability_zone, :string
|
|
29
40
|
attribute :created_at, :datetime
|
|
30
41
|
attribute :snapshot_id, :string
|
|
31
|
-
attribute :status, :string
|
|
32
42
|
end
|
|
33
43
|
|
|
34
44
|
alias_attribute :name, :display_name
|
|
35
45
|
|
|
36
46
|
validates :display_name, :presence => true, :format => {:with => /\A[\w\.\-]+\Z/}, :length => {:minimum => 2, :maximum => 255}
|
|
37
|
-
validates :size, :presence => true, :numericality => {
|
|
47
|
+
validates :size, :presence => true, :numericality => {:greater_than_or_equal_to => 1, :only_integer => true}
|
|
38
48
|
|
|
39
|
-
def initialize(attributes = {}, persisted = false)
|
|
49
|
+
def initialize(attributes = {}, persisted = false) #:notnew:
|
|
40
50
|
attributes = attributes.with_indifferent_access
|
|
41
51
|
new_attributes = {
|
|
42
52
|
:id => attributes[:id],
|
|
@@ -54,7 +64,6 @@ module OpenStack
|
|
|
54
64
|
super(new_attributes, persisted)
|
|
55
65
|
end
|
|
56
66
|
|
|
57
|
-
|
|
58
67
|
# True if the image is a snapshot
|
|
59
68
|
def snapshot?
|
|
60
69
|
persisted? and snapshot_id.present?
|
|
@@ -65,7 +74,7 @@ module OpenStack
|
|
|
65
74
|
!attachments.empty?
|
|
66
75
|
end
|
|
67
76
|
|
|
68
|
-
#
|
|
77
|
+
# The first server to which this volume is attached to (if any)
|
|
69
78
|
def server
|
|
70
79
|
Compute::Server.find(attachments[0].server_id) if attached?
|
|
71
80
|
end
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "openstack_activeresource"
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.3.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Davide Guerri"]
|
|
12
|
-
s.date = "2013-02-
|
|
12
|
+
s.date = "2013-02-07"
|
|
13
13
|
s.description = "OpenStack Ruby and RoR bindings implemented with ActiveResource - See also http://www.unicloud.it"
|
|
14
14
|
s.email = "d.guerri@rd.unidata.it"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -223,13 +223,11 @@ class TestOpenStackActiveResource < Test::Unit::TestCase
|
|
|
223
223
|
assert_not_nil my_server, "Server not spawned after 5 seconds!?!"
|
|
224
224
|
|
|
225
225
|
# Wait for a network address
|
|
226
|
-
|
|
226
|
+
my_address = loop_block(60) do
|
|
227
227
|
my_server = OpenStack::Nova::Compute::Server.find new_server_id
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
nil
|
|
228
|
+
my_server.addresses.keys.count > 0 ? my_server.addresses : nil
|
|
231
229
|
end
|
|
232
|
-
assert_not_nil
|
|
230
|
+
assert_not_nil my_address, "No address after a minute!"
|
|
233
231
|
|
|
234
232
|
assert_nothing_raised ActiveResource::ClientError, "Problem retrieving the server '#{new_server_id}'" do
|
|
235
233
|
my_server = OpenStack::Nova::Compute::Server.find new_server_id
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openstack_activeresource
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-02-
|
|
12
|
+
date: 2013-02-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activemodel
|
|
@@ -212,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
212
212
|
version: '0'
|
|
213
213
|
segments:
|
|
214
214
|
- 0
|
|
215
|
-
hash:
|
|
215
|
+
hash: 952086221477201945
|
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
none: false
|
|
218
218
|
requirements:
|