コード例 #1
0
ファイル: peer_install.py プロジェクト: subutai-io/launcher
def subutaistart():
    subutai.CheckDirectories()
    tmpDir = subutai.GetTmpDir()
    targetDir = subutai.GetInstallDir()

    subutai.download("snappy.ova")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("subutai_"+subutai.GetMasterVersion()+"_amd64.snap")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    #os.system("tar zxf "+tmpDir+"/snappy.ova -C "+targetDir+"/resources/snappy.ovf")

    #subutai.VBox("import "+targetDir+"/resources/snappy.ovf")
    subutai.VBox("import "+tmpDir+"/snappy.ova")
    subutai.VBox("modifyvm snappy --cpus 2")
    subutai.VBox("modifyvm snappy --memory 200000")
    subutai.VBox("modifyvm snappy --nic1 nat")
    subutai.VBox("modifyvm snappy --cableconnected1 on")
    subutai.VBox('modifyvm snappy --natpf1 "ssh-fwd,tcp,,4567,,22" --natpf1 "https-fwd,tcp,,9999,,8443"')
    subutai.VBox("modifyvm snappy --rtcuseutc on")
    subutai.VBox("modifyvm snappy --name subutai-1")
    subutai.VBox("startvm --type headless subutai-1")

    #subutai.VBox("controlvm subuati-1 poweroff soft")

    subutai.Shutdown()
コード例 #2
0
def subutaistart():
    subutai.CheckDirectories()
    tmpDir = subutai.GetTmpDir()
    targetDir = subutai.GetInstallDir()

    subutai.download("snappy.ova")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("subutai_" + subutai.GetMasterVersion() + "_amd64.snap")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    #os.system("tar zxf "+tmpDir+"/snappy.ova -C "+targetDir+"/resources/snappy.ovf")

    #subutai.VBox("import "+targetDir+"/resources/snappy.ovf")
    subutai.VBox("import " + tmpDir + "/snappy.ova")
    subutai.VBox("modifyvm snappy --cpus 2")
    subutai.VBox("modifyvm snappy --memory 200000")
    subutai.VBox("modifyvm snappy --nic1 nat")
    subutai.VBox("modifyvm snappy --cableconnected1 on")
    subutai.VBox(
        'modifyvm snappy --natpf1 "ssh-fwd,tcp,,4567,,22" --natpf1 "https-fwd,tcp,,9999,,8443"'
    )
    subutai.VBox("modifyvm snappy --rtcuseutc on")
    subutai.VBox("modifyvm snappy --name subutai-1")
    subutai.VBox("startvm --type headless subutai-1")

    #subutai.VBox("controlvm subuati-1 poweroff soft")

    subutai.Shutdown()
コード例 #3
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
コード例 #4
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
コード例 #5
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
コード例 #6
0
ファイル: ui-banner.py プロジェクト: subutai-attic/launcher
def subutaistart():
    subutai.download("launcher-ad-1.png")
    while !subutai.isDownloadComplete() == 1:
        sleep(0.05)

    subutai.download("launcher-ad-2.png")
    while !subutai.isDownloadComplete() == 1:
        sleep(0.05)

    subutai.download("launcher-ad-3.png")
    while !subutai.isDownloadComplete() == 1:
        sleep(0.05)

    subutai.download("launcher-ad-4.png")
    while !subutai.isDownloadComplete() == 1:
        sleep(0.05)
コード例 #7
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
コード例 #8
0
ファイル: subul.py プロジェクト: subutai-io/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()
    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
コード例 #9
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
コード例 #10
0
ファイル: subuco.py プロジェクト: subutai-io/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
コード例 #11
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
コード例 #12
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
コード例 #13
0
    def __installTuntap(self):
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            self.progress.setTuntapProgress(subutai.GetBytesDownload())

        self.progress.setTuntapProgress(self.progress.getTuntapSize())
        self.progress.updateProgress()
        return 0
コード例 #14
0
ファイル: subuw.py プロジェクト: subutai-io/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
コード例 #15
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
コード例 #16
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
コード例 #17
0
ファイル: subuco.py プロジェクト: subutai-attic/launcher
def DownloadP2P(p2p, progress):
    subutai.download(p2p)
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        progress.setP2PProgress(subutai.GetBytesDownload())
        progress.updateProgress()

    progress.setP2PProgress(subutai.getP2PSize())

    return 0
