Exemple #1
0
def scp_from(server, src, dst):
    general.shell_run("scp -r " + server + ":" + src + " " + dst,
                      events={
                          'Are you sure you want to continue connecting \(yes\/no\)\?': "YES\n",
                          server + "\'s password\:": app.get_root_password() + "\n"
                      }
    )
Exemple #2
0
def scp_from(server, src, dst):
    general.shell_run(
        "scp -r " + server + ":" + src + " " + dst,
        events={
            'Are you sure you want to continue connecting \(yes\/no\)\?':
            "YES\n",
            server + "\'s password\:": app.get_root_password() + "\n"
        })
Exemple #3
0
def download_cert(filename):
    '''
    Get certificate from ldap server.

    This is not needed to be done on the server.

    '''
    #Creating certs folder
    x("mkdir -p /etc/openldap/cacerts")

    ip = config.general.get_ldap_server_ip()
    fullpath = '/etc/openldap/cacerts/' + filename
    shell_run("scp root@%s:%s %s" % (ip, fullpath, fullpath),
        events={
            'Are you sure you want to continue connecting \(yes\/no\)\?': "YES\n",
            "root@" + ip + "\'s password\:": app.get_root_password() + "\n"
        }
    )
Exemple #4
0
def asadmin_exec(command, admin_port=None, events=None):
    if admin_port:
        cmd = "/usr/local/glassfish5/bin/asadmin --port " + admin_port + " " + command
    else:
        cmd = "/usr/local/glassfish5/bin/asadmin --echo " + command

    if events:
        return general.shell_run(cmd, user="******", events=events)
    else:
        return x(cmd, user="******")
Exemple #5
0
def asadmin_exec(command, admin_port=None, events=None):
    if (admin_port):
        cmd = GLASSFISH_INSTALL_PATH + "bin/asadmin --port " + admin_port + " " + command
    else:
        cmd = GLASSFISH_INSTALL_PATH + "bin/asadmin " + command

    if (events):
        return general.shell_run(cmd, user="******", events=events)
    else:
        return x(cmd, user="******")
Exemple #6
0
def asadmin_exec(command, admin_port=None, events=None):
  if (admin_port):
    cmd = GLASSFISH_INSTALL_PATH + "/bin/asadmin --port " + admin_port + " " + command
  else:
    cmd = GLASSFISH_INSTALL_PATH + "/bin/asadmin --echo " + command

  if (events):
    return general.shell_run(cmd, user="******", events=events)
  else:
    return x(cmd, user="******")
Exemple #7
0
def asadmin_exec(command, admin_port=None, events=None):
    if admin_port:
        cmd = "/usr/local/glassfish4/bin/asadmin --port " + admin_port + " " + command
    else:
        cmd = "/usr/local/glassfish4/bin/asadmin --echo " + command

    if events:
        return general.shell_run(cmd, user="******", events=events)
    else:
        return x(cmd, user="******")
Exemple #8
0
def download_cert(filename):
    """
    Get certificate from ldap server.

    This is not needed to be done on the server.

    """
    # Creating certs folder
    x("mkdir -p /etc/openldap/cacerts")

    ip = config.general.get_ldap_server_ip()
    fullpath = '/etc/openldap/cacerts/' + filename
    shell_run("scp root@%s:%s %s" % (ip, fullpath, fullpath),
              events={
                  'Are you sure you want to continue connecting \(yes\/no\)\?':
                  "YES\n",
                  "root@" + ip + "\'s password\:":
                  app.get_root_password() + "\n"
              })
Exemple #9
0
def umount_syco(args):
  '''
  SSH Umount all syco servers on ~/mount/XX

  Tested on Ubuntu and os x.

  '''
  app.print_verbose("Umount syco servers.")

  # Cache master password.
  app.get_root_password()

  user_name = pwd.getpwuid(os.getuid()).pw_name

  for hostname in config.get_servers():
    ip = config.host(hostname).get_back_ip()
    mount_dir = os.environ['HOME'] + "/mount/" + hostname

    if os.access(mount_dir, os.W_OK):
      shell_run("umount " + mount_dir)
Exemple #10
0
def umount_syco(args):
    '''
  SSH Umount all syco servers on ~/mount/XX

  Tested on Ubuntu and os x.

  '''
    app.print_verbose("Umount syco servers.")

    # Cache master password.
    app.get_root_password()

    user_name = pwd.getpwuid(os.getuid()).pw_name

    for hostname in config.get_servers():
        ip = config.host(hostname).get_back_ip()
        mount_dir = os.environ['HOME'] + "/mount/" + hostname

        if os.access(mount_dir, os.W_OK):
            shell_run("umount " + mount_dir)
