109
# NOVA will inject something like eth0, rewrite that to use the
110
# virtio-based BSD adapter.
109
# NOVA will inject something like eth0, rewrite that to use the FreeBSD
110
# adapter. Since this adapter is based on the used driver, we need to
111
# figure out which interfaces are available. On KVM platforms this is
112
# vtnet0, where Xen would use xn0.
111
113
def getnetifname(self, dev):
112
114
LOG.debug("Translating network interface %s", dev)
113
115
if dev.startswith('lo'):
115
118
n = re.search('\d+$', dev)
116
return 'vtnet' + n.group(0)
121
(out, err) = util.subp(['ifconfig', '-a'])
122
ifconfigoutput = [x for x in (out.strip()).splitlines() if len(x.split()) > 0]
123
for line in ifconfigoutput:
124
m = re.match('^\w+', line)
126
if m.group(0).startswith('lo'):
128
# Just settle with the first non-lo adapter we find, since it's
129
# rather unlikely there will be multiple nicdrivers involved.
133
# Replace the index with the one we're after.
134
bsddev = re.sub('\d+$', index, bsddev)
135
LOG.debug("Using network interface %s", bsddev)
118
138
def _read_system_hostname(self):
119
139
sys_hostname = self._read_hostname(filename=None)