コード例 #18
0
ファイル: subuco.py プロジェクト: subutai-io/launcher
def DownloadP2P(p2p, progress):
    subutai.download(p2p)
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        progress.setP2PProgress(subutai.GetBytesDownload())
        progress.updateProgress()

    progress.setP2PProgress(subutai.getP2PSize())

    return 0
コード例 #19
0
    def Download(self):
        rc = 0
        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
コード例 #20
0
def subutaistart():
    print "Subutai Start"
    print subutai.hello()
    print subutai.debug()
    print subutai.version()
    print subutai.download("p2p")

    while subutai.isDownloadComplete() != 1:
        print subutai.getProgress(), "%"

    return 0
コード例 #21
0
ファイル: subul.py プロジェクト: subutai-io/launcher
    def Download(self):
        rc = 0
        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
コード例 #22
0
ファイル: launcher-test.py プロジェクト: subutai-io/launcher
def subutaistart():
    print "Subutai Start"
    print subutai.hello()
    print subutai.debug()
    print subutai.version()
    print subutai.download("p2p")

    while subutai.isDownloadComplete() != 1:
        print subutai.getProgress(), "%"

    return 0
コード例 #23
0
ファイル: subul.py プロジェクト: subutai-io/launcher
    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
コード例 #24
0
def setupVm(machineName):
    if subutai.CheckVMExists(machineName) != 0:
        subutai.download("core.ova")
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
        subutai.download("subutai_4.0.15_amd64-dev.snap")
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
        subutai.VBox("import /tmp/subutai/core.ova")
        subutai.VBox("modifyvm core --cpus 2")
        subutai.VBox("modifyvm core --nic1 nat")
        subutai.VBox("modifyvm core --cableconnected1 on")
        subutai.VBox(
            "modifyvm core --natpf1 ssh-fwd,tcp,,4567,,22 --natpf1 https-fwd,tcp,,9999,,8443"
        )
        subutai.VBox("modifyvm core --rtcuseutc on")
        ret = subutai.VBoxS("modifyvm core --name " + machineName)
        if ret != 0:
            print(machineName + " is already exists")

    return
コード例 #25
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
コード例 #26
0
ファイル: p2p_install.py プロジェクト: subutai-attic/launcher
def subutaistart():
    subutai.CheckDirectories()
    subutai.download("p2p")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("p2p-ubuntu-service")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

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

    copyfile(tmpDir + "/p2p", targetDir + "/bin/p2p")
    if os.path.isfile("/usr/bin/p2p"):
        os.remove("/usr/bin/p2p")
    st = os.stat(targetDir + "/bin/p2p")
    os.chmod(targetDir + "/bin/p2p",
             st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)
    os.symlink(targetDir + "/bin/p2p", "/usr/bin/p2p")

    copyfile(tmpDir + "/p2p-ubuntu-service", "/etc/init.d/p2p")
    os.chmod("/etc/init.d/p2p",
             st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)

    ret = os.system("which service")
    if ret == 0:
        os.system("service p2p restart")
        ret = os.system("update-rc.d p2p defaults")
        if ret != 0:
            os.system("uptate-rc.d p2p enable")

    ret = os.system("which systemctl")
    if ret == 0:
        os.system("systemctl daemon-reload")
        os.system("systemctl enable p2p.service")
        os.system("systemctl restart p2p.service")

    subutai.Shutdown()