Exemple #11
0
def _install_jdk():
    '''
  Installation of the java sdk.

  '''
    if (not os.access(JDK_INSTALL_PATH, os.F_OK)):
        os.chdir(app.INSTALL_DIR)
        if (not os.access(JDK_INSTALL_FILE, os.F_OK)):
            general.download_file(JDK_REPO_URL, user="******")
            x("chmod u+rx " + JDK_INSTALL_FILE)

        if (os.access(JDK_INSTALL_FILE, os.F_OK)):
            general.shell_run("./" + JDK_INSTALL_FILE,
                              events={
                                  "ename: ": "A\r\n",
                                  "Press Enter to continue.....": "\r\n\r\n",
                                  "timeout": "-1"
                              })
        else:
            raise Exception("Not able to download " + JDK_INSTALL_FILE)
def _install_jdk():
  '''
  Installation of the java sdk.

  '''
  if (not os.access(JDK_INSTALL_PATH, os.F_OK)):
    os.chdir(app.INSTALL_DIR)
    if (not os.access(JDK_INSTALL_FILE, os.F_OK)):
      general.download_file(JDK_REPO_URL, user="******")
      x("chmod u+rx " + JDK_INSTALL_FILE)

    if (os.access(JDK_INSTALL_FILE, os.F_OK)):
      general.shell_run("./" + JDK_INSTALL_FILE,
        events={
          "ename: ": "A\r\n",
          "Press Enter to continue.....": "\r\n\r\n",
          "timeout":"-1"
        }
      )
    else:
      raise Exception("Not able to download " + JDK_INSTALL_FILE)
Exemple #13
0
def mount_syco(args):
    '''
  SSH Mount all syco servers to ~/mount/XX

  Tested on Ubuntu and os x.

  '''
    app.print_verbose("Mount syco servers.")

    # Cache master password.
    app.get_root_password()

    user_name = pwd.getpwuid(os.getuid()).pw_name

    # What servers to install
    remote_host = []
    if args[1] == "":
        remote_host = config.get_servers()
    else:
        remote_host.append(args[1])

    for hostname in remote_host:
        ip = config.host(hostname).get_back_ip()
        app.print_verbose("Mount ~/mount/" + hostname + " from " + ip)
        obj = ssh.Ssh(ip, app.get_root_password())
        if (obj.is_alive()):
            obj.install_ssh_key()

            # ssh_mount_server
            mount_dir = os.environ['HOME'] + "/mount/" + hostname

            if not os.access(mount_dir, os.W_OK):
                os.makedirs(mount_dir)

            shell_run("umount " + mount_dir, user=user_name)
            sshopt = "-o StrictHostKeychecking=no -o BatchMode=yes -o PasswordAuthentication=no -o GSSAPIAuthentication=no"
            shell_run("sshfs root@" + ip + ":/opt/ " + mount_dir +
                      " -oauto_cache,reconnect " + sshopt,
                      user=user_name)
Exemple #14
0
def mount_syco(args):
  '''
  SSH Mount all syco servers to ~/mount/XX

  Tested on Ubuntu and os x.

  '''
  app.print_verbose("Mount syco servers.")

  # Cache master password.
  app.get_root_password()

  user_name = pwd.getpwuid(os.getuid()).pw_name

  # What servers to install
  remote_host = []
  if args[1] == "":
    remote_host = config.get_servers()
  else:
    remote_host.append(args[1])

  for hostname in remote_host:
    ip = config.host(hostname).get_back_ip()
    app.print_verbose("Mount ~/mount/" + hostname + " from " + ip)
    obj = ssh.Ssh(ip, app.get_root_password())
    if (obj.is_alive()):
      obj.install_ssh_key()

      # ssh_mount_server
      mount_dir = os.environ['HOME'] + "/mount/" + hostname

      if not os.access(mount_dir, os.W_OK):
        os.makedirs(mount_dir)

      shell_run("umount " + mount_dir, user=user_name)
      sshopt = "-o StrictHostKeychecking=no -o BatchMode=yes -o PasswordAuthentication=no -o GSSAPIAuthentication=no"
      shell_run("sshfs root@" + ip + ":/opt/ " + mount_dir + " -oauto_cache,reconnect " + sshopt, user=user_name)