Exemplo n.º 1
0
from json import dumps

from boto.exception import EC2ResponseError
from dateutil.relativedelta import relativedelta
from fabric.api import env, local, put, settings, sudo, task, run
from fabric.contrib.files import append

from django_fabfile.instances import (attach_snapshot, create_temp_inst,
                                      get_avail_dev, get_vol_dev, mount_volume)
from django_fabfile.utils import (
    Config, StateNotChangedError, add_tags, config_temp_ssh,
    get_descr_attr, get_inst_by_id, get_region_conn, get_snap_device,
    get_snap_time, get_snap_vol, timestamp, wait_for, wait_for_sudo)


config = Config()
username = config.get('DEFAULT', 'USERNAME')
env.update({'user': username, 'disable_known_hosts': True})

logger = logging.getLogger(__name__)


def create_snapshot(vol, description='', tags=None, synchronously=True,
                    consistent=False):
    """Return new snapshot for the volume.

    vol
        volume to snapshot;
    synchronously
        wait for successful completion;
    description
Exemplo n.º 2
0
from fabric.api import env, settings, sudo, abort, put, task
from os.path import isfile as _isfile

from django_fabfile.utils import Config, get_inst_by_id


config = Config()


try:
    preconfigured_user = config.get('DEFAULT', 'USERNAME')
except:
    pass    # Expecting user to be provided as `-u` option.
else:
    FABRIC_DEFAULT_USER = '******'    # XXX `-u user` will be overridden.
    if env['user'] == FABRIC_DEFAULT_USER:  # Not provided as `-u` option.
        env.update({'user': preconfigured_user})

env.update({'disable_known_hosts': True})


def _sudo(cmd):
    """ Shows output of cmd and allows interaction """
    sudo(cmd, shell=False, pty=True)


def _create_account(username, region, instance_ids, passwordless, sudo):
    if not _isfile(username + '.pub'):
        abort("%s.pub does not exist" % username)
    env.ssh_key = username + '.pub'
    env.username = username     # Own attribute for string formatting.
Exemplo n.º 3
0
from datetime import date
import logging
import os
import sys

from fabric.api import output

from django_fabfile.utils import Config
from django_fabfile.version import __version__


__copyright__ = ('2010-{0}, oDesk http://www.odesk.com/. '
                 'All rights reserved.').format(date.today().year)

config = Config()

# Set up a specific logger with desired output level
LOG_FORMAT = '%(asctime)-15s %(levelname)s:%(message)s'
LOG_DATEFORMAT = '%Y-%m-%d %H:%M:%S %Z'

logger = logging.getLogger()

debug = config.getboolean('DEFAULT', 'DEBUG')
if debug:
    logger.setLevel(logging.DEBUG)
    output['debug'] = True
else:
    logger.setLevel(logging.INFO)

logging_folder = config.get('DEFAULT', 'LOGGING_FOLDER')
if logging_folder: