From a73acb6b3e7d38c7389dc4ffd1c6db1d737e96e5 Mon Sep 17 00:00:00 2001 From: sameera Date: Wed, 11 Jun 2014 23:49:20 +0530 Subject: [PATCH] Improve VTN Coordinator code to avoid some redundant code sections Change-Id: I02a6d51f9e021d788377499289df6490be2f4ab0 Signed-off-by: sameera --- .../modules/odcdriver/include/odc_vbr.hh | 7 +- .../odcdriver/include/odc_vbr_vlanmap.hh | 7 +- .../modules/odcdriver/include/odc_vbrif.hh | 5 +- .../modules/odcdriver/include/odc_vtn.hh | 7 +- .../include/driver/driver_command.hh | 222 +++--------------- .../vtndrvintf/include/request_template.hh | 146 ++++++------ .../vtndrvintf/include/vtn_drv_module.hh | 10 + .../modules/vtndrvintf/vtn_drv_module.cc | 150 +++++------- .../driver/driver_command.hh | 180 +------------- .../driver/driver_interface.hh | 8 +- .../ut/test_request_template.cc | 163 ++++--------- .../ut/vtn_drv_transaction_handle_ut.cc | 9 +- 12 files changed, 246 insertions(+), 668 deletions(-) diff --git a/coordinator/modules/odcdriver/include/odc_vbr.hh b/coordinator/modules/odcdriver/include/odc_vbr.hh index f8528989..2815a0ce 100644 --- a/coordinator/modules/odcdriver/include/odc_vbr.hh +++ b/coordinator/modules/odcdriver/include/odc_vbr.hh @@ -27,11 +27,12 @@ namespace unc { namespace odcdriver { -class OdcVbrCommand: public unc::driver::vbr_driver_command { +class OdcVbrCommand: public unc::driver::vtn_driver_command + { public: /** - * @brief Parametrised Constructor - * @param[in] - conf file values + * @brief - Parametrised Constructor + * @param[in] - conf file values */ explicit OdcVbrCommand(unc::restjson::ConfFileValues_t conf_values); diff --git a/coordinator/modules/odcdriver/include/odc_vbr_vlanmap.hh b/coordinator/modules/odcdriver/include/odc_vbr_vlanmap.hh index 59143308..392d80f2 100644 --- a/coordinator/modules/odcdriver/include/odc_vbr_vlanmap.hh +++ b/coordinator/modules/odcdriver/include/odc_vbr_vlanmap.hh @@ -25,11 +25,12 @@ namespace unc { namespace odcdriver { -class OdcVbrVlanMapCommand: public unc::driver::vbrvlanmap_driver_command { +class OdcVbrVlanMapCommand: public unc::driver::vtn_driver_command + { public: /** - * @brief Parametrised Constructor - * @param[in] - conf file values + * @brief - Parametrised Constructor + * @param[in] - conf file values */ explicit OdcVbrVlanMapCommand(unc::restjson::ConfFileValues_t conf_values); diff --git a/coordinator/modules/odcdriver/include/odc_vbrif.hh b/coordinator/modules/odcdriver/include/odc_vbrif.hh index e337db54..de294a93 100644 --- a/coordinator/modules/odcdriver/include/odc_vbrif.hh +++ b/coordinator/modules/odcdriver/include/odc_vbrif.hh @@ -25,10 +25,11 @@ namespace unc { namespace odcdriver { -class OdcVbrIfCommand: public unc::driver::vbrif_driver_command { +class OdcVbrIfCommand: public unc::driver::vtn_driver_command + { public: /** - * @brief Parametrised Constructor + * @brief - Parametrised Constructor * @param[in] - conf file values */ explicit OdcVbrIfCommand(unc::restjson::ConfFileValues_t conf_values); diff --git a/coordinator/modules/odcdriver/include/odc_vtn.hh b/coordinator/modules/odcdriver/include/odc_vtn.hh index 56ead42c..e0511584 100644 --- a/coordinator/modules/odcdriver/include/odc_vtn.hh +++ b/coordinator/modules/odcdriver/include/odc_vtn.hh @@ -24,11 +24,12 @@ namespace unc { namespace odcdriver { -class OdcVtnCommand: public unc::driver::vtn_driver_command { +class OdcVtnCommand: public unc::driver::vtn_driver_command + { public: /** - * @brief Parametrised Constructor - * @param[in] - conf file values + * @brief - Parametrised Constructor + * @param[in] - conf file values */ explicit OdcVtnCommand(unc::restjson::ConfFileValues_t conf_values); diff --git a/coordinator/modules/vtndrvintf/include/driver/driver_command.hh b/coordinator/modules/vtndrvintf/include/driver/driver_command.hh index 2ea9e990..d93cce9e 100644 --- a/coordinator/modules/vtndrvintf/include/driver/driver_command.hh +++ b/coordinator/modules/vtndrvintf/include/driver/driver_command.hh @@ -31,11 +31,10 @@ typedef struct val_root { class driver_command { public: virtual ~driver_command() {} - virtual unc_key_type_t get_key_type()=0; /** * @brief - Method to revoke the commit with triggring audit for any - failed Operation + failed Operation * @param[in]- controller pointer * @retval - UNC_RC_SUCCESS */ @@ -64,205 +63,54 @@ class driver_command { * @param[out] - list of configurations * @retval - UNC_RC_SUCCESS / UNC_DRV_RC_ERR_GENERIC */ - virtual UncRespCode fetch_config(unc::driver::controller* ctr, - void* parent_key, - std::vector&) = 0; + virtual UncRespCode fetch_config( + unc::driver::controller* ctr, + void* parent_key, + std::vector&) = 0; }; /* - * @desc:Abstract base Class to be extended for VTN Commands + * @desc:Template Class For Driver Commands */ +template class vtn_driver_command: public driver_command { public: - /** - * @brief - Method to create VTN in the controller - * @param[in]- key_vtn_t, val_vtn_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode create_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_, - unc::driver::controller*)=0; - /** - * @brief - Method to update VTN in the controller - * @param[in]- key_vtn_t, val_vtn_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode update_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_, - unc::driver::controller*)=0; - /** - * @brief - Method to delete VTN in the controller - * @param[in]- key_vtn_t, val_vtn_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode delete_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_, - unc::driver::controller*)=0; - /** - * @brief - Method to return the Keytype - * @param[in]- None - * @retval - unc_key_type_t - UNC_KT_VTN - */ - unc_key_type_t get_key_type() { - return UNC_KT_VTN; - } -}; - -/* - * @desc:Abstract base Class to be extended for VBR Commands - */ -class vbr_driver_command: public driver_command { - public: - /** - * @brief - Method to create Vbridge in the controller - * @param[in]- key_vbr_t, val_vbr_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode create_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_, - unc::driver::controller*) = 0; - /** - * @brief - Method to update Vbridge in the controller - * @param[in]- key_vbr_t, val_vbr_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode update_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_, - unc::driver::controller*) = 0; - - /** - * @brief - Method to delete Vbridge in the controller - * @param[in]- key_vbr_t, val_vbr_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode delete_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_, - unc::driver::controller*)=0; - /** - * @brief - Method to return the Keytype - * @param[in]- None - * @retval - unc_key_type_t - UNC_KT_VBRIDGE - */ - unc_key_type_t get_key_type() { - return UNC_KT_VBRIDGE; - } -}; -/* - * @desc:Abstract base Class to be extended for VBRIf Commands - */ -class vbrif_driver_command: public driver_command { - public: /** - * @brief - Method to create Vbr Interface in the controller - * @param[in]- key_vbr_if_t, pfcdrv_val_vbr_if_t, controller* + * @brief - Method to create VTN/Vbridge/Vbridge Interface/VLANMAP in + * controller + * @param[in]- key_vtn_t, val_vtn_t, key_vbr_t, val_vbr_t, key_vbr_if_t, + * pfcdrv_val_vbr_if_t, key_vbr_if_t, pfcdrv_val_vbr_if_t, + * key_vlan_map_t, pfcdrv_val_vlan_map_t controller* * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC */ - virtual UncRespCode create_cmd(key_vbr_if_t& key, - pfcdrv_val_vbr_if_t& val, unc::driver::controller *conn)=0; + virtual UncRespCode create_cmd(key_cmd& key_st, + val_cmd& val_st, + unc::driver::controller*)=0; /** - * @brief - Method to update Vbr Interface in the controller - * @param[in]- key_vbr_if_t, pfcdrv_val_vbr_if_t, controller* + * @brief - Method to update VTN/Vbridge/Vbridge Interface/VLANMAP in + * controller + * @param[in]- key_vtn_t, val_vtn_t, key_vbr_t, val_vbr_t, key_vbr_if_t, + * pfcdrv_val_vbr_if_t, key_vbr_if_t, pfcdrv_val_vbr_if_t, + * key_vlan_map_t, pfcdrv_val_vlan_map_t controller* * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC */ - virtual UncRespCode update_cmd(key_vbr_if_t& key, - pfcdrv_val_vbr_if_t& val, unc::driver::controller *conn) = 0; + virtual UncRespCode update_cmd(key_cmd& key_st, + val_cmd& val_st, + unc::driver::controller*)=0; /** - * @brief - Method to delete Vbr Interface in the controller - * @param[in]- key_vbr_if_t, pfcdrv_val_vbr_if_t, controller* + * @brief - Method to delete VTN/Vbridge/Vbridge Interface/VLANMAP in + * controller + * @param[in]- key_vtn_t, val_vtn_t, key_vbr_t, val_vbr_t, key_vbr_if_t, + * pfcdrv_val_vbr_if_t, key_vbr_if_t, pfcdrv_val_vbr_if_t, + * key_vlan_map_t, pfcdrv_val_vlan_map_t controller* * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC */ - virtual UncRespCode delete_cmd(key_vbr_if_t& key, - pfcdrv_val_vbr_if_t& val, unc::driver::controller *conn) = 0; - - /** - * @brief - Method to return the Keytype - * @param[in]- None - * @retval - unc_key_type_t - UNC_KT_VBR_IF - */ - unc_key_type_t get_key_type() { - return UNC_KT_VBR_IF; - } -}; - -class vbrvlanmap_driver_command: public driver_command { - public: - /** - * @brief - Method to create Vbr Vlan-Map in the controller - * @param[in]- key_vlan_map_t, val_vlan_map_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode create_cmd(key_vlan_map_t& key, - pfcdrv_val_vlan_map_t& val, - unc::driver::controller *conn)=0; - - /** - * @brief - Method to update Vbr Vlan-Map in the controller - * @param[in]- key_vlan_map_t, val_vlan_map_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode update_cmd(key_vlan_map_t& key, - pfcdrv_val_vlan_map_t& val, - unc::driver::controller *conn) = 0; - - /** - * @brief - Method to delete Vbr Vlan-Map in the controller - * @param[in]- key_vlan_map_t, val_vlan_map_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - virtual UncRespCode delete_cmd(key_vlan_map_t& key, - pfcdrv_val_vlan_map_t& val, - unc::driver::controller *conn) = 0; - - /** - * @brief - Method to return the Keytype - * @param[in]- None - * @retval - unc_key_type_t - UNC_KT_VBR_VLANMAP - */ - unc_key_type_t get_key_type() { - return UNC_KT_VBR_VLANMAP; - } -}; - -/* - * @desc:Abstract base Class to be extended for VBRIf Commands - */ -class controller_command: public driver_command { - public: - /** - * @brief - Method to create controller configuration - * @param[in]- key_ctr_t, val_ctr_t, controller* - * @retval - UNC_DRV_RC_ERR_GENERIC - */ - UncRespCode create_cmd(key_ctr_t& key, - val_ctr_t & val, unc::driver::controller *conn) { - return UNC_DRV_RC_ERR_GENERIC; - } - - /** - * @brief - Method to update controller configuration - * @param[in]- key_ctr_t, val_ctr_t, controller* - * @retval - UNC_DRV_RC_ERR_GENERIC - */ - UncRespCode update_cmd(key_ctr_t & key, - val_ctr_t& val, unc::driver::controller *conn) { - return UNC_DRV_RC_ERR_GENERIC; - } - - /** - * @brief - Method to update controller configuration - * @param[in]- key_ctr_t, val_ctr_t, controller* - * @retval - UNC_DRV_RC_ERR_GENERIC - */ - UncRespCode delete_cmd(key_ctr_t & key, - val_ctr_t & val, unc::driver::controller *conn) { - return UNC_DRV_RC_ERR_GENERIC; - } - - /** - * @brief - Method to return the Keytype - * @param[in]- None - * @retval - unc_key_type_t - UNC_KT_CONTROLLER - */ - unc_key_type_t get_key_type() { - return UNC_KT_CONTROLLER; - } + virtual UncRespCode delete_cmd(key_cmd& key_st, + val_cmd& val_st, + unc::driver::controller*)=0; }; /* @@ -318,14 +166,6 @@ class root_driver_command : public driver_command { read_all_child(unc::vtndrvcache::ConfigNode*, std::vector&, unc::driver::controller*)=0; - /** - * @brief - Method to return the Keytype - * @param[in]- None - * @retval - unc_key_type_t - UNC_KT_ROOT - */ - unc_key_type_t get_key_type() { - return UNC_KT_ROOT; - } }; } // namespace driver } // namespace unc diff --git a/coordinator/modules/vtndrvintf/include/request_template.hh b/coordinator/modules/vtndrvintf/include/request_template.hh index 2aea941b..13b50059 100644 --- a/coordinator/modules/vtndrvintf/include/request_template.hh +++ b/coordinator/modules/vtndrvintf/include/request_template.hh @@ -29,7 +29,7 @@ typedef std::map kt_handler_map; * @brief KtRequestHandler provides function for handling request and response * **/ -template +template class KtRequestHandler : public KtHandler { public: /* @@ -44,7 +44,7 @@ class KtRequestHandler : public KtHandler { /** * @brief - This method handles request received from platform layer - * @param[in]- ServerSession, odl_drv_request_header_t,ControllerFramework* + * @param[in]- ServerSession, odl_drv_request_header_t, ControllerFramework* * @retval - UncRespCode **/ UncRespCode @@ -64,7 +64,7 @@ class KtRequestHandler : public KtHandler { /** * @brief - This method retrieves the key and val structures - * @param[in] - ServerSession, odl_drv_request_header_t,key,val + * @param[in] - ServerSession, odl_drv_request_header_t, key, val * @retval - UncRespCode **/ @@ -92,10 +92,10 @@ class KtRequestHandler : public KtHandler { val &val_generic_); /** - * @brief - This method executes the Create,Delete,Update and Read requests of + * @brief - This method executes the Create, Delete, Update and Read requests of * Keytypes * @param[in]- ServerSession, odl_drv_request_header_t, ControllerFramework* - * UncRespCode,key,val + * UncRespCode, key, val * @retval - UncRespCode **/ UncRespCode @@ -108,8 +108,8 @@ class KtRequestHandler : public KtHandler { /** * @brief - This method handles response from controller * and send response to platform layer - * @param[in] - ServerSession, odl_drv_request_header_t,ControllerFramework*, - * key,val,UncRespCode + * @param[in] - ServerSession, odl_drv_request_header_t, ControllerFramework*, + * key, val, UncRespCode * @retval - UncRespCode **/ UncRespCode @@ -123,7 +123,7 @@ class KtRequestHandler : public KtHandler { /** * @brief - This method creates the Response Header * @param[in]- odl_drv_response_header_t, - * odl_drv_request_header_t,UncRespCode + * odl_drv_request_header_t, UncRespCode * @retval - void */ void @@ -157,8 +157,8 @@ class KtRequestHandler : public KtHandler { * @brief: Default Destructor **/ -template -KtRequestHandler::~KtRequestHandler() { +template +KtRequestHandler::~KtRequestHandler() { std::map :: iterator map_it; for (map_it = key_map_.begin(); map_it != key_map_.end(); map_it++) { delete map_it->second; @@ -178,8 +178,8 @@ KtRequestHandler::~KtRequestHandler() { * @param[in]- ConfigNode* * @retval - void* **/ -template -void* KtRequestHandler:: +template +void* KtRequestHandler:: get_key_struct(unc::vtndrvcache::ConfigNode *cfgptr) { unc::vtndrvcache::CacheElementUtil * cache_util_ptr = static_cast * > @@ -198,8 +198,8 @@ get_key_struct(unc::vtndrvcache::ConfigNode *cfgptr) { * @param[in]- ConfigNode* * @retval - void* **/ -template -void* KtRequestHandler:: +template +void* KtRequestHandler:: get_val_struct(unc::vtndrvcache::ConfigNode *cfgptr) { unc::vtndrvcache::CacheElementUtil * cache_util_ptr = static_cast +template UncRespCode -KtRequestHandler::parse_request( +KtRequestHandler::parse_request( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, key &key_generic_, @@ -240,15 +240,15 @@ KtRequestHandler::parse_request( } /** - * @brief - This method executes the Create,Delete,Update requests of + * @brief - This method executes the Create, Delete, Update requests of * Keytypes * @param[in]- ServerSession, odl_drv_request_header_t, ControllerFramework* - * UncRespCode,key,val + * UncRespCode, key, val * @retval - UncRespCode **/ -template +template UncRespCode -KtRequestHandler::execute( +KtRequestHandler::execute( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, unc::driver::ControllerFramework* ctrl_int, @@ -279,7 +279,7 @@ KtRequestHandler::execute( pfc_log_debug("getting conn status..ctr nt NULL"); if (ctrl_ptr->get_connection_status() == CONNECTION_DOWN) { - // check controller connection status, if down send disconnected + // check controller connection status, if down send disconnected pfc_log_debug("%s Controller status is down, send disconnected", PFC_FUNCNAME); return UNC_RC_CTR_DISCONNECTED; @@ -290,7 +290,10 @@ KtRequestHandler::execute( PFC_ASSERT(drv_command_ptr_ != NULL); - command_class *command_ptr_ = static_cast (drv_command_ptr_); + unc::driver::vtn_driver_command * command_ptr_ = + static_cast*>(drv_command_ptr_); + // command_class *command_ptr_ = + // static_cast (drv_command_ptr_); PFC_ASSERT(command_ptr_ != NULL); @@ -376,13 +379,13 @@ KtRequestHandler::execute( /** * @brief - This method is the Template Specialization for parsing - * KT_Controller structures(Key,Val) - * @param[in] - ServerSession, odl_drv_request_header_t,key_ctr_t,val_ctr_t + * KT_Controller structures(Key, Val) + * @param[in] - ServerSession, odl_drv_request_header_t, key_ctr_t, val_ctr_t * @retval - UncRespCode **/ template<> UncRespCode -KtRequestHandler::parse_request( +KtRequestHandler::parse_request( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, key_ctr_t &key_generic_, @@ -413,13 +416,13 @@ KtRequestHandler::parse_request( /** * @brief - This method is template Specialization for parsing KT_ROOT - * @param[in] - ServerSession,odl_drv_request_header_t,key_root_t + * @param[in] - ServerSession, odl_drv_request_header_t, key_root_t * val_root_t * @retval - UncRespCode **/ template<> UncRespCode -KtRequestHandler::parse_request( +KtRequestHandler::parse_request( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, key_root_t &key_generic_, @@ -432,12 +435,12 @@ KtRequestHandler::parse_request( * @brief - This method is the template Specialization for * KT ROOT command Execution * @param[in]- ServerSession, odl_drv_request_header_t, ControllerFramework* - * UncRespCode,key_root_t,val_root_t + * UncRespCode, key_root_t, val_root_t * @retval - UncRespCode **/ template<> UncRespCode -KtRequestHandler::execute( +KtRequestHandler::execute( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, unc::driver::ControllerFramework* ctrl_int, @@ -492,11 +495,11 @@ KtRequestHandler::execute( pfc_log_debug("parent is UNC_KT_ROOT"); std::vector cfg_list; - // fetch all root child configuration + // fetch all root child configuration resp_code_ = drv_command_ptr_->fetch_config(ctrl_ptr, NULL, cfg_list); pfc_log_debug("vtn resp_code_%u", resp_code_); if (resp_code_ != UNC_RC_SUCCESS) { - pfc_log_error("%s:GetDriverByControllerName failed VTN .rt,%u", + pfc_log_error("%s:GetDriverByControllerName failed VTN .rt, %u", PFC_FUNCNAME, resp_code_); delete drv_command_ptr_; return resp_code_; @@ -532,7 +535,7 @@ KtRequestHandler::execute( cfg_list); pfc_log_debug("resp_code_%u", resp_code_); if (resp_code_!= UNC_RC_SUCCESS) { - pfc_log_error("%s:GetDriverByControllerName failed .rt,%u", + pfc_log_error("%s:GetDriverByControllerName failed .rt, %u", PFC_FUNCNAME, resp_code_); delete drv_command_ptr_; return resp_code_; @@ -557,9 +560,9 @@ KtRequestHandler::execute( return resp_code_; } -template +template KtHandler* -KtRequestHandler::get_handler(unc_key_type_t keytype) { +KtRequestHandler::get_handler(unc_key_type_t keytype) { std::map ::iterator iter = kt_map_->begin(); iter = kt_map_->find(keytype); KtHandler* hnd_ptr = NULL; @@ -573,12 +576,12 @@ KtRequestHandler::get_handler(unc_key_type_t keytype) { /** * @brief - This method is the template Specialization for KT Controller command Execution * @param[in]- ServerSession, odl_drv_request_header_t, ControllerFramework* - * UncRespCode,key_root_t,val_root_t + * UncRespCode, key_root_t, val_root_t * @retval - UncRespCode **/ template<> UncRespCode -KtRequestHandler::execute( +KtRequestHandler::execute( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, unc::driver::ControllerFramework* ctrl_int, @@ -649,12 +652,12 @@ KtRequestHandler::execute( /** * @brief - This method handles request received from platform layer - * @param[in]- ServerSession, odl_drv_request_header_t,ControllerFramework* + * @param[in]- ServerSession, odl_drv_request_header_t, ControllerFramework* * @retval - UncRespCode **/ -template +template UncRespCode -KtRequestHandler::handle_request( +KtRequestHandler::handle_request( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, unc::driver::ControllerFramework* ctrl_int) { @@ -699,9 +702,9 @@ KtRequestHandler::handle_request( * @param[in]- ConfigNode*, controller*, driver* * @retval - UncRespCode **/ -template +template UncRespCode -KtRequestHandler::execute_cmd( +KtRequestHandler::execute_cmd( unc::vtndrvcache::ConfigNode *cfgptr, unc::driver::controller* conn, unc::driver::driver* drv_ptr) { @@ -715,12 +718,13 @@ KtRequestHandler::execute_cmd( PFC_ASSERT(cache_element_ptr != NULL); unc_key_type_t keytype = cfgptr->get_type_name(); - unc::driver::driver_command * drv_command_ptr_ = + unc::driver::driver_command * driver_cmd_ptr = drv_ptr->create_driver_command(keytype); - PFC_ASSERT(drv_command_ptr_ != NULL); - command_class * config_cmd_ptr = NULL; - config_cmd_ptr = static_cast (drv_command_ptr_); + // command_class * config_cmd_ptr = NULL; + // config_cmd_ptr = static_cast (drv_command_ptr_); + unc::driver::vtn_driver_command * config_cmd_ptr = + static_cast *>(driver_cmd_ptr); uint32_t config_operation = cfgptr->get_operation(); pfc_log_debug("keytype:%u, config_operation:%u", keytype, config_operation); @@ -773,13 +777,13 @@ KtRequestHandler::execute_cmd( /** * @brief - This method handles response from controller, * doesnot support audit - * @param[in] - ServerSession, odl_drv_request_header_t,ControllerFramework*, - * key,val,UncRespCode + * @param[in] - ServerSession, odl_drv_request_header_t, ControllerFramework*, + * key, val, UncRespCode * @retval - UncRespCode **/ -template +template UncRespCode -KtRequestHandler::handle_response( +KtRequestHandler::handle_response( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, unc::driver::ControllerFramework* ctrl_int, @@ -794,7 +798,7 @@ KtRequestHandler::handle_response( UncRespCode resp_code_ = UNC_DRV_RC_ERR_GENERIC; resp_code_ = populate_response_header(sess, resp_hdr); if (resp_code_ != UNC_RC_SUCCESS) { - pfc_log_error("%s: populate_response_header failed with ret_code ,%u", + pfc_log_error("%s: populate_response_header failed with ret_code , %u", PFC_FUNCNAME, resp_code_); return resp_code_; } @@ -815,7 +819,7 @@ KtRequestHandler::handle_response( if (resp_hdr.header.data_type != UNC_DT_RUNNING) { uint32_t ret_code = sess.addOutput(key_generic_); if (ret_code) { - pfc_log_error("%s: addOutput failed with ret_code ,%u", + pfc_log_error("%s: addOutput failed with ret_code , %u", PFC_FUNCNAME, ret_code); return UNC_DRV_RC_ERR_GENERIC; } @@ -826,13 +830,13 @@ KtRequestHandler::handle_response( /** * @brief - This method handles response from controller for Audit - * @param[in] - ServerSession, odl_drv_request_header_t,ControllerFramework*, - * key_root_t,val_root_t,UncRespCode + * @param[in] - ServerSession, odl_drv_request_header_t, ControllerFramework*, + * key_root_t, val_root_t, UncRespCode * @retval - UncRespCode **/ template<> UncRespCode -KtRequestHandler::handle_response( +KtRequestHandler::handle_response( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_request_header_t &request_header, unc::driver::ControllerFramework* ctrl_int, @@ -849,7 +853,7 @@ KtRequestHandler::handle_response( resp_code_ = populate_response_header(sess, resp_hdr); if (resp_code_ != UNC_RC_SUCCESS) { pfc_log_error("%s: populate_response_header failed" - "with ret_code root ,%u", PFC_FUNCNAME, resp_code_); + "with ret_code root , %u", PFC_FUNCNAME, resp_code_); return resp_code_; } std::string ctr_name(resp_hdr.controller_name); @@ -866,7 +870,7 @@ KtRequestHandler::handle_response( uint32_t size = ctr->controller_cache->audit_cfg_list_count(); pfc_log_debug("config node size is %d for controller %s", size, ctr_name.c_str()); - // Not Success and Error Case check for Reps + // Not Success and Error Case check for Reps if ((size == 0) && (resp_hdr.result == UNC_RC_NO_SUCH_INSTANCE)) { pfc_log_debug("%s: Value list empty and Response" @@ -876,7 +880,7 @@ KtRequestHandler::handle_response( sess.addOutput((uint32_t) UNC_KT_ROOT); sess.addOutput(key_generic_); - // delete cache + // delete cache delete ctr->controller_cache; ctr->controller_cache = NULL; @@ -889,7 +893,7 @@ KtRequestHandler::handle_response( sess.addOutput((uint32_t) resp_hdr.result); sess.addOutput((uint32_t) UNC_KT_ROOT); sess.addOutput(key_generic_); - // delete cache + // delete cache delete ctr->controller_cache; ctr->controller_cache = NULL; pfc_log_trace("ResponseHandler::%s Exiting", PFC_FUNCNAME); @@ -927,11 +931,11 @@ KtRequestHandler::handle_response( pfc_log_debug("Add empty success"); } unc_key_type_t keytype = cfgnode->get_type_name(); - pfc_log_debug("%u,keytype", keytype); + pfc_log_debug("%u, keytype", keytype); uint32_t ret_code = sess.addOutput((uint32_t)keytype); if (ret_code) { - pfc_log_error("%s: addOutput failed for keytype ,%u", + pfc_log_error("%s: addOutput failed for keytype , %u", PFC_FUNCNAME, ret_code); delete ctr->controller_cache; ctr->controller_cache = NULL; @@ -947,7 +951,7 @@ KtRequestHandler::handle_response( pfc_ipcstdef_t* val_sdf =val_map_.find(keytype)->second; ret_code = sess.addOutput(*key_sdf, key); if (ret_code) { - pfc_log_error("%s: addOutput failed for key_sdf with ret_code ,%u", + pfc_log_error("%s: addOutput failed for key_sdf with ret_code , %u", PFC_FUNCNAME, ret_code); delete ctr->controller_cache; ctr->controller_cache = NULL; @@ -958,7 +962,7 @@ KtRequestHandler::handle_response( pfc_log_debug("Add key success"); ret_code = sess.addOutput(*val_sdf, val); if (ret_code) { - pfc_log_error("%s: addOutput failed for val_sdf with ret_code ,%u", + pfc_log_error("%s: addOutput failed for val_sdf with ret_code , %u", PFC_FUNCNAME, ret_code); delete ctr->controller_cache; ctr->controller_cache = NULL; @@ -967,7 +971,7 @@ KtRequestHandler::handle_response( } pfc_log_debug("Add val success"); } // for loop - // delete cache + // delete cache delete ctr->controller_cache; ctr->controller_cache = NULL; } else { @@ -986,12 +990,12 @@ KtRequestHandler::handle_response( /** * @brief - This method creates the Response Header * @param[in]- odl_drv_response_header_t, - * odl_drv_request_header_t,UncRespCode + * odl_drv_request_header_t, UncRespCode * @retval - void */ -template +template void -KtRequestHandler::create_response_header( +KtRequestHandler::create_response_header( unc::driver::odl_drv_request_header_t &reqhdr, unc::driver::odl_drv_response_header_t &resphdr, UncRespCode &resp_code_) { @@ -1031,9 +1035,9 @@ KtRequestHandler::create_response_header( * @param[in]- ServerSession, odl_drv_response_header_t * @retval - UncRespCode **/ -template +template UncRespCode -KtRequestHandler::populate_response_header( +KtRequestHandler::populate_response_header( pfc::core::ipc::ServerSession &sess, unc::driver::odl_drv_response_header_t &resp_hdr) { ODC_FUNC_TRACE; @@ -1139,9 +1143,9 @@ KtRequestHandler::populate_response_header( * @brief - This method initializes map for STDEF * @retval - void **/ -template +template void -KtRequestHandler::initialize_map() { +KtRequestHandler::initialize_map() { uint32_t loop = 0; unc_key_type_t KT[] = {UNC_KT_VTN, UNC_KT_VBRIDGE, UNC_KT_VBR_IF, UNC_KT_VBR_VLANMAP}; diff --git a/coordinator/modules/vtndrvintf/include/vtn_drv_module.hh b/coordinator/modules/vtndrvintf/include/vtn_drv_module.hh index d2d155e3..45246fd8 100644 --- a/coordinator/modules/vtndrvintf/include/vtn_drv_module.hh +++ b/coordinator/modules/vtndrvintf/include/vtn_drv_module.hh @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include @@ -190,6 +192,14 @@ class VtnDrvIntf :public pfc::core::Module { val_link_st_t &new_val_struct, val_link_st_t &old_val_struct); + /** + * @brief : Method to create Kt handler + * @param[in] : unc_key_type_t + * @retval : None + */ + template + void create_handler(unc_key_type_t keytype); + // used for Controller ping pfc::core::TaskQueue* taskq_; diff --git a/coordinator/modules/vtndrvintf/vtn_drv_module.cc b/coordinator/modules/vtndrvintf/vtn_drv_module.cc index dd1a7423..c3ab74ca 100644 --- a/coordinator/modules/vtndrvintf/vtn_drv_module.cc +++ b/coordinator/modules/vtndrvintf/vtn_drv_module.cc @@ -8,9 +8,7 @@ */ #include -#include #include -#include "unc/unc_events.h" namespace unc { namespace driver { @@ -52,76 +50,14 @@ pfc_bool_t VtnDrvIntf::init(void) { PFC_ASSERT(ctrl_inst_ != NULL); set_controller_instance(ctrl_inst_); - // Initialize KT_Handler_Instance - KtHandler* ctrl_req = new unc::driver::KtRequestHandler(NULL); - - if (NULL == ctrl_req) { - pfc_log_error("controller request handler is NULL"); - return PFC_FALSE; - } - map_kt_.insert(std::pair( - UNC_KT_CONTROLLER, - ctrl_req)); - - KtHandler* kt_root_req = new unc::driver::KtRequestHandler(&map_kt_); - if (NULL == kt_root_req) { - pfc_log_error("KT_ROOT request handler is NULL"); - return PFC_FALSE; - } - map_kt_.insert(std::pair( - UNC_KT_ROOT, - kt_root_req)); - - KtHandler* vtn_req = new unc::driver::KtRequestHandler(NULL); - if (NULL == vtn_req) { - pfc_log_error("vtn request handler is NULL"); - return PFC_FALSE; - } - map_kt_.insert(std::pair(UNC_KT_VTN, vtn_req)); - - KtHandler* vbr_req = new unc::driver::KtRequestHandler (NULL); - if (NULL == vbr_req) { - pfc_log_error("vbr request handler is NULL"); - return PFC_FALSE; - } - - map_kt_.insert(std::pair( - UNC_KT_VBRIDGE, - vbr_req)); - - KtHandler* vbrif_req = new unc::driver::KtRequestHandler(NULL); - if (NULL == vbrif_req) { - pfc_log_error("vbr interface request handler is NULL"); - return PFC_FALSE; - } - - map_kt_.insert(std::pair( - UNC_KT_VBR_IF, - vbrif_req)); - - KtHandler* vbrvlanmap_req = new unc::driver::KtRequestHandler (NULL); - - if (NULL == vbrvlanmap_req) { - pfc_log_error("vbrvlanmap request handler is NULL"); - return PFC_FALSE; - } - - map_kt_.insert(std::pair( - UNC_KT_VBR_VLANMAP, - vbrvlanmap_req)); + create_handler(UNC_KT_ROOT); + create_handler(UNC_KT_CONTROLLER); + create_handler(UNC_KT_VTN); + create_handler(UNC_KT_VBRIDGE); + create_handler + (UNC_KT_VBR_IF); + create_handler + (UNC_KT_VBR_VLANMAP); unc::tclib::TcLibModule* tclib_obj = static_cast(pfc::core::Module::getInstance( @@ -348,11 +284,11 @@ void VtnDrvIntf::read_conf_file() { conf_parser_.time_interval = drv_block.getUint32("physical_attributes_read_interval", default_time_interval); - pfc_log_debug("%s: Block Handle is Valid,Time interval %d", PFC_FUNCNAME, + pfc_log_debug("%s: Block Handle is Valid, Time interval %d", PFC_FUNCNAME, conf_parser_.time_interval); } else { conf_parser_.time_interval = default_time_interval; - pfc_log_debug("%s: Block Handle is Invalid,set default Value %d", + pfc_log_debug("%s: Block Handle is Invalid, set default Value %d", PFC_FUNCNAME, conf_parser_.time_interval); } } @@ -419,9 +355,9 @@ void VtnDrvIntf::logicalport_event(oper_type operation, (const char*)key_struct.domain_key.ctr_key.controller_name; std::string domain_name= (const char*)key_struct.domain_key.domain_name; std::string logical_port_id = (const char*)key_struct.port_id; - pfc_log_debug("%s,key structure fields:" - "controller_name: %s," - "domain_id: %s," + pfc_log_debug("%s, key structure fields:" + "controller_name: %s, " + "domain_id: %s, " "logicalport_id: %s", PFC_FUNCNAME, controller_name.c_str(), domain_name.c_str(), logical_port_id.c_str()); Domain_event = ctrl_inst_->GetDomainFlag(controller_name); @@ -478,9 +414,9 @@ void VtnDrvIntf::switch_event(oper_type operation, (const char*)key_struct.ctr_key.controller_name; std::string switch_id = (const char*)key_struct.switch_id; - pfc_log_debug("%s,key structure fields:" - "controller_name: %s," - "switch_id: %s,", PFC_FUNCNAME, controller_name.c_str(), + pfc_log_debug("%s, key structure fields:" + "controller_name: %s, " + "switch_id: %s, ", PFC_FUNCNAME, controller_name.c_str(), switch_id.c_str()); pfc_log_debug("Switch event Operation received is %d", operation); switch (operation) { @@ -533,9 +469,9 @@ void VtnDrvIntf::switch_event(oper_type operation, (const char*)key_struct.ctr_key.controller_name; std::string switch_id = (const char*)key_struct.switch_id; - pfc_log_debug("%s,key structure fields:" - "controller_name: %s," - "switch_id: %s,", PFC_FUNCNAME, controller_name.c_str(), + pfc_log_debug("%s, key structure fields:" + "controller_name: %s, " + "switch_id: %s, ", PFC_FUNCNAME, controller_name.c_str(), switch_id.c_str()); pfc_log_debug("Update Switch event Operation received is %d", operation); if (operation == VTN_SWITCH_UPDATE) { @@ -571,9 +507,9 @@ void VtnDrvIntf::port_event(oper_type operation, std::string switch_id = (const char*)key_struct.sw_key.switch_id; std::string port_id = (const char*)key_struct.port_id; - pfc_log_debug("%s,key structure fields:" - "controller_name: %s," - "switch_id: %s," + pfc_log_debug("%s, key structure fields:" + "controller_name: %s, " + "switch_id: %s, " "port_id: %s", PFC_FUNCNAME, controller_name.c_str(), switch_id.c_str(), port_id.c_str()); pfc_log_debug("Port event Operation received is %d", operation); @@ -626,9 +562,9 @@ void VtnDrvIntf::port_event(oper_type operation, std::string switch_id = (const char*)key_struct.sw_key.switch_id; std::string port_id = (const char*)key_struct.port_id; - pfc_log_debug("%s,key structure fields:" - "controller_name: %s," - "switch_id: %s," + pfc_log_debug("%s, key structure fields:" + "controller_name: %s, " + "switch_id: %s, " "port_id: %s", PFC_FUNCNAME, controller_name.c_str(), switch_id.c_str(), port_id.c_str()); pfc_log_debug("Update Port event Operation received [%d]", operation); @@ -666,13 +602,13 @@ void VtnDrvIntf::link_event(oper_type operation, std::string switch_id2 = (const char*)key_struct.switch_id2; std::string port_id2 = (const char*)key_struct.port_id2; - pfc_log_debug("%s,key structure fields:" - "controller_name: %s," - "switch_id1: %s," + pfc_log_debug("%s, key structure fields:" + "controller_name: %s, " + "switch_id1: %s, " "port_id1: %s", PFC_FUNCNAME, controller_name.c_str(), switch_id1.c_str(), port_id1.c_str()); - pfc_log_debug("switch_id2: %s," + pfc_log_debug("switch_id2: %s, " "port_id2: %s", switch_id2.c_str(), port_id2.c_str()); pfc_log_debug("Link event Operation received is %d", operation); @@ -728,13 +664,13 @@ void VtnDrvIntf::link_event(oper_type operation, std::string switch_id2 = (const char*)key_struct.switch_id2; std::string port_id2 = (const char*)key_struct.port_id2; - pfc_log_debug("%s,key structure fields:" - "controller_name: %s," - "switch_id1: %s," + pfc_log_debug("%s, key structure fields:" + "controller_name: %s, " + "switch_id1: %s, " "port_id1: %s", PFC_FUNCNAME, controller_name.c_str(), switch_id1.c_str(), port_id1.c_str()); - pfc_log_debug("switch_id2: %s," + pfc_log_debug("switch_id2: %s, " "port_id2: %s", switch_id2.c_str(), port_id2.c_str()); pfc_log_debug("Update Link event Operation received is %d", operation); @@ -754,6 +690,26 @@ void VtnDrvIntf::link_event(oper_type operation, } } +/** + * @brief : Method to create Kt handler + * @param[in] : unc_key_type_t + * @retval : None + */ +template +void VtnDrvIntf::create_handler(unc_key_type_t keytype) { + if (keytype == UNC_KT_ROOT) { + KtHandler* handler_= new KtRequestHandler(&map_kt_); + map_kt_.insert(std::pair( + keytype, + handler_)); + } else { + KtHandler* handler_= new KtRequestHandler(NULL); + map_kt_.insert(std::pair( + keytype, + handler_)); +} +} + } // namespace driver } // namespace unc PFC_MODULE_IPC_DECL(unc::driver::VtnDrvIntf, 3); diff --git a/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_command.hh b/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_command.hh index ddba938c..7a563e3b 100644 --- a/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_command.hh +++ b/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_command.hh @@ -25,75 +25,30 @@ class driver_command { public: virtual ~driver_command() { } - virtual unc_key_type_t get_key_type()=0; virtual UncRespCode revoke(unc::driver::controller* ctr_ptr) { return UNC_RC_SUCCESS; } virtual UncRespCode fetch_config(unc::driver::controller* ctr, - void* parent_key, - std::vector&) = 0; + void* parent_key, + std::vector&) = 0; }; - +template class vtn_driver_command: public driver_command { public: - UncRespCode create_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_, - controller*) { - return UNC_RC_SUCCESS; - } - - UncRespCode update_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_, - controller*) { - return UNC_RC_SUCCESS; - } - - UncRespCode delete_cmd(key_vtn_t& keyvtn_, val_vtn_t& valvtn_, - controller*) { - return UNC_RC_SUCCESS; - } - - UncRespCode validate_op(key_vtn_t& keyvtn_, val_vtn_t& valvtn_, - controller*, uint32_t op) { - return UNC_RC_SUCCESS; - } - - unc_key_type_t get_key_type() { - return UNC_KT_VTN; - } - UncRespCode fetch_config( - unc::driver::controller* ctr, - void* parent_key, - std::vector&) { - return UNC_RC_SUCCESS; - } -}; - -class vbr_driver_command: public driver_command { - public: - UncRespCode create_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_, - unc::driver::controller*) { + UncRespCode create_cmd(key_temp& key_st, val_temp& val_st, + unc::driver::controller*) { return UNC_RC_SUCCESS; } - - - UncRespCode update_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_, - unc::driver::controller*) { + UncRespCode update_cmd(key_temp& key_st, val_temp& val_st, + unc::driver::controller*) { return UNC_RC_SUCCESS; } - - UncRespCode delete_cmd(key_vbr_t& keyvbr_, val_vbr_t& valvbr_, - unc::driver::controller*) { + UncRespCode delete_cmd(key_temp& key_st, val_temp& val_st, + unc::driver::controller*) { return UNC_RC_SUCCESS; } - UncRespCode validate_op(key_vbr_t& keyvbr_, val_vbr_t& valvbr_, - unc::driver::controller*, uint32_t op) { - return UNC_RC_SUCCESS; - } - - unc_key_type_t get_key_type() { - return UNC_KT_VBRIDGE; - } UncRespCode fetch_config( unc::driver::controller* ctr, void* parent_key, @@ -102,120 +57,6 @@ class vbr_driver_command: public driver_command { } }; -class vbrif_driver_command: public driver_command { - public: - UncRespCode create_cmd(key_vbr_if_t& key, - pfcdrv_val_vbr_if_t& val, unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - UncRespCode update_cmd(key_vbr_if_t& key, - pfcdrv_val_vbr_if_t& val, unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - UncRespCode delete_cmd(key_vbr_if_t& key, - pfcdrv_val_vbr_if_t& val, unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - UncRespCode validate_op(key_vbr_if_t& key, - pfcdrv_val_vbr_if_t& val, unc::driver::controller* ctr, - uint32_t op) { - return UNC_RC_SUCCESS; - } - - unc_key_type_t get_key_type() { - return UNC_KT_VBR_IF; - } - UncRespCode fetch_config( - unc::driver::controller* ctr, - void* parent_key, - std::vector&) { - return UNC_RC_SUCCESS; - } -}; - -class controller_command: public driver_command { - public: - UncRespCode create_cmd(key_ctr_t& key, - val_ctr_t & val, unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - UncRespCode update_cmd(key_ctr_t & key, - val_ctr_t& val, unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - UncRespCode delete_cmd(key_ctr_t & key, - val_ctr_t & val, unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - UncRespCode validate_op(key_ctr_t & key, - val_ctr_t& val, unc::driver::controller* ctr, - uint32_t op) { - return UNC_RC_SUCCESS; - } - - unc_key_type_t get_key_type() { - return UNC_KT_CONTROLLER; - } - UncRespCode fetch_config( - unc::driver::controller* ctr, - void* parent_key, - std::vector&) { - return UNC_RC_SUCCESS; - } -}; - - class vbrvlanmap_driver_command: public driver_command { - public: - /** - * @brief - Method to create Vbr VLAN-Map in the controller - * @param[in]- key_vlan_map_t, val_vlan_map_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - UncRespCode create_cmd(key_vlan_map_t& key, - val_vlan_map_t& val, - unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - /** - * @brief - Method to update Vbr VLAN-Map in the controller - * @param[in]- key_vlan_map_t, val_vlan_map_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - UncRespCode update_cmd(key_vlan_map_t& key, - val_vlan_map_t& val, - unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - /** - * @brief - Method to delete Vbr VLAN-Map in the controller - * @param[in]- key_vlan_map_t, val_vlan_map_t, controller* - * @retval - UNC_RC_SUCCESS/UNC_DRV_RC_ERR_GENERIC - */ - UncRespCode delete_cmd(key_vlan_map_t& key, - val_vlan_map_t& val, - unc::driver::controller *conn) { - return UNC_RC_SUCCESS; - } - - /** - * @brief - Method to return the Keytype - * @param[in]- None - * @retval - unc_key_type_t - UNC_KT_VBR_VLANMAP - */ - unc_key_type_t get_key_type() { - return UNC_KT_VBR_VLANMAP; - } - }; - - class root_driver_command : public driver_command { public: UncRespCode @@ -266,9 +107,6 @@ class root_driver_command : public driver_command { return UNC_RC_SUCCESS; } - unc_key_type_t get_key_type() { - return UNC_KT_ROOT; - } UncRespCode fetch_config( unc::driver::controller* ctr, void* parent_key, diff --git a/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_interface.hh b/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_interface.hh index d3494ab4..f2a319ce 100644 --- a/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_interface.hh +++ b/coordinator/test/modules/stub/ContrllerFrameworkStub/driver/driver_interface.hh @@ -72,7 +72,7 @@ class driver { switch (key_type) { case UNC_KT_CONTROLLER: ptr = static_cast - (new controller_command); + (new unc::driver::vtn_driver_command); return ptr; break; case UNC_KT_ROOT: @@ -82,17 +82,17 @@ class driver { break; case UNC_KT_VTN: ptr = static_cast - (new vtn_driver_command); + (new unc::driver::vtn_driver_command); return ptr; break; case UNC_KT_VBRIDGE: ptr = static_cast - (new vbr_driver_command); + (new unc::driver::vtn_driver_command); return ptr; break; case UNC_KT_VBR_IF: ptr = static_cast - (new vbrif_driver_command); + (new unc::driver::vtn_driver_command); return ptr; break; default: diff --git a/coordinator/test/modules/vtndrvintf/request_template/ut/test_request_template.cc b/coordinator/test/modules/vtndrvintf/request_template/ut/test_request_template.cc index 0f14875a..382a2d94 100644 --- a/coordinator/test/modules/vtndrvintf/request_template/ut/test_request_template.cc +++ b/coordinator/test/modules/vtndrvintf/request_template/ut/test_request_template.cc @@ -25,9 +25,7 @@ TEST(KT_VTN, Validate_Request1) { unc::driver::ControllerFramework* ctrl_int = new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.clearStubData(); @@ -64,9 +62,7 @@ TEST(KT_VTN, Validate_Request12) { unc::driver::ControllerFramework* ctrl_int = new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.clearStubData(); @@ -104,9 +100,7 @@ TEST(KT_VTN, Validate_Request13) { unc::driver::ControllerFramework* ctrl_int = new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -148,9 +142,7 @@ TEST(KT_VTN, Validate_Request14) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.clearStubData(); @@ -189,9 +181,7 @@ TEST(KT_VTN, Validate_Request15) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -233,9 +223,7 @@ TEST(KT_VTN, Validate_Request16) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -278,9 +266,7 @@ TEST(KT_VTN, Validate_Request17) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.stub_setArgument_(0); @@ -323,9 +309,7 @@ TEST(KT_VTN, Validate_Request18) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -372,9 +356,7 @@ TEST(KT_VTN, Validate_Request19) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -420,9 +402,7 @@ TEST(KT_VTN, Validate_Request191) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -469,9 +449,7 @@ TEST(KT_VTN, Validate_Request192) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -519,9 +497,7 @@ TEST(KT_VTN, Validate_Request193) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -570,9 +546,7 @@ TEST(KT_VTN, Validate_Request194) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -624,9 +598,7 @@ TEST(KT_VTN, Validate_Request2) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -676,9 +648,7 @@ TEST(KT_VTN, Validate_Request3) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -728,9 +698,7 @@ TEST(KT_VBR, Validate_Request1) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vbr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -780,9 +748,7 @@ TEST(KT_VBR, Validate_Request2) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vbr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -832,9 +798,7 @@ TEST(KT_VBR, Validate_Request3) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vbr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -884,9 +848,8 @@ TEST(KT_VBR_IF, Validate_Request1) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vbrif_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler + (&kt_map); pfc::core::ipc::ServerSession sess; @@ -937,9 +900,8 @@ TEST(KT_VBR_IF, Validate_Request2) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vbrif_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler + (&kt_map); pfc::core::ipc::ServerSession sess; @@ -989,9 +951,8 @@ TEST(KT_VBR_IF, Validate_Request3) { new unc::driver::ControllerFramework; unc::driver::KtHandler* vbrif_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler + (&kt_map); pfc::core::ipc::ServerSession sess; @@ -1042,9 +1003,7 @@ TEST(KT_CTR, Validate_Request1) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.clearStubData(); @@ -1091,9 +1050,7 @@ TEST(KT_CTR, Validate_Request11) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.clearStubData(); @@ -1142,9 +1099,7 @@ TEST(KT_CTR, Validate_Request12) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.clearStubData(); @@ -1197,9 +1152,7 @@ TEST(KT_CTR, Validate_Request13) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; sess.clearStubData(); @@ -1251,9 +1204,7 @@ TEST(KT_CTR, Validate_Request2) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -1305,9 +1256,7 @@ TEST(KT_CTR, Validate_Request21) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -1361,9 +1310,7 @@ TEST(KT_CTR, Validate_Request3) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -1415,9 +1362,7 @@ TEST(KT_CTR, Validate_Request31) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -1470,9 +1415,7 @@ TEST(KT_CTR, Validate_Request32) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -1525,9 +1468,7 @@ TEST(KT_CTR, Validate_Request4) { new unc::driver::ControllerFramework; unc::driver::KtHandler* ctr_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); pfc::core::ipc::ServerSession sess; @@ -1592,9 +1533,7 @@ TEST(GLOBAL_CREATE, execute_cmd1) { std::string ctr_name = "odc1"; ctrl_int->GetControllerInstance(ctr_name, &ctr, &drv); unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); uint32_t ret_val = vtn_req->execute_cmd(cfgptr, ctr, drv); @@ -1628,9 +1567,7 @@ TEST(GLOBAL_DELETE, execute_cmd2) { std::string ctr_name = "odc1"; ctrl_int->GetControllerInstance(ctr_name, &ctr, &drv); unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); uint32_t ret_val = vtn_req->execute_cmd(cfgptr, ctr, drv); @@ -1664,9 +1601,7 @@ TEST(GLOBAL_UPDATE, execute_cmd3) { std::string ctr_name = "odc1"; ctrl_int->GetControllerInstance(ctr_name, &ctr, &drv); unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); uint32_t ret_val = vtn_req->execute_cmd(cfgptr, ctr, drv); @@ -1700,9 +1635,7 @@ TEST(GLOBAL_DEFAULT, execute_cmd4) { std::string ctr_name = "odc1"; ctrl_int->GetControllerInstance(ctr_name, &ctr, &drv); unc::driver::KtHandler* vtn_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler(&kt_map); uint32_t ret_val = vtn_req->execute_cmd(cfgptr, ctr, drv); @@ -1727,9 +1660,8 @@ TEST(KT_ROOT, Validate_Request1) { ctrl_int->set_root_result(1); unc::driver::KtHandler* root_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler + (&kt_map); pfc::core::ipc::ServerSession sess; @@ -1782,9 +1714,8 @@ TEST(KT_ROOT, Validate_Request2) { ctrl_int->set_root_result(2); unc::driver::KtHandler* root_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler + (&kt_map); pfc::core::ipc::ServerSession sess; @@ -1836,9 +1767,8 @@ TEST(KT_ROOT, Validate_Request3) { ctrl_int->set_root_result(3); unc::driver::KtHandler* root_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler + (&kt_map); pfc::core::ipc::ServerSession sess; @@ -1887,9 +1817,8 @@ TEST(KT_ROOT, Validate_Request4) { ctrl_int->set_root_result(3); unc::driver::KtHandler* root_req = - new unc::driver::KtRequestHandler(&kt_map); + new unc::driver::KtRequestHandler + (&kt_map); pfc::core::ipc::ServerSession sess; diff --git a/coordinator/test/modules/vtndrvintf/transaction_handle/ut/vtn_drv_transaction_handle_ut.cc b/coordinator/test/modules/vtndrvintf/transaction_handle/ut/vtn_drv_transaction_handle_ut.cc index a0bc4ea4..0eac53a9 100644 --- a/coordinator/test/modules/vtndrvintf/transaction_handle/ut/vtn_drv_transaction_handle_ut.cc +++ b/coordinator/test/modules/vtndrvintf/transaction_handle/ut/vtn_drv_transaction_handle_ut.cc @@ -359,8 +359,7 @@ TEST_F(DriverTxnInterfaceTest, HandleCommitVoteCacheSuccess) { kt_handler_map map_kt_; KtHandler* vtn_req = - new unc::driver::KtRequestHandler(NULL); + new unc::driver::KtRequestHandler(NULL); map_kt_.insert(std::pair(UNC_KT_VTN, vtn_req)); @@ -424,8 +423,7 @@ TEST_F(DriverTxnInterfaceTest, HandleCommitCacheSuccess) { kt_handler_map map_kt_; KtHandler* vtn_req = - new unc::driver::KtRequestHandler(NULL); + new unc::driver::KtRequestHandler(NULL); map_kt_.insert(std::pair(UNC_KT_VTN, vtn_req)); @@ -467,8 +465,7 @@ TEST_F(DriverTxnInterfaceTest, HandleCommitCacheCmdFailure) { kt_handler_map map_kt_; KtHandler* vtn_req = - new unc::driver::KtRequestHandler(NULL); + new unc::driver::KtRequestHandler(NULL); map_kt_.insert(std::pair(UNC_KT_VTN, vtn_req)); -- 2.36.6