コード例 #1
0
def subutaistart():

    tmpDir = subutai.GetTmpDir()

    chromeFilename = "GoogleChromeStandaloneEnterprise64.msi"

    chromeSize = subutai.GetFileSize(chromeFilename)
    totalSize = chromeSize
    chromeProgress = 0

    if subutai.IsChromeInstalled() != 0:
        subutai.AddStatus("Downloading Chrome")
        subutai.download(chromeFilename)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            chromeProgress = subutai.GetBytesDownload()
            updateProgress(chromeProgress, totalSize)

        chromeProgress = chromeSize

        subutai.AddStatus("Installing Chrome")
        try:
            call(['msiexec', '/qn', '/i', tmpDir + chromeFilename])
        except:
            subutai.RaiseError("Failed to install Google Chrome")
            sleep(5)

    subutai.AddStatus("Installing Browser Plugin")

    subutai.RegisterPlugin()

    subutai.Shutdown()

    return 0
コード例 #2
0
def subutaistart():
    p2pSize = subutai.GetFileSize("p2p")
    totalSize = p2pSize
    p2pProgress = 0

    subutai.AddStatus("Download p2p binary")

    sfile = "/etc/systemd/system/p2p.service"
    if os.path.exists(sfile):
        subutai.RemoveSystemdUnit("p2p.service")

    subutai.download("p2p")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        p2pProgress = subutai.GetBytesDownload()
        updateProgress(p2pProgress, totalSize)

    subutai.SetProgress(1.0)

    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()

    subutai.AddStatus("Download finished. Installing")
    copyfile(tmpDir+"/p2p", installDir+"/bin/p2p")

    st = os.stat(installDir+"/bin/p2p")
    os.chmod(installDir+"/bin/p2p", st.st_mode | stat.S_IEXEC)

    subutai.AddStatus("Creating symlink")
    subutai.MakeLink(installDir+"/bin/p2p", "/usr/bin/p2p")

    subutai.AddStatus("Creating systemd unit")

    unit = '''
[Unit]
Description=Service for Subutai p2p daemon
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/opt/subutai/bin/p2p daemon
Restart=on-failure
WorkingDirectory=/opt/subutai/

TimeoutStopSec=30
Type=simple

[Install]
WantedBy=multi-user.target
    '''.strip()

    f = open(tmpDir+"p2p.service", 'w')
    f.write(unit)
    f.close()

    subutai.AddSystemdUnit("p2p.service", tmpDir+"p2p.service")

    subutai.Shutdown()

    return 0
コード例 #3
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
    def SetupVirtualMachine(self):
        subutai.AddStatus("Setting up virtual machine")
        subutai.SetAction("INSTVM")
        rc = 0
        subutai.AddStatus("Installing VM")
        if subutai.CheckVMExists(self.name) != 0:
            subutai.download("core.ova")
            while subutai.isDownloadComplete() != 1:
                sleep(0.05)
                self.progress.setCoreProgress(subutai.GetBytesDownload())
                self.progress.updateProgress()

            subutai.AddStatus("VM Image downloaded")

        self.progress.setCoreProgress(self.progress.getCoreSize())
        self.progress.updateProgress()
        rc = subutai.VBoxS("import " +
                           subutai.GetTmpDir().replace(" ", "+++") +
                           "core.ova --vsys 0 --vmname " + self.name)
        if rc != 0:
            subutai.RaiseError("Failed to import Virtual Machine")
            return rc

        sleep(3)
        cpus = subutai.GetCoreNum()
        mem = subutai.GetMemSize() * 1024
        subutai.VBox("modifyvm " + self.name + " --cpus " + str(cpus))
        subutai.VBox("modifyvm " + self.name + " --memory " + str(mem))
        return rc
