Fetch the CQL that can be used to recreate the current environment's keyspace
 @return [String] CQL commands
 @raise [RuntimeError] if the {Cassie.configuration[:keyspace]} keyspace could not be described.
346537
def keyspace_structure
      @keyspace_structure ||= begin
        args = ["-e", "'DESCRIBE KEYSPACE #{Cassie.configuration[:keyspace]}'"]
        runner = Cassie::Support::SystemCommand.new("cqlsh", args)
        runner.succeed

        runner.output
      end
    end
1352796
def namedb_get_all_importing_namespace_hashes( self, current_block ):
    

    query = "SELECT preorder_hash FROM namespaces WHERE (op = ? AND reveal_block < ?) OR (op = ? AND block_number < ?);"
    args = (NAMESPACE_REVEAL, current_block + NAMESPACE_REVEAL_EXPIRE, NAMESPACE_PREORDER, current_block + NAMESPACE_PREORDER_EXPIRE )

    namespace_rows = namedb_query_execute( cur, query, args )
    ret = []
    for namespace_row in namespace_rows:
        ret.append( namespace_row['preorder_hash'] )

    return ret
496634
def get_fun(fun):
    '''
    
    '''
    query = '''SELECT minion_id, last_fun FROM {keyspace}.minions
               WHERE last_fun = ?;'''.format(keyspace=_get_keyspace())

    ret = {}

    # cassandra_cql.cql_query may raise a CommandExecutionError
    try:
        data = __salt__['cassandra_cql.cql_query'](query, 'get_fun', [fun])
        if data:
            for row in data:
                minion = row.get('minion_id')
                last_fun = row.get('last_fun')
                if minion and last_fun:
                    ret[minion] = last_fun
    except CommandExecutionError:
        log.critical('Could not get the list of minions.')
        raise
    except Exception as e:
        log.critical(
            'Unexpected error while getting list of minions: %s', e)
        raise

    return ret
782792
def get_source(self, key, name_spaces=None, default_prefix=''):
        
        source = self.source or key
        prefix = default_prefix
        if name_spaces and self.name_space and self.name_space in name_spaces:
            prefix = ''.join([name_spaces[self.name_space], ':'])
        return ''.join([prefix, source])
624276
def namespace(namespace = nil, options = {})
      return @namespace unless namespace

      @namespace      = namespace.to_sym if namespace
      @base_namespace = options[:base].to_sym if options[:base]
    end
1310681
def get(self, namespace, key):
        """"""
        cfg = self.dbconfig.get(key, namespace, as_object=True)
        return self.make_response({
            'message': None,
            'config': cfg
        })
1129294
@NonNull
  public static CreateKeyspaceStart createKeyspace(@NonNull String keyspaceName) {
    return createKeyspace(CqlIdentifier.fromCql(keyspaceName));
  }
176507
def namedb_get_namespace_preorder( db, namespace_preorder_hash, current_block ):
    

    cur = db.cursor()
    select_query = "SELECT * FROM preorders WHERE preorder_hash = ? AND op = ? AND block_number < ?;"
    args = (namespace_preorder_hash, NAMESPACE_PREORDER, current_block + NAMESPACE_PREORDER_EXPIRE)
    preorder_rows = namedb_query_execute( cur, select_query, args )

    preorder_row = preorder_rows.fetchone()
    if preorder_row is None:
        # no such preorder 
        return None 

    preorder_rec = {}
    preorder_rec.update( preorder_row )

    # make sure that the namespace doesn't already exist 
    cur = db.cursor()
    select_query = "SELECT preorder_hash FROM namespaces WHERE preorder_hash = ? AND ((op = ?) OR (op = ? AND reveal_block < ?));"
    args = (namespace_preorder_hash, NAMESPACE_READY, NAMESPACE_REVEAL, current_block + NAMESPACE_REVEAL_EXPIRE)
    ns_rows = namedb_query_execute( cur, select_query, args )

    ns_row = ns_rows.fetchone()
    if ns_row is not None:
        # exists
        return None 

    return preorder_rec
