Merge "Add device_id when a loadbalancer is created instead of at listener create"
This commit is contained in:
commit
9062e94372
|
@ -98,7 +98,7 @@ class LoadBalancerPluginDbv2(base_db.CommonDbMixin,
|
||||||
'network_id': subnet['network_id'],
|
'network_id': subnet['network_id'],
|
||||||
'mac_address': attributes.ATTR_NOT_SPECIFIED,
|
'mac_address': attributes.ATTR_NOT_SPECIFIED,
|
||||||
'admin_state_up': False,
|
'admin_state_up': False,
|
||||||
'device_id': '',
|
'device_id': lb_db.id,
|
||||||
'device_owner': n_constants.DEVICE_OWNER_LOADBALANCERV2,
|
'device_owner': n_constants.DEVICE_OWNER_LOADBALANCERV2,
|
||||||
'fixed_ips': [fixed_ip]
|
'fixed_ips': [fixed_ip]
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from neutron.common import exceptions as n_exc
|
from neutron.common import exceptions as n_exc
|
||||||
from neutron.extensions import portbindings
|
from neutron.extensions import portbindings
|
||||||
from neutron.i18n import _LW
|
from neutron.i18n import _LW
|
||||||
|
@ -166,8 +164,6 @@ class LoadBalancerCallbacks(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
port['admin_state_up'] = True
|
port['admin_state_up'] = True
|
||||||
port['device_owner'] = 'neutron:' + constants.LOADBALANCERV2
|
|
||||||
port['device_id'] = str(uuid.uuid5(uuid.NAMESPACE_DNS, str(host)))
|
|
||||||
port[portbindings.HOST_ID] = host
|
port[portbindings.HOST_ID] = host
|
||||||
self.plugin.db._core_plugin.update_port(
|
self.plugin.db._core_plugin.update_port(
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import uuid
|
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
from neutron.agent.common import config
|
from neutron.agent.common import config
|
||||||
|
@ -148,10 +147,6 @@ class HaproxyNSDriver(driver_base.LoadBalancerBaseDriver):
|
||||||
|
|
||||||
def _build_port_dict(self):
|
def _build_port_dict(self):
|
||||||
return {'admin_state_up': True,
|
return {'admin_state_up': True,
|
||||||
'device_owner': 'neutron:{0}'.format(
|
|
||||||
constants.LOADBALANCER),
|
|
||||||
'device_id': str(uuid.uuid5(uuid.NAMESPACE_DNS,
|
|
||||||
str(self.conf.host))),
|
|
||||||
portbindings.HOST_ID: self.conf.host}
|
portbindings.HOST_ID: self.conf.host}
|
||||||
|
|
||||||
def _get_state_file_path(self, loadbalancer_id, kind,
|
def _get_state_file_path(self, loadbalancer_id, kind,
|
||||||
|
|
|
@ -162,6 +162,8 @@ class TestLoadBalancerCallbacks(
|
||||||
|
|
||||||
with self.loadbalancer() as loadbalancer:
|
with self.loadbalancer() as loadbalancer:
|
||||||
lb_id = loadbalancer['loadbalancer']['id']
|
lb_id = loadbalancer['loadbalancer']['id']
|
||||||
|
if 'device_id' not in expected:
|
||||||
|
expected['device_id'] = lb_id
|
||||||
self.plugin_instance.db.update_loadbalancer_provisioning_status(
|
self.plugin_instance.db.update_loadbalancer_provisioning_status(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
loadbalancer['loadbalancer']['id'])
|
loadbalancer['loadbalancer']['id'])
|
||||||
|
@ -175,7 +177,6 @@ class TestLoadBalancerCallbacks(
|
||||||
def test_plug_vip_port(self):
|
def test_plug_vip_port(self):
|
||||||
exp = {
|
exp = {
|
||||||
'device_owner': 'neutron:' + constants.LOADBALANCERV2,
|
'device_owner': 'neutron:' + constants.LOADBALANCERV2,
|
||||||
'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f',
|
|
||||||
'admin_state_up': True
|
'admin_state_up': True
|
||||||
}
|
}
|
||||||
self._update_port_test_helper(
|
self._update_port_test_helper(
|
||||||
|
@ -187,7 +188,6 @@ class TestLoadBalancerCallbacks(
|
||||||
def test_plug_vip_port_mock_with_host(self):
|
def test_plug_vip_port_mock_with_host(self):
|
||||||
exp = {
|
exp = {
|
||||||
'device_owner': 'neutron:' + constants.LOADBALANCERV2,
|
'device_owner': 'neutron:' + constants.LOADBALANCERV2,
|
||||||
'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f',
|
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
portbindings.HOST_ID: 'host'
|
portbindings.HOST_ID: 'host'
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import uuid
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from neutron.common import exceptions
|
from neutron.common import exceptions
|
||||||
|
@ -138,9 +137,6 @@ class TestHaproxyNSDriver(base.BaseTestCase):
|
||||||
def test_build_port_dict(self):
|
def test_build_port_dict(self):
|
||||||
self.driver.conf.host = 'host1'
|
self.driver.conf.host = 'host1'
|
||||||
ret = {'admin_state_up': True,
|
ret = {'admin_state_up': True,
|
||||||
'device_owner': 'neutron:LOADBALANCER',
|
|
||||||
'device_id': str(uuid.uuid5(uuid.NAMESPACE_DNS,
|
|
||||||
str(self.conf.host))),
|
|
||||||
portbindings.HOST_ID: self.conf.host}
|
portbindings.HOST_ID: self.conf.host}
|
||||||
self.assertEqual(ret, self.driver._build_port_dict())
|
self.assertEqual(ret, self.driver._build_port_dict())
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,6 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
|
||||||
def test_plug_vip_port(self):
|
def test_plug_vip_port(self):
|
||||||
exp = {
|
exp = {
|
||||||
'device_owner': 'neutron:' + constants.LOADBALANCER,
|
'device_owner': 'neutron:' + constants.LOADBALANCER,
|
||||||
'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f',
|
|
||||||
'admin_state_up': True
|
'admin_state_up': True
|
||||||
}
|
}
|
||||||
self._update_port_test_helper(
|
self._update_port_test_helper(
|
||||||
|
@ -342,7 +341,6 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
|
||||||
def test_plug_vip_port_mock_with_host(self):
|
def test_plug_vip_port_mock_with_host(self):
|
||||||
exp = {
|
exp = {
|
||||||
'device_owner': 'neutron:' + constants.LOADBALANCER,
|
'device_owner': 'neutron:' + constants.LOADBALANCER,
|
||||||
'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f',
|
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
portbindings.HOST_ID: 'host'
|
portbindings.HOST_ID: 'host'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue