def enableHostonlyif():
    adapterName = subutai.GetVBoxHostOnlyInterface()

    if adapterName == 'undefined':
        subutai.VBox("hostonlyif create")
        adapterName = subutai.GetVBoxHostOnlyInterface()
        subutai.VBox("hostonlyif ipconfig " + adapterName + " --ip 192.168.56.1")
        out = subutai.VBox("list dhcpservers")
        if out == '':
            subutai.VBox("dhcpserver add --ifname " + adapterName + " --ip 192.168.56.1 --netmask 255.255.255.0 --lowerip 192.168.56.100 --upperip 192.168.56.200")
            subutai.VBox("dhcpserver modify --ifname " + adapterName + " --enable")

    return 0
Пример #2
0
 def EnableHostonlyInterface(self):
     subutai.Information("Enabling host-only interface")
     adapterName = subutai.GetVBoxHostOnlyInterface()
     if adapterName == 'undefined':
         subutai.Information("Setting up host-only interface " +
                             adapterName)
         adapter = adapterName.replace(' ', '+++')
         subutai.VBox("hostonlyif create")
         adapter = subutai.GetVBoxHostOnlyInterface()
         subutai.VBox("hostonlyif ipconfig " + adapter +
                      " --ip 192.168.56.1")
         out = subutai.VBox("list dhcpservers")
         if out == '':
             subutai.Information("Configuring DHCP server on " +
                                 adapterName)
             subutai.VBox(
                 "dhcpserver add --ifname " + adapter +
                 " --ip 192.168.56.1 --netmask 255.255.255.0 --lowerip 192.168.56.100 --upperip 192.168.56.200"
             )
             subutai.VBox("dhcpserver modify --ifname " + adapter +
                          " --enable")
     return 0
def reconfigureNic(machineName):
    subutai.AddStatus("Configuring Network")
    subutai.log("info", "Reconfiguring NIC")
    gateway = subutai.GetDefaultRoutingInterface()
    bridged = subutai.GetVBoxBridgedInterface(gateway)
    subutai.VBox("modifyvm " + machineName + ' --nic1 bridged --bridgeadapter1 ' + bridged)
    subutai.VBox("modifyvm " + machineName + " --nic2 nat")
    subutai.VBox("modifyvm " + machineName + " --cableconnected2 on")
    subutai.VBox("modifyvm " + machineName + ' --natpf2 ssh-fwd,tcp,,4567,,22 --natpf2 https-fwd,tcp,,9999,,8443')

    adapterName = subutai.GetVBoxHostOnlyInterface()

    if adapterName != 'undefined':
        subutai.VBox("modifyvm " + machineName + " --nic3 hostonly --hostonlyadapter3 " + adapterName)

    return
Пример #4
0
    def PreconfigureNetwork(self):
        subutai.AddStatus("Configuring Network")
        subutai.SetAction("NETPCONF")
        subutai.VBox("modifyvm " + self.name + " --nic1 nat")
        subutai.VBox("modifyvm " + self.name + " --cableconnected1 on")
        subutai.VBox(
            "modifyvm " + self.name +
            " --natpf1 ssh-fwd,tcp,,4567,,22 --natpf1 https-fwd,tcp,,9999,,8443"
        )
        subutai.VBox("modifyvm " + self.name + " --rtcuseutc on")
        adapterName = subutai.GetVBoxHostOnlyInterface()
        adapter = adapterName.replace(' ', '+++')
        if adapter != 'undefined':
            subutai.Information("Enabling host-only adapter " + adapterName)
            subutai.VBox("modifyvm " + self.name +
                         " --nic3 hostonly --hostonlyadapter3 " + adapter)

        return 0
def setupVm(machineName, progress):
    subutai.log("info", "Setting up a VM")
    subutai.AddStatus("Installing VM")
    rc = 0
    if subutai.CheckVMExists(machineName) != 0:
        subutai.download("core.ova")
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            progress.setCoreProgress(subutai.GetBytesDownload())
            progress.updateProgress()

        progress.setCoreProgress(progress.getCoreSize())
        progress.updateProgress()

        rc = subutai.VBoxS("import " +
                         subutai.GetTmpDir().replace(" ", "+++") + "core.ova --vsys 0 --vmname "+machineName)
        if rc != 0:
            return rc

        sleep(3)

        cpus = subutai.GetCoreNum()
        mem = subutai.GetMemSize() * 1024

        subutai.VBox("modifyvm " + machineName + " --cpus " + str(cpus))
        subutai.VBox("modifyvm " + machineName + " --memory " + str(mem))
        subutai.VBox("modifyvm " + machineName + " --nic1 nat")
        subutai.VBox("modifyvm " + machineName + " --cableconnected1 on")
        subutai.VBox("modifyvm " + machineName + " --natpf1 ssh-fwd,tcp,,4567,,22 --natpf1 https-fwd,tcp,,9999,,8443")
        subutai.VBox("modifyvm " + machineName + " --rtcuseutc on")
        adapterName = subutai.GetVBoxHostOnlyInterface()
        if adapterName != 'undefined':
            subutai.VBox("modifyvm " + machineName + " --nic3 hostonly --hostonlyadapter3 " + adapterName)

        sleep(1)

    return rc