コード例 #1
0
ファイル: general.py プロジェクト: mattiashem/syco
def run_remote_command(host, command):
    shell_run("ssh root@{0} {1}".format(host, command),
                  events={
                      'Are you su1re you want to continue connecting \(yes\/no\)\?': "YES\n",
                      host + "\'s password\:": app.get_root_password() + "\n"
                  }
              )
コード例 #2
0
ファイル: remoteInstall.py プロジェクト: ysoldak/syco
    def _install_host(self, hostname):
        '''
        Execute the commands on the remote host.

        Create one process for each remote host.

        '''
        try:
            server = config.host(hostname).get_front_ip()
            app.print_verbose("Try to install " + hostname + " (" + server + ")", 2)

            obj = ssh.Ssh(server, app.get_root_password())
            self._validate_alive(obj, hostname)
            app.print_verbose("========================================================================================")
            app.print_verbose("=== Update " + hostname + " (" + server + ")")
            app.print_verbose("========================================================================================")

            obj.install_ssh_key()
            self._install_syco_on_remote_host(obj)
            self._execute_commands(obj, hostname)

        except pexpect.EOF, e:
            app.print_error(e, 2)

            # Remove progress state.
            if hostname in self._installed:
                del(self._installed[hostname])
コード例 #3
0
ファイル: general.py プロジェクト: ysoldak/syco
def _scp_from(server, src, dst):
    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"
              })
コード例 #4
0
ファイル: remoteInstall.py プロジェクト: anderska/syco-anders
  def _install_host(self, hostname):
    '''
    Execute the commands on the remote host.

    Create one process for each remote host.

    '''
    try:
      server = config.host(hostname).get_back_ip()
      app.print_verbose("Try to install " + hostname + " (" + server + ")", 2)

      obj = ssh.Ssh(server, app.get_root_password())
      self._validate_alive(obj, hostname)
      app.print_verbose("========================================================================================")
      app.print_verbose("=== Update " + hostname + " (" + server + ")")
      app.print_verbose("========================================================================================")

      obj.install_ssh_key()
      self._install_syco_on_remote_host(obj)
      self._execute_commands(obj, hostname)

    except pexpect.EOF, e:
      app.print_error(e, 2)

      # Remove progress state.
      if hostname in self.installed:
        del(self.installed[hostname])
コード例 #5
0
ファイル: ssh.py プロジェクト: Nemie/syco
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"
                      }
    )
コード例 #6
0
ファイル: general.py プロジェクト: mattiashem/syco
def is_server_root_open(server):
    """Check if root account is accessible."""
    ssh_con = ssh.Ssh(server, app.get_root_password())
    try:
        ssh_con.ssh_exec('whoami', silent = True)
        return True
    except Exception:
        return False
コード例 #7
0
def run_remote_command(host, command):
    shell_run(
        "ssh root@{0} {1}".format(host, command),
        events={
            'Are you su1re you want to continue connecting \(yes\/no\)\?':
            "YES\n",
            host + "\'s password\:": app.get_root_password() + "\n"
        })
コード例 #8
0
def is_server_root_open(server):
    """Check if root account is accessible."""
    ssh_con = ssh.Ssh(server, app.get_root_password())
    try:
        ssh_con.ssh_exec('whoami', silent=True)
        return True
    except Exception:
        return False
コード例 #9
0
ファイル: mount.py プロジェクト: Nemie/syco
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)
コード例 #10
0
ファイル: mount.py プロジェクト: anderska/syco-anders
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)
コード例 #11
0
ファイル: mount.py プロジェクト: anderska/syco-anders
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)
コード例 #12
0
ファイル: mount.py プロジェクト: Nemie/syco
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)
コード例 #13
0
ファイル: installHaproxy.py プロジェクト: arlukin/syco
def install_haproxy(args):
    app.print_verbose("Install HA Proxy version: %d" % script_version)
    version_obj = version.Version("InstallHaproxy", script_version)
    version_obj.check_executed()

    # Prompt for syco pw early, certificate copy requires root pw
    app.get_root_password()

    setup_global_vars()

    # Validate all command line parameters.
    if len(args) != 3:
        print_killmessage()

    env = haproxy_env(args)
    state = haproxy_state(args)

    install_packages("tcl haproxy")
    iptables.add_haproxy_chain()
    iptables.save()
    _copy_certificate_files(env)
    _configure_haproxy(env, state)

    version_obj.mark_executed()
コード例 #14
0
def install_haproxy(args):
    app.print_verbose("Install HA Proxy version: %d" % script_version)
    version_obj = version.Version("InstallHaproxy", script_version)
    version_obj.check_executed()

    # Prompt for syco pw early, certificate copy requires root pw
    app.get_root_password()

    setup_global_vars()

    # Validate all command line parameters.
    if len(args) != 3:
        print_killmessage()

    env = haproxy_env(args)
    state = haproxy_state(args)

    install_packages("tcl haproxy")
    iptables.add_haproxy_chain()
    iptables.save()
    _copy_certificate_files(env)
    _configure_haproxy(env, state)

    version_obj.mark_executed()
コード例 #15
0
ファイル: installSyco.py プロジェクト: anderska/syco-anders
def passwords(args):
  app.print_verbose("Set all passwords used by syco")
  app.init_all_passwords()
  print "root: ", app.get_root_password()
  print "svn: ", app.get_svn_password()
  print "ldap_admin: ", app.get_ldap_admin_password()
  print "ldap_sssd: ", app.get_ldap_sssd_password()
  print "glassfish_master: ", app.get_glassfish_master_password()
  print "glassfish_admin: ", app.get_glassfish_admin_password()
  print "glassfish_user: "******"glassfish")
  print "mysql_root: ", app.get_mysql_root_password()
  print "mysql_int: ", app.get_mysql_integration_password()
  print "mysql_stable: ", app.get_mysql_stable_password()
  print "mysql_uat: ", app.get_mysql_uat_password()
  print "mysql_prod: ", app.get_mysql_production_password()
