Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
slntopp committed Dec 16, 2024
1 parent 7f3c49b commit 11fd7a7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
29 changes: 1 addition & 28 deletions providers/os/connection/device/device_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package device

import (
"errors"
"os"
"path"
"runtime"
"strings"
Expand Down Expand Up @@ -197,26 +196,6 @@ func tryDetectAsset(connId uint32, partition *snapshot.PartitionInfo, conf *inve
fsPath = path.Join(fsPath, partition.Bind)
}

// debug
etc, err := os.ReadDir(path.Join(fsPath, "etc"))
etcs := make([]string, 0)
for _, e := range etc {
etcs = append(etcs, e.Name())
}
log.Debug().Any("etc", etcs).Err(err).Msg("device connection> etc dir")

// debug
ssh, err := os.ReadDir(path.Join(fsPath, "etc", "ssh"))
sshs := make([]string, 0)
for _, s := range ssh {
sshs = append(sshs, s.Name())
}
log.Debug().Any("ssh", sshs).Err(err).Msg("device connection> etc/ssh dir")

// debug
_, err = os.Stat(path.Join(fsPath, "etc", "machine-id"))
log.Debug().Err(err).Msg("device connection> machine-id existance check")

// create and initialize fs provider
log.Debug().Str("path", fsPath).Msg("device connection> trying to detect asset")
conf.Options["path"] = fsPath
Expand All @@ -240,25 +219,19 @@ func tryDetectAsset(connId uint32, partition *snapshot.PartitionInfo, conf *inve
}

log.Debug().Err(err).
Str("partition", partition.Name). // debug
Str("path", fsPath). // debug
Strs("id-detectors", asset.IdDetector). // debug
Msg("device connection> detecting platform from device")

asset.IdDetector = append(asset.IdDetector, ids.IdDetector_MachineID)
fingerprint, p, err := id.IdentifyPlatform(fsConn, &plugin.ConnectReq{}, p, asset.IdDetector)
if err != nil {
if len(asset.PlatformIds) == 0 {
log.Debug().Err(err).
Str("partition", partition.Name). // debug
Str("path", fsPath). // debug
Strs("id-detectors", asset.IdDetector). // debug
Msg("device connection> failed to identify platform from device")
return nil, err
}

log.Warn().Err(err).
Msg("device connection> failed to identify platform from device")
Msg("device connection> failed to identify platform from device, using existing platform ids")
}
if p == nil {
log.Debug().Msg("device connection> no platform detected")
Expand Down
2 changes: 0 additions & 2 deletions providers/os/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"regexp"
"time"

"github.com/rs/zerolog/log"
"github.com/spf13/afero"
)

Expand Down Expand Up @@ -54,7 +53,6 @@ func (t *MountedFs) MkdirAll(path string, perm os.FileMode) error {

func (t *MountedFs) Open(name string) (afero.File, error) {
mountedPath := t.getPath(name)
log.Debug().Str("mountedPath", mountedPath).Str("requestedPath", name).Msg("opening file") // debug
f, e := os.Open(mountedPath)
if f == nil {
// while this looks strange, we need to return a bare nil (of type nil) not
Expand Down
3 changes: 0 additions & 3 deletions providers/os/id/sshhostkey/sshhostkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ func Detect(t shared.Connection, p *inventory.Platform) ([]string, error) {
if os.IsPermission(err) {
log.Warn().Err(err).Str("hostkey", hostKeyFilePath).Msg("no permission to access ssh hostkey")
continue
} else if os.IsNotExist(err) {
log.Debug().Str("hostkey", hostKeyFilePath).Msg("ssh hostkey not found") // debug
continue
} else if err != nil {
return nil, errors.Wrap(err, "could not read file:"+hostKeyFilePath)
}
Expand Down

0 comments on commit 11fd7a7

Please sign in to comment.