801949
def init_tables
      # Do nothing if keyspace already exists
      if @cassandra.keyspaces.include?(@keyspace)
        @cassandra.keyspace = @keyspace
      else
        freq_table    = Cassandra::ColumnFamily.new({:keyspace => @keyspace, :name => "classes"}) # word  => {classname => count}
        summary_table = Cassandra::ColumnFamily.new({:keyspace => @keyspace, :name => "totals"})  # class => {wordcount => count}
        ks_def = Cassandra::Keyspace.new({
            :name               => @keyspace,
            :strategy_class     => 'org.apache.cassandra.locator.SimpleStrategy',
            :replication_factor => 1,
            :cf_defs            => [freq_table, summary_table] 
          })
        @cassandra.add_keyspace ks_def
        @cassandra.keyspace = @keyspace
      end
    end
53220
def get_instance namespace, classname=nil, properties={}
    case namespace
    when Sfcc::Cim::ObjectPath
      objectpath = namespace
      namespace = objectpath.namespace
    else
      objectpath = objectpath namespace.to_s, classname, properties
    end
    ret = []
    @client.get_instance(objectpath)
  end
989250
def get_all_preordered_namespace_hashes( self ):
        
        cur = self.db.cursor()
        namespace_hashes = namedb_get_all_preordered_namespace_hashes( cur, self.lastblock )
        return namespace_hashes
839983
def load_options(self, argv=None, keyring_namespace=None):
        
        defaults = self.get_defaults()
        args = self.cli_values(argv=argv)
        env = self.parse_env()
        secrets = self.parse_keyring(keyring_namespace)
        ini = self.parse_ini()

        results = defaults
        results.update(ini)
        results.update(secrets)
        results.update(env)
        results.update(args)
        return results
129993
def get_minions():
    '''
    
    '''
    query = '''SELECT DISTINCT minion_id
               FROM {keyspace}.minions;'''.format(keyspace=_get_keyspace())

    ret = []

    # cassandra_cql.cql_query may raise a CommandExecutionError
    try:
        data = __salt__['cassandra_cql.cql_query'](query)
        if data:
            for row in data:
                minion = row.get('minion_id')
                if minion:
                    ret.append(minion)
    except CommandExecutionError:
        log.critical('Could not get the list of minions.')
        raise
    except Exception as e:
        log.critical(
            'Unexpected error while getting list of minions: %s', e)
        raise

    return ret
222971
@Override
    public void createNamespace() {
        KeyspaceMetadata ksMetadata = m_cluster.getMetadata().getKeyspace(m_keyspace);
        if (ksMetadata == null) {
            new CQLSchemaManager(this).createKeyspace();
        }
    }
820679
def export_as_string(self):
        
        cql = "\n\n".join([self.as_cql_query() + ';'] +
                          self.user_type_strings() +
                          [f.export_as_string() for f in self.functions.values()] +
                          [a.export_as_string() for a in self.aggregates.values()] +
                          [t.export_as_string() for t in self.tables.values()])
        if self._exc_info:
            import traceback
            ret = "/*\nWarning: Keyspace %s is incomplete because of an error processing metadata.\n" % \
                  (self.name)
            for line in traceback.format_exception(*self._exc_info):
                ret += line
            ret += "\nApproximate structure, for reference:\n(this should not be used to reproduce this schema)\n\n%s\n*/" % cql
            return ret
        if self.virtual:
            return ("/*\nWarning: Keyspace {ks} is a virtual keyspace and cannot be recreated with CQL.\n"
                    "Structure, for reference:*/\n"
                    "{cql}\n"
                    "").format(ks=self.name, cql=cql)
        return cql
1244038
def _set_keyspace_for_all_pools(self, keyspace, callback):
        
        with self._lock:
            self.keyspace = keyspace
            remaining_callbacks = set(self._pools.values())
        errors = {}

        if not remaining_callbacks:
            callback(errors)
            return

        def pool_finished_setting_keyspace(pool, host_errors):
            remaining_callbacks.remove(pool)
            if host_errors:
                errors[pool.host] = host_errors

            if not remaining_callbacks:
                callback(host_errors)

        for pool in tuple(self._pools.values()):
            pool._set_keyspace_for_all_conns(keyspace, pool_finished_setting_keyspace)
1335975
def _get_space(self):
        
        assert 'space' in self.config, 'The search space is NOT configured!'
        
        space_config = self.config['space']
        constraint_config = self.config['constraints']
        from ..core.task.space import Design_space
        return Design_space.fromConfig(space_config, constraint_config)