コード例 #16
0
ファイル: vir.py プロジェクト: anderska/syco-anders
def vir_list(args):
  old_verbose = app.options.verbose
  app.options.verbose = 2
  try:
    for hostname in config.get_hosts():
      server = config.host(hostname).get_back_ip()

      obj = ssh.Ssh(server, app.get_root_password())

      app.print_verbose("List KVM guests on host " + hostname + " (" + server + ")")
      if (obj.is_alive()):
        obj.install_ssh_key()
        obj.ssh_exec("virsh list --all")
      else:
        app.print_verbose("   Not online.")
  except SettingsError, e:
    app.print_error(e, 2)
コード例 #17
0
ファイル: vir.py プロジェクト: ysoldak/syco
def vir_list(args):
  old_verbose = app.options.verbose
  app.options.verbose = 2
  try:
    for hostname in config.get_hosts():
      server = config.host(hostname).get_front_ip()

      obj = ssh.Ssh(server, app.get_root_password())

      app.print_verbose("List KVM guests on host " + hostname + " (" + server + ")")
      if (obj.is_alive()):
        obj.install_ssh_key()
        obj.ssh_exec("virsh list --all")
      else:
        app.print_verbose("   Not online.")
  except SettingsError, e:
    app.print_error(e, 2)
コード例 #18
0
ファイル: remoteInstall.py プロジェクト: anderska/syco-anders
  def remote_install_syco(self, hostname):
    '''
    Execute the commands on the remote host.

    Create one process for each remote host.

    '''
    try:
      server = config.host(hostname).get_back_ip()
      app.print_verbose("Install syco on " + hostname + " (" + server + ")", 2)

      obj = ssh.Ssh(server, app.get_root_password())
      self._validate_alive(obj, hostname)
      obj.install_ssh_key()
      self._install_syco_on_remote_host(obj)

    except pexpect.EOF, e:
      app.print_error(e, 2)
コード例 #19
0
ファイル: installSyco.py プロジェクト: rikardev/syco
def passwords(args):
    app.print_verbose("Set all passwords used by syco")
    app.init_all_passwords()
    print "root: ", app.get_root_password()
    print "svn: ", app.get_svn_password()
    print "ldap_admin: ", app.get_ldap_admin_password()
    print "ldap_sssd: ", app.get_ldap_sssd_password()
    print "glassfish_master: ", app.get_glassfish_master_password()
    print "glassfish_admin: ", app.get_glassfish_admin_password()
    print "glassfish_user: "******"glassfish")
    print "mysql_root: ", app.get_mysql_root_password()
    print "mysql_int: ", app.get_mysql_integration_password()
    print "mysql_stable: ", app.get_mysql_stable_password()
    print "mysql_uat: ", app.get_mysql_uat_password()
    print "mysql_prod: ", app.get_mysql_production_password()
    print "mysql_backup: ", app.get_mysql_backup_password()
    print "mysql_monitor: ", app.get_mysql_monitor_password()
    print "switch_icmp: ", app.get_switch_icmp_password()
コード例 #20
0
ファイル: installSssd.py プロジェクト: eliskullberg/syco
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"
        }
    )
コード例 #21
0
ファイル: installSssd.py プロジェクト: ysoldak/syco
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"
              })
コード例 #22
0
ファイル: remoteInstall.py プロジェクト: anderska/syco-anders
    def remote_install_syco(self, hostname):
        '''
    Execute the commands on the remote host.

    Create one process for each remote host.

    '''
        try:
            server = config.host(hostname).get_back_ip()
            app.print_verbose(
                "Install syco on " + hostname + " (" + server + ")", 2)

            obj = ssh.Ssh(server, app.get_root_password())
            self._validate_alive(obj, hostname)
            obj.install_ssh_key()
            self._install_syco_on_remote_host(obj)

        except pexpect.EOF, e:
            app.print_error(e, 2)
コード例 #23
0
ファイル: installBackup.py プロジェクト: anderska/syco-anders
def _setup_backup_for_all_servers():
    servers = config.get_servers()
    total_servers = len(servers)
    checked_servers = 0
    while (len(servers)):
        checked_servers += 1
        hostname = servers.pop()
        ip = config.host(hostname).get_back_ip()
        remote_server = ssh.Ssh(ip, app.get_root_password())
        if (remote_server.is_alive()):
            remote_server.install_ssh_key()
            _configure_backup_pathes(remote_server, ip, hostname)
        else:
            servers.insert(0, hostname)
            app.print_error("Server " + hostname + " is not alive.")

        if (checked_servers > total_servers):
            total_servers = len(servers)
            checked_servers = 0
            time.sleep(60)
コード例 #24
0
ファイル: installBackup.py プロジェクト: Nemie/syco
def _setup_backup_for_all_servers():
  servers = config.get_servers()
  total_servers = len(servers)
  checked_servers = 0
  while(len(servers)):
    checked_servers += 1
    hostname = servers.pop()
    ip = config.host(hostname).get_back_ip()
    remote_server = ssh.Ssh(ip, app.get_root_password())
    if (remote_server.is_alive()):
      remote_server.install_ssh_key()
      _configure_backup_pathes(remote_server, ip, hostname)
    else:
      servers.insert(0, hostname)
      app.print_error("Server " + hostname + " is not alive.")

    if (checked_servers > total_servers):
      total_servers = len(servers)
      checked_servers = 0
      time.sleep(60)