3636 set_neutron_runtime_properties ,
3737 create_object_dict ,
3838 COMMON_RUNTIME_PROPERTIES_KEYS ,
39- OPENSTACK_ID_PROPERTY ,
4039 is_external_relationship_not_conditionally_created )
4140
4241from neutron_plugin .network import NETWORK_OPENSTACK_TYPE
@@ -137,7 +136,6 @@ def create(neutron_client, args, **kwargs):
137136@with_nova_client
138137@with_neutron_client
139138def attach (nova_client , neutron_client , ** kwargs ):
140-
141139 if is_external_relationship (ctx ):
142140 ctx .logger .info ('Not attaching port from server since '
143141 'external port and server are being used' )
@@ -146,33 +144,13 @@ def attach(nova_client, neutron_client, **kwargs):
146144 server_id = get_openstack_id (ctx .source )
147145 port_id = get_openstack_id (ctx .target )
148146 port = neutron_client .show_port (port_id )
149- server = nova_client .servers .get (server_id )
150- network = neutron_client .show_network (port ['port' ]['network_id' ])
151- network_name = network ['network' ]['name' ]
152-
153- floating_ip_address = None
154- for target in ctx .target .instance .relationships :
155- if target .type == PORT_ADDRESS_REL_TYPE :
156- target_instance = target .target .instance
157- floatingip_id = \
158- target_instance .runtime_properties [OPENSTACK_ID_PROPERTY ]
159- floating_ip = neutron_client .show_floatingip (floatingip_id )
160- floating_ip_address = \
161- floating_ip ['floatingip' ]['floating_ip_address' ]
162-
163- server_addresses = \
164- [addr ['addr' ] for addr in server .addresses [network_name ]]
165-
166- if floating_ip_address and floating_ip_address not in server_addresses :
167- ctx .logger .info ('We will attach floating ip {0} to server {1}'
168- .format (floating_ip_address , server_id ))
169- server .add_floating_ip (floating_ip_address )
170- return ctx .operation .retry (
171- message = 'Waiting for the floating ip {0} to '
172- 'attach to server {1}..'
173- .format (floating_ip_address ,
174- server_id ),
175- retry_after = 10 )
147+
148+ # If port is attached to floating ip then once the port is attached to
149+ # the server, the floating ip will be assigned to the server directly,
150+ # in case of healing/deployment update it is not necessary to attach
151+ # floating ip associated with assigned port to server and will raise
152+ # error in since the port is not yet attached the server in case of
153+ # healing/deployment update the port
176154 change = {
177155 PORT_OPENSTACK_TYPE : {
178156 'device_id' : server_id ,
@@ -240,7 +218,6 @@ def delete(neutron_client, **kwargs):
240218@with_nova_client
241219@with_neutron_client
242220def detach (nova_client , neutron_client , ** kwargs ):
243-
244221 if is_external_relationship (ctx ):
245222 ctx .logger .info ('Not detaching port from server since '
246223 'external port and server are being used' )
0 commit comments