Change router's prop name agent_id to l3_agent_id

Currently, the OS::Neutron::Router supports associating the L3Agent via
"agent_id" property.

However, Neutron supports a few kind of agents(L3, DHCP and etc).
The property name of "agent_id" is little bit ambiguous.

It's nice to change property name "agent_id" to "l3_agent_id".

Change-Id: Ie3c90d703df81bbf9d541a7d7c08641eed9c8e2a
Closes-bug: #1296608
This commit is contained in:
Mitsuru Kanabuchi 2014-03-25 14:08:22 +09:00
parent 0d19394458
commit 0eb5dc5de2
2 changed files with 16 additions and 16 deletions

View File

@ -31,10 +31,10 @@ class Router(neutron.NeutronResource):
PROPERTIES = ( PROPERTIES = (
NAME, EXTERNAL_GATEWAY, VALUE_SPECS, ADMIN_STATE_UP, NAME, EXTERNAL_GATEWAY, VALUE_SPECS, ADMIN_STATE_UP,
AGENT_ID, L3_AGENT_ID,
) = ( ) = (
'name', 'external_gateway_info', 'value_specs', 'admin_state_up', 'name', 'external_gateway_info', 'value_specs', 'admin_state_up',
'agent_id', 'l3_agent_id',
) )
_EXTERNAL_GATEWAY_KEYS = ( _EXTERNAL_GATEWAY_KEYS = (
@ -80,7 +80,7 @@ class Router(neutron.NeutronResource):
default=True, default=True,
update_allowed=True update_allowed=True
), ),
AGENT_ID: properties.Schema( L3_AGENT_ID: properties.Schema(
properties.Schema.STRING, properties.Schema.STRING,
_('ID of the L3 agent. NOTE: The default policy setting in ' _('ID of the L3 agent. NOTE: The default policy setting in '
'Neutron restricts usage of this property to administrative ' 'Neutron restricts usage of this property to administrative '
@ -115,13 +115,13 @@ class Router(neutron.NeutronResource):
self.properties, self.properties,
self.physical_resource_name()) self.physical_resource_name())
agent_id = props.pop(self.AGENT_ID, None) l3_agent_id = props.pop(self.L3_AGENT_ID, None)
router = self.neutron().create_router({'router': props})['router'] router = self.neutron().create_router({'router': props})['router']
self.resource_id_set(router['id']) self.resource_id_set(router['id'])
if agent_id: if l3_agent_id:
self._replace_agent(agent_id) self._replace_agent(l3_agent_id)
def _show_resource(self): def _show_resource(self):
return self.neutron().show_router( return self.neutron().show_router(
@ -143,25 +143,25 @@ class Router(neutron.NeutronResource):
def handle_update(self, json_snippet, tmpl_diff, prop_diff): def handle_update(self, json_snippet, tmpl_diff, prop_diff):
props = self.prepare_update_properties(json_snippet) props = self.prepare_update_properties(json_snippet)
agent_id = props.pop(self.AGENT_ID, None) l3_agent_id = props.pop(self.L3_AGENT_ID, None)
if self.AGENT_ID in prop_diff: if self.L3_AGENT_ID in prop_diff:
self._replace_agent(agent_id) self._replace_agent(l3_agent_id)
del prop_diff[self.AGENT_ID] del prop_diff[self.L3_AGENT_ID]
if len(prop_diff) > 0: if len(prop_diff) > 0:
self.neutron().update_router( self.neutron().update_router(
self.resource_id, {'router': props}) self.resource_id, {'router': props})
def _replace_agent(self, agent_id=None): def _replace_agent(self, l3_agent_id=None):
ret = self.neutron().list_l3_agent_hosting_routers( ret = self.neutron().list_l3_agent_hosting_routers(
self.resource_id) self.resource_id)
for agent in ret['agents']: for agent in ret['agents']:
self.neutron().remove_router_from_l3_agent( self.neutron().remove_router_from_l3_agent(
agent['id'], self.resource_id) agent['id'], self.resource_id)
if agent_id: if l3_agent_id:
self.neutron().add_router_to_l3_agent( self.neutron().add_router_to_l3_agent(
agent_id, {'router_id': self.resource_id}) l3_agent_id, {'router_id': self.resource_id})
class RouterInterface(neutron.NeutronResource): class RouterInterface(neutron.NeutronResource):

View File

@ -96,7 +96,7 @@ neutron_template = '''
"router": { "router": {
"Type": "OS::Neutron::Router", "Type": "OS::Neutron::Router",
"Properties": { "Properties": {
"agent_id": "792ff887-6c85-4a56-b518-23f24fa65581" "l3_agent_id": "792ff887-6c85-4a56-b518-23f24fa65581"
} }
}, },
"router_interface": { "router_interface": {
@ -1115,13 +1115,13 @@ class NeutronRouterTest(HeatTestCase):
"Properties": { "Properties": {
"admin_state_up": False, "admin_state_up": False,
"name": "myrouter", "name": "myrouter",
"agent_id": "63b3fd83-2c5f-4dad-b3ae-e0f83a40f216" "l3_agent_id": "63b3fd83-2c5f-4dad-b3ae-e0f83a40f216"
} }
} }
prop_diff = { prop_diff = {
"admin_state_up": False, "admin_state_up": False,
"name": "myrouter", "name": "myrouter",
"agent_id": "63b3fd83-2c5f-4dad-b3ae-e0f83a40f216" "l3_agent_id": "63b3fd83-2c5f-4dad-b3ae-e0f83a40f216"
} }
rsrc.handle_update(update_snippet, {}, prop_diff) rsrc.handle_update(update_snippet, {}, prop_diff)