コード例 #4
0
def installOpenjre(openjreFile, progress):
    td = "/var/snap/subutai-dev/common/lxc/tmpdir/"
    awk = " | awk '{print $5}'"

    rc = subutai.SSHStartSession("mng-setup2")
    if rc != 0:
        subutai.AddStatus("Downloading JVM")
        subutai.SSHRun("sudo subutai -d import openjre16 1>/tmp/openjre16-1.log 2>/tmp/openjre16-2.log")
        return 0

    subutai.AddStatus("Downloading JVM")
    rc = subutai.SSHExecute("mng-setup2", "sudo subutai import openjre16 &")
    if rc[0] != 0:
        subutai.RaiseError("Failed to install OpenJRE in background. Switching to static install")
        subutai.SSHRun("sudo subutai import openjre16 >/tmp/openjre16.log 2>&1")
    else:
        checks = 0
        while True:
            out = subutai.SSHRunOut("ps -ef | grep \"subutai import\" | grep -v grep | awk '{print $2}'")
            if out == '':
                break
            sleep(1)
            checks = checks + 1
            if checks >= 60:
                subutai.SSHExecute("mng-setup2", "ls / &")
                checks = 0
            out = subutai.SSHRunOut("ls -l "+td+openjreFile+awk)
            try:
                val = int(out)
                progress.setOpenjreProgress(val)
                progress.updateProgress()
            except:
                pass

    subutai.SSHStopSession("mng-setup2")
コード例 #5
0
def subutaistart():
    subutai.AddStatus("Download Tray application")

    trayFile = "SubutaiTray_libs.tar.gz"

    traySize = subutai.GetFileSize(trayFile)
    totalSize = traySize
    trayProgress = 0

    subutai.download(trayFile)
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        trayProgress = subutai.GetBytesDownload()
        updateProgress(trayProgress, totalSize)

    trayProgress = traySize

    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()

    subutai.AddStatus("Unpacking Tray")

    call(['/usr/bin/killall', '-9', 'SubutaiTray'])

    tar = tarfile.open(tmpDir + "/" + trayFile, "r:gz")
    tar.extractall(installDir + "/bin/")
    tar.close()

    subutai.AddStatus("Creating Symlink")
    subutai.MakeLink(installDir + "/bin/SubutaiTray",
                     "/usr/local/bin/SubutaiTray")

    desktop = '''
[Desktop Entry]
Version=1.0
Name=Subutai Tray
Comment=Subutai Tray
Keywords=Internet;
Exec=SubutaiTray
Terminal=false
Type=Application
Icon=/usr/share/icons/launcher-logo.png
Categories=GNOME;Network;
StartupNotify=true
    '''.strip()

    f = open(tmpDir + "SubutaiTray.desktop", 'w')
    f.write(desktop)
    f.close()

    subutai.DesktopFileInstall(tmpDir + "SubutaiTray.desktop")
    subutai.StartTray()

    subutai.Shutdown()

    return 0
