57
57
from nova import exception
58
58
from nova .i18n import _
59
59
from nova .network .neutronv2 import api as neutron_api
60
+ from nova .network .neutronv2 import constants
60
61
from nova import objects
61
62
from nova .objects import block_device as block_device_obj
62
63
from nova .objects import build_request as build_request_obj
@@ -1676,16 +1677,17 @@ def _get_ports(ctxt, instance, neutron):
1676
1677
try :
1677
1678
return neutron .list_ports (
1678
1679
ctxt , device_id = instance .uuid ,
1679
- fields = ['id' , 'resource_request' , 'binding:profile' ])['ports' ]
1680
+ fields = ['id' , 'resource_request' , constants .BINDING_PROFILE ]
1681
+ )['ports' ]
1680
1682
except neutron_client_exc .NeutronClientException as e :
1681
1683
raise exception .UnableToQueryPorts (
1682
1684
instance_uuid = instance .uuid , error = six .text_type (e ))
1683
1685
1684
1686
@staticmethod
1685
1687
def _has_request_but_no_allocation (port ):
1686
1688
request = port .get ('resource_request' )
1687
- binding_profile = port .get ('binding:profile' , {}) or {}
1688
- allocation = binding_profile .get ('allocation' )
1689
+ binding_profile = port .get (constants . BINDING_PROFILE , {}) or {}
1690
+ allocation = binding_profile .get (constants . ALLOCATION )
1689
1691
# We are defensive here about 'resources' and 'required' in the
1690
1692
# 'resource_request' as neutron API is not clear about those fields
1691
1693
# being optional.
@@ -1871,9 +1873,9 @@ def _get_port_allocations_to_heal(
1871
1873
# We also need to record the RP we are allocated from in the
1872
1874
# port. This will be sent back to Neutron before the allocation
1873
1875
# is updated in placement
1874
- binding_profile = port .get ('binding:profile' , {}) or {}
1875
- binding_profile ['allocation' ] = rp_uuid
1876
- port ['binding:profile' ] = binding_profile
1876
+ binding_profile = port .get (constants . BINDING_PROFILE , {}) or {}
1877
+ binding_profile [constants . ALLOCATION ] = rp_uuid
1878
+ port [constants . BINDING_PROFILE ] = binding_profile
1877
1879
1878
1880
output (_ ("Found resource provider %(rp_uuid)s having matching "
1879
1881
"traits for port %(port_uuid)s with resource request "
@@ -1890,7 +1892,8 @@ def _update_ports(self, neutron, ports_to_update, output):
1890
1892
for port in ports_to_update :
1891
1893
body = {
1892
1894
'port' : {
1893
- 'binding:profile' : port ['binding:profile' ]
1895
+ constants .BINDING_PROFILE :
1896
+ port [constants .BINDING_PROFILE ]
1894
1897
}
1895
1898
}
1896
1899
output (
@@ -1917,11 +1920,11 @@ def _rollback_port_updates(neutron, ports_to_rollback, output):
1917
1920
manual_rollback_needed = []
1918
1921
last_exc = None
1919
1922
for port in ports_to_rollback :
1920
- profile = port ['binding:profile' ]
1921
- profile .pop ('allocation' )
1923
+ profile = port [constants . BINDING_PROFILE ]
1924
+ profile .pop (constants . ALLOCATION )
1922
1925
body = {
1923
1926
'port' : {
1924
- 'binding:profile' : profile
1927
+ constants . BINDING_PROFILE : profile
1925
1928
}
1926
1929
}
1927
1930
try :
0 commit comments