当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.NeutronClientException方法代码示例

本文整理汇总了Python中neutronclient.common.exceptions.NeutronClientException方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.NeutronClientException方法的具体用法?Python exceptions.NeutronClientException怎么用?Python exceptions.NeutronClientException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neutronclient.common.exceptions的用法示例。


在下文中一共展示了exceptions.NeutronClientException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_request_vif_port_create_failed

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def test_request_vif_port_create_failed(self, m_to_vif):
        cls = nested_macvlan_vif.NestedMacvlanPodVIFDriver
        m_driver = mock.Mock(spec=cls)
        neutron = self.useFixture(k_fix.MockNeutronClient()).client

        pod = mock.sentinel.pod
        project_id = mock.sentinel.project_id
        subnets = mock.sentinel.subnets
        security_groups = mock.sentinel.security_groups

        port_request = mock.sentinel.port_request
        m_driver._get_port_request.return_value = port_request
        neutron.create_port.side_effect = n_exc.NeutronClientException

        self.assertRaises(n_exc.NeutronClientException, cls.request_vif,
                          m_driver, pod, project_id, subnets, security_groups)
        m_driver._get_port_request.assert_called_once_with(
            pod, project_id, subnets, security_groups)
        neutron.create_port.assert_called_once_with(port_request)
        m_driver._add_to_allowed_address_pairs.assert_not_called()
        m_to_vif.assert_not_called() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:23,代码来源:test_nested_macvlan_vif.py

示例2: test_release_vif_parent_not_found

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def test_release_vif_parent_not_found(self):
        cls = nested_macvlan_vif.NestedMacvlanPodVIFDriver
        m_driver = mock.Mock(spec=cls)
        neutron = self.useFixture(k_fix.MockNeutronClient()).client

        port_id = lib_utils.get_hash()
        pod = mock.sentinel.pod
        vif = mock.Mock()
        vif.id = port_id

        container_mac = mock.sentinel.mac_address
        container_ip = mock.sentinel.ip_address
        container_port = self._get_fake_port(port_id, container_ip,
                                             container_mac)
        neutron.show_port.return_value = container_port

        m_driver.lock = mock.MagicMock(spec=threading.Lock())
        m_driver._get_parent_port.side_effect = n_exc.NeutronClientException

        self.assertRaises(n_exc.NeutronClientException, cls.release_vif,
                          m_driver, pod, vif)
        neutron.show_port.assert_called_once_with(port_id)
        m_driver._get_parent_port.assert_called_once_with(neutron, pod)
        m_driver._remove_from_allowed_address_pairs.assert_not_called()
        neutron.delete_port.assert_not_called() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:27,代码来源:test_nested_macvlan_vif.py

示例3: test_update_port_address_pairs_failure

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def test_update_port_address_pairs_failure(self):
        cls = nested_macvlan_vif.NestedMacvlanPodVIFDriver
        m_driver = mock.Mock(spec=cls)
        neutron = self.useFixture(k_fix.MockNeutronClient()).client

        port_id = lib_utils.get_hash()
        pairs = mock.sentinel.allowed_address_pairs
        neutron.update_port.side_effect = n_exc.NeutronClientException

        self.assertRaises(n_exc.NeutronClientException,
                          cls._update_port_address_pairs, m_driver, neutron,
                          port_id, pairs)

        neutron.update_port.assert_called_with(
            port_id,
            {'port': {'allowed_address_pairs': pairs}})

    # TODO(garyloug) consider exending and moving to a parent class 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:20,代码来源:test_nested_macvlan_vif.py

示例4: test_release_pub_ip_alloc_method_pool_neutron_exception

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def test_release_pub_ip_alloc_method_pool_neutron_exception(self):
        cls = d_lb_public_ip.FloatingIpServicePubIPDriver
        m_driver = mock.Mock(spec=cls)
        m_driver._drv_pub_ip = public_ip.FipPubIpDriver()
        neutron = self.useFixture(k_fix.MockNeutronClient()).client
        neutron.delete_floatingip.side_effect = n_exc.NeutronClientException

        floating_ip = {'floating_ip_address': '1.2.3.5',
                       'id': 'ec29d641-fec4-4f67-928a-124a76b3a888'}

        service_pub_ip_info = \
            obj_lbaas.LBaaSPubIp(ip_id=floating_ip['id'],
                                 ip_addr=floating_ip['floating_ip_address'],
                                 alloc_method='pool')
        rc = cls.release_pub_ip(m_driver, service_pub_ip_info)
        self.assertEqual(rc, False) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:18,代码来源:test_lb_public_ip.py

