squall 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e4e877b7b98d79a741107b805282e235e4f18a7b
|
4
|
+
data.tar.gz: 0d74e4d6ab3b2765e7c60f488e353f97b575965c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ae37aad74e9d15a958c9bd1524c8c72a63fd0971bd16bebea5c62ed1fbcef551be04d58153329f6df2eff4de67ca27806816a570adae97b07559a269668fa21
|
7
|
+
data.tar.gz: 29ddbec2e6e0de8af682dc088fad4df8fb07c0b92e946b154b526e4cdbdcd43876b62421d0eb9adc82e003ea8cb25c107063c2bb1d8355517a9e314e8694e398
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -3,21 +3,31 @@ Squall [![Squall Build Status][Build Icon]][Build Status]
|
|
3
3
|
|
4
4
|
A Ruby library for working with the [OnApp REST API][].
|
5
5
|
|
6
|
-
Squall has been tested on MRI
|
7
|
-
|
6
|
+
Squall has been tested on MRI versions 1.9.2, 1.9.3, 2.0.0 and 1.9-compatible
|
7
|
+
JRuby.
|
8
8
|
|
9
|
-
Documentation is available in [
|
9
|
+
Documentation is available in [TomDoc][] format.
|
10
10
|
|
11
11
|
[Build Status]: http://travis-ci.org/site5/squall
|
12
12
|
[Build Icon]: https://secure.travis-ci.org/site5/squall.png?branch=master
|
13
|
-
[OnApp REST API]:
|
14
|
-
[
|
13
|
+
[OnApp REST API]: http://onapp.com/cloud/technology/api/
|
14
|
+
[TomDoc]: http://site5.github.io/squall/
|
15
15
|
|
16
16
|
Install
|
17
17
|
-------
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
To install Squall using [Bundler](http://bundler.io):
|
20
|
+
|
21
|
+
```
|
22
|
+
echo "gem 'squall'" >> Gemfile
|
23
|
+
bundle install
|
24
|
+
```
|
25
|
+
|
26
|
+
To install Squall globally using RubyGems:
|
27
|
+
|
28
|
+
```
|
29
|
+
gem install squall
|
30
|
+
```
|
21
31
|
|
22
32
|
Configuration
|
23
33
|
-------------
|
@@ -26,30 +36,38 @@ You have two main options for configuring Squall.
|
|
26
36
|
|
27
37
|
Directly in a config block:
|
28
38
|
|
29
|
-
|
39
|
+
```ruby
|
40
|
+
require 'squall'
|
30
41
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
Squall.config do |c|
|
43
|
+
c.base_uri 'https://onappurl.com' # Root level URI for OnApp instance
|
44
|
+
c.username 'username' # OnApp username
|
45
|
+
c.password 'topsecret' # OnApp password
|
46
|
+
c.debug true # Toggle HTTP/Faraday debugging (prints to $stderr)
|
47
|
+
end
|
48
|
+
```
|
37
49
|
|
38
50
|
Squall can load configuration from a yaml file:
|
39
51
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
52
|
+
```yaml
|
53
|
+
# .squall.yml
|
54
|
+
base_uri: 'https://onappurl.com'
|
55
|
+
username: 'username'
|
56
|
+
password: 'topsecret'
|
57
|
+
debug: false
|
58
|
+
```
|
45
59
|
|
46
60
|
To load it (by default it assumes ~/.squall.yml):
|
47
61
|
|
48
|
-
|
62
|
+
```ruby
|
63
|
+
Squall.config_file("/path/to/.squall.yml")
|
64
|
+
```
|
49
65
|
|
50
66
|
It is also possible to change individual configuration settings on the fly.
|
51
67
|
|
52
|
-
|
68
|
+
```ruby
|
69
|
+
Squall.configuration.debug(true)
|
70
|
+
```
|
53
71
|
|
54
72
|
Note: you will need to re-instantiate all modules after changing Squall's configuration.
|
55
73
|
|
@@ -58,25 +76,29 @@ Usage
|
|
58
76
|
|
59
77
|
Show the info for a VM:
|
60
78
|
|
61
|
-
|
62
|
-
|
79
|
+
```ruby
|
80
|
+
vm = Squall::VirtualMachine.new
|
81
|
+
vm.show 1
|
82
|
+
```
|
63
83
|
|
64
84
|
Create a new VM:
|
65
85
|
|
66
|
-
|
86
|
+
```ruby
|
87
|
+
vm = Squall::VirtualMachine.new
|
67
88
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
89
|
+
params = {
|
90
|
+
label: 'testmachine',
|
91
|
+
hypervisor_id: 5,
|
92
|
+
hostname: 'testmachine',
|
93
|
+
memory: 512,
|
94
|
+
cpus: 1,
|
95
|
+
cpu_shares: 10,
|
96
|
+
primary_disk_size: 10,
|
97
|
+
template_id: 1
|
98
|
+
}
|
78
99
|
|
79
|
-
|
100
|
+
vm.create params
|
101
|
+
```
|
80
102
|
|
81
103
|
Supported Methods
|
82
104
|
-----------------
|
@@ -101,13 +123,13 @@ The following OnApp modules have been added:
|
|
101
123
|
* Transactions
|
102
124
|
* Virtual machines
|
103
125
|
* Whitelists
|
126
|
+
* Disks
|
104
127
|
|
105
128
|
The following still need to be added:
|
106
129
|
|
107
130
|
* Billing plans
|
108
131
|
* Currencies
|
109
132
|
* Network interfaces
|
110
|
-
* Disks
|
111
133
|
* Template groups
|
112
134
|
* Software licenses
|
113
135
|
* Resolvers
|
@@ -129,8 +151,10 @@ Tests
|
|
129
151
|
|
130
152
|
Squall uses rspec for tests. To run:
|
131
153
|
|
132
|
-
|
133
|
-
|
154
|
+
```
|
155
|
+
bundle exec rake # Runs all tests
|
156
|
+
bundle exec rspec spec/squall/[module]_spec.rb # Runs tests for a specific module
|
157
|
+
```
|
134
158
|
|
135
159
|
Squall uses [VCR](https://github.com/myronmarston/vcr) to cache server
|
136
160
|
responses to test against. To test via live http connections, pass RERECORD=1
|
@@ -142,8 +166,7 @@ Known issues:
|
|
142
166
|
|
143
167
|
1. VirtualMachine#change_user currently breaks the parser on an invalid
|
144
168
|
user_id because OnApp returns html instead of JSON
|
145
|
-
2. VirtualMachine#create is currently broken in certain cases.
|
146
|
-
<https://help.onapp.com/kb_article.php?s=0b397f5b851334cea54da9ddd829bf5f&ref=8181-TYFH-8069>
|
169
|
+
2. VirtualMachine#create is currently broken in certain cases.
|
147
170
|
3. FirewallRule#edit and #create break the parser by returning invalid JSON
|
148
171
|
|
149
172
|
Note on Patches/Pull Requests
|
@@ -161,4 +184,4 @@ Note on Patches/Pull Requests
|
|
161
184
|
Copyright
|
162
185
|
---------
|
163
186
|
|
164
|
-
Copyright (c)
|
187
|
+
Copyright (c) 2010-2014 Site5.com. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,18 +1,12 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require 'uri'
|
3
1
|
begin
|
2
|
+
require 'bundler/gem_tasks'
|
4
3
|
require 'rspec/core/rake_task'
|
4
|
+
require 'rake-tomdoc' unless RUBY_PLATFORM == 'java'
|
5
5
|
rescue LoadError
|
6
|
-
|
7
|
-
exit
|
6
|
+
abort "Please run `bundle install` first"
|
8
7
|
end
|
9
8
|
|
10
9
|
RSpec::Core::RakeTask.new :spec
|
11
10
|
Bundler::GemHelper.install_tasks
|
12
11
|
|
13
|
-
desc "Open an irb session preloaded with this library"
|
14
|
-
task :console do
|
15
|
-
sh "irb -rubygems -r ./lib/squall.rb -I ./lib"
|
16
|
-
end
|
17
|
-
|
18
12
|
task :default => [:spec]
|
@@ -1,56 +1,50 @@
|
|
1
1
|
module Squall
|
2
2
|
# OnApp DataStoreZone
|
3
3
|
class DataStoreZone < Base
|
4
|
-
#
|
4
|
+
# Public: List data store zones.
|
5
|
+
#
|
6
|
+
# Returns an Array.
|
5
7
|
def list
|
6
8
|
response = request(:get, "/data_store_zones.json")
|
7
9
|
response.collect { |i| i['data_store_group'] }
|
8
10
|
end
|
9
11
|
|
10
|
-
# Get the details for a data store zone
|
12
|
+
# Public: Get the details for a data store zone.
|
11
13
|
#
|
12
|
-
#
|
14
|
+
# id - ID of the data store zone
|
13
15
|
#
|
14
|
-
#
|
16
|
+
# Returns a Hash.
|
15
17
|
def show(id)
|
16
18
|
response = request(:get, "/data_store_zones/#{id}.json")
|
17
19
|
response['data_store_group']
|
18
20
|
end
|
19
21
|
|
20
|
-
# Updates an existing data store zone
|
21
|
-
#
|
22
|
-
# ==== Params
|
23
|
-
#
|
24
|
-
# * +id+ - ID of the data store zone
|
25
|
-
# * +options+ - Params for the data store zone
|
22
|
+
# Public: Updates an existing data store zone.
|
26
23
|
#
|
27
|
-
#
|
24
|
+
# id - ID of the data store zone
|
25
|
+
# options - Params for the data store zone:
|
26
|
+
# :label - Label for the data store zone
|
28
27
|
#
|
29
|
-
#
|
28
|
+
# Returns an empty Hash.
|
30
29
|
def edit(id, options = {})
|
31
|
-
|
32
|
-
response = request(:put, "/data_store_zones/#{id}.json", :query => {:pack => options})
|
30
|
+
request(:put, "/data_store_zones/#{id}.json", query: { pack: options })
|
33
31
|
end
|
34
32
|
|
35
|
-
# Creates a new DataStoreZone
|
36
|
-
#
|
37
|
-
# ==== Params
|
38
|
-
#
|
39
|
-
# * +options+ - Params for the data store zone
|
33
|
+
# Public: Creates a new DataStoreZone.
|
40
34
|
#
|
41
|
-
#
|
35
|
+
# options - Params for the data store zone:
|
36
|
+
# :label - Label for the data store zone
|
42
37
|
#
|
43
|
-
#
|
38
|
+
# Returns a Hash.
|
44
39
|
def create(options = {})
|
45
|
-
|
46
|
-
response = request(:post, "/data_store_zones.json", :query => {:pack => options})
|
40
|
+
request(:post, "/data_store_zones.json", query: { pack: options })
|
47
41
|
end
|
48
42
|
|
49
|
-
# Deletes an existing DataStoreZone
|
43
|
+
# Public: Deletes an existing DataStoreZone.
|
50
44
|
#
|
51
|
-
#
|
45
|
+
# id - ID of the data store zone
|
52
46
|
#
|
53
|
-
#
|
47
|
+
# Returns an empty Hash.
|
54
48
|
def delete(id)
|
55
49
|
request(:delete, "/data_store_zones/#{id}.json")
|
56
50
|
end
|
data/lib/squall/disk.rb
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
module Squall
|
2
|
+
# OnApp Disk
|
3
|
+
class Disk < Base
|
4
|
+
# Public: List all disks.
|
5
|
+
#
|
6
|
+
# Returns an Array.
|
7
|
+
def list
|
8
|
+
response = request(:get, "/settings/disks.json")
|
9
|
+
response.collect { |i| i['disk'] }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: List all disks available for a particular VM.
|
13
|
+
#
|
14
|
+
# id - ID of the virtual machine
|
15
|
+
#
|
16
|
+
# Returns an Array.
|
17
|
+
def vm_disk_list(id)
|
18
|
+
response = request(:get, "/virtual_machines/#{id}/disks.json")
|
19
|
+
response.collect { |i| i['disk'] }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Public: Creates a new Disk.
|
23
|
+
#
|
24
|
+
# id - ID of the virtual machine
|
25
|
+
# options - Params for the disk:
|
26
|
+
# :add_to_linux_fstab - Set true to add
|
27
|
+
# :data_store_id - The ID of a data store where this disk is
|
28
|
+
# located
|
29
|
+
# :disk_size - The disk space in GB
|
30
|
+
# :is_swap - Set true if this is a swap disk
|
31
|
+
# :mount_point - a physical location in the partition used
|
32
|
+
# as a root filesystem
|
33
|
+
# :require_format_disk – set true to format disk
|
34
|
+
#
|
35
|
+
# Example
|
36
|
+
#
|
37
|
+
# create(
|
38
|
+
# add_to_linux_fstab: 1,
|
39
|
+
# data_store_id: 1,
|
40
|
+
# disk_size: 10,
|
41
|
+
# is_swap: 0,
|
42
|
+
# mount_point: '/disk2',
|
43
|
+
# require_format_disk: 1
|
44
|
+
# )
|
45
|
+
#
|
46
|
+
# Returns a Hash.
|
47
|
+
def create(id, options = {})
|
48
|
+
request(:post, "/virtual_machines/#{id}/disks.json", default_params(options))
|
49
|
+
end
|
50
|
+
|
51
|
+
# Public: Updates an existing disk.
|
52
|
+
#
|
53
|
+
# id - ID of the disk
|
54
|
+
# options - Params for the disk
|
55
|
+
# :disk_size - The disk space in GB
|
56
|
+
#
|
57
|
+
# Returns a Hash.
|
58
|
+
def edit(id, options = {})
|
59
|
+
request(:put, "/settings/disks/#{id}.json", default_params(options))
|
60
|
+
end
|
61
|
+
|
62
|
+
# Public: Migrates a VM disk to another data store.
|
63
|
+
#
|
64
|
+
# vm_id - ID of the virtual machine
|
65
|
+
# id - ID of the disk
|
66
|
+
# options - Params for the disk
|
67
|
+
# :data_store_id - The disk space in GB
|
68
|
+
#
|
69
|
+
# Returns a Hash.
|
70
|
+
def migrate(vm_id, id, options = {})
|
71
|
+
request(:post, "/virtual_machines/#{vm_id}/disks/#{id}/migrate.json", default_params(options))
|
72
|
+
end
|
73
|
+
|
74
|
+
# Public: View Input/Output statistics for a disk.
|
75
|
+
#
|
76
|
+
# id - ID of the disk
|
77
|
+
#
|
78
|
+
# Returns an Array
|
79
|
+
def iops_usage(id)
|
80
|
+
response = request(:get, "/settings/disks/#{id}/usage.json")
|
81
|
+
response.collect { |i| i['disk_hourly_stat'] }
|
82
|
+
end
|
83
|
+
|
84
|
+
# Public: Builds a disk.
|
85
|
+
#
|
86
|
+
# id - ID of the disk
|
87
|
+
#
|
88
|
+
# Returns a Hash.
|
89
|
+
def build(id)
|
90
|
+
response = request(:post, "/settings/disks/#{id}/build.json")
|
91
|
+
response['disk']
|
92
|
+
end
|
93
|
+
|
94
|
+
# Public: Unlock a disk.
|
95
|
+
#
|
96
|
+
# id - ID of the disk
|
97
|
+
#
|
98
|
+
# Returns a Hash.
|
99
|
+
def unlock(id)
|
100
|
+
response = request(:post, "/settings/disks/#{id}/unlock.json")
|
101
|
+
response['disk']
|
102
|
+
end
|
103
|
+
|
104
|
+
# Public: Enable autobackups for a disk.
|
105
|
+
#
|
106
|
+
# id - ID of the disk
|
107
|
+
#
|
108
|
+
# Returns a Hash.
|
109
|
+
def auto_backup_on(id)
|
110
|
+
response = request(:post, "/settings/disks/#{id}/autobackup_enable.json")
|
111
|
+
response['disk']
|
112
|
+
end
|
113
|
+
|
114
|
+
# Public: Disable autobackups for a disk
|
115
|
+
#
|
116
|
+
# id - ID of the disk
|
117
|
+
#
|
118
|
+
# Returns a Hash.
|
119
|
+
def auto_backup_off(id)
|
120
|
+
response = request(:post, "/settings/disks/#{id}/autobackup_disable.json")
|
121
|
+
response['disk']
|
122
|
+
end
|
123
|
+
|
124
|
+
# Public: Get the list of schedules for a disk.
|
125
|
+
#
|
126
|
+
# id - ID of the disk
|
127
|
+
#
|
128
|
+
# Returns an Array.
|
129
|
+
def schedules(id)
|
130
|
+
response = request(:get, "/settings/disks/#{id}/schedules.json")
|
131
|
+
response.collect { |i| i['schedule'] }
|
132
|
+
end
|
133
|
+
|
134
|
+
# Public: Add autobackup schedule to a disk
|
135
|
+
#
|
136
|
+
# id - ID of the disk
|
137
|
+
# options - Params for the disk
|
138
|
+
# :action - set Autobackup to add a backup schedule
|
139
|
+
# :duration - specify duration
|
140
|
+
# :period - set the period (days|weeks|months|years)
|
141
|
+
#
|
142
|
+
# Example
|
143
|
+
#
|
144
|
+
# params = {
|
145
|
+
# action: 'autobackup',
|
146
|
+
# duration: 10,
|
147
|
+
# period: days
|
148
|
+
# }
|
149
|
+
#
|
150
|
+
# Returns an Array.
|
151
|
+
def add_schedule(id, options = {})
|
152
|
+
request(:post, "/settings/disks/#{id}/schedules.json", default_params(options))
|
153
|
+
end
|
154
|
+
|
155
|
+
# Public: List backups available for a disk.
|
156
|
+
#
|
157
|
+
# id - ID of the disk
|
158
|
+
#
|
159
|
+
# Returns an Array.
|
160
|
+
def backups(id)
|
161
|
+
response = request(:get, "/settings/disks/#{id}/backups.json")
|
162
|
+
response.collect { |i| i['backup'] }
|
163
|
+
end
|
164
|
+
|
165
|
+
# Public: Delete a disk.
|
166
|
+
#
|
167
|
+
# id - ID of the disk
|
168
|
+
#
|
169
|
+
# Returns a Hash.
|
170
|
+
def delete(id)
|
171
|
+
request(:delete, "/settings/disks/#{id}.json")
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
data/lib/squall/firewall_rule.rb
CHANGED
@@ -1,66 +1,59 @@
|
|
1
1
|
module Squall
|
2
2
|
# OnApp FirewallRule
|
3
3
|
class FirewallRule < Base
|
4
|
-
|
5
|
-
# Return a list of all firewall rules for a virtual machine
|
4
|
+
# Public: Lists all firewall rules for a virtual machine.
|
6
5
|
#
|
7
|
-
#
|
6
|
+
# vm_id - ID of the virtual machine
|
8
7
|
#
|
9
|
-
#
|
8
|
+
# Returns an Array.
|
10
9
|
def list(vm_id)
|
11
10
|
response = request(:get, "/virtual_machines/#{vm_id}/firewall_rules.json")
|
12
11
|
response.collect { |firewall_rule| user['firewall_rule'] }
|
13
12
|
end
|
14
13
|
|
15
|
-
# Create a firewall rule for a virtual machine
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
|
14
|
+
# Public: Create a firewall rule for a virtual machine.
|
15
|
+
#
|
16
|
+
# vm_id - ID of the virtual machine
|
17
|
+
# options - A Hash of options for the firewall rule:
|
18
|
+
# :address - IP address or range scope for rule.
|
19
|
+
# Leave blank to apply to all.
|
20
|
+
# :command - DROP or ACCEPT
|
21
|
+
# :network_interface_id - ID of the network interface
|
22
|
+
# :port - Port address for rule
|
23
|
+
# :protocol - TCP or UDP
|
24
|
+
#
|
25
|
+
# Example
|
26
|
+
#
|
27
|
+
# create(
|
28
|
+
# command: "DROP",
|
29
|
+
# protocol "TCP",
|
30
|
+
# network_interface_id: 1
|
31
|
+
# )
|
32
|
+
#
|
33
|
+
# Returns a Hash.
|
34
|
+
def create(vm_id, options = {})
|
36
35
|
request(:post, "/virtual_machines/#{vm_id}/firewall_rules.json", default_params(options))
|
37
36
|
end
|
38
37
|
|
39
|
-
# Edit a firewall rule
|
40
|
-
#
|
41
|
-
# ==== Params
|
38
|
+
# Public: Edit a firewall rule.
|
42
39
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
40
|
+
# vm_id - ID of the virtual machine
|
41
|
+
# id - ID of the firewall rule
|
42
|
+
# options - A Hash of options for the firewall rule, see `#create`.
|
46
43
|
#
|
47
|
-
#
|
48
|
-
|
49
|
-
# See #create
|
50
|
-
def edit(vm_id, id, options={})
|
51
|
-
params.accepts(:command, :protocol, :network_interface_id, :address, :port).validate!(options)
|
44
|
+
# Returns a Hash.
|
45
|
+
def edit(vm_id, id, options = {})
|
52
46
|
request(:put, "/virtual_machines/#{vm_id}/firewall_rules/#{id}.json", default_params(options))
|
53
47
|
end
|
54
48
|
|
55
|
-
# Delete a firewall rule
|
49
|
+
# Public: Delete a firewall rule.
|
56
50
|
#
|
57
|
-
#
|
51
|
+
# vm_id - ID of the virtual machine
|
52
|
+
# id - ID of the firewall rule
|
58
53
|
#
|
59
|
-
#
|
60
|
-
# * +id+ - ID of the firewall rule
|
54
|
+
# Returns a Hash.
|
61
55
|
def delete(vm_id, id)
|
62
56
|
request(:delete, "/virtual_machines/#{vm_id}/firewall_rules/#{id}.json")
|
63
57
|
end
|
64
|
-
|
65
58
|
end
|
66
59
|
end
|