Ejemplo n.º 1
0
def create_key(policy=None,
               description=None,
               key_usage=None,
               region=None,
               key=None,
               keyid=None,
               profile=None):
    '''
    Creates a master key.

    CLI example::

        salt myminion boto_kms.create_key '{"Statement":...}' "My master key"
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    r = {}
    _policy = json.serialize(policy)
    try:
        key_metadata = conn.create_key(_policy,
                                       description=description,
                                       key_usage=key_usage)
        r['key_metadata'] = key_metadata['KeyMetadata']
    except boto.exception.BotoServerError as e:
        r['error'] = __utils__['boto.get_error'](e)
    return r
Ejemplo n.º 2
0
    def test_serialize_json(self):
        data = {"foo": "bar"}
        serialized = json.serialize(data)
        assert serialized == '{"foo": "bar"}', serialized

        deserialized = json.deserialize(serialized)
        assert deserialized == data, deserialized
def get_all(json_format=False):
    '''
        .. note::
            Get all of these settings:
                - NoFPGAApp
                - NoApp
                - ConsoleOut
                - EmbeddedUI
                - LabVIEWAccess
        :param json_format: If true, returns the result in JSON format
        :return: Returns settings
        CLI Example:

        .. code-block:: bash
        salt '*' startup.get_all
        salt '*' startup.get_all True
    '''
    settings = {
        'NoFPGAApp': get('nofpgaapp'),
        'NoApp': get('noapp'),
        'ConsoleOut': get('consoleout'),
        'LabVIEWAccess': get('labviewaccess')
    }
    cpuarch = __grains__.get('cpuarch')
    if cpuarch == 'x86_64':
        settings['EmbeddedUI'] = get('embeddedui')
    if not json_format:
        return settings
    return json.serialize(settings)
Ejemplo n.º 4
0
    def test_serialize_json(self):
        data = {
            "foo": "bar"
        }
        serialized = json.serialize(data)
        assert serialized == '{"foo": "bar"}', serialized

        deserialized = json.deserialize(serialized)
        assert deserialized == data, deserialized
Ejemplo n.º 5
0
def put_key_policy(key_id, policy_name, policy, region=None, key=None,
                   keyid=None, profile=None):
    '''
    Attach a key policy to the specified key.

    CLI example::

        salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}'
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    r = {}
    try:
        conn.put_key_policy(key_id, policy_name, json.serialize(policy))
        r['result'] = True
    except boto.exception.BotoServerError as e:
        r['result'] = False
        r['error'] = __utils__['boto.get_error'](e)
    return r
Ejemplo n.º 6
0
def put_key_policy(key_id, policy_name, policy, region=None, key=None,
                   keyid=None, profile=None):
    '''
    Attach a key policy to the specified key.

    CLI example::

        salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}'
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    r = {}
    try:
        conn.put_key_policy(key_id, policy_name, json.serialize(policy))
        r['result'] = True
    except boto.exception.BotoServerError as e:
        r['result'] = False
        r['error'] = __utils__['boto.get_error'](e)
    return r
Ejemplo n.º 7
0
def create_key(policy=None, description=None, key_usage=None, region=None,
               key=None, keyid=None, profile=None):
    '''
    Creates a master key.

    CLI example::

        salt myminion boto_kms.create_key '{"Statement":...}' "My master key"
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    r = {}
    _policy = json.serialize(policy)
    try:
        key_metadata = conn.create_key(
            _policy,
            description=description,
            key_usage=key_usage
        )
        r['key_metadata'] = key_metadata['KeyMetadata']
    except boto.exception.BotoServerError as e:
        r['error'] = __utils__['boto.get_error'](e)
    return r