Created
December 5, 2011 19:09
-
-
Save willkelly/1434824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: tabstop=4 shiftwidth=4 softtabstop=4 | |
# Copyright 2011 OpenStack, LLC. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
# License for the specific language governing permissions and limitations | |
# under the License. | |
"""Extra Manager to limit networks by availability zone.""" | |
from nova import flags | |
from nova.network import manager | |
from nova import context | |
from nova import log as logging | |
FLAGS = flags.FLAGS | |
class AZDHCPManager(manager.FlatDHCPManager): | |
"""Extends FlatDHCPManager to limit networks to availability zone.""" | |
def _get_networks_for_instance(self, context, instance_id, project_id, | |
requested_networks=None): | |
supercls = super(manager.FlatDHCPManager, self) | |
networks = supercls._get_networks_for_instance(context, | |
instance_id, | |
project_id, | |
requested_networks) | |
# NOTE(vish): expects label to be set to the name of the availability | |
# zone. This is easier than adding a new field to the | |
# database. | |
i_ref = self.db.instance_get(context, instance_id) | |
return [network for network in networks if | |
network['label'] == i_ref['availability_zone']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment