~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/openstack/common/network_utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012 OpenStack LLC.
 
4
# All Rights Reserved.
 
5
#
 
6
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
7
#    not use this file except in compliance with the License. You may obtain
 
8
#    a copy of the License at
 
9
#
 
10
#         http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
#    Unless required by applicable law or agreed to in writing, software
 
13
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
14
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
15
#    License for the specific language governing permissions and limitations
 
16
#    under the License.
 
17
 
 
18
"""
 
19
Network-related utilities and helper functions.
 
20
"""
 
21
 
 
22
import logging
 
23
 
 
24
LOG = logging.getLogger(__name__)
 
25
 
 
26
 
 
27
def parse_host_port(address, default_port=None):
 
28
    """
 
29
    Interpret a string as a host:port pair.
 
30
    An IPv6 address MUST be escaped if accompanied by a port,
 
31
    because otherwise ambiguity ensues: 2001:db8:85a3::8a2e:370:7334
 
32
    means both [2001:db8:85a3::8a2e:370:7334] and
 
33
    [2001:db8:85a3::8a2e:370]:7334.
 
34
 
 
35
    >>> parse_host_port('server01:80')
 
36
    ('server01', 80)
 
37
    >>> parse_host_port('server01')
 
38
    ('server01', None)
 
39
    >>> parse_host_port('server01', default_port=1234)
 
40
    ('server01', 1234)
 
41
    >>> parse_host_port('[::1]:80')
 
42
    ('::1', 80)
 
43
    >>> parse_host_port('[::1]')
 
44
    ('::1', None)
 
45
    >>> parse_host_port('[::1]', default_port=1234)
 
46
    ('::1', 1234)
 
47
    >>> parse_host_port('2001:db8:85a3::8a2e:370:7334', default_port=1234)
 
48
    ('2001:db8:85a3::8a2e:370:7334', 1234)
 
49
 
 
50
    """
 
51
    if address[0] == '[':
 
52
        # Escaped ipv6
 
53
        _host, _port = address[1:].split(']')
 
54
        host = _host
 
55
        if ':' in _port:
 
56
            port = _port.split(':')[1]
 
57
        else:
 
58
            port = default_port
 
59
    else:
 
60
        if address.count(':') == 1:
 
61
            host, port = address.split(':')
 
62
        else:
 
63
            # 0 means ipv4, >1 means ipv6.
 
64
            # We prohibit unescaped ipv6 addresses with port.
 
65
            host = address
 
66
            port = default_port
 
67
 
 
68
    return (host, None if port is None else int(port))