Save the load to the specified jid id

    .. versionadded:: 2015.8.1
182481
def save_load(jid, load, minions=None):
    '''
    
    '''
    options = _get_options()

    index = options['master_job_cache_index']
    doc_type = options['master_job_cache_doc_type']

    if options['index_date']:
        index = '{0}-{1}'.format(index,
            datetime.date.today().strftime('%Y.%m.%d'))

    _ensure_index(index)

    # addressing multiple types (bool, string, dict, ...) issue in master_job_cache index for return key (#20826)
    if not load.get('return', None) is None:
        # if load.return is not a dict, moving the result to load.return.<job_fun_escaped>.return
        if not isinstance(load['return'], dict):
            job_fun_escaped = load['fun'].replace('.', '_')
            load['return'] = {job_fun_escaped: {'return': load['return']}}
        # rename load.return to load.data in order to have the same key in all indices (master_job_cache, job)
        load['data'] = load.pop('return')

    data = {
        'jid': jid,
        'load': load,
    }

    ret = __salt__['elasticsearch.document_create'](index=index,
                                                    doc_type=doc_type,
                                                    id=jid,
                                                    body=salt.utils.json.dumps(data))
655616
def get_load(jid):
    '''
    
    '''
    jid = _escape_jid(jid)
    conn = _get_conn()
    if conn is None:
        return None
    cur = conn.cursor()
    sql = '''SELECT jid, tgt_type, cmd, tgt, kwargs, ret, username, arg,''' \
          ''' fun FROM jids WHERE jid = %s'''
    cur.execute(sql, (jid,))
    data = cur.fetchone()
    if data:
        return _build_dict(data)
    _close_conn(conn)
    return {}
863693
def download(self, resource_id):
        
        self.resource_id(str(resource_id))
        self._request_uri = '{}/download'.format(self._request_uri)
1186157
def save(self):
        
        LOGGER.debug("NIC.save")
        post_payload = {}

        if self.id is not None:
            post_payload['nicID'] = self.id

        if self.name is not None:
            post_payload['nicName'] = self.name

        if self.mac_address is not None:
            post_payload['nicMacAddress'] = self.mac_address

        if self.duplex is not None:
            post_payload['nicDuplex'] = self.duplex

        if self.speed is not None:
            post_payload['nicSpeed'] = self.speed

        if self.mtu is not None:
            post_payload['nicMtu'] = self.mtu

        if self.nic_osi_id is not None:
            post_payload['nicOSInstanceID'] = self.nic_osi_id

        if self.nic_ipa_id is not None:
            post_payload['nicIPAddressID'] = self.nic_ipa_id

        args = {'http_operation': 'POST', 'operation_path': '', 'parameters': {'payload': json.dumps(post_payload)}}
        response = NICService.requester.call(args)
        if response.rc != 0:
            LOGGER.warning(
                'NIC.save - Problem while saving NIC ' + self.name +
                '. Reason: ' + str(response.response_content) + '-' + str(response.error_message) +
                " (" + str(response.rc) + ")"
            )
        else:
            self.id = response.response_content['nicID']

        self.sync()
        return self
1160169
def get_load(jid):
    '''
    
    '''
    with _get_serv(ret=None, commit=True) as cur:

        sql = '''SELECT load FROM jids WHERE jid = %s;'''
        cur.execute(sql, (jid,))
        data = cur.fetchone()
        if data:
            return data[0]
        return {}
283402
def prep_jid(nocache=False, passed_jid=None):
    '''
    
    '''
    conn = _get_conn()
    if conn is None:
        return None
    cur = conn.cursor()
    if passed_jid is None:
        jid = _gen_jid(cur)
    else:
        jid = passed_jid
    while not jid:
        log.info("jid clash, generating a new one")
        jid = _gen_jid(cur)

    cur.close()
    conn.close()
    return jid
17441
def load(self, id, *args, **kwargs):
        
        self._pre_load(id, *args, **kwargs)
        response = self._load(id, *args, **kwargs)
        response = self._post_load(response, *args, **kwargs)
        return response
713720
def pub_ret(self, load, skip_verify=False):
        '''
        
        '''
        if not skip_verify and any(key not in load for key in ('jid', 'id')):
            return {}
        else:
            auth_cache = os.path.join(
                    self.opts['cachedir'],
                    'publish_auth')
            if not os.path.isdir(auth_cache):
                os.makedirs(auth_cache)
            jid_fn = os.path.join(auth_cache, load['jid'])
            with salt.utils.files.fopen(jid_fn, 'r') as fp_:
                if not load['id'] == salt.utils.stringutils.to_unicode(fp_.read()):
                    return {}

            return self.local.get_cache_returns(load['jid'])
