Ejemplo n.º 1
0
def controller_encryption_disable(handle,
                                  controller_type,
                                  controller_slot,
                                  server_id=1):
    """
    Disables encryption on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                                "MEZZ","0"-"9", "HBA"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_disable(handle,
                                  controller_type='SAS',
                                  controller_slot='HBA'')
    """
    dn = _get_controller_dn(handle, controller_type, controller_slot,
                            server_id)

    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    mo.admin_action = \
        SelfEncryptStorageControllerConsts.ADMIN_ACTION_DISABLE_SELF_ENCRYPT
    handle.set_mo(mo)
    return handle.query_dn(dn)
Ejemplo n.º 2
0
def controller_unlock_foreign_drives(handle, controller_type,
                                     controller_slot, security_key,
                                     server_id=1):
    """
    Unlocks on the given controller, drives encrypted on another controller.

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                                "MEZZ","0"-"9", "HBA"
        security_key (str): Security Key used to encrypt the foreign drive
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        key = controller_unlock_foreign_drives(
                handle,
                controller_type='SAS',
                controller_slot='HBA'',
                security_key='12345')
    """
    dn = _get_controller_dn(handle, controller_type, controller_slot, server_id)
    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    params = {
        'security_key': security_key,
        'admin_action': SelfEncryptStorageControllerConsts.ADMIN_ACTION_UNLOCK_SECURED_DRIVES
    }
    mo.set_prop_multiple(**params)
    return handle.query_dn(dn)
Ejemplo n.º 3
0
def controller_encryption_disable(handle, controller_type,
                                  controller_slot, server_id=1):
    """
    Disables encryption on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                                "MEZZ","0"-"9", "HBA"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_disable(handle,
                                  controller_type='SAS',
                                  controller_slot='HBA'')
    """
    dn = _get_controller_dn(
                handle,
                controller_type,
                controller_slot,
                server_id)

    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    mo.admin_action = \
        SelfEncryptStorageControllerConsts.ADMIN_ACTION_DISABLE_SELF_ENCRYPT
    handle.set_mo(mo)
    return handle.query_dn(dn)
Ejemplo n.º 4
0
def controller_unlock_foreign_drives(handle, controller_type,
                                     controller_slot, security_key,
                                     server_id=1):
    """
    Unlocks on the given controller, drives encrypted on another controller.

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                                "MEZZ","0"-"9", "HBA"
        security_key (str): Security Key used to encrypt the foreign drive
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        key = controller_unlock_foreign_drives(
                handle,
                controller_type='SAS',
                controller_slot='HBA'',
                security_key='12345')
    """
    dn = _get_controller_dn(handle, controller_type, controller_slot, server_id)
    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    params = {
        'security_key': security_key,
        'admin_action': SelfEncryptStorageControllerConsts.ADMIN_ACTION_UNLOCK_SECURED_DRIVES
    }
    mo.set_prop_multiple(**params)
    return handle.query_dn(dn)
Ejemplo n.º 5
0
def controller_encryption_enable(handle,
                                 controller_type,
                                 controller_slot,
                                 key_id,
                                 security_key,
                                 key_management="local",
                                 server_id=1,
                                 **kwargs):
    """
    Enables encryption on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                               "MEZZ","0"-"9"
        key_id (str): Security Key Identifier.
                      Max Length is 256 characters.
        security_key (str): Security key used to enable controller security.
                            Max Length is 32 characters.
        key_management (str): "local" or "remote"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_enable(handle,
                                 controller_type='SAS',
                                 controller_slot='HBA'',
                                 key_id='*****', security_key='*****')
    """
    from imcsdk.mometa.self.SelfEncryptStorageController import \
        SelfEncryptStorageController, SelfEncryptStorageControllerConsts

    enabled, mo = controller_encryption_exists(handle, controller_type,
                                               controller_slot, server_id)
    if enabled:
        return mo
    dn = mo.dn
    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    params = {
        'key_id':
        key_id,
        'security_key':
        security_key,
        'key_management':
        key_management,
        'admin_action':
        SelfEncryptStorageControllerConsts.ADMIN_ACTION_ENABLE_SELF_ENCRYPT,
    }

    mo.set_prop_multiple(**params)
    handle.set_mo(mo)
    return handle.query_dn(dn)
