From 5920f5797fd6b7660de8d7f6610253859e7f01c9 Mon Sep 17 00:00:00 2001 From: Vasundhara Volam Date: Fri, 24 Jan 2025 23:53:43 +0000 Subject: [PATCH] Remove old way of HALT Reboot method --- common_utils/context.go | 3 --- gnmi_server/gnoi_system.go | 23 +---------------------- sonic_service_client/dbus_client.go | 19 ------------------- 3 files changed, 1 insertion(+), 44 deletions(-) diff --git a/common_utils/context.go b/common_utils/context.go index 52d5b2570..b9869a3c7 100644 --- a/common_utils/context.go +++ b/common_utils/context.go @@ -54,7 +54,6 @@ const ( DBUS_STOP_SERVICE DBUS_RESTART_SERVICE DBUS_FILE_STAT - DBUS_HALT_SYSTEM DBUS_IMAGE_DOWNLOAD DBUS_IMAGE_INSTALL DBUS_IMAGE_LIST @@ -96,8 +95,6 @@ func (c CounterType) String() string { return "DBUS restart service" case DBUS_FILE_STAT: return "DBUS file stat" - case DBUS_HALT_SYSTEM: - return "DBUS halt system" case DBUS_IMAGE_DOWNLOAD: return "DBUS image download" case DBUS_IMAGE_INSTALL: diff --git a/gnmi_server/gnoi_system.go b/gnmi_server/gnoi_system.go index c228af412..ea562bd86 100644 --- a/gnmi_server/gnoi_system.go +++ b/gnmi_server/gnoi_system.go @@ -91,19 +91,6 @@ func (srv *Server) KillProcess(ctx context.Context, req *syspb.KillProcessReques return &resp, nil } -func HaltSystem() error { - sc, err := ssc.NewDbusClient() - if err != nil { - return err - } - log.V(2).Infof("Halting the system..") - err = sc.HaltSystem() - if err != nil { - log.V(2).Infof("Failed to Halt the system %v", err) - } - return err -} - // Processes message payload as op, data, field-value pairs. func processMsgPayload(pload string) (string, string, map[string]string, error) { var payload []string @@ -210,15 +197,7 @@ func (srv *Server) Reboot(ctx context.Context, req *syspb.RebootRequest) (*syspb if err := ValidateRebootRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, err.Error()) } - // Handle the HALT request. - if req.GetMethod() == syspb.RebootMethod_HALT { - log.V(1).Info("Reboot method is HALT. Halting the system...") - err = HaltSystem() - if err != nil { - return nil, err - } - return &syspb.RebootResponse{}, nil - } + // Initialize State DB. rclient, err := common_utils.GetRedisDBClient() if err != nil { diff --git a/sonic_service_client/dbus_client.go b/sonic_service_client/dbus_client.go index 37853fa9c..d940a15d6 100644 --- a/sonic_service_client/dbus_client.go +++ b/sonic_service_client/dbus_client.go @@ -24,7 +24,6 @@ type Service interface { StopService(service string) error RestartService(service string) error GetFileStat(path string) (map[string]string, error) - HaltSystem() error DownloadImage(url string, save_as string) error InstallImage(where string) error ListImages() (string, error) @@ -212,24 +211,6 @@ func (c *DbusClient) GetFileStat(path string) (map[string]string, error) { return data, nil } -func (c *DbusClient) HaltSystem() error { - // Increment the counter for the DBUS_HALT_SYSTEM event - common_utils.IncCounter(common_utils.DBUS_HALT_SYSTEM) - - // Set the module name and update the D-Bus properties - modName := "systemd" - busName := c.busNamePrefix + modName - busPath := c.busPathPrefix + modName - intName := c.intNamePrefix + modName + ".execute_reboot" - - //Set the method to HALT(3) the system - const RebootMethod_HALT = 3 - - // Invoke the D-Bus API to execute the halt command - _, err := DbusApi(busName, busPath, intName, 10, RebootMethod_HALT) - return err -} - func (c *DbusClient) DownloadImage(url string, save_as string) error { common_utils.IncCounter(common_utils.DBUS_IMAGE_DOWNLOAD) modName := "image_service"