t_std_error nas_int_cps_init(cps_api_operation_handle_t handle) {

    cps_api_registration_functions_t f;
    char buff[CPS_API_KEY_STR_MAX];
    memset(&f,0,sizeof(f));

    if (!cps_api_key_from_attr_with_qual(&f.key,BASE_IF_PHY_PHYSICAL_OBJ,cps_api_qualifier_TARGET)) {
        EV_LOG(ERR,INTERFACE,0,"NAS-IF-REG","Could not translate %d to key %s",
                            (int)(DELL_BASE_IF_CMN_IF_INTERFACES_INTERFACE_OBJ),
                            cps_api_key_print(&f.key,buff,sizeof(buff)-1));
        return STD_ERR(INTERFACE,FAIL,0);
    }
    EV_LOG(INFO,INTERFACE,0,"NAS-IF-REG","Registering for %s",
                        cps_api_key_print(&f.key,buff,sizeof(buff)-1));
    f.handle = handle;
    f._read_function = _phy_int_get;
    f._write_function = _phy_int_set;
    if (cps_api_register(&f)!=cps_api_ret_code_OK) {
        return STD_ERR(INTERFACE,FAIL,0);
    }

    t_std_error rc = STD_ERR_OK;
    npu_id_t npu = 0;
    npu_id_t npu_max = (npu_id_t)nas_switch_get_max_npus();
    for ( ; npu < npu_max ; ++npu ) {
        rc = ndi_port_event_cb_register(npu,_ndi_port_event_update_);
        if (rc!=STD_ERR_OK) return rc;
    }

    if ((rc=nas_int_breakout_init(handle))!=STD_ERR_OK) return rc;

    return nas_int_logical_init(handle);
}
t_std_error ds_api_linux_route_init(cps_api_operation_handle_t handle) {
    cps_api_registration_functions_t f;
    memset(&f,0,sizeof(f));
    f.handle = handle;
    f._read_function = db_read_function;
    f._write_function = _write_function;

    cps_api_key_init(&f.key,cps_api_qualifier_TARGET,cps_api_obj_cat_ROUTE,cps_api_route_obj_ROUTE,0);
    cps_api_return_code_t rc = cps_api_register(&f);
    if (rc!=cps_api_ret_code_OK) {
        return STD_ERR(INTERFACE,FAIL,rc);
    }

    f._read_function = NULL;
    cps_api_key_init(&f.key,cps_api_qualifier_TARGET,cps_api_obj_cat_ROUTE,cps_api_route_obj_EVENT,0);
    rc = cps_api_register(&f);

    return STD_ERR_OK_IF_TRUE(rc==cps_api_ret_code_OK,STD_ERR(INTERFACE,FAIL,rc));
}
t_std_error ds_api_linux_interface_init(cps_api_operation_handle_t handle) {
    cps_api_registration_functions_t f;
    memset(&f,0,sizeof(f));
    f.handle = handle;
    f._read_function = ds_api_linux_interface_get_function;
    f._write_function = ds_api_linux_interface_set_function;
    cps_api_key_init(&f.key,cps_api_qualifier_TARGET,cps_api_obj_cat_INTERFACE,0,0);

    cps_api_return_code_t rc = cps_api_register(&f);
    return STD_ERR_OK_IF_TRUE(rc==cps_api_ret_code_OK,STD_ERR(INTERFACE,FAIL,rc));
}
PyObject * py_cps_obj_reg(PyObject *self, PyObject *args) {
    cps_api_operation_handle_t *handle=NULL;
    PyObject *h,*o;
    const char *path;
    if (! PyArg_ParseTuple( args, "O!sO!",  &PyByteArray_Type, &h,&path,&PyDict_Type, &o)) return NULL;

    handle = (cps_api_operation_handle_t*)PyByteArray_AsString(h);
    if (PyByteArray_Size(h)!=sizeof(*handle)) {
        py_set_error_string("Invalid handle");
        return nullptr;
    }
    std::unique_ptr<py_callbacks_t> p (new py_callbacks_t);
    if (p.get()==NULL) {
        py_set_error_string("Memory allocation error");
        return nullptr;
    }
    p->_methods = o;

    cps_api_registration_functions_t f;
    memset(&f,0,sizeof(f));
    f.handle = *handle;
    f.context = p.get();
    f._read_function = _read_function;
    f._write_function = _write_function;
    f._rollback_function = _rollback_function;

    if (!cps_api_key_from_string(&f.key,path)) {
        py_set_error_string("Key translation error");
        return nullptr;
    }

    cps_api_return_code_t rc;
    {
        NonBlockingPythonContext l;
        rc = cps_api_register(&f);
    }

    if (rc!=cps_api_ret_code_OK) {
        Py_RETURN_FALSE;
    }
    p.release();
    Py_INCREF(o);

    Py_RETURN_TRUE;
}
t_std_error nas_switch_log_init(cps_api_operation_handle_t handle) {

    cps_api_return_code_t rc;
    cps_api_registration_functions_t f;
    memset(&f,0,sizeof(f));

    f.handle = handle;
    f._write_function = cps_nas_switch_log_set_function;

    char buff[CPS_API_KEY_STR_MAX];
    if (!cps_api_key_from_attr_with_qual(&f.key,BASE_SWITCH_SET_LOG_OBJ,cps_api_qualifier_TARGET)) {
        EV_LOG(ERR,SYSTEM,0,"NAS-DIAG","Could not translate %d to key %s",
               (int)(BASE_SWITCH_SET_LOG_OBJ),cps_api_key_print(&f.key,buff,sizeof(buff)-1));
        return STD_ERR(DIAG,FAIL,0);
    }

    if ((rc = cps_api_register(&f)) != cps_api_ret_code_OK) return STD_ERR(DIAG,FAIL,rc);

    return STD_ERR_OK;
}
static t_std_error _cps_init ()
{
    cps_api_operation_handle_t       handle;
    cps_api_return_code_t            rc;
    cps_api_registration_functions_t f;

    rc = cps_api_operation_subsystem_init (&handle,1);

    if (rc != cps_api_ret_code_OK) {
        NAS_ACL_LOG_ERR ("NAS ACL CPS Subsystem Init failed");
        return STD_ERR(QOS, FAIL, rc);
    }

    memset (&f, 0, sizeof(f));

    f.handle             = handle;
    f._read_function     = nas_acl_cps_api_read;
    f._write_function    = nas_acl_cps_api_write;
    f._rollback_function = nas_acl_cps_api_rollback;

    /*
     * Register all ACL objects
     * TODO: Need to check with CPS app teams, if ACL needs to register for
     * OBSERVED state.
     */
    cps_api_key_init (&f.key,
                      cps_api_qualifier_TARGET,
                      cps_api_obj_CAT_BASE_ACL,
                      0, /* register all sub-categories */
                      0);

    rc = cps_api_register (&f);

    if (rc != cps_api_ret_code_OK) {
        NAS_ACL_LOG_ERR ("NAS ACL CPS object Register failed");
        return STD_ERR(QOS, FAIL, rc);
    }

    return STD_ERR_OK;
}