コード例 #27
0
ファイル: subuw.py プロジェクト: subutai-io/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
コード例 #28
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
コード例 #29
0
ファイル: p2p_install.py プロジェクト: subutai-io/launcher
def subutaistart():
    subutai.CheckDirectories()
    subutai.download("p2p")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("p2p-ubuntu-service")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

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

    copyfile(tmpDir+"/p2p", targetDir+"/bin/p2p")
    if os.path.isfile("/usr/bin/p2p"):
        os.remove("/usr/bin/p2p")
    st = os.stat(targetDir+"/bin/p2p")
    os.chmod(targetDir+"/bin/p2p", st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)
    os.symlink(targetDir+"/bin/p2p", "/usr/bin/p2p")

    copyfile(tmpDir+"/p2p-ubuntu-service", "/etc/init.d/p2p")
    os.chmod("/etc/init.d/p2p", st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)

    ret = os.system("which service")
    if ret == 0:
        os.system("service p2p restart")
        ret = os.system("update-rc.d p2p defaults")
        if ret != 0:
            os.system("uptate-rc.d p2p enable")

    ret = os.system("which systemctl")
    if ret == 0:
        os.system("systemctl daemon-reload")
        os.system("systemctl enable p2p.service")
        os.system("systemctl restart p2p.service")

    subutai.Shutdown()
コード例 #30
0
def subutaistart():
    subutai.CheckDirectories()
    subutai.download("SubutaiTray_dev")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("subutai-tray.desktop")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libicudata.so.52")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libicui18n.so.52")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libicuuc.so.52")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libssh2_app")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

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

    copyfile(tmpDir + "/SubutaiTray_dev", targetDir + "/bin/subutai-tray")
    if os.path.isfile("/usr/bin/subutai-tray"):
        os.remove("/usr/bin/subutai-tray")

    st = os.stat(targetDir + "/bin/subutai-tray")
    os.chmod(targetDir + "/bin/subutai-tray",
             st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)
    os.symlink(targetDir + "/bin/subutai-tray", "/usr/bin/subutai-tray")

    copyfile(tmpDir + "/subutai-tray.desktop",
             "/usr/share/applications/subutai-tray.desktop")

    copyfile(tmpDir + "/libicudata.so.52", targetDir + "/lib/libicudata.so.52")
    copyfile(tmpDir + "/libicui18n.so.52", targetDir + "/lib/libicui18n.so.52")
    copyfile(tmpDir + "/libicuuc.so.52", targetDir + "/lib/libicuuc.so.52")
    copyfile(tmpDir + "/libssh2_app", targetDir + "/bin/libssh2_app")

    if os.path.isfile("/usr/bin/libssh2_app"):
        os.remove("/usr/bin/libssh2_app")
    os.symlink(targetDir + "/bin/libssh2_app", "/usr/bin/libssh2_app")
    os.chmod(targetDir + "/bin/libssh2_app",
             st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)

    os.system(
        "desktop-file-install /usr/share/applications/subutai-tray.desktop")
    os.system("updatedb")

    subutai.Shutdown()
コード例 #31
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
コード例 #32
0
ファイル: subuw.py プロジェクト: subutai-io/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
コード例 #33
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
コード例 #34
0
ファイル: subuw.py プロジェクト: subutai-io/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
コード例 #35
0
ファイル: tray_install.py プロジェクト: subutai-io/launcher
def subutaistart():
    subutai.CheckDirectories()
    subutai.download("SubutaiTray_dev")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("subutai-tray.desktop")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libicudata.so.52")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libicui18n.so.52")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libicuuc.so.52")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    subutai.download("libssh2_app")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

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

    copyfile(tmpDir+"/SubutaiTray_dev", targetDir+"/bin/subutai-tray")
    if os.path.isfile("/usr/bin/subutai-tray"):
        os.remove("/usr/bin/subutai-tray")

    st = os.stat(targetDir+"/bin/subutai-tray")
    os.chmod(targetDir+"/bin/subutai-tray", st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)
    os.symlink(targetDir+"/bin/subutai-tray", "/usr/bin/subutai-tray")

    copyfile(tmpDir+"/subutai-tray.desktop", "/usr/share/applications/subutai-tray.desktop")

    copyfile(tmpDir+"/libicudata.so.52", targetDir+"/lib/libicudata.so.52")
    copyfile(tmpDir+"/libicui18n.so.52", targetDir+"/lib/libicui18n.so.52")
    copyfile(tmpDir+"/libicuuc.so.52", targetDir+"/lib/libicuuc.so.52")
    copyfile(tmpDir+"/libssh2_app", targetDir+"/bin/libssh2_app")

    if os.path.isfile("/usr/bin/libssh2_app"):
        os.remove("/usr/bin/libssh2_app")
    os.symlink(targetDir+"/bin/libssh2_app", "/usr/bin/libssh2_app")
    os.chmod(targetDir+"/bin/libssh2_app", st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)

    os.system("desktop-file-install /usr/share/applications/subutai-tray.desktop")
    os.system("updatedb")

    subutai.Shutdown()
