ns-fog 1.22.8 → 1.22.9
Sign up to get free protection for your applications and to get access to all the features.
data/fog.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
## If your rubyforge_project name is different, then edit it and comment out
|
7
7
|
## the sub! line in the Rakefile
|
8
8
|
s.name = 'ns-fog'
|
9
|
-
s.version = '1.22.
|
9
|
+
s.version = '1.22.9'
|
10
10
|
s.date = '2014-07-21'
|
11
11
|
s.rubyforge_project = 'fog'
|
12
12
|
|
@@ -112,7 +112,7 @@ module Fog
|
|
112
112
|
requires :id
|
113
113
|
json = service.describe_router_statics(id, rule_ids, type).body['router_static_set']
|
114
114
|
json.inject([]) do |ret, o|
|
115
|
-
ret <<
|
115
|
+
ret << RouterRule.convert_type(o['static_type']).new(o)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
alias_method :statics, :rules
|
@@ -122,10 +122,10 @@ module Fog
|
|
122
122
|
end
|
123
123
|
alias_method :get_static, :get_rule
|
124
124
|
|
125
|
-
def add_rules(rules)
|
125
|
+
def add_rules(rules, auto_apply = true)
|
126
126
|
requires :id
|
127
|
-
service.add_router_statics(id,
|
128
|
-
service.update_routers(id)
|
127
|
+
service.add_router_statics(id, RouterRule.to_query([*rules]))
|
128
|
+
service.update_routers(id) if auto_apply
|
129
129
|
wait_for {ready?}
|
130
130
|
true
|
131
131
|
end
|
@@ -133,6 +133,39 @@ module Fog
|
|
133
133
|
alias_method :add_statics, :add_rules
|
134
134
|
alias_method :add_static, :add_rules
|
135
135
|
|
136
|
+
def add_port_forward_rule(src_port, dst_ip, dst_port, protocol, auto_apply = true)
|
137
|
+
rule = PortForwardRule.new(
|
138
|
+
src_port: src_port,
|
139
|
+
dst_ip: dst_ip,
|
140
|
+
dst_port: dst_port,
|
141
|
+
protocol: protocol
|
142
|
+
)
|
143
|
+
add_rules(rule, auto_apply)
|
144
|
+
end
|
145
|
+
|
146
|
+
def add_vpn_rule(type, port, protocol, cidr, auto_apply = true)
|
147
|
+
rule = VPNRule.new(
|
148
|
+
vpn_type: type,
|
149
|
+
vpn_port: port,
|
150
|
+
vpn_protocol: protocol,
|
151
|
+
vpn_cidr_block: cidr
|
152
|
+
)
|
153
|
+
add_rules(rule, auto_apply)
|
154
|
+
end
|
155
|
+
|
156
|
+
def add_dhcp_rule(server_id, dhcp_options, auto_apply = true)
|
157
|
+
rule = DHCPRule.new(
|
158
|
+
server_id: server_id,
|
159
|
+
dhcp_options: dhcp_options
|
160
|
+
)
|
161
|
+
add_rules(rule, auto_apply)
|
162
|
+
end
|
163
|
+
|
164
|
+
def add_gre_rule(gre_options, auto_apply = true)
|
165
|
+
rule = GRERule.new(gre_options: gre_options)
|
166
|
+
add_rules(rule, auto_apply)
|
167
|
+
end
|
168
|
+
|
136
169
|
def delete_rules(rule_id)
|
137
170
|
requires :id
|
138
171
|
service.delete_router_statics([*rule_id])
|
@@ -23,6 +23,17 @@ module Fog
|
|
23
23
|
service.security_group_rules.new(attrs).save
|
24
24
|
end
|
25
25
|
|
26
|
+
def add_rules(rules, auto_apply = true)
|
27
|
+
requires :id
|
28
|
+
args = {}
|
29
|
+
rules.each_with_index { |r, i|
|
30
|
+
args.merge! service.security_group_rules.new(r).to_query(i + 1)
|
31
|
+
}
|
32
|
+
service.add_security_group_rules(id, args)
|
33
|
+
service.apply_security_group(id) if auto_apply
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
26
37
|
def ingress_rules
|
27
38
|
requires :id
|
28
39
|
rules(:ingress)
|
@@ -35,6 +46,7 @@ module Fog
|
|
35
46
|
|
36
47
|
def rules(direction = nil)
|
37
48
|
requires :id
|
49
|
+
direction = [:egress, :ingress].index(direction)
|
38
50
|
service.security_group_rules.all('group-id' => id, 'direction' => direction)
|
39
51
|
end
|
40
52
|
|
@@ -76,7 +76,6 @@ module Fog::Compute
|
|
76
76
|
(val1.to_i .. port_end.to_i)
|
77
77
|
end
|
78
78
|
|
79
|
-
private
|
80
79
|
def to_range(stuff)
|
81
80
|
if stuff.is_a? Range
|
82
81
|
[stuff.first, stuff.end]
|
@@ -89,9 +88,10 @@ module Fog::Compute
|
|
89
88
|
query = ['protocol', 'priority', 'action',
|
90
89
|
'direction', 'val1', 'val2', 'val3'
|
91
90
|
].inject({}) do |ret, x|
|
92
|
-
ret["rules
|
91
|
+
ret["rules.#{n}.#{x}"] = send(x.to_sym)
|
92
|
+
ret
|
93
93
|
end
|
94
|
-
query[
|
94
|
+
query["rules.#{n}.security_group_rule_name"] = name
|
95
95
|
query
|
96
96
|
end
|
97
97
|
end
|