Ejemplo n.º 6
0
def controller_encryption_enable(handle, controller_type,
                                 controller_slot, key_id, security_key,
                                 key_management="local", server_id=1,
                                 **kwargs):
    """
    Enables encryption on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                               "MEZZ","0"-"9"
        key_id (str): Security Key Identifier.
                      Max Length is 256 characters.
        security_key (str): Security key used to enable controller security.
                            Max Length is 32 characters.
        key_management (str): "local" or "remote"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_enable(handle,
                                 controller_type='SAS',
                                 controller_slot='HBA'',
                                 key_id='ABCD12345', security_key='12345')
    """
    from imcsdk.mometa.self.SelfEncryptStorageController import \
        SelfEncryptStorageController, SelfEncryptStorageControllerConsts

    enabled, mo = controller_encryption_exists(handle,
                                               controller_type,
                                               controller_slot,
                                               server_id)
    if enabled:
        return mo
    dn = mo.dn
    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    params = {
        'key_id': key_id,
        'security_key': security_key,
        'key_management': key_management,
        'admin_action':
        SelfEncryptStorageControllerConsts.ADMIN_ACTION_ENABLE_SELF_ENCRYPT,
    }

    mo.set_prop_multiple(**params)
    handle.set_mo(mo)
    return handle.query_dn(dn)
Ejemplo n.º 7
0
def controller_encryption_modify_security_key(handle,
                                              controller_type,
                                              controller_slot,
                                              existing_security_key,
                                              security_key,
                                              key_management="local",
                                              server_id=1):
    """
    Modifies the security key on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                                "MEZZ","0"-"9", "HBA"
        existing_security_key (str): Existing Security Key
        security_key (str): New Security Key
        key_management (str): "local" or "remote"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_modify_security_key(
                     handle,
                     controller_type='SAS',
                     controller_slot='HBA'',
                     existing_security_key='Nbv12345',
                     security_key='Nbv123456')
    """
    dn = _get_controller_dn(handle,
                            controller_type,
                            controller_slot,
                            server_id)
    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    params = {
        'existing_security_key': existing_security_key,
        'security_key': security_key,
        'key_management': key_management,
    }
    mo.set_prop_multiple(**params)
    handle.set_mo(mo)
    return handle.query_dn(dn)
Ejemplo n.º 8
0
def controller_encryption_modify_security_key(handle,
                                              controller_type,
                                              controller_slot,
                                              existing_security_key,
                                              security_key,
                                              key_management="local",
                                              server_id=1):
    """
    Modifies the security key on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                                "MEZZ","0"-"9", "HBA"
        existing_security_key (str): Existing Security Key
        security_key (str): New Security Key
        key_management (str): "local" or "remote"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_modify_security_key(
                     handle,
                     controller_type='SAS',
                     controller_slot='HBA'',
                     existing_security_key='Nbv12345',
                     security_key='Nbv123456')
    """
    dn = _get_controller_dn(handle,
                            controller_type,
                            controller_slot,
                            server_id)
    mo = SelfEncryptStorageController(parent_mo_or_dn=dn)
    params = {
        'existing_security_key': existing_security_key,
        'security_key': security_key,
        'key_management': key_management,
    }
    mo.set_prop_multiple(**params)
    handle.set_mo(mo)
    return handle.query_dn(dn)
