Beispiel #1
0
def service_update(hostname):
    """
    Runs a series of typical service update operations in the
    range of servers for the hive infra-structure.

    These operations are safe to be run in any occasion as they
    do not create any data destruction or change.

    @type hostname: String
    @param hostname: The name of the host to be used for this
    operation, this should be a fully qualified name.
    """

    ssh = deployers.get_ssh(hostname)
    uptime_s = deployers.uptime(ssh)
    deployers.print_host(hostname, uptime_s)

    dns_update(hostname)
    dhcp_update(hostname)
    apt_update(hostname)
Beispiel #2
0
def upgrade(hostname):
    ssh = deployers.get_ssh(hostname)
    deployers.print_host(hostname, "system upgrading...")
    deployers.update_apt(ssh)
    deployers.print_host(hostname, "system upgraded")
    deployers.reboot(ssh)
    deployers.print_host(hostname, "reboot order sent")
Beispiel #3
0
def cleermob_backup(hostname):
    date_s = deployers.get_date_s()
    file_name = "cleermob_%s.sql.gz" % date_s
    cleermob_path = os.path.join(config.BACKUPS_PATH, "cleermob")
    local_path = os.path.join(cleermob_path, file_name)
    if not os.path.exists(cleermob_path): os.makedirs(cleermob_path)

    ssh = deployers.get_ssh(hostname)
    deployers.print_host(hostname, "dumping database...")
    remote_path = deployers.mysql_dump(
        ssh,
        database = config.CLEER_DB_NAME,
        username = config.CLEER_DB_USERNAME,
        password = config.CLEER_DB_PASSWORD
    )
    deployers.print_host(hostname, "dumped database")
    deployers.print_host(hostname, "transferring file...")
    deployers.get(ssh, remote_path, local_path, remove = True)
    deployers.print_host(hostname, "file transfered")
Beispiel #4
0
def init(hostname):
    """
    Initializes the system, creating a series of files that
    may be required for a series of base operations.

    This script is recommended for every setup of a machine
    running under the current infrastructure.

    @type hostname: String
    @param hostname: The name of the host to be used for this
    operation, this should be a fully qualified name.
    """

    ssh = deployers.get_ssh(hostname)
    deployers.print_host(hostname, "deploying the ssh keys...")
    deployers.deploy_keys(ssh)
    deployers.print_host(hostname, "finished deploying the ssh keys")
    deployers.print_host(hostname, "creating users")
    deployers.create_users(ssh, config.USERS)
    deployers.print_host(hostname, "finished creating users...")
Beispiel #5
0
def omni_deploy(hostname, local_path = None):
    ssh = deployers.get_ssh(hostname)
    deployers.print_host(hostname, "deploying mysql...")
    db.mysql_deploy(hostname)
    deployers.print_host(hostname, "deployed mysql")
    deployers.print_host(hostname, "setting users...")
    deployers.mysql_add_user(ssh, config.OMNI_DB_USERNAME, config.OMNI_DB_PASSWORD)
    deployers.print_host(hostname, "transferring file...")
    deployers.put(ssh, local_path, "/tmp/omni_deploy.tar.gz", remove = False)
    deployers.print_host(hostname, "creating '%s' database..." % config.OMNI_DB_NAME)
    deployers.mysql_create_database(
        ssh,
        config.OMNI_DB_NAME,
        username = config.OMNI_DB_USERNAME,
        password = config.OMNI_DB_PASSWORD
    )
    deployers.print_host(hostname, "created database")
    deployers.print_host(hostname, "loading database...")
    deployers.mysql_load(
        ssh,
        database = config.OMNI_DB_NAME,
        path = "/tmp/omni_deploy.tar.gz",
        username = config.OMNI_DB_USERNAME,
        password = config.OMNI_DB_PASSWORD
    )
    deployers.print_host(hostname, "loaded database")
    deployers.print_host(hostname, "removing temporary files...")
    deployers.rm(ssh, "/tmp/omni_deploy.tar")
    deployers.rm(ssh, "/tmp/omni_deploy.tar.gz")
    deployers.print_host(hostname, "removed temporary files")
Beispiel #6
0
def apt_update(hostname):
    ssh = deployers.get_ssh(hostname)
    deployers.print_host(hostname, "upgrading software...")
    deployers.update_apt(ssh)
    deployers.print_host(hostname, "software upgraded")
Beispiel #7
0
def dhcp_update(hostname):
    ssh = deployers.get_ssh(hostname)
    if not hostname in config.DHCP_SERVERS: return
    config_v = config.DHCP_CONFIG.get(hostname, {})
    deployers.update_dhcp(ssh, **config_v)
    deployers.print_host(hostname, "updated dhcp registers")
Beispiel #8
0
def dns_update(hostname):
    ssh = deployers.get_ssh(hostname)
    if not hostname in config.DNS_SERVERS: return
    config_v = config.DNS_CONFIG.get(hostname, {})
    deployers.update_dns(ssh, **config_v)
    deployers.print_host(hostname, "updated dns registers")
Beispiel #9
0
def reboot(hostname):
    ssh = deployers.get_ssh(hostname)
    deployers.reboot(ssh)
    deployers.print_host(hostname, "reboot order sent")
Beispiel #10
0
def run_machine(method, *args):
    for hostname in config.MACHINE_SERVERS:
        try: method(hostname, *args)
        except BaseException as exception:
            deployers.print_host(hostname, str(exception))
Beispiel #11
0
def run_remote(method,*args):
    for hostname in config.REMOTE_SERVERS:
        try: method(hostname, *args)
        except BaseException as exception:
            deployers.print_host(hostname, str(exception))
Beispiel #12
0
def run_local(method, *args):
    for hostname in config.LOCAL_SERVERS:
        try: method(hostname, *args)
        except BaseException as exception:
            deployers.print_host(hostname, str(exception))