Start watching a new volume

    :type connection: boto.ec2.connection.EC2Connection
    :param connection: EC2 connection object
    :type file_name: str
    :param file_name: path to config file
    :returns: None
352050
def watch_from_file(connection, file_name):
    
    with open(file_name, 'r') as filehandle:
        for line in filehandle.xreadlines():
            volume, interval, retention = line.rstrip().split(',')
            watch(
                connection,
                get_volume_id(connection, volume),
                interval, retention)
718858
def init_db_conn(
        connection_name, HOST=None, PORT=None, DB=None, PASSWORD=None):
    
    rpool = redis.ConnectionPool(
        host=HOST, port=PORT, db=DB, password=PASSWORD)
    r = redis.Redis(connection_pool=rpool)
    redis_pool.connections[connection_name] = RedisClient(r)
190868
def init_db_conn(connection_name, HOSTS=None):
    
    el = elasticsearch.Elasticsearch(hosts=HOSTS)
    el_pool.connections[connection_name] = ElasticSearchClient(el)
283611
def open_connection(request)
      connection = ConnectionAdapters.establish_connection(request, dispatcher)

      assign_connection_id connection
      register_user_connection connection

      connections[connection.id] = connection

      info "Connection opened: #{connection}"
      connection.rack_response
    end
1062923
def _startRecording(self, filename):
        
        self.setOption('_log_file_name', filename)
        self.setOption('_log_input_only', True)
        self.setOption('_log', True)
342277
def on_connection_open(self, unused_connection):
        
        self._logger.info('Connection opened')
        self.add_on_connection_close_callback()
        self.open_channel()
397379
public static void openFile(Connection connection, String fileName, String tableName) throws SQLException {
        String ext = fileName.substring(fileName.lastIndexOf('.') + 1,fileName.length());
        final boolean isH2 = JDBCUtilities.isH2DataBase(connection.getMetaData());
        for(DriverDef driverDef : DRIVERS) {
            if(driverDef.getFileExt().equalsIgnoreCase(ext)) {
                try (Statement st = connection.createStatement()) {
                    st.execute(String.format("CREATE TABLE %s COMMENT %s ENGINE %s WITH %s",
                            TableLocation.parse(tableName, isH2).toString(isH2),StringUtils.quoteStringSQL(fileName),
                            StringUtils.quoteJavaString(driverDef.getClassName()),StringUtils.quoteJavaString(fileName)));
                }
                return;
            }
        }
        throw new SQLException("No driver is available to open the "+ext+" file format");
    }
847120
def _setup_source_conn(self, source_conn_id, source_bucket_name=None):
        
        self.source_conn = BaseHook.get_hook(source_conn_id)
        self.source_conn_id = source_conn_id

        # Workaround for getting hook in case of s3 connection
        # This is needed because get_hook silently returns None for s3 connections
        # See https://issues.apache.org/jira/browse/AIRFLOW-2316 for more info
        connection = BaseHook._get_connection_from_env(source_conn_id)
        self.log.info(connection.extra_dejson)
        if connection.conn_type == 's3':
            self.log.info("Setting up s3 connection {0}".format(source_conn_id))
            self.source_conn = S3Hook(aws_conn_id=source_conn_id)
            # End Workaround
            if source_bucket_name is None:
                raise AttributeError("Missing source bucket for s3 connection")
            self.source_bucket_name = source_bucket_name

        if not isinstance(self.source_conn, DbApiHook) and not isinstance(self.source_conn, S3Hook):
            raise AttributeError(
                "Only s3_csv, local and sql connection types are allowed, not {0}".format(type(self.source_conn)))
189959
def _new_conn(self):
        
        self.num_connections += 1
        log.info("Starting new HTTPS connection (%d): %s"
                 % (self.num_connections, self.host))

        if not ssl:
            return HTTPSConnection(host=self.host, port=self.port)

        connection = VerifiedHTTPSConnection(host=self.host, port=self.port)
        connection.set_cert(key_file=self.key_file, cert_file=self.cert_file,
                            cert_reqs=self.cert_reqs, ca_certs=self.ca_certs)
        return connection
