~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/network/linux_net.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-12-13 10:17:01 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101213101701-txhhqbzsxw4avnxv
Tags: upstream-2011.1~bzr456
ImportĀ upstreamĀ versionĀ 2011.1~bzr456

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
                    '/etc/nova/nova-dhcpbridge.conf',
39
39
                    'location of flagfile for dhcpbridge')
40
40
 
41
 
flags.DEFINE_string('networks_path', utils.abspath('../networks'),
 
41
flags.DEFINE_string('networks_path', '$state_path/networks',
42
42
                    'Location to keep network config files')
43
43
flags.DEFINE_string('public_interface', 'vlan1',
44
44
                    'Interface for public IP addresses')
45
 
flags.DEFINE_string('bridge_dev', 'eth0',
46
 
                        'network device for bridges')
 
45
flags.DEFINE_string('vlan_interface', 'eth0',
 
46
                    'network device for vlans')
47
47
flags.DEFINE_string('dhcpbridge', _bin_file('nova-dhcpbridge'),
48
48
                        'location of nova-dhcpbridge')
 
49
flags.DEFINE_string('cc_host', utils.get_my_ip(), 'ip of api server')
 
50
flags.DEFINE_integer('cc_port', 8773, 'cloud controller port')
49
51
flags.DEFINE_string('routing_source_ip', '127.0.0.1',
50
52
                    'Public IP of network host')
51
53
flags.DEFINE_bool('use_nova_chains', False,
54
56
DEFAULT_PORTS = [("tcp", 80), ("tcp", 22), ("udp", 1194), ("tcp", 443)]
55
57
 
56
58
 
57
 
def init_host():
58
 
    """Basic networking setup goes here"""
59
 
    # NOTE(devcamcar): Cloud public DNAT entries, CloudPipe port
60
 
    # forwarding entries and a default DNAT entry.
 
59
def metadata_forward():
 
60
    """Create forwarding rule for metadata"""
61
61
    _confirm_rule("PREROUTING", "-t nat -s 0.0.0.0/0 "
62
62
             "-d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT "
63
63
             "--to-destination %s:%s" % (FLAGS.cc_host, FLAGS.cc_port))
64
64
 
 
65
 
 
66
def init_host():
 
67
    """Basic networking setup goes here"""
65
68
    # NOTE(devcamcar): Cloud public SNAT entries and the default
66
69
    # SNAT rule for outbound traffic.
67
70
    _confirm_rule("POSTROUTING", "-t nat -s %s "
134
137
    if not _device_exists(interface):
135
138
        logging.debug("Starting VLAN inteface %s", interface)
136
139
        _execute("sudo vconfig set_name_type VLAN_PLUS_VID_NO_PAD")
137
 
        _execute("sudo vconfig add %s %s" % (FLAGS.bridge_dev, vlan_num))
 
140
        _execute("sudo vconfig add %s %s" % (FLAGS.vlan_interface, vlan_num))
138
141
        _execute("sudo ifconfig %s up" % interface)
139
142
    return interface
140
143
 
142
145
def ensure_bridge(bridge, interface, net_attrs=None):
143
146
    """Create a bridge unless it already exists"""
144
147
    if not _device_exists(bridge):
145
 
        logging.debug("Starting Bridge inteface for %s", interface)
 
148
        logging.debug("Starting Bridge interface for %s", interface)
146
149
        _execute("sudo brctl addbr %s" % bridge)
147
150
        _execute("sudo brctl setfd %s 0" % bridge)
148
151
        # _execute("sudo brctl setageing %s 10" % bridge)
149
152
        _execute("sudo brctl stp %s off" % bridge)
150
 
        _execute("sudo brctl addif %s %s" % (bridge, interface))
 
153
        if interface:
 
154
            _execute("sudo brctl addif %s %s" % (bridge, interface))
151
155
    if net_attrs:
152
156
        _execute("sudo ifconfig %s %s broadcast %s netmask %s up" % \
153
157
                (bridge,