squall 1.3.0 → 1.3.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.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +64 -41
- data/Rakefile +3 -9
- data/lib/squall/data_store_zone.rb +20 -26
- data/lib/squall/disk.rb +174 -0
- data/lib/squall/firewall_rule.rb +34 -41
- data/lib/squall/hypervisor.rb +40 -38
- data/lib/squall/hypervisor_zone.rb +51 -63
- data/lib/squall/ip_address.rb +32 -37
- data/lib/squall/ip_address_join.rb +13 -22
- data/lib/squall/network.rb +36 -33
- data/lib/squall/network_zone.rb +27 -29
- data/lib/squall/payment.rb +22 -32
- data/lib/squall/role.rb +30 -37
- data/lib/squall/statistic.rb +3 -1
- data/lib/squall/support/base.rb +35 -31
- data/lib/squall/support/config.rb +25 -1
- data/lib/squall/support/version.rb +1 -1
- data/lib/squall/template.rb +7 -5
- data/lib/squall/transaction.rb +6 -4
- data/lib/squall/user.rb +84 -83
- data/lib/squall/user_group.rb +17 -30
- data/lib/squall/virtual_machine.rb +154 -178
- data/lib/squall/whitelist.rb +29 -40
- data/lib/squall.rb +27 -25
- data/spec/spec_helper.rb +6 -11
- data/spec/squall/data_store_zone_spec.rb +2 -20
- data/spec/squall/disk_spec.rb +189 -0
- data/spec/squall/firewall_rule_spec.rb +2 -32
- data/spec/squall/hypervisor_spec.rb +3 -47
- data/spec/squall/hypervisor_zone_spec.rb +3 -28
- data/spec/squall/ip_address_join_spec.rb +1 -15
- data/spec/squall/ip_address_spec.rb +10 -35
- data/spec/squall/network_spec.rb +20 -31
- data/spec/squall/network_zone_spec.rb +2 -36
- data/spec/squall/payment_spec.rb +2 -21
- data/spec/squall/role_spec.rb +4 -16
- data/spec/squall/support/base_spec.rb +10 -16
- data/spec/squall/template_spec.rb +0 -4
- data/spec/squall/transaction_spec.rb +1 -3
- data/spec/squall/user_group_spec.rb +1 -17
- data/spec/squall/user_spec.rb +4 -92
- data/spec/squall/virtual_machine_spec.rb +8 -242
- data/spec/squall/whitelist_spec.rb +2 -40
- data/spec/squall_spec.rb +2 -2
- data/spec/vcr_cassettes/disk/add_schedule.yml +40 -0
- data/spec/vcr_cassettes/disk/auto_backup_off.yml +40 -0
- data/spec/vcr_cassettes/disk/auto_backup_on.yml +40 -0
- data/spec/vcr_cassettes/disk/backups.yml +40 -0
- data/spec/vcr_cassettes/disk/build.yml +40 -0
- data/spec/vcr_cassettes/disk/create.yml +40 -0
- data/spec/vcr_cassettes/disk/delete.yml +38 -0
- data/spec/vcr_cassettes/disk/edit.yml +40 -0
- data/spec/vcr_cassettes/disk/iops_usage.yml +40 -0
- data/spec/vcr_cassettes/disk/list.yml +40 -0
- data/spec/vcr_cassettes/disk/migrate.yml +38 -0
- data/spec/vcr_cassettes/disk/schedules.yml +40 -0
- data/spec/vcr_cassettes/disk/unlock.yml +40 -0
- data/spec/vcr_cassettes/disk/vm_disk_list.yml +40 -0
- data/spec/vcr_cassettes/network/rebuild.yml +41 -0
- metadata +217 -66
- data/.gitignore +0 -13
- data/.rspec +0 -2
- data/.rvmrc +0 -41
- data/.travis.yml +0 -17
- data/lib/squall/support/params.rb +0 -50
- data/lib/squall/support/yaml.rb +0 -5
- data/spec/squall/support/params_spec.rb +0 -195
- data/squall.gemspec +0 -32
data/lib/squall/user.rb
CHANGED
@@ -1,183 +1,184 @@
|
|
1
1
|
module Squall
|
2
2
|
# OnApp User
|
3
3
|
class User < Base
|
4
|
-
#
|
4
|
+
# Public: Lists all users.
|
5
|
+
#
|
6
|
+
# Returns an Array.
|
5
7
|
def list
|
6
8
|
response = request(:get, '/users.json')
|
7
9
|
response.collect { |user| user['user'] }
|
8
10
|
end
|
9
11
|
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
12
|
+
# Public: Create a new User
|
13
|
+
#
|
14
|
+
# options - Params for creating the User:
|
15
|
+
# :login - Login name
|
16
|
+
# :email - Email address
|
17
|
+
# :first_name - First name
|
18
|
+
# :last_name - Last name
|
19
|
+
# :password - Password
|
20
|
+
# :passwor_confirmation - Password
|
21
|
+
# :role - Role to be assigned to user
|
22
|
+
# :time_zone - Time zone for user. If not provided it
|
23
|
+
# will be set automatically.
|
24
|
+
# :locale - Locale for user. If not provided it will
|
25
|
+
# be set automatically.
|
26
|
+
# :status - User's status: `active`, `suspended`,
|
27
|
+
# `deleted`
|
28
|
+
# :billing_plan_id - ID of billing plan to be applied to
|
29
|
+
# user's account
|
30
|
+
# :role_ids - Array of IDs of roles to be assigned to
|
31
|
+
# the user
|
32
|
+
# :suspend_after_hours - Number of hours after which the account
|
33
|
+
# will be automatically suspended
|
34
|
+
# :suspend_at - Time after which the account will
|
35
|
+
# automatically be suspended, formatted
|
36
|
+
# as +YYYYMMDD ThhmmssZ+
|
37
|
+
#
|
38
|
+
# Example
|
39
|
+
#
|
40
|
+
# create login: 'bob',
|
41
|
+
# email: 'something@example.com',
|
42
|
+
# password: 'secret',
|
43
|
+
# password_confirmation: 'secret'
|
44
|
+
# first_name: 'Bob',
|
45
|
+
# last_name: 'Smith'
|
46
|
+
#
|
47
|
+
# Returns a Hash.
|
42
48
|
def create(options = {})
|
43
|
-
params.required(:login, :email,:first_name, :last_name, :password, :password_confirmation).accepts(:role, :time_zone, :locale, :status, :billing_plan_id, :role_ids, :suspend_after_hours, :suspend_at).validate!(options)
|
44
49
|
request(:post, '/users.json', default_params(options))
|
45
50
|
end
|
46
51
|
|
47
|
-
# Edit a user
|
48
|
-
#
|
49
|
-
# ==== Params
|
52
|
+
# Public: Edit a user
|
50
53
|
#
|
51
|
-
#
|
52
|
-
#
|
54
|
+
# id - ID of user
|
55
|
+
# options - Params for creating the user, see `#create`
|
53
56
|
#
|
54
|
-
#
|
55
|
-
|
56
|
-
# See #create
|
57
|
-
def edit(id, options={})
|
58
|
-
params.accepts(:email, :password, :password_confirmation, :first_name, :last_name, :user_group_id, :billing_plan_id, :role_ids, :suspend_at).validate!(options)
|
57
|
+
# Returns a Hash.
|
58
|
+
def edit(id, options = {})
|
59
59
|
request(:put, "/users/#{id}.json", default_params(options))
|
60
60
|
end
|
61
61
|
|
62
|
-
#
|
62
|
+
# Public: Get info for a user.
|
63
63
|
#
|
64
|
-
#
|
64
|
+
# id - ID of user
|
65
65
|
#
|
66
|
-
#
|
66
|
+
# Returns a Hash.
|
67
67
|
def show(id)
|
68
68
|
response = request(:get, "/users/#{id}.json")
|
69
69
|
response["user"]
|
70
70
|
end
|
71
71
|
|
72
|
-
# Create a new API Key for a user
|
72
|
+
# Public: Create a new API Key for a user.
|
73
73
|
#
|
74
|
-
#
|
74
|
+
# id - ID of user
|
75
75
|
#
|
76
|
-
#
|
76
|
+
# Return a Hash.
|
77
77
|
def generate_api_key(id)
|
78
78
|
response = request(:post, "/users/#{id}/make_new_api_key.json")
|
79
79
|
response["user"]
|
80
80
|
end
|
81
81
|
|
82
|
-
# Suspend a user
|
82
|
+
# Public: Suspend a user.
|
83
83
|
#
|
84
|
-
#
|
84
|
+
# id - ID of user
|
85
85
|
#
|
86
|
-
#
|
86
|
+
# Return a Hash.
|
87
87
|
def suspend(id)
|
88
88
|
response = request(:get, "/users/#{id}/suspend.json")
|
89
89
|
response["user"]
|
90
90
|
end
|
91
91
|
|
92
|
-
# Activate a user
|
92
|
+
# Public: Activate a user.
|
93
93
|
#
|
94
|
-
#
|
94
|
+
# id - ID of user
|
95
95
|
#
|
96
|
-
#
|
96
|
+
# Return a Hash.
|
97
97
|
def activate(id)
|
98
98
|
response = request(:get, "/users/#{id}/activate_user.json")
|
99
99
|
response["user"]
|
100
100
|
end
|
101
101
|
alias_method :unsuspend, :activate
|
102
102
|
|
103
|
-
# Delete a user
|
103
|
+
# Public: Delete a user.
|
104
104
|
#
|
105
|
-
#
|
105
|
+
# id - ID of user
|
106
106
|
#
|
107
|
-
#
|
107
|
+
# Note: this does not delete remove a user from the database. First,
|
108
|
+
# their status will be set to "Deleted." If you call this method again,
|
109
|
+
# the user will be completely removed.
|
108
110
|
#
|
109
|
-
#
|
111
|
+
# Return a Hash.
|
110
112
|
def delete(id)
|
111
113
|
request(:delete, "/users/#{id}.json")
|
112
114
|
end
|
113
115
|
|
114
|
-
# Get the stats for each of a User's VirtualMachines
|
116
|
+
# Public: Get the stats for each of a User's VirtualMachines
|
115
117
|
#
|
116
|
-
#
|
118
|
+
# id - ID of user
|
117
119
|
#
|
118
|
-
#
|
120
|
+
# Return a Hash.
|
119
121
|
def stats(id)
|
120
122
|
request(:get, "/users/#{id}/vm_stats.json")
|
121
123
|
end
|
122
124
|
|
123
|
-
#
|
125
|
+
# Public: List a User's bills.
|
124
126
|
#
|
125
|
-
#
|
127
|
+
# id - ID of user
|
126
128
|
#
|
127
|
-
#
|
129
|
+
# Return a Hash.
|
128
130
|
def monthly_bills(id)
|
129
|
-
|
131
|
+
request(:get, "/users/#{id}/monthly_bills.json")
|
130
132
|
end
|
131
133
|
|
132
|
-
#
|
134
|
+
# Public: List User's VirtualMachines.
|
133
135
|
#
|
134
|
-
#
|
136
|
+
# id - ID of user
|
135
137
|
#
|
136
|
-
#
|
138
|
+
# Return a Hash.
|
137
139
|
def virtual_machines(id)
|
138
140
|
response = request(:get, "/users/#{id}/virtual_machines.json")
|
139
141
|
response.collect { |vm| vm['virtual_machine']}
|
140
142
|
end
|
141
143
|
|
142
|
-
#
|
144
|
+
# Public: List Hypervisors for a User's VirtualMachines.
|
143
145
|
#
|
144
|
-
#
|
146
|
+
# id - ID of user
|
145
147
|
#
|
146
|
-
#
|
148
|
+
# Return a Hash.
|
147
149
|
def hypervisors(id)
|
148
150
|
response = request(:get, "/users/#{id}/hypervisors.json")
|
149
151
|
response.collect { |vm| vm['hypervisor']}
|
150
152
|
end
|
151
153
|
|
152
|
-
#
|
154
|
+
# Public: List data store zones associated with user.
|
153
155
|
#
|
154
|
-
#
|
156
|
+
# id - ID of user
|
155
157
|
#
|
156
|
-
#
|
158
|
+
# Return a Hash.
|
157
159
|
def data_store_zones(id)
|
158
160
|
response = request(:get, "/users/#{id}/data_store_zones.json")
|
159
161
|
response.collect { |vm| vm['data-store-group']}
|
160
162
|
end
|
161
163
|
|
162
|
-
#
|
164
|
+
# Public: List network zones associated with user.
|
163
165
|
#
|
164
|
-
#
|
166
|
+
# id - ID of user
|
165
167
|
#
|
166
|
-
#
|
168
|
+
# Return a Hash.
|
167
169
|
def network_zones(id)
|
168
170
|
response = request(:get, "/users/#{id}/network_zones.json")
|
169
171
|
response.collect { |vm| vm['network_group']}
|
170
172
|
end
|
171
173
|
|
172
|
-
#
|
174
|
+
# Public: Show resources available to a user for creating a virtual machine.
|
173
175
|
#
|
174
|
-
#
|
176
|
+
# id - ID of user
|
175
177
|
#
|
176
|
-
#
|
178
|
+
# Returns a Hash.
|
177
179
|
def limits(id)
|
178
180
|
response = request(:get, "/users/#{id}/limits.json")
|
179
181
|
response["limits"]
|
180
182
|
end
|
181
|
-
|
182
183
|
end
|
183
184
|
end
|
data/lib/squall/user_group.rb
CHANGED
@@ -1,56 +1,43 @@
|
|
1
1
|
module Squall
|
2
2
|
# OnApp UserGroup
|
3
3
|
class UserGroup < Base
|
4
|
-
|
5
|
-
#
|
4
|
+
# Public: List all user groups.
|
5
|
+
#
|
6
|
+
# Returns an Array.
|
6
7
|
def list
|
7
8
|
response = request(:get, "/user_groups.json")
|
8
9
|
response.collect { |user_group| user_group['user_group'] }
|
9
10
|
end
|
10
11
|
|
11
|
-
# Create a user group
|
12
|
-
#
|
13
|
-
# ==== Params
|
14
|
-
#
|
15
|
-
# * +options+ - Params for creating the user groups
|
16
|
-
#
|
17
|
-
# ==== Options
|
12
|
+
# Public: Create a user group.
|
18
13
|
#
|
19
|
-
#
|
14
|
+
# options - Params for creating the user groups:
|
15
|
+
# :label - Label for the user group
|
20
16
|
#
|
21
|
-
#
|
17
|
+
# Example
|
22
18
|
#
|
23
|
-
#
|
24
|
-
def create(options={})
|
25
|
-
params.required(:label).validate!(options)
|
19
|
+
# create label: "My new user group"
|
20
|
+
def create(options = {})
|
26
21
|
request(:post, "/user_groups.json", default_params(options))
|
27
22
|
end
|
28
23
|
|
29
|
-
# Edit a user group
|
24
|
+
# Public: Edit a user group.
|
30
25
|
#
|
31
|
-
#
|
26
|
+
# id - ID of the user group
|
27
|
+
# options - Params for editing the user group, see `#create`
|
32
28
|
#
|
33
|
-
#
|
34
|
-
|
35
|
-
#
|
36
|
-
# ==== Options
|
37
|
-
#
|
38
|
-
# See #create
|
39
|
-
#
|
40
|
-
# * +options+ - Params for editing the user group.
|
41
|
-
def edit(id, options={})
|
42
|
-
params.accepts(:label).validate!(options)
|
29
|
+
# Returns a Hash.
|
30
|
+
def edit(id, options = {})
|
43
31
|
request(:put, "/user_groups/#{id}.json", default_params(options))
|
44
32
|
end
|
45
33
|
|
46
|
-
# Delete a user group
|
34
|
+
# Public: Delete a user group.
|
47
35
|
#
|
48
|
-
#
|
36
|
+
# id - ID of the user group
|
49
37
|
#
|
50
|
-
#
|
38
|
+
# Returns a Hash.
|
51
39
|
def delete(id)
|
52
40
|
request(:delete, "/user_groups/#{id}.json")
|
53
41
|
end
|
54
|
-
|
55
42
|
end
|
56
43
|
end
|