コード例 #1
0
from neutronclient.common import exceptions as n_exc
from neutronclient.neutron import v2_0 as neutronv20
from oslo.config import cfg
from webob import exc

from nova.compute import api as compute_api
from nova import exception
from nova.network import neutronv2
from nova.network.security_group import security_group_base
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
from nova.openstack.common import uuidutils
from nova import utils


wrap_check_security_groups_policy = compute_api.policy_decorator(
    scope='compute:security_groups')

CONF = cfg.CONF
LOG = logging.getLogger(__name__)


class SecurityGroupAPI(security_group_base.SecurityGroupBase):

    id_is_uuid = True

    def create_security_group(self, context, name, description):
        neutron = neutronv2.get_client(context)
        body = self._make_neutron_security_group_dict(name, description)
        try:
            security_group = neutron.create_security_group(
                body).get('security_group')
コード例 #2
0
ファイル: neutron_driver.py プロジェクト: zhichangwu/icehouse
from neutronclient.neutron import v2_0 as neutronv20
from oslo.config import cfg
from webob import exc

from nova.compute import api as compute_api
from nova import exception
from nova.network import neutronv2
from nova.network.security_group import security_group_base
from nova.objects import security_group
from nova.openstack.common import excutils
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
from nova.openstack.common import uuidutils
from nova import utils

wrap_check_security_groups_policy = compute_api.policy_decorator(
    scope='compute:security_groups')

CONF = cfg.CONF
LOG = logging.getLogger(__name__)

# NOTE: Neutron client has a max URL length of 8192, so we have
# to limit the number of IDs we include in any single search.  Really
# doesn't seem to be any point in making this a config value.
MAX_SEARCH_IDS = 150


class SecurityGroupAPI(security_group_base.SecurityGroupBase):

    id_is_uuid = True

    def create_security_group(self, context, name, description):