]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add enable_new_agents to neutron server
authorHirofumi Ichihara <ichihara.hirofumi@lab.ntt.co.jp>
Wed, 26 Aug 2015 05:47:36 +0000 (14:47 +0900)
committerHirofumi Ichihara <ichihara.hirofumi@lab.ntt.co.jp>
Fri, 28 Aug 2015 05:41:59 +0000 (14:41 +0900)
Neutron doesn't have a way to test a newly added network node
by deploying test resource before any customer resource on the node
is deployed. Nova and Cinder has the setting of “enable_new_services”
in each conf to disable the initial service status to achieve this.
This proposal adds enable_new_agents config.

DocImpact

Change-Id: Ie0d0b2dd4d95de95f3839d1c35f24b708e893801
Implements: blueprint enable-new-agents
Related-Bug: 1472076

etc/neutron.conf
neutron/db/agents_db.py
neutron/tests/unit/db/test_agents_db.py

index 1c185a805107bd05fab5bc86f4f1ae82ff5a24e1..0f4a206aad1f9e2442770b6b40e991675f3783ab 100644 (file)
 # Seconds to regard the agent as down; should be at least twice
 # report_interval, to be sure the agent is down for good
 # agent_down_time = 75
+
+# Agent starts with admin_state_up=False when enable_new_agents=False.
+# In the case, user's resources will not be scheduled automatically to the
+# agent until admin changes admin_state_up to True.
+# enable_new_agents = True
 # ===========  end of items for agent management extension =====
 
 # =========== items for agent scheduler extension =============
index 702f2e497d174ca5eafa960524fccaa6cb2bda09..9417d5e3c37d407f35cb406dea9c1d7105b140ec 100644 (file)
@@ -56,6 +56,11 @@ AGENT_OPTS = [
                       'dhcp_load_type can be configured to represent the '
                       'choice for the resource being balanced. '
                       'Example: dhcp_load_type=networks')),
+    cfg.BoolOpt('enable_new_agents', default=True,
+                help=_("Agent starts with admin_state_up=False when "
+                       "enable_new_agents=False. In the case, user's "
+                       "resources will not be scheduled automatically to the "
+                       "agent until admin changes admin_state_up to True.")),
 ]
 cfg.CONF.register_opts(AGENT_OPTS)
 
@@ -236,7 +241,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase):
                 res['created_at'] = current_time
                 res['started_at'] = current_time
                 res['heartbeat_timestamp'] = current_time
-                res['admin_state_up'] = True
+                res['admin_state_up'] = cfg.CONF.enable_new_agents
                 agent_db = Agent(**res)
                 greenthread.sleep(0)
                 context.session.add(agent_db)
index a47266314581e7d6e02169544ab99293a2c7818c..3aeea2b3ab4ef8971709639971ace5d40f128509 100644 (file)
@@ -16,6 +16,7 @@
 import datetime
 import mock
 
+from oslo_config import cfg
 from oslo_db import exception as exc
 from oslo_utils import timeutils
 import testscenarios
@@ -154,6 +155,12 @@ class TestAgentsDbMixin(TestAgentsDbBase):
             self.assertEqual(add_mock.call_count, 2,
                              "Agent entry creation hasn't been retried")
 
+    def test_create_or_update_agent_disable_new_agents(self):
+        cfg.CONF.set_override('enable_new_agents', False)
+        self.plugin.create_or_update_agent(self.context, self.agent_status)
+        agent = self.plugin.get_agents(self.context)[0]
+        self.assertFalse(agent['admin_state_up'])
+
 
 class TestAgentsDbGetAgents(TestAgentsDbBase):
     scenarios = [