Ejemplo n.º 9
0
def controller_encryption_enable(handle, controller_type, controller_slot,
                                 security_key=None, key_id=None,
                                 existing_security_key=None,
                                 key_management="local",
                                 server_id=1, **kwargs):
    """
    Enables encryption on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                               "MEZZ","0"-"9"
        security_key (str): Security key used to enable controller security.
                            Max Length is 32 characters.
        key_id (str): Security Key Identifier.
                      Max Length is 256 characters.
        existing_security_key (str): Existing security key.
                            Max Length is 32 characters.
        key_management (str): "local" or "remote"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_enable(handle, controller_type='SAS',
                                     controller_slot='HBA'',
                                     key_id='ABCD12345', security_key='12345')
    """
    from imcsdk.mometa.self.SelfEncryptStorageController import \
        SelfEncryptStorageController, SelfEncryptStorageControllerConsts

    controller_mo = _get_controller(handle, controller_type, controller_slot,
                                    server_id)

    enabled = controller_mo.self_encrypt_enabled.lower() in ['yes', 'true']
    if not enabled:
        action = \
            SelfEncryptStorageControllerConsts.ADMIN_ACTION_ENABLE_SELF_ENCRYPT
        existing_security_key = None
    else:
        action = \
            SelfEncryptStorageControllerConsts.ADMIN_ACTION_MODIFY_SELF_ENCRYPT

    if not enabled and key_management == "local" and security_key is None:
        raise ImcOperationError("Enable encryption on Controller: %s" % controller_slot,
                                "Missing param 'security_key'.")

    mo = SelfEncryptStorageController(parent_mo_or_dn=controller_mo.dn)
    params = {
        'key_id': key_id,
        'existing_security_key': existing_security_key,
        'security_key': security_key,
        'key_management': key_management,
        'admin_action': action,
    }

    mo.set_prop_multiple(**params)
    mo.set_prop_multiple(**kwargs)
    handle.set_mo(mo)
    return handle.query_dn(controller_mo.dn)
Ejemplo n.º 10
0
def controller_encryption_enable(handle,
                                 controller_type,
                                 controller_slot,
                                 security_key=None,
                                 key_id=None,
                                 existing_security_key=None,
                                 key_management="local",
                                 server_id=1,
                                 **kwargs):
    """
    Enables encryption on the controller

    Args:
        handle (ImcHandle)
        controller_type (str): Controller type
                               'SAS'
        controller_slot (str): Controller slot name/number
                               "MEZZ","0"-"9"
        security_key (str): Security key used to enable controller security.
                            Max Length is 32 characters.
        key_id (str): Security Key Identifier.
                      Max Length is 256 characters.
        existing_security_key (str): Existing security key.
                            Max Length is 32 characters.
        key_management (str): "local" or "remote"
        server_id (int): server_id for UCS 3260 platform

    Returns:
        StorageController object

    Examples:
        controller_encryption_enable(handle, controller_type='SAS',
                                     controller_slot='HBA'',
                                     key_id='ABCD12345', security_key='12345')
    """
    from imcsdk.mometa.self.SelfEncryptStorageController import \
        SelfEncryptStorageController, SelfEncryptStorageControllerConsts

    controller_mo = _get_controller(handle, controller_type, controller_slot,
                                    server_id)

    enabled = controller_mo.self_encrypt_enabled.lower() in ['yes', 'true']
    if not enabled:
        action = \
            SelfEncryptStorageControllerConsts.ADMIN_ACTION_ENABLE_SELF_ENCRYPT
        existing_security_key = None
    else:
        action = \
            SelfEncryptStorageControllerConsts.ADMIN_ACTION_MODIFY_SELF_ENCRYPT

    if not enabled and key_management == "local" and security_key is None:
        raise ImcOperationError(
            "Enable encryption on Controller: %s" % controller_slot,
            "Missing param 'security_key'.")

    mo = SelfEncryptStorageController(parent_mo_or_dn=controller_mo.dn)
    params = {
        'key_id': key_id,
        'existing_security_key': existing_security_key,
        'security_key': security_key,
        'key_management': key_management,
        'admin_action': action,
    }

    mo.set_prop_multiple(**params)
    mo.set_prop_multiple(**kwargs)
    handle.set_mo(mo)
    return handle.query_dn(controller_mo.dn)