902211
def get_jid(jid):
    '''
    
    '''
    conn = _get_conn(ret=None)
    cur = conn.cursor()
    sql = '''SELECT id, full_ret FROM salt_returns WHERE jid = ?'''

    cur.execute(sql, (jid,))
    data = cur.fetchall()
    ret = {}
    if data:
        for minion, full_ret in data:
            ret[minion] = salt.utils.json.loads(full_ret)
    _close_conn(conn)
    return ret
1154893
def save_load(jid, load, minions=None):
    '''
    
    '''
    # Load is being stored as a text datatype. Single quotes are used in the
    # VALUES list. Therefore, all single quotes contained in the results from
    # salt.utils.json.dumps(load) must be escaped Cassandra style.
    query = '''INSERT INTO {keyspace}.jids (
                 jid, load
               ) VALUES (?, ?)'''.format(keyspace=_get_keyspace())

    statement_arguments = [
        jid,
        salt.utils.json.dumps(load).replace("'", "''")
    ]

    # cassandra_cql.cql_query may raise a CommandExecutionError
    try:
        __salt__['cassandra_cql.cql_query_with_prepare'](query, 'save_load',
                                                         statement_arguments,
                                                         asynchronous=True)
    except CommandExecutionError:
        log.critical('Could not save load in jids table.')
        raise
    except Exception as e:
        log.critical('Unexpected error while inserting into jids: %s', e)
        raise
1121761
def save
      __robject.content_type = model.content_type
      __robject.data = __persist_attributes

      __check_unique_indices
      __update_indices
      __robject.store

      @id = __robject.key

      self
    end
651406
def save(self, filename="temp.pkl"):
    
    output = open(filename, 'wb')
    cPickle.dump(self.tm, output, protocol=cPickle.HIGHEST_PROTOCOL)
233994
def get_load(jid):
    '''
    
    '''
    with _get_serv(ret=None, commit=True) as cur:

        sql = '''SELECT `load` FROM `jids` WHERE `jid` = %s;'''
        cur.execute(sql, (jid,))
        data = cur.fetchone()
        if data:
            return salt.utils.json.loads(data[0])
        return {}
1561
def get_jid(jid):
    '''
    
    '''
    with _get_serv(ret=None, commit=True) as cur:

        sql = '''SELECT id, full_ret FROM `salt_returns`
                WHERE `jid` = %s'''

        cur.execute(sql, (jid,))
        data = cur.fetchall()
        ret = {}
        if data:
            for minion, full_ret in data:
                ret[minion] = salt.utils.json.loads(full_ret)
        return ret
1112433
def _store_inserted_ids(self, mapping, job_id, local_ids_for_batch):
        """"""
        id_table_name = self._reset_id_table(mapping)
        conn = self.session.connection()
        for batch_id, local_ids in local_ids_for_batch.items():
            try:
                results_url = "{}/job/{}/batch/{}/result".format(
                    self.bulk.endpoint, job_id, batch_id
                )
                # Download entire result file to a temporary file first
                # to avoid the server dropping connections
                with _download_file(results_url, self.bulk) as f:
                    self.logger.info(
                        "  Downloaded results for batch {}".format(batch_id)
                    )
                    self._store_inserted_ids_for_batch(
                        f, local_ids, id_table_name, conn
                    )
                self.logger.info(
                    "  Updated {} for batch {}".format(id_table_name, batch_id)
                )
            except Exception:  # pragma: nocover
                # If we can't download one result file,
                # don't let that stop us from downloading the others
                self.logger.error(
                    "Could not download batch results: {}".format(batch_id)
                )
                continue
        self.session.commit()
364290
def get_load(jid):
    '''
    
    '''
    serv = _get_serv(ret=None)
    sql = "select load from jids where jid = '{0}'".format(jid)

    log.debug(">> Now in get_load %s", jid)
    data = serv.query(sql)
    log.debug(">> Now Data: %s", data)
    if data:
        return data
    return {}
1319358
def prep_jid(nocache=False, passed_jid=None):
    '''
    
    '''
    return passed_jid if passed_jid is not None else salt.utils.jid.gen_jid(__opts__)