コード例 #1
0
ファイル: p2p-install.py プロジェクト: subutai-attic/launcher
def subutaistart():
    rc = 0
    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()

    p2p = subup.P2P(tmpDir, installDir)
    rc = p2p.PreInstall()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc
    rc = p2p.Download()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc
    rc = p2p.PostInstall()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc
    subutai.SetProgress(1.00)

    sleep(3)
    subutai.Shutdown()

    return 0
コード例 #2
0
ファイル: e2e-install.py プロジェクト: subutai-attic/launcher
def subutaistart():
    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()

    rc = 0

    e2e = subup.E2E(tmpDir, installDir)
    rc = e2e.PreInstall()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc
    rc = e2e.Download()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc
    rc = e2e.Install()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc
    rc = e2e.PostInstall()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc

    subutai.Shutdown()
    return 0
コード例 #3
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
コード例 #4
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
コード例 #5
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()
コード例 #6
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()
コード例 #7
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
コード例 #8
0
def subutaistart():
    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()

    tray = subup.Tray(tmpDir, installDir)
    tray.PreInstall()
    tray.Download()
    tray.PostInstall()

    subutai.Shutdown()

    return 0
コード例 #9
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()
コード例 #10
0
def subutaistart():
    coreFile = "core.ova"
    vboxFile = "VirtualBox.pkg"
    ubuntuFile = "ubuntu16-subutai-template_4.0.0_amd64.tar.gz"
    openjreFile = "openjre16-subutai-template_4.0.0_amd64.tar.gz"
    mngFile = "management"
    progress = subuco.Progress(coreFile,
                               vboxFile,
                               ubuntuFile,
                               openjreFile,
                               mngFile)

    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()
    rc = subup.InstallPeerPrerequisites(tmpDir, installDir, progress)
    if rc != 0:
        subutai.RaiseError("Failed to install prerequisites")
        sleep(10)
        return 29

    sleep(3)

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

    peer = subuco.SubutaiPeer(subup.GetVirtualMachineName(),
                              progress,
                              ubuntuFile,
                              openjreFile,
                              mngFile)

    if peer.SetupVirtualMachine() != 0:
        sleep(10)
        subutai.Shutdown()
        return

    peer.ConfigureNetwork()

    rc = peer.StartVirtualMachine()

    subutai.AddStatus("Waiting for peer to start and initialize")
    sleep(40)
    if subutai.CheckVMRunning(peer.GetName()) != 0:
        peer.StartVirtualMachine()
        sleep(50)

    if subutai.CheckVMRunning(peer.GetName()) != 0:
        subutai.RaiseError("Aborting")
        sleep(15)
        subutai.Shutdown()
        return 21

    progress.spin()
    rc = peer.WaitSSH()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc

    peer.SetupSSH()
    rc = peer.waitForNetwork()
    if rc != 0:
        sleep(10)
        return rc
    rc = peer.InstallSnap()
    if rc != 0:
        subutai.RaiseError("Failed to install Subutai. Aborting")
        sleep(10)
        subutai.Shutdown()
        return rc
    peer.InitBTRFS()
    peer.SetupAlias()
    peer.RetrievePeerIP()
    progress.unspin()
    peer.InstallUbuntu()
    peer.installOpenJRE()
    peer.installManagement()
    peer.WaitPeerResponse()
    subutai.SetProgress(1.0)
    subutai.Shutdown()

    return 0
コード例 #11
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
コード例 #12
0
ファイル: rh-install.py プロジェクト: subutai-attic/launcher
def subutaistart():
    coreFile = "core.ova"
    vboxFile = "VirtualBox.pkg"
    progress = subuco.Progress()
    progress.setCore(coreFile)
    progress.setVBox(vboxFile)
    progress.calculateTotal()

    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()
    rc = subup.InstallPeerPrerequisites(tmpDir, installDir, progress)
    if rc != 0:
        subutai.RaiseError("Failed to install prerequisites")
        sleep(10)
        return 29

    sleep(3)

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

    peer = subuco.SubutaiPeer(subup.GetVirtualMachineName(), progress, "", "",
                              "")

    if peer.SetupVirtualMachine() != 0:
        sleep(10)
        subutai.Shutdown()
        return

    peer.ConfigureNetwork()

    rc = peer.StartVirtualMachine()

    subutai.AddStatus("Waiting for RH to start and initialize")
    sleep(40)
    if subutai.CheckVMRunning(peer.GetName()) != 0:
        peer.StartVirtualMachine()
        sleep(50)

    if subutai.CheckVMRunning(peer.GetName()) != 0:
        subutai.RaiseError("Aborting")
        sleep(15)
        subutai.Shutdown()
        return 21

    progress.spin()
    rc = peer.WaitSSH()
    if rc != 0:
        sleep(10)
        subutai.Shutdown()
        return rc

    peer.SetupSSH()
    rc = peer.WaitForNetwork()
    if rc != 0:
        sleep(10)
        return rc
    rc = peer.InstallSnap()
    if rc != 0:
        subutai.RaiseError("Failed to install Subutai. Aborting")
        sleep(10)
        subutai.Shutdown()
        return rc
    peer.InitBTRFS()
    peer.SetupAlias()
    peer.RetrievePeerIP()
    progress.unspin()
    subutai.SetProgress(1.0)
    subutai.Shutdown()

    return 0