コード例 #36
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
コード例 #37
0
ファイル: subuw.py プロジェクト: subutai-io/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
コード例 #38
0
def installSubutai(snapFile, user, host, port):
    subutai.download("launcher-prepare-server")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    call([
        '/usr/bin/scp', '-P4567', '-o', 'StrictHostKeyChecking=no',
        '/tmp/subutai/launcher-prepare-server',
        '[email protected]:~/prepare-server'
    ])
    call([
        '/usr/bin/scp', '-P4567', '-o', 'StrictHostKeyChecking=no',
        '/tmp/subutai/subutai_4.0.15_amd64-dev.snap',
        '[email protected]:~/subutai_latest.snap'
    ])

    subutai.SSHRun("sudo chmod +x /home/ubuntu/prepare-server")
    subutai.SSHRun("sudo /home/ubuntu/prepare-server")

    return
コード例 #39
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
コード例 #40
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
コード例 #41
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
コード例 #42
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
コード例 #43
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
コード例 #44
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
コード例 #45
0
def installVBox(tmpDir, progress):
    if subutai.IsVBoxInstalled() != 0:
        subutai.AddStatus("Downloading VirtualBox")
        vboxfile = "VirtualBox.exe"
        subutai.download(vboxfile)
        while subutai.isDownloadComplete() != 1:
            progress.setVboxProgress(subutai.GetBytesDownload())
            progress.updateProgress()

        subutai.AddStatus("Installing VirtualBox")
        try:
            call([tmpDir+vboxfile, '-silent'])
        except:
            subutai.RaiseError("Failed to install VirtualBox. Aborting")
            sleep(10)
            return 45

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

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

        subutai.AddStatus("Virtual Machine Image file downloaded")

    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()
    adapterName = adapterName.replace(' ', '+++')
    subutai.VBox("modifyvm " + machineName + " --nic3 hostonly --hostonlyadapter3 " + adapterName)
    sleep(1)

    return rc
コード例 #47
0
def subutaistart():
    tmpDir = subutai.GetTmpDir()
    subutai.AddStatus("Downloading Google Chrome")

    chromeFilename = "google-chrome-stable_current_amd64.deb"

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

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

    chromeProgress = chromeSize

    try:
        call([
            '/usr/bin/gksudo', '--message',
            'Install Google Chrome Dependencies',
            'apt-get install libappindicator1 -y'
        ])

        call([
            '/usr/bin/gksudo', '--message', 'Install Google Chrome',
            'dpkg -i ' + tmpDir + chromeFilename
        ])
        sleep(20)
    except:
        subutai.RaiseError("Failed to install Google Chrome")
        sleep(5)

    subutai.AddStatus("Installing Browser Plugin")

    #location = os.environ['HOME'] + '/.config/google-chrome/Default/External Extensions'
    location = '/opt/google/chrome/extensions/'
    if not os.path.exists(location):
        try:
            call([
                '/usr/bin/gksudo', '--message', 'Create extension directory',
                'mkdir -p ' + location
            ])
        except:
            subutai.RaiseError("Failed to create " + location + " directory")
            sleep(5)
            return -22

    ete = '{\n\t"external_update_url": "https://clients2.google.com/service/update2/crx"\n}\n'

    f = open(tmpDir + "kpmiofpmlciacjblommkcinncmneeoaa.json", 'w')
    f.write(ete)  # python will convert \n to os.linesep
    f.close()

    try:
        call([
            '/usr/bin/gksudo', '--message', 'Create extension directory',
            'cp ' + tmpDir + 'kpmiofpmlciacjblommkcinncmneeoaa.json ' +
            location
        ])
    except:
        subutai.RaiseError("Failed to move extension file")
        sleep(5)
        return -22

    subutai.Shutdown()

    return 0