示例5: test_disassociate_pub_ip_neutron_exception

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def test_disassociate_pub_ip_neutron_exception(self):
        cls = d_lb_public_ip.FloatingIpServicePubIPDriver
        m_driver = mock.Mock(spec=cls)
        m_driver._drv_pub_ip = public_ip.FipPubIpDriver()
        neutron = self.useFixture(k_fix.MockNeutronClient()).client
        neutron.update_floatingip.side_effect = n_exc.NeutronClientException
        floating_ip = {'floating_ip_address': '1.2.3.5',
                       'id': 'ec29d641-fec4-4f67-928a-124a76b3a888'}
        service_pub_ip_info = \
            obj_lbaas.LBaaSPubIp(ip_id=floating_ip['id'],
                                 ip_addr=floating_ip['floating_ip_address'],
                                 alloc_method='pool')

        self.assertRaises(
            n_exc.NeutronClientException, cls.disassociate_pub_ip,
            m_driver, service_pub_ip_info) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:18,代码来源:test_lb_public_ip.py

示例6: allocate_ip

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def allocate_ip(self, pub_net_id, pub_subnet_id, project_id, description):

        neutron = clients.get_neutron_client()
        try:
            response = neutron.create_floatingip({'floatingip': {
                'tenant_id': project_id,
                'project_id': project_id,
                'floating_network_id': pub_net_id,
                'subnet_id': pub_subnet_id,
                'description': description}})
        except n_exc.NeutronClientException as ex:
            LOG.error("Failed to create floating IP - subnetid=%s ",
                      pub_subnet_id)
            raise ex
        return response['floatingip']['id'], response[
            'floatingip']['floating_ip_address'] 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:18,代码来源:public_ip.py

示例7: _get_parent_port_by_host_ip

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def _get_parent_port_by_host_ip(self, neutron, node_fixed_ip):
        node_subnet_id = oslo_cfg.CONF.pod_vif_nested.worker_nodes_subnet
        if not node_subnet_id:
            raise oslo_cfg.RequiredOptError(
                'worker_nodes_subnet', oslo_cfg.OptGroup('pod_vif_nested'))

        try:
            fixed_ips = ['subnet_id=%s' % str(node_subnet_id),
                         'ip_address=%s' % str(node_fixed_ip)]
            ports = neutron.list_ports(fixed_ips=fixed_ips)
        except n_exc.NeutronClientException as ex:
            LOG.error("Parent vm port with fixed ips %s not found!",
                      fixed_ips)
            raise ex

        if ports['ports']:
            return ports['ports'][0]
        else:
            LOG.error("Neutron port for vm port with fixed ips %s"
                      " not found!", fixed_ips)
            raise kl_exc.NoResourceException 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:23,代码来源:nested_vif.py

示例8: delete

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def delete(self, request, obj_id):
        try:
            # detach all interfaces before attempting to delete the router
            search_opts = {'device_owner': 'network:router_interface',
                           'device_id': obj_id}
            ports = api.neutron.port_list(request, **search_opts)
            for port in ports:
                api.neutron.router_remove_interface(request, obj_id,
                                                    port_id=port.id)
            api.neutron.router_delete(request, obj_id)
        except q_ext.NeutronClientException as e:
            msg = _('Unable to delete router "%s"') % e
            LOG.info(msg)
            messages.error(request, msg)
            redirect = reverse(self.redirect_url)
            raise exceptions.Http302(redirect, message=msg)
        except Exception:
            obj = self.table.get_object_by_id(obj_id)
            name = self.table.get_object_display(obj)
            msg = _('Unable to delete router "%s"') % name
            LOG.info(msg)
            exceptions.handle(request, msg) 
开发者ID:Mirantis,项目名称:mos-horizon,代码行数:24,代码来源:tables.py

示例9: create_host_iface

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def create_host_iface(self, endpoint_id, neutron_port, subnets,
                          network=None):
        """Instantiates a host interface and binds it to the host.

        A host interface will be created for the specific Neutron port and
        bound to the related network subsystem on the host by delegating to the
        pre-selected kuryr-lib driver.

        :param endpoint_id:  the ID of the endpoint as string
        :param neutron_port: the container Neutron port dictionary as returned
                             by python-neutronclient
        :param subnets:      an iterable of all the Neutron subnets which the
                             endpoint is trying to join
        :param network:      the Neutron network which the endpoint is trying
                             to join
        :returns: the tuple of stdout and stderr returned by
                  processutils.execute invoked with the executable script for
                  binding
        :raises: exceptions.VethCreationFailure,
                 exceptions.BindingNotSupportedFailure
                 exceptions.KuryrException,
                 neutronclient.common.NeutronClientException,
                 processutils.ProcessExecutionError
        """
        raise NotImplementedError() 
开发者ID:openstack,项目名称:kuryr-libnetwork,代码行数:27,代码来源:driver.py

