def default_bridge2(conn=None): if platform.system() == 'SunOS': return ["bridge", default_nic()] dev = util.default_route() if (dev is not None and (not conn or not is_uri_remote(conn.getURI(), conn=conn))): # New style peth0 == phys dev, eth0 == bridge, eth0 == default route if os.path.exists("/sys/class/net/%s/bridge" % dev): return ["bridge", dev] # Old style, peth0 == phys dev, eth0 == netloop, xenbr0 == bridge, # vif0.0 == netloop enslaved, eth0 == default route try: defn = int(dev[-1]) except: defn = -1 if (defn >= 0 and os.path.exists("/sys/class/net/peth%d/brport" % defn) and os.path.exists("/sys/class/net/xenbr%d/bridge" % defn)): return ["bridge", "xenbr%d" % defn] return None
def default_bridge2(conn = None): if platform.system() == 'SunOS': return ["bridge", default_nic()] dev = util.default_route() if (dev is not None and (not conn or not is_uri_remote(conn.getURI()))): # New style peth0 == phys dev, eth0 == bridge, eth0 == default route if os.path.exists("/sys/class/net/%s/bridge" % dev): return ["bridge", dev] # Old style, peth0 == phys dev, eth0 == netloop, xenbr0 == bridge, # vif0.0 == netloop enslaved, eth0 == default route try: defn = int(dev[-1]) except: defn = -1 if (defn >= 0 and os.path.exists("/sys/class/net/peth%d/brport" % defn) and os.path.exists("/sys/class/net/xenbr%d/bridge" % defn)): return ["bridge", "xenbr%d" % defn] return None
def install_args(self, guest): """Construct kernel cmdline args for the installer, consisting of: the pathname of the kernel (32/64) to load, kernel options and args, and '-B' boot properties.""" (kopts, kargs, ignore_smfargs, kbargs) = \ self.process_extra_args(guest.extraargs) args = [''] if kopts: args += ['-%s' % kopts] if kbargs: args += ['-B', kbargs] netmask = '' # Yuck. Non-default netmasks require this option to be passed. # It's distinctly not-trivial to work out the netmask to be used # automatically. if kargs: for karg in kargs.split(): if karg.startswith('subnet-mask'): netmask = karg.split('=')[1] else: args += [kargs] iargs = '' if not guest.graphics['enabled']: iargs += 'nowin ' if guest.location.startswith('nfs:'): try: guestIP = socket.gethostbyaddr(guest.name)[2][0] except: iargs += ' dhcp' else: iserver = guest.location.split(':')[1] ipath = guest.location.split(':')[2] iserverIP = socket.gethostbyaddr(iserver)[2][0] iargs += ' -B install_media=' + iserverIP + ':' + ipath iargs += ',host-ip=' + guestIP if netmask: iargs += ',subnet-mask=%s' % netmask droute = util.default_route(guest.nics[0].bridge) if droute: iargs += ',router-ip=' + droute if guest.nics[0].macaddr: en = guest.nics[0].macaddr.split(':') for i in range(len(en)): # remove leading '0' from mac address element if len(en[i]) > 1 and en[i][0] == '0': en[i] = en[i][1] boot_mac = ':'.join(en) iargs += ',boot-mac=' + boot_mac else: iargs += '-B install_media=cdrom' args += ['-', iargs] return ' '.join(args)
def install_args(self, guest): """Construct kernel cmdline args for the installer, consisting of: the pathname of the kernel (32/64) to load, kernel options and args, and '-B' boot properties.""" (kopts, kargs, ignore_smfargs, kbargs) = \ self.process_extra_args(guest.extraargs) args = [''] if kopts: args += ['-%s' % kopts] if kbargs: args += ['-B', kbargs] netmask = '' # Yuck. Non-default netmasks require this option to be passed. # It's distinctly not-trivial to work out the netmask to be used # automatically. if kargs: for karg in kargs.split(): if karg.startswith('subnet-mask'): netmask = karg.split('=')[1] else: args += [kargs] iargs = '' if not guest.graphics['enabled']: iargs += 'nowin ' if guest.location.startswith('nfs:'): try: guestIP = socket.gethostbyaddr(guest.name)[2][0] except: iargs += ' dhcp' else: iserver = guest.location.split(':')[1] ipath = guest.location.split(':')[2] iserverIP = socket.gethostbyaddr(iserver)[2][0] iargs += ' -B install_media=' + iserverIP + ':' + ipath iargs += ',host-ip=' + guestIP if netmask: iargs += ',subnet-mask=%s' % netmask droute = util.default_route() if droute: iargs += ',router-ip=' + droute if guest.nics[0].macaddr: en = guest.nics[0].macaddr.split(':') for i in range(len(en)): # remove leading '0' from mac address element if len(en[i]) > 1 and en[i][0] == '0': en[i] = en[i][1] boot_mac = ':'.join(en) iargs += ',boot-mac=' + boot_mac else: iargs += '-B install_media=cdrom' args += ['-', iargs] return ' '.join(args)
def install_args(self, guest): """Construct kernel cmdline args for the installer, consisting of: the pathname of the kernel (32/64) to load, kernel options and args, and '-B' boot properties.""" (kopts, kargs, ignore_smfargs, kbargs) = self.process_extra_args(guest.extraargs) args = [""] if kopts: args += ["-%s" % kopts] if kbargs: args += ["-B", kbargs] netmask = "" # Yuck. Non-default netmasks require this option to be passed. # It's distinctly not-trivial to work out the netmask to be used # automatically. if kargs: for karg in kargs.split(): if karg.startswith("subnet-mask"): netmask = karg.split("=")[1] else: args += [kargs] iargs = "" if not guest.graphics["enabled"]: iargs += "nowin " if guest.location.startswith("nfs:"): try: guestIP = socket.gethostbyaddr(guest.name)[2][0] except: iargs += " dhcp" else: iserver = guest.location.split(":")[1] ipath = guest.location.split(":")[2] iserverIP = socket.gethostbyaddr(iserver)[2][0] iargs += " -B install_media=" + iserverIP + ":" + ipath iargs += ",host-ip=" + guestIP if netmask: iargs += ",subnet-mask=%s" % netmask droute = util.default_route(guest.nics[0].bridge) if droute: iargs += ",router-ip=" + droute if guest.nics[0].macaddr: en = guest.nics[0].macaddr.split(":") for i in range(len(en)): # remove leading '0' from mac address element if len(en[i]) > 1 and en[i][0] == "0": en[i] = en[i][1] boot_mac = ":".join(en) iargs += ",boot-mac=" + boot_mac else: iargs += "-B install_media=cdrom" args += ["-", iargs] return " ".join(args)