コード例 #48
0
def subutaistart():
    subutai.AddStatus("Download Tray application")

    trayFile = "SubutaiTray_libs.zip"
    sshlibFile = "ssh.zip"

    traySize = subutai.GetFileSize(trayFile)
    libsshSize = subutai.GetFileSize(sshlibFile)
    totalSize = traySize + libsshSize
    trayProgress = 0
    libsshProgress = 0

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

    trayProgress = traySize

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

    libsshProgress = libsshSize

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

    subutai.AddStatus("Installing Tray")

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

    try:
        zf = zipfile.ZipFile(tmpDir+"/"+trayFile, 'r')
        zf.extractall(installDir)
        zf.close()
        zfl = zipfile.ZipFile(tmpDir+"/"+sshlibFile, 'r')
        zfl.extractall(installDir+"/bin")
        zfl.close()
    except:
        subutai.RaiseError("Failed to replace tray")

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

    subutai.AddStatus("Writing configuration")
    unPath = installDir.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.Shutdown()

    return 0
コード例 #49
0
def subutaistart():
    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()

    cocoasudoSize = subutai.GetFileSize("cocoasudo")
    chromeSize = subutai.GetFileSize("GoogleChrome_osx.tar.gz")
    totalSize = cocoasudoSize + chromeSize
    cocoasudoProgress = 0
    chromeProgress = 0

    if not os.path.exists(installDir+"bin/cocoasudo"):
        subutai.AddStatus("Downloading cocoasudo application")
        subutai.download("cocoasudo")
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            cocoasudoProgress = subutai.GetBytesDownload()
            updateProgress(cocoasudoProgress, chromeProgress, totalSize)

        try:
            copyfile(tmpDir+"cocoasudo", installDir+"bin/cocoasudo")
            st = os.stat(installDir+"bin/cocoasudo")
            os.chmod(installDir+"bin/cocoasudo", st.st_mode | stat.S_IEXEC)
        except:
            subutai.RaiseError("Failed to install cocoasudo. Aborting")
            sleep(10)
            return -99

    cocoasudoProgress = cocoasudoSize

    subutai.AddStatus("Checking Google Chrome Installation")
    if not os.path.exists("/Applications/Google Chrome.app"):
        subutai.AddStatus("Downloading Google Chrome")
        subutai.download("GoogleChrome_osx.tar.gz")
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            chromeProgress = subutai.GetBytesDownload()
            updateProgress(cocoasudoProgress, chromeProgress, totalSize)

        subutai.AddStatus("Download Complete")
        chromeProgress = chromeSize
        updateProgress(cocoasudoProgress, chromeProgress, totalSize)

        #try:
        #    script = 'quit Application \"Google Chrome.app\"'
        #    p = Popen(['osascript', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
        #    stdout, stderr = p.communicate(script)
        #except:
        #    subutai.RaiseError("Failed to stop Google Chrome")
        #    sleep(10)

        sleep(1)
        subutai.AddStatus("Installing Google Chrome")
        try:
            script = 'do shell script "/usr/bin/tar -xf '+tmpDir+'GoogleChrome_osx.tar.gz -C /Applications" with administrator privileges'
            p = Popen(['osascript', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
            stdout, stderr = p.communicate(script)
        except:
            subutai.RaiseError("Failed to install Google Chrome")
            sleep(5)

    subutai.AddStatus("Installing Browser Plugin")
    sleep(3)

    location = os.environ['HOME'] + '/Library/Application Support/Google/Chrome/External Extensions'
    if not os.path.exists(location):
        os.makedirs(location)

    ete = '{\n\t"external_update_url": "https://clients2.google.com/service/update2/crx"\n}'

    try:
        f = open(location+"/kpmiofpmlciacjblommkcinncmneeoaa.json", 'w')
        f.write(ete)  # python will convert \n to os.linesep
        f.close()
    except:
        subutai.RaiseError("Can't write plugin to Extensions directory")

    subutai.Shutdown()

    return 0
コード例 #50
0
def subutaistart():
    coreFile = "core.ova"
    vboxFile = "VirtualBox.exe"
    ubuntuFile = "ubuntu16-subutai-template_4.0.0_amd64.tar.gz"
    openjreFile = "openjre16-subutai-template_4.0.0_amd64.tar.gz"
    mngFile = "management"
    progress = Progress(coreFile, vboxFile, ubuntuFile, openjreFile, mngFile)

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

    rc = installVBox(tmpDir, progress)
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc

    sshlib = "ssh.zip"

    subutai.download(sshlib)
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)

    zfl = zipfile.ZipFile(tmpDir+"/"+sshlib, 'r')
    zfl.extractall(installDir+"/bin")
    zfl.close()

    m = hashlib.md5()
    m.update(datetime.datetime.now().isoformat().encode('utf-8'))
    machineName = "subutai-dw-" + m.hexdigest()[:5]

    installDir = subutai.GetInstallDir()
    call([installDir+'/bin/ssh-keygen.exe', '-R', '[127.0.0.1]:4567'])

    subutai.SetSSHCredentials("subutai", "ubuntai", "127.0.0.1", 4567)

    if setupVm(machineName, progress) != 0:
        subutai.RaiseError("Failed to install Virtual Machine. See the logs for details")
        sleep(10)
        subutai.Shutdown()
        return -4

    startVm(machineName)
    subutai.AddStatus("Waiting for peer to start and initialize")
    sleep(40)
    if subutai.CheckVMRunning(machineName) != 0:
        subutai.AddStatus("Failed to start VM. Retrying")
        startVm(machineName)
        sleep(50)

    if subutai.CheckVMRunning(machineName) != 0:
        subutai.RaiseError("Failed to start VM. Aborting")
        sleep(15)
        subutai.Shutdown()
        return 21

    rc = waitSSH()
    if rc != 0:
        subutai.Shutdown()
        return rc

    setupSSH()
    rc = waitForNetwork()
    if rc != 0:
        sleep(10)
        return rc
    progress.spin()
    rc = installSnapFromStore()
    if rc != 0:
        subutai.RaiseError("Failed to install Subutai. Aborting")
        sleep(10)
        subutai.Shutdown()
        return rc
    initBtrfs()
    setAlias()
    peerip = GetPeerIP()
    progress.unspin()
    installUbuntu(ubuntuFile, progress)
    installOpenjre(openjreFile, progress)
    installManagement(mngFile, progress)
    WaitForPeer(peerip)

    sleep(3)
    stopVm(machineName)
    sleep(5)
    if subutai.CheckVMRunning(machineName) == 0:
        subutai.AddStatus("Failed to stop VM. Retrying")
        stopVm(machineName)
        sleep(20)

    if subutai.CheckVMRunning(machineName) == 0:
        subutai.RaiseError("Failed to stop VM. Retrying")
        sleep(20)
        subutai.Shutdown()
        return 22

    reconfigureNic(machineName)
    sleep(3)
    startVm(machineName)
    sleep(10)
    if subutai.CheckVMRunning(machineName) != 0:
        subutai.AddStatus("Failed to start VM. Retrying")
        startVm(machineName)
        sleep(30)

    if subutai.CheckVMRunning(machineName) != 0:
        subutai.RaiseError("Failed to start VM. Aborting")
        sleep(15)
        subutai.Shutdown()
        return 21

    subutai.SetProgress(1.0)
    subutai.Shutdown()

    return 0
コード例 #51
0
def subutaistart():
    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()

    cocoasudoFile = "cocoasudo"
    p2pFile = "p2p_osx"
    tuntapFile = "tuntap_20150118_osx.pkg"

    cocoasudoSize = subutai.GetFileSize(cocoasudoFile)
    p2pSize = subutai.GetFileSize(p2pFile)
    tuntapSize = subutai.GetFileSize(tuntapFile)
    totalSize = cocoasudoSize + p2pSize + tuntapSize
    cocoasudoProgress = 0
    p2pProgress = 0
    tuntapProgress = 0

    if not os.path.exists(installDir+"bin/cocoasudo"):
        subutai.AddStatus("Downloading cocoasudo application")
        subutai.download(cocoasudoFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            cocoasudoProgress = subutai.GetBytesDownload()
            updateProgress(cocoasudoProgress, p2pProgress, tuntapProgress,
                           totalSize)

        try:
            copyfile(tmpDir+cocoasudoFile, installDir+"bin/cocoasudo")
            st = os.stat(installDir+"bin/cocoasudo")
            os.chmod(installDir+"bin/cocoasudo", st.st_mode | stat.S_IEXEC)
        except:
            subutai.RaiseError("Failed to install cocoasudo. Aborting")
            sleep(10)
            return -99

    cocoasudoProgress = cocoasudoSize
    subutai.AddStatus("Download TUNTAP driver")
    subutai.download(tuntapFile)
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        tuntapProgress = subutai.GetBytesDownload()
        updateProgress(cocoasudoProgress, p2pProgress, tuntapProgress,
                       totalSize)

    tuntapProgress = tuntapSize
    subutai.AddStatus("Download p2p binary")

    subutai.download(p2pFile)
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        p2pProgress = subutai.GetBytesDownload()
        updateProgress(cocoasudoProgress, p2pProgress, tuntapProgress,
                       totalSize)

    p2pProgress = p2pSize
    subutai.AddStatus("Download finished. Installing")

    try:
        copyfile(tmpDir+p2pFile, installDir+"bin/p2p")
    except:
        subutai.RaiseError("Failed to move p2p binary to " +
                           installDir + "bin/p2p")
        return 21

    subutai.SetProgress(0.99)

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

    subutai.AddStatus("Creating p2p service")
    service = '''
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>io.subutai.p2p.daemon</string>

    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/bin/p2p</string>
    <string>daemon</string>
    </array>

    <key>KeepAlive</key>
    <true/>

    <key>StandardOutPath</key>
    <string>/var/log/p2p.log</string>

    <key>StandardErrorPath</key>
    <string>/var/log/p2p.log</string>

    <key>Debug</key>
    <true/>
    </dict>
    </plist>
    '''.strip()

    daemonFile = 'io.subutai.p2p.daemon.plist'

    f = open(tmpDir+daemonFile, 'w')
    f.write(service)
    f.close()

    syslog = '''
    # logfilename          [owner:group]    mode count size when  flags [/pid_file] [sig_num]
    /var/log/p2p.log                       644  7     *    $D0   J
    '''.strip()
    sf = open(tmpDir+'p2p.conf', 'w')
    sf.write(syslog)
    sf.close()

    subutai.AddStatus("Configure P2P Daemon")
    installScript = "#!/bin/bash\n\n"
    installScript = installScript + "cp " + tmpDir + daemonFile + " /Library/LaunchDaemons/" + daemonFile + "\n"
    installScript = installScript + "cp " + tmpDir + "p2p.conf /etc/newsyslog.d/p2p.conf\n"
    installScript = installScript + "launchctl load /Library/LaunchDaemons/" + daemonFile + "\n"
    installScript = installScript + "installer -pkg " + tmpDir + "tuntap_20150118.pkg -target /\n"
    installScript = installScript + "ln -s "+installDir+"/bin/p2p /usr/local/bin/p2p\n"

    f = open(tmpDir+"p2p-setup.sh", 'w')
    f.write(installScript)
    f.close()

    try:
        st = os.stat(tmpDir+"p2p-setup.sh")
        os.chmod(tmpDir+"p2p-setup.sh", st.st_mode | stat.S_IEXEC)
    except:
        subutai.RaiseError("Failed to configure p2p daemon")
        sleep(10)
        return 31

    try:
        script = 'do shell script "'+tmpDir+'p2p-setup.sh" with administrator privileges'
        p = Popen(['osascript', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
        stdout, stderr = p.communicate(script)
    except:
        subutai.RaiseError("Failed to install p2p daemon")
        sleep(10)
        return 22

    subutai.SetProgress(1.00)

    sleep(5)
    subutai.Shutdown()

    return 0
コード例 #52
0
def subutaistart():
    tmpDir = subutai.GetTmpDir()
    subutai.AddStatus("Downloading Google Chrome")

    chromeFilename = "google-chrome-stable_current_amd64.deb"

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

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

    chromeProgress = chromeSize

    try:
        call(['/usr/bin/gksudo',
              '--message',
              'Install Google Chrome Dependencies',
              'apt-get install libappindicator1 -y'])

        call(['/usr/bin/gksudo',
              '--message',
              'Install Google Chrome',
              'dpkg -i '+tmpDir+chromeFilename])
        sleep(20)
    except:
        subutai.RaiseError("Failed to install Google Chrome")
        sleep(5)

    subutai.AddStatus("Installing Browser Plugin")

    #location = os.environ['HOME'] + '/.config/google-chrome/Default/External Extensions'
    location = '/opt/google/chrome/extensions/'
    if not os.path.exists(location):
        try:
            call(['/usr/bin/gksudo',
                  '--message',
                  'Create extension directory',
                  'mkdir -p '+location])
        except:
            subutai.RaiseError("Failed to create "+location+" directory")
            sleep(5)
            return -22

    ete = '{\n\t"external_update_url": "https://clients2.google.com/service/update2/crx"\n}\n'

    f = open(tmpDir+"kpmiofpmlciacjblommkcinncmneeoaa.json", 'w')
    f.write(ete)  # python will convert \n to os.linesep
    f.close()

    try:
        call(['/usr/bin/gksudo',
              '--message',
              'Create extension directory',
              'cp '+tmpDir+'kpmiofpmlciacjblommkcinncmneeoaa.json '+location])
    except:
        subutai.RaiseError("Failed to move extension file")
        sleep(5)
        return -22

    subutai.Shutdown()

    return 0
コード例 #53
0
def subutaistart():

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

    trayFile = "SubutaiTray_libs_osx.tar.gz"
    libsshFile = "libssh2-1.6.0-0_osx.pkg"
    cocoasudoFile = "cocoasudo"

    cocoasudoSize = subutai.GetFileSize(cocoasudoFile)
    traySize = subutai.GetFileSize(trayFile)
    libsshSize = subutai.GetFileSize(libsshFile)
    totalSize = cocoasudoSize + traySize + libsshSize
    cocoasudoProgress = 0
    trayProgress = 0
    libsshProgress = 0

    if not os.path.exists(installDir+"bin/cocoasudo"):
        subutai.AddStatus("Downloading cocoasudo application")
        subutai.download(cocoasudoFile)
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            cocoasudoProgress = subutai.GetBytesDownload()
            updateProgress(cocoasudoProgress, trayProgress, libsshProgress,
                           totalSize)

        try:
            copyfile(tmpDir+cocoasudoFile, installDir+"bin/cocoasudo")
            st = os.stat(installDir+"bin/cocoasudo")
            os.chmod(installDir+"bin/cocoasudo", st.st_mode | stat.S_IEXEC)
        except:
            subutai.RaiseError("Failed to install cocoasudo. Aborting")
            sleep(10)
            return -99

    cocoasudoProgress = cocoasudoSize

    subutai.AddStatus("Download Tray application")

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

    trayProgress = traySize

    subutai.AddStatus("Installing Tray")

    try:
        tar = tarfile.open(tmpDir+"/"+trayFile, "r:gz")
        tar.extractall("/Applications/Subutai")
        tar.close()
    except:
        subutai.RaiseError("Failed to unpack Tray archive. Aborting")
        sleep(10)
        return 86

    subutai.AddStatus("Installing Tray dependencies")
    subutai.download(libsshFile)
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        libsshProgress = subutai.GetBytesDownload()
        updateProgress(cocoasudoProgress, trayProgress, libsshProgress,
                       totalSize)

    libsshProgress = libsshSize

    try:
        call([installDir+'bin/cocoasudo',
              '-prompt="Install libssh"',
              'installer',
              '-pkg',
              tmpDir+'/'+libsshFile,
              '-target',
              '/'])
    except:
        subutai.RaiseError("Failed to install libssh. Aborting")
        sleep(10)
        return -99

    try:
        launch = 'tell application "SubutaiTray.app" to activate'
        p = Popen(['osascript', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
        stdout, stderr = p.communicate(launch)
    except:
        subutai.RaiseError("Failed to launch Subutai Tray application")

    subutai.Shutdown()

    return 0