示例10: delete_host_iface

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host interface associated to the Neutron port will be unbound from
        its network subsystem and deleted by delegating to the selected
        kuryr-lib driver.

        :param endpoint_id:  the ID of the Docker container as string
        :param neutron_port: a port dictionary returned from
                             python-neutronclient
        :returns: the tuple of stdout and stderr returned by
                  processutils.execute invoked with the executable script for
                  unbinding
        :raises: exceptions.VethDeletionFailure,
                 exceptions.KuryrException,
                 neutronclient.common.NeutronClientException,
                 processutils.ProcessExecutionError
        """
        raise NotImplementedError() 
开发者ID:openstack,项目名称:kuryr-libnetwork,代码行数:21,代码来源:driver.py

示例11: delete_host_iface

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host Slave interface associated to the Neutron port will be deleted
        by delegating to the selected kuryr-lib driver.
        This driver will also remove the IP and MAC address pairs of the
        Endpoint to the allowed_address_pairs list of the Neutron port
        associated to the underlying host interface.

        :param endpoint_id:  the ID of the endpoint as string
        :param neutron_port: a port dictionary returned from
                             python-neutronclient
        :returns: the tuple of stdout and stderr returned
                  by processutils.execute invoked with the executable script
                  for unbinding
        :raises: exceptions.VethDeletionFailure,
                 exceptions.KuryrException,
                 n_exceptions.NeutronClientException,
                 processutils.ProcessExecutionError,
        """
        vm_port = self._get_port_from_host_iface(self.link_iface)
        container_ips = neutron_port['fixed_ips']

        self._remove_from_allowed_address_pairs(vm_port, container_ips)
        return binding.port_unbind(endpoint_id, neutron_port) 
开发者ID:openstack,项目名称:kuryr-libnetwork,代码行数:27,代码来源:nested.py

示例12: _create_port

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def _create_port(endpoint_id, neutron_network_id, interface_mac, fixed_ips):
    port = {
        'name': utils.get_neutron_port_name(endpoint_id),
        'admin_state_up': True,
        'network_id': neutron_network_id,
        'device_owner': lib_const.DEVICE_OWNER,
        'device_id': endpoint_id,
        'binding:host_id': lib_utils.get_hostname(),
        'fixed_ips': fixed_ips
    }
    if interface_mac:
        port['mac_address'] = interface_mac
    try:
        rcvd_port = app.neutron.create_port({'port': port})
    except n_exceptions.NeutronClientException as ex:
        LOG.error("Error happened during creating a"
                  " Neutron port: %s", ex)
        raise
    return rcvd_port['port'] 
开发者ID:openstack,项目名称:kuryr-libnetwork,代码行数:21,代码来源:controllers.py

示例13: create_port

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def create_port(self, context, network_uuid, server_uuid):
        """Create neutron port."""

        client = get_client(context.auth_token)
        body = {
            'port': {
                'network_id': network_uuid,
                'device_id': server_uuid,
            }
        }

        try:
            port = client.create_port(body)
        except neutron_exceptions.NeutronClientException as e:
            msg = (_("Could not create neutron port on network %(net)s for "
                     "server %(server)s. %(exc)s"),
                   {'net': network_uuid, 'server': server_uuid, 'exc': e})
            LOG.exception(msg)
            raise exception.NetworkError(msg)

        return port['port'] 
开发者ID:openstack,项目名称:mogan,代码行数:23,代码来源:api.py

示例14: _safe_get_floating_ips

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def _safe_get_floating_ips(self, client, **kwargs):
        """Get floating IP gracefully handling 404 from Neutron."""
        try:
            return client.list_floatingips(**kwargs)['floatingips']
        # If a neutron plugin does not implement the L3 API a 404 from
        # list_floatingips will be raised.
        except neutron_exceptions.NotFound:
            return []
        except neutron_exceptions.NeutronClientException as e:
            # bug/1513879 neutron client is currently using
            # NeutronClientException when there is no L3 API
            if e.status_code == 404:
                return []
            with excutils.save_and_reraise_exception():
                LOG.exception('Unable to access floating IP for %s',
                              ', '.join(['%s %s' % (k, v)
                                         for k, v in kwargs.items()])) 
开发者ID:openstack,项目名称:mogan,代码行数:19,代码来源:api.py

示例15: get_or_create_default

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NeutronClientException [as 别名]
def get_or_create_default(self, zone=None):
        """
        Subnet zone is not supported by OpenStack and is thus ignored.
        """
        try:
            sn = self.find(name=OpenStackSubnet.CB_DEFAULT_SUBNET_NAME)
            if sn:
                return sn[0]
            # No default; create one
            net = self.provider.networking.networks.create(
                name=OpenStackNetwork.CB_DEFAULT_NETWORK_NAME,
                cidr_block='10.0.0.0/16')
            sn = net.create_subnet(name=OpenStackSubnet.CB_DEFAULT_SUBNET_NAME,
                                   cidr_block='10.0.0.0/24')
            router = self.provider.networking.routers.create(
                network=net, name=OpenStackRouter.CB_DEFAULT_ROUTER_NAME)
            router.attach_subnet(sn)
            gteway = (self.provider.networking.gateways
                .get_or_create_inet_gateway(
                OpenStackInternetGateway.CB_DEFAULT_INET_GATEWAY_NAME
            ))
            router.attach_gateway(gteway)
            return sn
        except NeutronClientException:
            return None 
开发者ID:ms-azure-cloudbroker,项目名称:cloudbridge,代码行数:27,代码来源:services.py


注:本文中的neutronclient.common.exceptions.NeutronClientException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。