57481
def list(connection):
    
    volumes = get_watched_volumes(connection)

    if not volumes:
        logger.info('No watched volumes found')
        return

    logger.info(
        '+-----------------------'
        '+----------------------'
        '+--------------'
        '+------------+')
    logger.info(
        '| {volume:<21} '
        '| {volume_name:<20.20} '
        '| {interval:<12} '
        '| {retention:<10} |'.format(
            volume='Volume ID',
            volume_name='Volume name',
            interval='Interval',
            retention='Retention'))
    logger.info(
        '+-----------------------'
        '+----------------------'
        '+--------------'
        '+------------+')

    for volume in volumes:
        if 'AutomatedEBSSnapshots' not in volume.tags:
            interval = 'Interval tag not found'
        elif volume.tags['AutomatedEBSSnapshots'] not in VALID_INTERVALS:
            interval = 'Invalid interval'
        else:
            interval = volume.tags['AutomatedEBSSnapshots']

        if 'AutomatedEBSSnapshotsRetention' not in volume.tags:
            retention = 0
        else:
            retention = volume.tags['AutomatedEBSSnapshotsRetention']

        # Get the volume name
        try:
            volume_name = volume.tags['Name']
        except KeyError:
            volume_name = ''

        logger.info(
            '| {volume_id:<14} '
            '| {volume_name:<20.20} '
            '| {interval:<12} '
            '| {retention:<10} |'.format(
                volume_id=volume.id,
                volume_name=volume_name,
                interval=interval,
                retention=retention))

    logger.info(
        '+-----------------------'
        '+----------------------'
        '+--------------'
        '+------------+')
706664
def _createConnection(self, connections):
        

        for c in connections:
            # Create GSSHAPY Connection object
            connection = Connection(slinkNumber=c['slinkNumber'],
                                    upSjuncNumber=c['upSjunc'],
                                    downSjuncNumber=c['downSjunc'])

            # Associate Connection with StormPipeNetworkFile
            connection.stormPipeNetworkFile = self
740555
def start(self):
        
        if self.via_ip:
            connect_to = self.via_ip
            self.description = '[%s@%s via %s]' % (self._user,
                                                   self._hostname,
                                                   self.via_ip)
        else:
            connect_to = self._hostname
            self.description = '[%s@%s]' % (self._user,
                                            self._hostname)

        exception = None
        for i in range(60):
            try:
                self._client.connect(
                    connect_to,
                    username=self._user,
                    allow_agent=True,
                    key_filename=self._key_filename)
            # NOTE(Gonéri): TypeError is in the list because of
            # https://github.com/paramiko/paramiko/issues/615
                self._transport = self._get_transport()
            except (OSError,
                    TypeError,
                    ssh_exception.SSHException,
                    ssh_exception.NoValidConnectionsError) as e:
                exception = e
                LOG.info('%s waiting for %s: %s' %
                         (self.description, connect_to, str(exception)))
                time.sleep(1)
            else:
                LOG.debug('%s connected' % self.description)
                self._started = True
                return

        _error = ("unable to connect to ssh service on '%s': %s" %
                  (self._hostname, str(exception)))
        LOG.error(_error)
        raise exception
531122
def _open_connection(self):
        
        if self._scheme == 'unix':
            self._connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
            self._connection.connect(self._path)
        elif self._scheme == 'tcp':
            self._connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP)
            self._connection.connect((self._host, self._port))
        elif self._scheme == 'http':
            self._connection =  httplib.HTTPConnection(self._host, self._port, strict=False)
        else:
            raise ConnectionError("Connection scheme not recognized!")
311623
def connect(self, connection_config=None, *args, **kwargs):
        
        if self.connected: return self.connected

        if connection_config: self.connection_config = connection_config

        self.connected = True
        try:
            self._connect(self.connection_config)

        except Exception as e:
            self.connected = False
            self.raise_error(e)

        self.log("Connected {}", self.connection_config.interface_name)
        return self.connected
45480
def run(connection):
    
    volumes = volume_manager.get_watched_volumes(connection)

    for volume in volumes:
        _ensure_snapshot(connection, volume)
        _remove_old_snapshots(connection, volume)
1193940
def connect_to_ec2(region, access_key_id, secret_access_key):
    
    conn = boto.ec2.connect_to_region(region,
                                      aws_access_key_id=access_key_id,
                                      aws_secret_access_key=secret_access_key)
    return conn
546647
def onConnect(self, request):
        
        logger.debug("Connection opened ({peer})".format(peer=self.peer))

        self.storage = {}
        self._client_id = str(uuid1())