@@ -28,7 +28,7 @@ def self.instances
2828 :id => attrs [ 'id' ] ,
2929 :cidr => attrs [ 'cidr' ] ,
3030 :ip_version => attrs [ 'ip_version' ] ,
31- :gateway_ip => attrs [ 'gateway_ip' ] ,
31+ :gateway_ip => parse_gateway_ip ( attrs [ 'gateway_ip' ] ) ,
3232 :allocation_pools => parse_allocation_pool ( attrs [ 'allocation_pools' ] ) ,
3333 :host_routes => parse_host_routes ( attrs [ 'host_routes' ] ) ,
3434 :dns_nameservers => parse_dns_nameservers ( attrs [ 'dns_nameservers' ] ) ,
@@ -48,6 +48,11 @@ def self.prefetch(resources)
4848 end
4949 end
5050
51+ def self . parse_gateway_ip ( value )
52+ return '' if value . nil?
53+ return value
54+ end
55+
5156 def self . parse_allocation_pool ( values )
5257 allocation_pools = [ ]
5358 return [ ] if values . empty?
@@ -89,7 +94,11 @@ def create
8994 end
9095
9196 if @resource [ :gateway_ip ]
92- opts << "--gateway-ip=#{ @resource [ :gateway_ip ] } "
97+ if @resource [ :gateway_ip ] == ''
98+ opts << '--no-gateway'
99+ else
100+ opts << "--gateway-ip=#{ @resource [ :gateway_ip ] } "
101+ end
93102 end
94103
95104 if @resource [ :enable_dhcp ]
@@ -139,7 +148,7 @@ def create
139148 :id => attrs [ 'id' ] ,
140149 :cidr => attrs [ 'cidr' ] ,
141150 :ip_version => attrs [ 'ip_version' ] ,
142- :gateway_ip => attrs [ 'gateway_ip' ] ,
151+ :gateway_ip => self . class . parse_gateway_ip ( attrs [ 'gateway_ip' ] ) ,
143152 :allocation_pools => self . class . parse_allocation_pool ( attrs [ 'allocation_pools' ] ) ,
144153 :host_routes => self . class . parse_host_routes ( attrs [ 'host_routes' ] ) ,
145154 :dns_nameservers => self . class . parse_dns_nameservers ( attrs [ 'dns_nameservers' ] ) ,
@@ -158,7 +167,11 @@ def destroy
158167 end
159168
160169 def gateway_ip = ( value )
161- auth_neutron ( 'subnet-update' , "--gateway-ip=#{ value } " , name )
170+ if value == ''
171+ auth_neutron ( 'subnet-update' , '--no-gateway' , name )
172+ else
173+ auth_neutron ( 'subnet-update' , "--gateway-ip=#{ value } " , name )
174+ end
162175 end
163176
164177 def enable_dhcp = ( value )
0 commit comments