コード例 #13
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
コード例 #14
0
def subutaistart():

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

    nssmSize = subutai.GetFileSize("nssm.exe")
    p2pSize = subutai.GetFileSize("p2p.exe")
    tuntapSize = subutai.GetFileSize("tap-windows-9.21.2.exe")
    totalSize = nssmSize + p2pSize + tuntapSize
    nssmProgress = 0
    p2pProgress = 0
    tuntapProgress = 0

    subutai.AddStatus("Installing Service Manager")

    if os.path.exists(installDir + "nssm.exe"):
        subutai.UnregisterService("Subutai P2P")
        sleep(30)
        subutai.ProcessKill("nssm.exe")
        subutai.download("nssm.exe")
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            nssmProgress = subutai.GetBytesDownload()
            updateProgress(nssmProgress, p2pProgress, tuntapProgress,
                           totalSize)

        copyfile(tmpDir + "nssm.exe", installDir + "bin/nssm.exe")

    if not os.path.exists(installDir + "nssm.exe"):
        subutai.download("nssm.exe")
        while subutai.isDownloadComplete() != 1:
            sleep(0.05)
            nssmProgress = subutai.GetBytesDownload()
            updateProgress(nssmProgress, p2pProgress, tuntapProgress,
                           totalSize)

        subutai.UnregisterService("Subutai P2P")
        sleep(30)
        subutai.ProcessKill("nssm.exe")
        copyfile(tmpDir + "nssm.exe", installDir + "bin/nssm.exe")

    nssmProgress = nssmSize

    subutai.AddStatus("Downloading p2p binary")
    subutai.download("p2p.exe")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        p2pProgress = subutai.GetBytesDownload()
        updateProgress(nssmProgress, p2pProgress, tuntapProgress, totalSize)

    p2pProgress = p2pSize

    subutai.AddStatus("Downloading extra tools")
    subutai.download("tap-windows-9.21.2.exe")
    while subutai.isDownloadComplete() != 1:
        sleep(0.05)
        tuntapProgress = subutai.GetBytesDownload()
        updateProgress(nssmProgress, p2pProgress, tuntapProgress, totalSize)

    tuntapProgress = tuntapSize

    subutai.ProcessKill("p2p.exe")
    subutai.AddStatus("Installing P2P")
    if os.path.exists(installDir + "bin/p2p.exe"):
        subutai.AddStatus("Removing previous installation")
        os.remove(installDir + "bin/p2p.exe")

    if os.path.exists(installDir + "bin/p2p.exe"):
        subutai.RaiseError("Failed to remove p2p binary")

    subutai.AddStatus("Copying files")
    copyfile(tmpDir + "p2p.exe", installDir + "bin/p2p.exe")

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

    subutai.AddStatus("Registering P2P as a Windows service")
    subutai.RegisterService("Subutai P2P", installDir + "bin/p2p.exe|daemon")

    subutai.AddStatus("Installing TUN/TAP driver")
    call([tmpDir + 'tap-windows-9.21.2.exe', '/S'])

    sleep(5)

    subutai.Shutdown()

    return 0
コード例 #15
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
コード例 #16
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
コード例 #17
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
コード例 #18
0
def subutaistart():
    tmpDir = subutai.GetTmpDir()
    installDir = subutai.GetInstallDir()
    m = hashlib.md5()
    m.update(datetime.datetime.now().isoformat().encode('utf-8'))
    machineName = "subutai-ld-" + m.hexdigest()[:5]

    coreFile = "core.ova"
    vboxFile = "virtualbox-5.1_xenial_amd64.deb"
    vnum = subutai.GetOSVersionNumber()
    if vnum == "16.10":
        vboxFile = "virtualbox-5.1_yakkety_amd64.deb"
    elif vnum == "17.04":
        vboxFile = "virtualbox-5.1_zesty_amd64.deb"
    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)
    rc = installVBox(vboxFile, tmpDir, installDir, progress)
    if rc != 0:
        sleep(10)
        return rc

    call(['ssh-keygen', '-R', '[127.0.0.1]:4567'])

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

    enableHostonlyif()

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

    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)
        return 21

    rc = waitSSH()
    if rc != 0:
        return rc

    setupSSH()
    rc = waitForNetwork()
    if rc != 0:
        sleep(10)
        return rc

    rc = installSnapFromStore()
    if rc != 0:
        subutai.RaiseError("Failed to install Subutai. Aborting")
        sleep(10)
        subutai.Shutdown()
        return rc

    initBtrfs()
    setAlias()
    peerip = GetPeerIP()
    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)
        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(50)

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

    subutai.SetProgress(1.0)

    subutai.Shutdown()

    return 0