Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions common_utils/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
23 changes: 1 addition & 22 deletions gnmi_server/gnoi_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 0 additions & 19 deletions sonic_service_client/dbus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down