コード例 #6
0
    def Download(self):
        rc = 0
        subutai.AddStatus("Installing")
        if not CheckOsascript() and not CheckCocoasudo(self.install):
            rc = InstallCocoasudo(self.tmp, self.install, self.progress)
            if rc != 0:
                return rc

        if not self.__checkTuntap():
            self.__installTuntap()    

        subutai.download(self.RemoteP2PFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setP2PProgress(subutai.GetBytesDownload())
            self.progress.updateProgress()

        self.progress.setP2PProgress(self.progress.getP2PSize())
        self.progress.updateProgress()
        try:
            copyfile(self.tmp+self.RemoteP2PFile, self.install+"bin/"+self.P2PFile)
        except:
            subutai.RaiseError("Failed to move p2p binary to " +
                            self.install + "bin/"+self.P2PFile)
            return 19

        try:
            st = os.stat(self.install+"/bin/"+self.P2PFile)
            os.chmod(self.install+"/bin/"+self.P2PFile, st.st_mode | stat.S_IEXEC)
        except:
            subutai.RaiseError("Failed to make p2p binary executable")
            return 31

        return rc
コード例 #7
0
    def Download(self):
        rc = 0
        
        if not CheckOsascript() and not CheckCocoasudo(self.install):
            rc = InstallCocoasudo(self.tmp, self.install, self.progress)
        if rc != 0:
            return rc

        if not self.__checkLibssh():
            subutai.AddStatus("Downloading libssh2")
            subutai.download(self.LibsshFile)
            while subutai.isDownloadComplete() != 1:
                sleep(0.05)
                self.progress.setLibsshProgress(subutai.GetBytesDownload())
                self.progress.updateProgress()

            self.progress.setLibsshProgress(self.progress.getLibsshSize())
            self.progress.updateProgress()
        
        subutai.download(self.TrayFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setTrayProgress(subutai.GetBytesDownload())
            self.progress.updateProgress()

        self.progress.setTrayProgress(self.progress.getTraySize())
        self.progress.updateProgress()
        return rc
コード例 #8
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
    def InstallUbuntu(self):
        subutai.SetAction("INSTUB")
        td = "/var/snap/subutai/common/lxc/tmpdir/"
        awk = " | awk '{print $5}'"

        subutai.AddStatus("Downloading Ubuntu Linux")
        rc = subutai.SSHStartSession("mng-setup")

        if rc != 0:
            subutai.RaiseError(
                "Failed to install Ubuntu interactively. Switching to static install"
            )
            subutai.SSHRun(
                "sudo subutai -d import ubuntu16 >/tmp/ubuntu16.log 2>&1")
            return 0

        rc = subutai.SSHExecute("mng-setup", "sudo subutai import ubuntu16 &")
        if rc[0] != 0:
            subutai.RaiseError(
                "Failed to install Ubuntu in background. Switching to static install"
            )
            subutai.SSHRun(
                "sudo subutai -d import ubuntu16 >/tmp/ubuntu16.log 2>&1")
        else:
            checks = 0
            while True:
                out = subutai.SSHRunOut(
                    "ps -ef | grep \"subutai import\" | grep -v grep | awk '{print $2}'"
                )
                if out == '':
                    subutai.AddStatus("Download completed")
                    break
                sleep(1)
                checks = checks + 1
                if checks >= 60:
                    subutai.SSHExecute("mng-setup", "ls / &")
                    checks = 0
                out = subutai.SSHRunOut("ls -l " + td + self.UbuntuFile + awk)
                try:
                    val = int(out)
                    self.progress.setUbuntuProgress(val)
                    self.progress.updateProgress()
                except:
                    pass

        subutai.SSHStopSession("mng-setup")
        return 0
コード例 #9
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
    def InstallManagement(self):
        subutai.SetAction("INSTMNG")
        td = "/var/snap/subutai/common/lxc/tmpdir/"
        awk = " | awk '{print $5}'"

        rc = subutai.SSHStartSession("mng-setup3")
        if rc != 0:
            subutai.AddStatus("Installing Management Container")
            subutai.SSHRun(
                "sudo subutai -d import management 1>/tmp/management-1.log 2>/tmp/management-2.log"
            )
            return 0

        subutai.AddStatus("Installing Management Container")
        rc = subutai.SSHExecute("mng-setup3",
                                "sudo subutai import management &")
        if rc[0] != 0:
            subutai.RaiseError(
                "Failed to install Management in background. Switching to static install"
            )
            subutai.SSHRun(
                "sudo subutai import management >/tmp/management.log 2>&1")
        else:
            checks = 0
            while True:
                out = subutai.SSHRunOut(
                    "ps -ef | grep \"subutai import\" | grep -v grep | awk '{print $2}'"
                )
                if out == '':
                    break
                sleep(1)
                checks = checks + 1
                if checks >= 60:
                    subutai.SSHExecute("mng-setup3", "ls / &")
                    checks = 0
                out = subutai.SSHRunOut("ls -l " + td + "*" +
                                        self.ManagementFile + "*" + awk)
                try:
                    val = int(out)
                    self.progress.setManagementProgress(val)
                    self.progress.updateProgress()
                except:
                    pass

        subutai.SSHStopSession("mng-setup3")
        return 0
コード例 #10
0
ファイル: subuw.py プロジェクト: subutai-attic/launcher
 def Install(self):
     subutai.AddStatus("Installing Chrome")
     try:
         call(['msiexec', '/qn', '/i', self.tmp + self.GoogleChromeFile])
     except:
         subutai.RaiseError("Failed to install Google Chrome")
         return 28
     return 0
コード例 #11
0
ファイル: subuw.py プロジェクト: subutai-attic/launcher
    def __installTuntap(self):
        subutai.SetStep("TAPINST")
        subutai.AddStatus("Downloading TUN/TAP driver")
        subutai.download(self.TapFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setTuntapProgress(subutai.GetBytesDownload())
            self.progress.updateProgress()

        self.progress.setTuntapProgress(self.progress.getTuntapSize())
        self.progress.updateProgress()
        subutai.Information("Running TAP installation")
        subutai.AddStatus("Installing TUN/TAP driver")
        r = call([self.tmp + self.TapFile, '/S'])
        if r != 0:
            subutai.RaiseError("Failed to install TUN/TAP Driver")
        return r
コード例 #12
0
ファイル: subuw.py プロジェクト: subutai-attic/launcher
def InstallVirtualBox(tmp, install, progress):
    subutai.AddStatus("Downloading VirtualBox")
    subutai.download(GetVirtualBoxName())
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        progress.setVboxProgress(subutai.GetBytesDownload())
        progress.updateProgress()

    progress.setVboxProgress(progress.getVboxSize())
    progress.updateProgress()
    subutai.AddStatus("Installing VirtualBox")
    try:
        call([tmp + GetVirtualBoxName(), '-silent'])
    except:
        subutai.RaiseError("Failed to install VirtualBox. Aborting")
        return 45

    return 0
コード例 #13
0
def installSnapFromStore():
    subutai.AddStatus("Installing Subutai")
    subutai.log("info", "Installing subutai snap")
    subutai.SSHRun("sudo snap install --beta --devmode subutai-dev > /tmp/subutai-snap.log 2>&1")

    sleep(5)
    out = subutai.SSHRunOut("which subutai-dev >/dev/null; echo $?")
    if out != '0':
        return 55

    return 0
コード例 #14
0
def installVBox(vboxFile, tmpDir, installDir, progress):
    if subutai.IsVBoxInstalled() != 0:
        subutai.AddStatus("Downloading VirtualBox")
        subutai.download(vboxFile)

        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            progress.setVboxProgress(subutai.GetBytesDownload())
            progress.updateProgress()

        subutai.AddStatus("Installing VirtualBox")
        subutai.InstallVBox(tmpDir+vboxFile)

    progress.setVboxProgress(progress.getVboxSize())
    progress.updateProgress()
    if subutai.IsVBoxInstalled() != 0:
        subutai.AddStatus("Failed to install VirtualBox. Aborting")
        return 24

    return 0
コード例 #15
0
def InstallCocoasudo(tmp, install, progress):
    subutai.AddStatus("Downloading cocoasudo application")
    subutai.download("cocoasudo")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        progress.setCocoasudoProgress(subutai.GetBytesDownload())
        progress.updateProgress()

    progress.setCocoasudoProgress(progress.getCocoasudoSize())
    progress.updateProgress()

    subutai.AddStatus("Installing cocoasudo")
    try:
        copyfile(tmp+"cocoasudo", install+"bin/cocoasudo")
        st = os.stat(install+"bin/cocoasudo")
        os.chmod(install+"bin/cocoasudo", st.st_mode | stat.S_IEXEC)
    except:
        subutai.RaiseError("Failed to install cocoasudo. Aborting")
        return -87
    return 0
コード例 #16
0
    def Download(self):
        rc = 0
        subutai.AddStatus("Downloading")
        subutai.download(self.RemoteP2PFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setP2PProgress(subutai.GetBytesDownload())
            self.progress.updateProgress()

        self.progress.setP2PProgress(self.progress.getP2PSize())
        self.progress.updateProgress()
        return rc
コード例 #17
0
def InstallVirtualBox(tmp, install, progress):
    subutai.AddStatus("Downloading VirtualBox")
    subutai.download("VirtualBox.pkg")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        progress.setVboxProgress(subutai.GetBytesDownload())
        progress.updateProgress()

    subutai.AddStatus("Installing VirtualBox")
    try:
        CheckAndKillVirtualBox()
        if not CheckOsascript():
            returnCode = call([install+"bin/cocoasudo",
                               '--prompt="Install VirtualBox"',
                               'installer',
                               '-pkg',
                               tmp+'VirtualBox.pkg',
                               '-target',
                               '/'])
            if returnCode != 0:
                return 21
        else:
            ins = 'do shell script "installer -pkg '+tmp+'VirtualBox.pkg -target /" with administrator privileges'
            p = Popen(['osascript', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
            stdout, stderr = p.communicate(ins)
            if p.returncode != 0:
                return 23

    except:
        subutai.RaiseError("Failed to install VirtualBox. Aborting")
        sleep(10)
        return 45

    progress.setVboxProgress(progress.getVboxSize())
    progress.updateProgress()
    if not os.path.exists("/Applications/VirtualBox.app"):
        subutai.AddStatus("Failed to install VirtualBox. Aborting")
        return 24

    return 0
コード例 #18
0
def InstallVirtualBox(tmp, install, progress):
    subutai.AddStatus("Downloading VirtualBox")
    subutai.download(GetVirtualBoxName())
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        progress.setVboxProgress(subutai.GetBytesDownload())
        progress.updateProgress()

    progress.setVboxProgress(progress.getVboxSize())
    progress.updateProgress()
    try:
        subutai.AddStatus("Installing VirtualBox")
        postinst = subuco.PostInstall(tmp)
        postinst.append('dpkg -i ' + tmp + GetVirtualBoxName())
        postinst.append('modprobe vboxdrv >> /tmp/subutai/vbox.log 2>&1')
        postinst.append('modprobe vboxnetflt >> /tmp/subutai/vbox.log 2>&1')
        postinst.append('modprobe vboxnetadp >> /tmp/subutai/vbox.log 2>&1')
        postinst.append('modprobe vboxpci >> /tmp/subutai/vbox.log 2>&1')
        postinst.append("apt-get install -f -y")
        postinst.append('cat /tmp/subutai/vbox.log')
        p = run([
            '/usr/bin/gksudo', '--message', 'Install VirtualBox',
            postinst.get()
        ],
                stdout=PIPE,
                stderr=PIPE,
                encoding="utf-8")
        if p.stdout != '':
            subutai.Information(p.stdout)
        if p.stderr != '':
            subutai.Error(p.stderr)
    except:
        subutai.RaiseError("Failed to install VirtualBox. Aborting")
        return 45
    if not CheckVirtualBox():
        subutai.RaiseError("Failed to install VirtualBox. Aborting")
        return 24

    return 0
コード例 #19
0
ファイル: subuw.py プロジェクト: subutai-attic/launcher
    def Download(self):
        rc = 0
        if not self.__checkGoogleChrome():
            subutai.AddStatus("Downloading Google Chrome")
            subutai.download(self.GoogleChromeFile)
            while subutai.isDownloadComplete() != 1:
                sleep(0.05)
                self.progress.setChromeProgress(subutai.GetBytesDownload())
                self.progress.updateProgress()

            self.progress.setChromeProgress(self.progress.getChromeSize())
            self.progress.updateProgress()

        return rc
コード例 #20
0
ファイル: subuw.py プロジェクト: subutai-attic/launcher
    def Download(self):
        rc = 0
        subutai.AddStatus("Installing")
        if not self.__checkNssm():
            subutai.download(self.NssmFile)
            while subutai.isDownloadComplete() != 1:
                sleep(0.05)
                self.progress.setNssmProgress(subutai.GetBytesDownload())
                self.progress.updateProgress()

            self.progress.setNssmProgress(self.progress.getNssmSize())
            self.progress.updateProgress()
            try:
                copyfile(self.tmp + self.NssmFile,
                         self.install + "bin/" + self.NssmFile)
            except:
                subutai.RaiseError(
                    "Failed to move NSSM file to it's destination")
                return 14
        else:
            subutai.UnregisterService("Subutai P2P")
            subutai.ProcessKill("nssm.exe")
            subutai.ProcessKill("p2p.exe")

        rc = self.__installTuntap()
        subutai.download(self.RemoteP2PFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setP2PProgress(subutai.GetBytesDownload())
            self.progress.updateProgress()

        self.progress.setP2PProgress(self.progress.getP2PSize())
        self.progress.updateProgress()
        try:
            copyfile(self.tmp + self.RemoteP2PFile,
                     self.install + "bin/" + self.P2PFile)
        except:
            subutai.RaiseError("Failed to move p2p binary to " + self.install +
                               "bin/" + self.P2PFile)
            return 19

        try:
            st = os.stat(self.install + "/bin/" + self.P2PFile)
            os.chmod(self.install + "/bin/" + self.P2PFile,
                     st.st_mode | stat.S_IEXEC)
        except:
            subutai.RaiseError("Failed to make p2p binary executable")
            return 31

        return rc
コード例 #21
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
    def WaitPeerResponse(self):
        subutai.SetAction("WAITREST")
        ip = self.LocalIP
        if self.PeerIP != '':
            ip = self.PeerIP

        subutai.AddStatus("Waiting for peer at " + ip)
        attempts = 0
        while subutai.IsPeerReady(ip) != 0:
            sleep(2)
            attempts = attempts + 1
            if attempts >= 30:
                return 14
        return 0
コード例 #22
0
def waitForNetwork():
    subutai.AddStatus("Waiting for network")

    attempts = 0
    while True:
        out = subutai.SSHRunOut('if [ $(timeout 3 ping 8.8.8.8 -c1 2>/dev/null | grep -c "1 received") -ne 1 ]; then echo 1; else echo 0; fi')
        if out == '0':
            break
        if attempts >= 60:
            subutai.RaiseError("Failed to establish Internet connection on peer")
            return 82
        attempts = attempts + 1
        sleep(1)

    return 0
コード例 #23
0
ファイル: subuw.py プロジェクト: subutai-attic/launcher
    def PostInstall(self):
        subutai.AddStatus("Writing configuration")
        unPath = self.install.replace('\\', '/')
        unVBoxPath = subutai.GetVBoxPath().replace('\\', '/')
        f = open(unPath + "/tray/subutai_tray.ini", "w")
        f.write("P2P_Path=" + unPath + "/bin/p2p.exe\n")
        if unVBoxPath != "":
            f.write("VBoxManage_Path=" + unVBoxPath + "\n")
        f.write("Ssh_Path=" + unPath + "/bin/ssh.exe\n")
        f.write("Ssh_Keygen_Cmd=" + unPath + "/bin/ssh-keygen.exe\n")
        f.close()

        subutai.CreateDesktopShortcut(self.install + "/tray/SubutaiTray.exe",
                                      "Subutai Tray")

        return 0
コード例 #24
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
コード例 #25
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
    def InstallSnap(self):
        subutai.SetAction("INSTSNAP")
        subutai.AddStatus("Installing Subutai. This may take a few minutes")
        command = 'sudo snap install --beta --devmode subutai > /tmp/subutai-snap.log 2>&1'
        attempts = 0
        while attempts < 10:
            subutai.SSHRun(
                "sudo snap install --beta --devmode subutai > /tmp/subutai-snap.log 2>&1"
            )

            out = subutai.SSHRunOut("which subutai >/dev/null; echo $?")
            if out == '0':
                return 0
            sleep(30)
            attempts = attempts + 1

        return 55
コード例 #26
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
 def ConfigureNetwork(self):
     subutai.AddStatus("(Re)configuring Network")
     subutai.SetAction("NETCONF")
     rc = 0
     gateway = subutai.GetDefaultRoutingInterface()
     bridged = subutai.GetVBoxBridgedInterface(gateway)
     bridged = bridged.replace(' ', '+++')
     subutai.VBox("modifyvm " + self.name +
                  ' --nic1 bridged --bridgeadapter1 ' + bridged)
     subutai.VBox("modifyvm " + self.name + " --cableconnected1 on")
     subutai.VBox("modifyvm " + self.name + " --nic2 nat")
     subutai.VBox("modifyvm " + self.name + " --cableconnected2 on")
     subutai.VBox(
         "modifyvm " + self.name +
         ' --natpf2 ssh-fwd,tcp,,4567,,22 --natpf2 https-fwd,tcp,,9999,,8443'
     )
     return rc
コード例 #27
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
    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
コード例 #28
0
    def Download(self):
        subutai.SetAction('DWL')
        rc = 0
        if not CheckOsascript() and not CheckCocoasudo(self.install):
            rc = InstallCocoasudo(self.tmp, self.install, self.progress)
        if rc != 0:
            return rc

        if not self.__checkGoogleChrome():
            subutai.AddStatus("Downloading Google Chrome")
            subutai.download(self.GoogleChromeFile)
            while subutai.isDownloadComplete() != 1:
                sleep(0.05)
                self.progress.setChromeProgress(subutai.GetBytesDownload())
                self.progress.updateProgress()

            self.progress.setChromeProgress(self.progress.getChromeSize())
            self.updateProgress()
        
        return rc
コード例 #29
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
コード例 #30
0
ファイル: subuw.py プロジェクト: subutai-attic/launcher
    def Download(self):
        rc = 0
        subutai.AddStatus("Downloading libssh2")
        subutai.download(self.LibsshFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setLibsshProgress(subutai.GetBytesDownload())
            self.progress.updateProgress()

        self.progress.setLibsshProgress(self.progress.getLibsshSize())
        self.progress.updateProgress()

        subutai.ProcessKill("SubutaiTray.exe")
        subutai.ProcessKill("ssh.exe")
        subutai.ProcessKill("ssh-keygen.exe")

        subutai.download(self.TrayFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setTrayProgress(subutai.GetBytesDownload())
            self.progress.updateProgress()

        self.progress.setTrayProgress(self.progress.getTraySize())
        self.progress.updateProgress()

        try:
            zf = zipfile.ZipFile(self.tmp + self.TrayFile, 'r')
            zf.extractall(self.install)
            zf.close()
            zfl = zipfile.ZipFile(self.tmp + self.LibsshFile, 'r')
            zfl.extractall(self.install + "/bin")
            zfl.close()
        except:
            subutai.RaiseError("Failed to replace tray")

        return rc