~ubuntu-branches/ubuntu/saucy/quantum/saucy

« back to all changes in this revision

Viewing changes to quantum/agent/linux/interface.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-05-31 09:37:25 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20130531093725-09i9oem8a2xlw442
Tags: upstream-2013.2~b1
ImportĀ upstreamĀ versionĀ 2013.2~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    cfg.BoolOpt('ovs_use_veth',
40
40
                default=False,
41
41
                help=_('Uses veth for an interface or not')),
42
 
    cfg.StrOpt('network_device_mtu',
 
42
    cfg.IntOpt('network_device_mtu',
43
43
               help=_('MTU setting for device.')),
44
44
    cfg.StrOpt('meta_flavor_driver_mappings',
45
45
               help=_('Mapping between flavor and LinuxInterfaceDriver')),
72
72
 
73
73
    def init_l3(self, device_name, ip_cidrs, namespace=None):
74
74
        """Set the L3 settings for the interface using data from the port.
75
 
           ip_cidrs: list of 'X.X.X.X/YY' strings
 
75
 
 
76
        ip_cidrs: list of 'X.X.X.X/YY' strings
76
77
        """
77
78
        device = ip_lib.IPDevice(device_name,
78
79
                                 self.root_helper,
167
168
            tap_name = self._get_tap_name(device_name, prefix)
168
169
 
169
170
            if self.conf.ovs_use_veth:
170
 
                root_dev, ns_dev = ip.add_veth(tap_name, device_name)
 
171
                # Create ns_dev in a namespace if one is configured.
 
172
                root_dev, ns_dev = ip.add_veth(tap_name,
 
173
                                               device_name,
 
174
                                               namespace2=namespace)
 
175
            else:
 
176
                ns_dev = ip.device(device_name)
171
177
 
172
178
            internal = not self.conf.ovs_use_veth
173
179
            self._ovs_add_port(bridge, tap_name, port_id, mac_address,
174
180
                               internal=internal)
175
181
 
176
 
            ns_dev = ip.device(device_name)
177
182
            ns_dev.link.set_address(mac_address)
178
183
 
179
184
            if self.conf.network_device_mtu:
181
186
                if self.conf.ovs_use_veth:
182
187
                    root_dev.link.set_mtu(self.conf.network_device_mtu)
183
188
 
184
 
            if namespace:
 
189
            # Add an interface created by ovs to the namespace.
 
190
            if not self.conf.ovs_use_veth and namespace:
185
191
                namespace_obj = ip.ensure_namespace(namespace)
186
192
                namespace_obj.add_device_to_namespace(ns_dev)
187
193
 
231
237
                tap_name = device_name.replace(prefix, 'tap')
232
238
            else:
233
239
                tap_name = device_name.replace(self.DEV_NAME_PREFIX, 'tap')
234
 
            root_veth, ns_veth = ip.add_veth(tap_name, device_name)
 
240
            # Create ns_veth in a namespace if one is configured.
 
241
            root_veth, ns_veth = ip.add_veth(tap_name, device_name,
 
242
                                             namespace2=namespace)
235
243
            ns_veth.link.set_address(mac_address)
236
244
 
237
245
            if self.conf.network_device_mtu:
238
246
                root_veth.link.set_mtu(self.conf.network_device_mtu)
239
247
                ns_veth.link.set_mtu(self.conf.network_device_mtu)
240
248
 
241
 
            if namespace:
242
 
                namespace_obj = ip.ensure_namespace(namespace)
243
 
                namespace_obj.add_device_to_namespace(ns_veth)
244
 
 
245
249
            root_veth.link.set_up()
246
250
            ns_veth.link.set_up()
247
251