From dd3aead3baabab62485f810f27820e6afb51c4d3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:56:44 +0530 Subject: [PATCH 1/6] chore: update all dependencies (#3275) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 6 +- go.sum | 6 + vendor/golang.org/x/sys/unix/ioctl_linux.go | 96 +++++++++++++ vendor/golang.org/x/sys/unix/mkerrors.sh | 12 ++ vendor/golang.org/x/sys/unix/syscall_linux.go | 1 + .../x/sys/unix/syscall_zos_s390x.go | 104 ++++++++++++++- vendor/golang.org/x/sys/unix/zerrors_linux.go | 22 +++ .../x/sys/unix/zerrors_linux_386.go | 14 ++ .../x/sys/unix/zerrors_linux_amd64.go | 14 ++ .../x/sys/unix/zerrors_linux_arm.go | 14 ++ .../x/sys/unix/zerrors_linux_arm64.go | 14 ++ .../x/sys/unix/zerrors_linux_loong64.go | 14 ++ .../x/sys/unix/zerrors_linux_mips.go | 14 ++ .../x/sys/unix/zerrors_linux_mips64.go | 14 ++ .../x/sys/unix/zerrors_linux_mips64le.go | 14 ++ .../x/sys/unix/zerrors_linux_mipsle.go | 14 ++ .../x/sys/unix/zerrors_linux_ppc.go | 14 ++ .../x/sys/unix/zerrors_linux_ppc64.go | 14 ++ .../x/sys/unix/zerrors_linux_ppc64le.go | 14 ++ .../x/sys/unix/zerrors_linux_riscv64.go | 14 ++ .../x/sys/unix/zerrors_linux_s390x.go | 14 ++ .../x/sys/unix/zerrors_linux_sparc64.go | 14 ++ .../golang.org/x/sys/unix/zsyscall_linux.go | 10 ++ vendor/golang.org/x/sys/unix/ztypes_linux.go | 120 ++++++++++++++++- .../golang.org/x/sys/unix/ztypes_zos_s390x.go | 6 + .../x/sys/windows/syscall_windows.go | 34 ++--- .../golang.org/x/sys/windows/types_windows.go | 126 ++++++++++++++++++ .../x/sys/windows/zsyscall_windows.go | 53 ++++++++ vendor/golang.org/x/term/README.md | 11 +- vendor/modules.txt | 6 +- 30 files changed, 783 insertions(+), 40 deletions(-) diff --git a/go.mod b/go.mod index 59d186d0a..8fed784a7 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,9 @@ require ( github.com/spf13/cobra v1.8.1 github.com/tidwall/gjson v1.18.0 github.com/zekroTJA/timedmap/v2 v2.0.0 - golang.org/x/sys v0.26.0 - golang.org/x/term v0.25.0 - golang.org/x/text v0.19.0 + golang.org/x/sys v0.27.0 + golang.org/x/term v0.26.0 + golang.org/x/text v0.20.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 90eb82a10..4a438b447 100644 --- a/go.sum +++ b/go.sum @@ -77,14 +77,20 @@ golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/vendor/golang.org/x/sys/unix/ioctl_linux.go b/vendor/golang.org/x/sys/unix/ioctl_linux.go index dbe680eab..7ca4fa12a 100644 --- a/vendor/golang.org/x/sys/unix/ioctl_linux.go +++ b/vendor/golang.org/x/sys/unix/ioctl_linux.go @@ -58,6 +58,102 @@ func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) { return &value, err } +// IoctlGetEthtoolTsInfo fetches ethtool timestamping and PHC +// association for the network device specified by ifname. +func IoctlGetEthtoolTsInfo(fd int, ifname string) (*EthtoolTsInfo, error) { + ifr, err := NewIfreq(ifname) + if err != nil { + return nil, err + } + + value := EthtoolTsInfo{Cmd: ETHTOOL_GET_TS_INFO} + ifrd := ifr.withData(unsafe.Pointer(&value)) + + err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd) + return &value, err +} + +// IoctlGetHwTstamp retrieves the hardware timestamping configuration +// for the network device specified by ifname. +func IoctlGetHwTstamp(fd int, ifname string) (*HwTstampConfig, error) { + ifr, err := NewIfreq(ifname) + if err != nil { + return nil, err + } + + value := HwTstampConfig{} + ifrd := ifr.withData(unsafe.Pointer(&value)) + + err = ioctlIfreqData(fd, SIOCGHWTSTAMP, &ifrd) + return &value, err +} + +// IoctlSetHwTstamp updates the hardware timestamping configuration for +// the network device specified by ifname. +func IoctlSetHwTstamp(fd int, ifname string, cfg *HwTstampConfig) error { + ifr, err := NewIfreq(ifname) + if err != nil { + return err + } + ifrd := ifr.withData(unsafe.Pointer(cfg)) + return ioctlIfreqData(fd, SIOCSHWTSTAMP, &ifrd) +} + +// FdToClockID derives the clock ID from the file descriptor number +// - see clock_gettime(3), FD_TO_CLOCKID macros. The resulting ID is +// suitable for system calls like ClockGettime. +func FdToClockID(fd int) int32 { return int32((int(^fd) << 3) | 3) } + +// IoctlPtpClockGetcaps returns the description of a given PTP device. +func IoctlPtpClockGetcaps(fd int) (*PtpClockCaps, error) { + var value PtpClockCaps + err := ioctlPtr(fd, PTP_CLOCK_GETCAPS2, unsafe.Pointer(&value)) + return &value, err +} + +// IoctlPtpSysOffsetPrecise returns a description of the clock +// offset compared to the system clock. +func IoctlPtpSysOffsetPrecise(fd int) (*PtpSysOffsetPrecise, error) { + var value PtpSysOffsetPrecise + err := ioctlPtr(fd, PTP_SYS_OFFSET_PRECISE2, unsafe.Pointer(&value)) + return &value, err +} + +// IoctlPtpSysOffsetExtended returns an extended description of the +// clock offset compared to the system clock. The samples parameter +// specifies the desired number of measurements. +func IoctlPtpSysOffsetExtended(fd int, samples uint) (*PtpSysOffsetExtended, error) { + value := PtpSysOffsetExtended{Samples: uint32(samples)} + err := ioctlPtr(fd, PTP_SYS_OFFSET_EXTENDED2, unsafe.Pointer(&value)) + return &value, err +} + +// IoctlPtpPinGetfunc returns the configuration of the specified +// I/O pin on given PTP device. +func IoctlPtpPinGetfunc(fd int, index uint) (*PtpPinDesc, error) { + value := PtpPinDesc{Index: uint32(index)} + err := ioctlPtr(fd, PTP_PIN_GETFUNC2, unsafe.Pointer(&value)) + return &value, err +} + +// IoctlPtpPinSetfunc updates configuration of the specified PTP +// I/O pin. +func IoctlPtpPinSetfunc(fd int, pd *PtpPinDesc) error { + return ioctlPtr(fd, PTP_PIN_SETFUNC2, unsafe.Pointer(pd)) +} + +// IoctlPtpPeroutRequest configures the periodic output mode of the +// PTP I/O pins. +func IoctlPtpPeroutRequest(fd int, r *PtpPeroutRequest) error { + return ioctlPtr(fd, PTP_PEROUT_REQUEST2, unsafe.Pointer(r)) +} + +// IoctlPtpExttsRequest configures the external timestamping mode +// of the PTP I/O pins. +func IoctlPtpExttsRequest(fd int, r *PtpExttsRequest) error { + return ioctlPtr(fd, PTP_EXTTS_REQUEST2, unsafe.Pointer(r)) +} + // IoctlGetWatchdogInfo fetches information about a watchdog device from the // Linux watchdog API. For more information, see: // https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html. diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index ac54ecaba..6ab02b6c3 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -158,6 +158,16 @@ includes_Linux=' #endif #define _GNU_SOURCE +// See the description in unix/linux/types.go +#if defined(__ARM_EABI__) || \ + (defined(__mips__) && (_MIPS_SIM == _ABIO32)) || \ + (defined(__powerpc__) && (!defined(__powerpc64__))) +# ifdef _TIME_BITS +# undef _TIME_BITS +# endif +# define _TIME_BITS 32 +#endif + // is broken on powerpc64, as it fails to include definitions of // these structures. We just include them copied from . #if defined(__powerpc__) @@ -256,6 +266,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -527,6 +538,7 @@ ccflags="$@" $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ || $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || $2 ~ /^NFC_.*_(MAX)?SIZE$/ || + $2 ~ /^PTP_/ || $2 ~ /^RAW_PAYLOAD_/ || $2 ~ /^[US]F_/ || $2 ~ /^TP_STATUS_/ || diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index f08abd434..230a94549 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1860,6 +1860,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error) //sys ClockGetres(clockid int32, res *Timespec) (err error) //sys ClockGettime(clockid int32, time *Timespec) (err error) +//sys ClockSettime(clockid int32, time *Timespec) (err error) //sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) //sys Close(fd int) (err error) //sys CloseRange(first uint, last uint, flags uint) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go index 312ae6ac1..7bf5c04bb 100644 --- a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -768,6 +768,15 @@ func Munmap(b []byte) (err error) { return mapper.Munmap(b) } +func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) { + xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset) + return unsafe.Pointer(xaddr), err +} + +func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) { + return mapper.munmap(uintptr(addr), length) +} + //sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A //sysnb Getgid() (gid int) //sysnb Getpid() (pid int) @@ -816,10 +825,10 @@ func Lstat(path string, stat *Stat_t) (err error) { // for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/ func isSpecialPath(path []byte) (v bool) { var special = [4][8]byte{ - [8]byte{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'}, - [8]byte{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'}, - [8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'}, - [8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}} + {'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'}, + {'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'}, + {'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'}, + {'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}} var i, j int for i = 0; i < len(special); i++ { @@ -3115,3 +3124,90 @@ func legacy_Mkfifoat(dirfd int, path string, mode uint32) (err error) { //sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT //sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT //sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT + +func fcntlAsIs(fd uintptr, cmd int, arg uintptr) (val int, err error) { + runtime.EnterSyscall() + r0, e2, e1 := CallLeFuncWithErr(GetZosLibVec()+SYS_FCNTL<<4, uintptr(fd), uintptr(cmd), arg) + runtime.ExitSyscall() + val = int(r0) + if int64(r0) == -1 { + err = errnoErr2(e1, e2) + } + return +} + +func Fcntl(fd uintptr, cmd int, op interface{}) (ret int, err error) { + switch op.(type) { + case *Flock_t: + err = FcntlFlock(fd, cmd, op.(*Flock_t)) + if err != nil { + ret = -1 + } + return + case int: + return FcntlInt(fd, cmd, op.(int)) + case *F_cnvrt: + return fcntlAsIs(fd, cmd, uintptr(unsafe.Pointer(op.(*F_cnvrt)))) + case unsafe.Pointer: + return fcntlAsIs(fd, cmd, uintptr(op.(unsafe.Pointer))) + default: + return -1, EINVAL + } + return +} + +func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + if raceenabled { + raceReleaseMerge(unsafe.Pointer(&ioSync)) + } + return sendfile(outfd, infd, offset, count) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + // TODO: use LE call instead if the call is implemented + originalOffset, err := Seek(infd, 0, SEEK_CUR) + if err != nil { + return -1, err + } + //start reading data from in_fd + if offset != nil { + _, err := Seek(infd, *offset, SEEK_SET) + if err != nil { + return -1, err + } + } + + buf := make([]byte, count) + readBuf := make([]byte, 0) + var n int = 0 + for i := 0; i < count; i += n { + n, err := Read(infd, buf) + if n == 0 { + if err != nil { + return -1, err + } else { // EOF + break + } + } + readBuf = append(readBuf, buf...) + buf = buf[0:0] + } + + n2, err := Write(outfd, readBuf) + if err != nil { + return -1, err + } + + //When sendfile() returns, this variable will be set to the + // offset of the byte following the last byte that was read. + if offset != nil { + *offset = *offset + int64(n) + // If offset is not NULL, then sendfile() does not modify the file + // offset of in_fd + _, err := Seek(infd, originalOffset, SEEK_SET) + if err != nil { + return -1, err + } + } + return n2, nil +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index de3b46248..ccba391c9 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -2625,6 +2625,28 @@ const ( PR_UNALIGN_NOPRINT = 0x1 PR_UNALIGN_SIGBUS = 0x2 PSTOREFS_MAGIC = 0x6165676c + PTP_CLK_MAGIC = '=' + PTP_ENABLE_FEATURE = 0x1 + PTP_EXTTS_EDGES = 0x6 + PTP_EXTTS_EVENT_VALID = 0x1 + PTP_EXTTS_V1_VALID_FLAGS = 0x7 + PTP_EXTTS_VALID_FLAGS = 0x1f + PTP_EXT_OFFSET = 0x10 + PTP_FALLING_EDGE = 0x4 + PTP_MAX_SAMPLES = 0x19 + PTP_PEROUT_DUTY_CYCLE = 0x2 + PTP_PEROUT_ONE_SHOT = 0x1 + PTP_PEROUT_PHASE = 0x4 + PTP_PEROUT_V1_VALID_FLAGS = 0x0 + PTP_PEROUT_VALID_FLAGS = 0x7 + PTP_PIN_GETFUNC = 0xc0603d06 + PTP_PIN_GETFUNC2 = 0xc0603d0f + PTP_RISING_EDGE = 0x2 + PTP_STRICT_FLAGS = 0x8 + PTP_SYS_OFFSET_EXTENDED = 0xc4c03d09 + PTP_SYS_OFFSET_EXTENDED2 = 0xc4c03d12 + PTP_SYS_OFFSET_PRECISE = 0xc0403d08 + PTP_SYS_OFFSET_PRECISE2 = 0xc0403d11 PTRACE_ATTACH = 0x10 PTRACE_CONT = 0x7 PTRACE_DETACH = 0x11 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 8aa6d77c0..0c00cb3f3 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -237,6 +237,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffff + PTP_CLOCK_GETCAPS = 0x80503d01 + PTP_CLOCK_GETCAPS2 = 0x80503d0a + PTP_ENABLE_PPS = 0x40043d04 + PTP_ENABLE_PPS2 = 0x40043d0d + PTP_EXTTS_REQUEST = 0x40103d02 + PTP_EXTTS_REQUEST2 = 0x40103d0b + PTP_MASK_CLEAR_ALL = 0x3d13 + PTP_MASK_EN_SINGLE = 0x40043d14 + PTP_PEROUT_REQUEST = 0x40383d03 + PTP_PEROUT_REQUEST2 = 0x40383d0c + PTP_PIN_SETFUNC = 0x40603d07 + PTP_PIN_SETFUNC2 = 0x40603d10 + PTP_SYS_OFFSET = 0x43403d05 + PTP_SYS_OFFSET2 = 0x43403d0e PTRACE_GETFPREGS = 0xe PTRACE_GETFPXREGS = 0x12 PTRACE_GET_THREAD_AREA = 0x19 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index da428f425..dfb364554 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -237,6 +237,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x80503d01 + PTP_CLOCK_GETCAPS2 = 0x80503d0a + PTP_ENABLE_PPS = 0x40043d04 + PTP_ENABLE_PPS2 = 0x40043d0d + PTP_EXTTS_REQUEST = 0x40103d02 + PTP_EXTTS_REQUEST2 = 0x40103d0b + PTP_MASK_CLEAR_ALL = 0x3d13 + PTP_MASK_EN_SINGLE = 0x40043d14 + PTP_PEROUT_REQUEST = 0x40383d03 + PTP_PEROUT_REQUEST2 = 0x40383d0c + PTP_PIN_SETFUNC = 0x40603d07 + PTP_PIN_SETFUNC2 = 0x40603d10 + PTP_SYS_OFFSET = 0x43403d05 + PTP_SYS_OFFSET2 = 0x43403d0e PTRACE_ARCH_PRCTL = 0x1e PTRACE_GETFPREGS = 0xe PTRACE_GETFPXREGS = 0x12 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index bf45bfec7..d46dcf78a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -234,6 +234,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffff + PTP_CLOCK_GETCAPS = 0x80503d01 + PTP_CLOCK_GETCAPS2 = 0x80503d0a + PTP_ENABLE_PPS = 0x40043d04 + PTP_ENABLE_PPS2 = 0x40043d0d + PTP_EXTTS_REQUEST = 0x40103d02 + PTP_EXTTS_REQUEST2 = 0x40103d0b + PTP_MASK_CLEAR_ALL = 0x3d13 + PTP_MASK_EN_SINGLE = 0x40043d14 + PTP_PEROUT_REQUEST = 0x40383d03 + PTP_PEROUT_REQUEST2 = 0x40383d0c + PTP_PIN_SETFUNC = 0x40603d07 + PTP_PIN_SETFUNC2 = 0x40603d10 + PTP_SYS_OFFSET = 0x43403d05 + PTP_SYS_OFFSET2 = 0x43403d0e PTRACE_GETCRUNCHREGS = 0x19 PTRACE_GETFDPIC = 0x1f PTRACE_GETFDPIC_EXEC = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 71c67162b..3af3248a7 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -240,6 +240,20 @@ const ( PROT_BTI = 0x10 PROT_MTE = 0x20 PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x80503d01 + PTP_CLOCK_GETCAPS2 = 0x80503d0a + PTP_ENABLE_PPS = 0x40043d04 + PTP_ENABLE_PPS2 = 0x40043d0d + PTP_EXTTS_REQUEST = 0x40103d02 + PTP_EXTTS_REQUEST2 = 0x40103d0b + PTP_MASK_CLEAR_ALL = 0x3d13 + PTP_MASK_EN_SINGLE = 0x40043d14 + PTP_PEROUT_REQUEST = 0x40383d03 + PTP_PEROUT_REQUEST2 = 0x40383d0c + PTP_PIN_SETFUNC = 0x40603d07 + PTP_PIN_SETFUNC2 = 0x40603d10 + PTP_SYS_OFFSET = 0x43403d05 + PTP_SYS_OFFSET2 = 0x43403d0e PTRACE_PEEKMTETAGS = 0x21 PTRACE_POKEMTETAGS = 0x22 PTRACE_SYSEMU = 0x1f diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 9476628fa..292bcf028 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -238,6 +238,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x80503d01 + PTP_CLOCK_GETCAPS2 = 0x80503d0a + PTP_ENABLE_PPS = 0x40043d04 + PTP_ENABLE_PPS2 = 0x40043d0d + PTP_EXTTS_REQUEST = 0x40103d02 + PTP_EXTTS_REQUEST2 = 0x40103d0b + PTP_MASK_CLEAR_ALL = 0x3d13 + PTP_MASK_EN_SINGLE = 0x40043d14 + PTP_PEROUT_REQUEST = 0x40383d03 + PTP_PEROUT_REQUEST2 = 0x40383d0c + PTP_PIN_SETFUNC = 0x40603d07 + PTP_PIN_SETFUNC2 = 0x40603d10 + PTP_SYS_OFFSET = 0x43403d05 + PTP_SYS_OFFSET2 = 0x43403d0e PTRACE_SYSEMU = 0x1f PTRACE_SYSEMU_SINGLESTEP = 0x20 RLIMIT_AS = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index b9e85f3cf..782b7110f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -234,6 +234,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETFPREGS = 0xe PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA_3264 = 0xc4 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index a48b68a76..84973fd92 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -234,6 +234,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETFPREGS = 0xe PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA_3264 = 0xc4 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ea00e8522..6d9cbc3b2 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -234,6 +234,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETFPREGS = 0xe PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA_3264 = 0xc4 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 91c646871..5f9fedbce 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -234,6 +234,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETFPREGS = 0xe PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA_3264 = 0xc4 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 8cbf38d63..bb0026ee0 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -237,6 +237,20 @@ const ( PPPIOCXFERUNIT = 0x2000744e PROT_SAO = 0x10 PR_SET_PTRACER_ANY = 0xffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETEVRREGS = 0x14 PTRACE_GETFPREGS = 0xe PTRACE_GETREGS64 = 0x16 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index a2df73419..46120db5c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -237,6 +237,20 @@ const ( PPPIOCXFERUNIT = 0x2000744e PROT_SAO = 0x10 PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETEVRREGS = 0x14 PTRACE_GETFPREGS = 0xe PTRACE_GETREGS64 = 0x16 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 247913792..5c951634f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -237,6 +237,20 @@ const ( PPPIOCXFERUNIT = 0x2000744e PROT_SAO = 0x10 PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETEVRREGS = 0x14 PTRACE_GETFPREGS = 0xe PTRACE_GETREGS64 = 0x16 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index d265f146e..11a84d5af 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -234,6 +234,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x80503d01 + PTP_CLOCK_GETCAPS2 = 0x80503d0a + PTP_ENABLE_PPS = 0x40043d04 + PTP_ENABLE_PPS2 = 0x40043d0d + PTP_EXTTS_REQUEST = 0x40103d02 + PTP_EXTTS_REQUEST2 = 0x40103d0b + PTP_MASK_CLEAR_ALL = 0x3d13 + PTP_MASK_EN_SINGLE = 0x40043d14 + PTP_PEROUT_REQUEST = 0x40383d03 + PTP_PEROUT_REQUEST2 = 0x40383d0c + PTP_PIN_SETFUNC = 0x40603d07 + PTP_PIN_SETFUNC2 = 0x40603d10 + PTP_SYS_OFFSET = 0x43403d05 + PTP_SYS_OFFSET2 = 0x43403d0e PTRACE_GETFDPIC = 0x21 PTRACE_GETFDPIC_EXEC = 0x0 PTRACE_GETFDPIC_INTERP = 0x1 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 3f2d64439..f78c4617c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -234,6 +234,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x80503d01 + PTP_CLOCK_GETCAPS2 = 0x80503d0a + PTP_ENABLE_PPS = 0x40043d04 + PTP_ENABLE_PPS2 = 0x40043d0d + PTP_EXTTS_REQUEST = 0x40103d02 + PTP_EXTTS_REQUEST2 = 0x40103d0b + PTP_MASK_CLEAR_ALL = 0x3d13 + PTP_MASK_EN_SINGLE = 0x40043d14 + PTP_PEROUT_REQUEST = 0x40383d03 + PTP_PEROUT_REQUEST2 = 0x40383d0c + PTP_PIN_SETFUNC = 0x40603d07 + PTP_PIN_SETFUNC2 = 0x40603d10 + PTP_SYS_OFFSET = 0x43403d05 + PTP_SYS_OFFSET2 = 0x43403d0e PTRACE_DISABLE_TE = 0x5010 PTRACE_ENABLE_TE = 0x5009 PTRACE_GET_LAST_BREAK = 0x5006 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index 5d8b727a1..aeb777c34 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -239,6 +239,20 @@ const ( PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCXFERUNIT = 0x2000744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTP_CLOCK_GETCAPS = 0x40503d01 + PTP_CLOCK_GETCAPS2 = 0x40503d0a + PTP_ENABLE_PPS = 0x80043d04 + PTP_ENABLE_PPS2 = 0x80043d0d + PTP_EXTTS_REQUEST = 0x80103d02 + PTP_EXTTS_REQUEST2 = 0x80103d0b + PTP_MASK_CLEAR_ALL = 0x20003d13 + PTP_MASK_EN_SINGLE = 0x80043d14 + PTP_PEROUT_REQUEST = 0x80383d03 + PTP_PEROUT_REQUEST2 = 0x80383d0c + PTP_PIN_SETFUNC = 0x80603d07 + PTP_PIN_SETFUNC2 = 0x80603d10 + PTP_SYS_OFFSET = 0x83403d05 + PTP_SYS_OFFSET2 = 0x83403d0e PTRACE_GETFPAREGS = 0x14 PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS64 = 0x19 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index af30da557..5cc1e8eb2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -592,6 +592,16 @@ func ClockGettime(clockid int32, time *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockSettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_SETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) { _, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 3a69e4549..8daaf3faf 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -1752,12 +1752,6 @@ const ( IFLA_IPVLAN_UNSPEC = 0x0 IFLA_IPVLAN_MODE = 0x1 IFLA_IPVLAN_FLAGS = 0x2 - NETKIT_NEXT = -0x1 - NETKIT_PASS = 0x0 - NETKIT_DROP = 0x2 - NETKIT_REDIRECT = 0x7 - NETKIT_L2 = 0x0 - NETKIT_L3 = 0x1 IFLA_NETKIT_UNSPEC = 0x0 IFLA_NETKIT_PEER_INFO = 0x1 IFLA_NETKIT_PRIMARY = 0x2 @@ -1796,6 +1790,7 @@ const ( IFLA_VXLAN_DF = 0x1d IFLA_VXLAN_VNIFILTER = 0x1e IFLA_VXLAN_LOCALBYPASS = 0x1f + IFLA_VXLAN_LABEL_POLICY = 0x20 IFLA_GENEVE_UNSPEC = 0x0 IFLA_GENEVE_ID = 0x1 IFLA_GENEVE_REMOTE = 0x2 @@ -1825,6 +1820,8 @@ const ( IFLA_GTP_ROLE = 0x4 IFLA_GTP_CREATE_SOCKETS = 0x5 IFLA_GTP_RESTART_COUNT = 0x6 + IFLA_GTP_LOCAL = 0x7 + IFLA_GTP_LOCAL6 = 0x8 IFLA_BOND_UNSPEC = 0x0 IFLA_BOND_MODE = 0x1 IFLA_BOND_ACTIVE_SLAVE = 0x2 @@ -1857,6 +1854,7 @@ const ( IFLA_BOND_AD_LACP_ACTIVE = 0x1d IFLA_BOND_MISSED_MAX = 0x1e IFLA_BOND_NS_IP6_TARGET = 0x1f + IFLA_BOND_COUPLED_CONTROL = 0x20 IFLA_BOND_AD_INFO_UNSPEC = 0x0 IFLA_BOND_AD_INFO_AGGREGATOR = 0x1 IFLA_BOND_AD_INFO_NUM_PORTS = 0x2 @@ -1925,6 +1923,7 @@ const ( IFLA_HSR_SEQ_NR = 0x5 IFLA_HSR_VERSION = 0x6 IFLA_HSR_PROTOCOL = 0x7 + IFLA_HSR_INTERLINK = 0x8 IFLA_STATS_UNSPEC = 0x0 IFLA_STATS_LINK_64 = 0x1 IFLA_STATS_LINK_XSTATS = 0x2 @@ -1977,6 +1976,15 @@ const ( IFLA_DSA_MASTER = 0x1 ) +const ( + NETKIT_NEXT = -0x1 + NETKIT_PASS = 0x0 + NETKIT_DROP = 0x2 + NETKIT_REDIRECT = 0x7 + NETKIT_L2 = 0x0 + NETKIT_L3 = 0x1 +) + const ( NF_INET_PRE_ROUTING = 0x0 NF_INET_LOCAL_IN = 0x1 @@ -4110,6 +4118,106 @@ type EthtoolDrvinfo struct { Regdump_len uint32 } +type EthtoolTsInfo struct { + Cmd uint32 + So_timestamping uint32 + Phc_index int32 + Tx_types uint32 + Tx_reserved [3]uint32 + Rx_filters uint32 + Rx_reserved [3]uint32 +} + +type HwTstampConfig struct { + Flags int32 + Tx_type int32 + Rx_filter int32 +} + +const ( + HWTSTAMP_FILTER_NONE = 0x0 + HWTSTAMP_FILTER_ALL = 0x1 + HWTSTAMP_FILTER_SOME = 0x2 + HWTSTAMP_FILTER_PTP_V1_L4_EVENT = 0x3 + HWTSTAMP_FILTER_PTP_V2_L4_EVENT = 0x6 + HWTSTAMP_FILTER_PTP_V2_L2_EVENT = 0x9 + HWTSTAMP_FILTER_PTP_V2_EVENT = 0xc +) + +const ( + HWTSTAMP_TX_OFF = 0x0 + HWTSTAMP_TX_ON = 0x1 + HWTSTAMP_TX_ONESTEP_SYNC = 0x2 +) + +type ( + PtpClockCaps struct { + Max_adj int32 + N_alarm int32 + N_ext_ts int32 + N_per_out int32 + Pps int32 + N_pins int32 + Cross_timestamping int32 + Adjust_phase int32 + Max_phase_adj int32 + Rsv [11]int32 + } + PtpClockTime struct { + Sec int64 + Nsec uint32 + Reserved uint32 + } + PtpExttsEvent struct { + T PtpClockTime + Index uint32 + Flags uint32 + Rsv [2]uint32 + } + PtpExttsRequest struct { + Index uint32 + Flags uint32 + Rsv [2]uint32 + } + PtpPeroutRequest struct { + StartOrPhase PtpClockTime + Period PtpClockTime + Index uint32 + Flags uint32 + On PtpClockTime + } + PtpPinDesc struct { + Name [64]byte + Index uint32 + Func uint32 + Chan uint32 + Rsv [5]uint32 + } + PtpSysOffset struct { + Samples uint32 + Rsv [3]uint32 + Ts [51]PtpClockTime + } + PtpSysOffsetExtended struct { + Samples uint32 + Rsv [3]uint32 + Ts [25][3]PtpClockTime + } + PtpSysOffsetPrecise struct { + Device PtpClockTime + Realtime PtpClockTime + Monoraw PtpClockTime + Rsv [4]uint32 + } +) + +const ( + PTP_PF_NONE = 0x0 + PTP_PF_EXTTS = 0x1 + PTP_PF_PEROUT = 0x2 + PTP_PF_PHYSYNC = 0x3 +) + type ( HIDRawReportDescriptor struct { Size uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go index d9a13af46..2e5d5a443 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go @@ -377,6 +377,12 @@ type Flock_t struct { Pid int32 } +type F_cnvrt struct { + Cvtcmd int32 + Pccsid int16 + Fccsid int16 +} + type Termios struct { Cflag uint32 Iflag uint32 diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 5cee9a314..4510bfc3f 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -725,20 +725,12 @@ func DurationSinceBoot() time.Duration { } func Ftruncate(fd Handle, length int64) (err error) { - curoffset, e := Seek(fd, 0, 1) - if e != nil { - return e - } - defer Seek(fd, curoffset, 0) - _, e = Seek(fd, length, 0) - if e != nil { - return e + type _FILE_END_OF_FILE_INFO struct { + EndOfFile int64 } - e = SetEndOfFile(fd) - if e != nil { - return e - } - return nil + var info _FILE_END_OF_FILE_INFO + info.EndOfFile = length + return SetFileInformationByHandle(fd, FileEndOfFileInfo, (*byte)(unsafe.Pointer(&info)), uint32(unsafe.Sizeof(info))) } func Gettimeofday(tv *Timeval) (err error) { @@ -894,6 +886,11 @@ const socket_error = uintptr(^uint32(0)) //sys GetACP() (acp uint32) = kernel32.GetACP //sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar //sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx +//sys GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) = iphlpapi.GetIfEntry2Ex +//sys GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) = iphlpapi.GetUnicastIpAddressEntry +//sys NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyIpInterfaceChange +//sys NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyUnicastIpAddressChange +//sys CancelMibChangeNotify2(notificationHandle Handle) (errcode error) = iphlpapi.CancelMibChangeNotify2 // For testing: clients can set this flag to force // creation of IPv6 sockets to return EAFNOSUPPORT. @@ -1685,13 +1682,16 @@ func (s NTStatus) Error() string { // do not use NTUnicodeString, and instead UTF16PtrFromString should be used for // the more common *uint16 string type. func NewNTUnicodeString(s string) (*NTUnicodeString, error) { - var u NTUnicodeString - s16, err := UTF16PtrFromString(s) + s16, err := UTF16FromString(s) if err != nil { return nil, err } - RtlInitUnicodeString(&u, s16) - return &u, nil + n := uint16(len(s16) * 2) + return &NTUnicodeString{ + Length: n - 2, // subtract 2 bytes for the NULL terminator + MaximumLength: n, + Buffer: &s16[0], + }, nil } // Slice returns a uint16 slice that aliases the data in the NTUnicodeString. diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index 7b97a154c..51311e205 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -2203,6 +2203,132 @@ const ( IfOperStatusLowerLayerDown = 7 ) +const ( + IF_MAX_PHYS_ADDRESS_LENGTH = 32 + IF_MAX_STRING_SIZE = 256 +) + +// MIB_IF_ENTRY_LEVEL enumeration from netioapi.h or +// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getifentry2ex. +const ( + MibIfEntryNormal = 0 + MibIfEntryNormalWithoutStatistics = 2 +) + +// MIB_NOTIFICATION_TYPE enumeration from netioapi.h or +// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ne-netioapi-mib_notification_type. +const ( + MibParameterNotification = 0 + MibAddInstance = 1 + MibDeleteInstance = 2 + MibInitialNotification = 3 +) + +// MibIfRow2 stores information about a particular interface. See +// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_row2. +type MibIfRow2 struct { + InterfaceLuid uint64 + InterfaceIndex uint32 + InterfaceGuid GUID + Alias [IF_MAX_STRING_SIZE + 1]uint16 + Description [IF_MAX_STRING_SIZE + 1]uint16 + PhysicalAddressLength uint32 + PhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8 + PermanentPhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8 + Mtu uint32 + Type uint32 + TunnelType uint32 + MediaType uint32 + PhysicalMediumType uint32 + AccessType uint32 + DirectionType uint32 + InterfaceAndOperStatusFlags uint8 + OperStatus uint32 + AdminStatus uint32 + MediaConnectState uint32 + NetworkGuid GUID + ConnectionType uint32 + TransmitLinkSpeed uint64 + ReceiveLinkSpeed uint64 + InOctets uint64 + InUcastPkts uint64 + InNUcastPkts uint64 + InDiscards uint64 + InErrors uint64 + InUnknownProtos uint64 + InUcastOctets uint64 + InMulticastOctets uint64 + InBroadcastOctets uint64 + OutOctets uint64 + OutUcastPkts uint64 + OutNUcastPkts uint64 + OutDiscards uint64 + OutErrors uint64 + OutUcastOctets uint64 + OutMulticastOctets uint64 + OutBroadcastOctets uint64 + OutQLen uint64 +} + +// MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See +// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row. +type MibUnicastIpAddressRow struct { + Address RawSockaddrInet6 // SOCKADDR_INET union + InterfaceLuid uint64 + InterfaceIndex uint32 + PrefixOrigin uint32 + SuffixOrigin uint32 + ValidLifetime uint32 + PreferredLifetime uint32 + OnLinkPrefixLength uint8 + SkipAsSource uint8 + DadState uint32 + ScopeId uint32 + CreationTimeStamp Filetime +} + +const ScopeLevelCount = 16 + +// MIB_IPINTERFACE_ROW stores interface management information for a particular IP address family on a network interface. +// See https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipinterface_row. +type MibIpInterfaceRow struct { + Family uint16 + InterfaceLuid uint64 + InterfaceIndex uint32 + MaxReassemblySize uint32 + InterfaceIdentifier uint64 + MinRouterAdvertisementInterval uint32 + MaxRouterAdvertisementInterval uint32 + AdvertisingEnabled uint8 + ForwardingEnabled uint8 + WeakHostSend uint8 + WeakHostReceive uint8 + UseAutomaticMetric uint8 + UseNeighborUnreachabilityDetection uint8 + ManagedAddressConfigurationSupported uint8 + OtherStatefulConfigurationSupported uint8 + AdvertiseDefaultRoute uint8 + RouterDiscoveryBehavior uint32 + DadTransmits uint32 + BaseReachableTime uint32 + RetransmitTime uint32 + PathMtuDiscoveryTimeout uint32 + LinkLocalAddressBehavior uint32 + LinkLocalAddressTimeout uint32 + ZoneIndices [ScopeLevelCount]uint32 + SitePrefixLength uint32 + Metric uint32 + NlMtu uint32 + Connected uint8 + SupportsWakeUpPatterns uint8 + SupportsNeighborDiscovery uint8 + SupportsRouterDiscovery uint8 + ReachableTime uint32 + TransmitOffload uint32 + ReceiveOffload uint32 + DisableDefaultRoutes uint8 +} + // Console related constants used for the mode parameter to SetConsoleMode. See // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details. diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 4c2e1bdc0..6f5252880 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -181,10 +181,15 @@ var ( procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute") procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute") + procCancelMibChangeNotify2 = modiphlpapi.NewProc("CancelMibChangeNotify2") procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx") procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") + procGetIfEntry2Ex = modiphlpapi.NewProc("GetIfEntry2Ex") + procGetUnicastIpAddressEntry = modiphlpapi.NewProc("GetUnicastIpAddressEntry") + procNotifyIpInterfaceChange = modiphlpapi.NewProc("NotifyIpInterfaceChange") + procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange") procAddDllDirectory = modkernel32.NewProc("AddDllDirectory") procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject") procCancelIo = modkernel32.NewProc("CancelIo") @@ -1606,6 +1611,14 @@ func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, si return } +func CancelMibChangeNotify2(notificationHandle Handle) (errcode error) { + r0, _, _ := syscall.SyscallN(procCancelMibChangeNotify2.Addr(), uintptr(notificationHandle)) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) if r0 != 0 { @@ -1638,6 +1651,46 @@ func GetIfEntry(pIfRow *MibIfRow) (errcode error) { return } +func GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) { + r0, _, _ := syscall.SyscallN(procGetIfEntry2Ex.Addr(), uintptr(level), uintptr(unsafe.Pointer(row))) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + +func GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) { + r0, _, _ := syscall.SyscallN(procGetUnicastIpAddressEntry.Addr(), uintptr(unsafe.Pointer(row))) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + +func NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) { + var _p0 uint32 + if initialNotification { + _p0 = 1 + } + r0, _, _ := syscall.SyscallN(procNotifyIpInterfaceChange.Addr(), uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle))) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + +func NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) { + var _p0 uint32 + if initialNotification { + _p0 = 1 + } + r0, _, _ := syscall.SyscallN(procNotifyUnicastIpAddressChange.Addr(), uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle))) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + func AddDllDirectory(path *uint16) (cookie uintptr, err error) { r0, _, e1 := syscall.Syscall(procAddDllDirectory.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) cookie = uintptr(r0) diff --git a/vendor/golang.org/x/term/README.md b/vendor/golang.org/x/term/README.md index d03d0aefe..05ff623f9 100644 --- a/vendor/golang.org/x/term/README.md +++ b/vendor/golang.org/x/term/README.md @@ -4,16 +4,13 @@ This repository provides Go terminal and console support packages. -## Download/Install - -The easiest way to install is to run `go get -u golang.org/x/term`. You can -also manually git clone the repository to `$GOPATH/src/golang.org/x/term`. - ## Report Issues / Send Patches This repository uses Gerrit for code changes. To learn how to submit changes to -this repository, see https://golang.org/doc/contribute.html. +this repository, see https://go.dev/doc/contribute. + +The git repository is https://go.googlesource.com/term. The main issue tracker for the term repository is located at -https://github.com/golang/go/issues. Prefix your issue with "x/term:" in the +https://go.dev/issues. Prefix your issue with "x/term:" in the subject line, so it is easy to find. diff --git a/vendor/modules.txt b/vendor/modules.txt index 8a1ae2d4b..06df6addc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -85,15 +85,15 @@ github.com/yusufpapurcu/wmi # github.com/zekroTJA/timedmap/v2 v2.0.0 ## explicit; go 1.19 github.com/zekroTJA/timedmap/v2 -# golang.org/x/sys v0.26.0 +# golang.org/x/sys v0.27.0 ## explicit; go 1.18 golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/term v0.25.0 +# golang.org/x/term v0.26.0 ## explicit; go 1.18 golang.org/x/term -# golang.org/x/text v0.19.0 +# golang.org/x/text v0.20.0 ## explicit; go 1.18 golang.org/x/text/cases golang.org/x/text/internal From 3e036ad4276b788591e89f869587cdc220d4d1d1 Mon Sep 17 00:00:00 2001 From: Rahul Date: Mon, 11 Nov 2024 14:46:38 +0530 Subject: [PATCH 2/6] ci: lint errors (#3276) --- pkg/util/portScanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/util/portScanner.go b/pkg/util/portScanner.go index 85cfdcc1f..6b0ee2299 100644 --- a/pkg/util/portScanner.go +++ b/pkg/util/portScanner.go @@ -41,7 +41,7 @@ func CheckFreePorts(address string, ports []int) map[int]struct{} { } }() - for range len(ports) { + for range ports { port := <-results if port != 0 { freeports[port] = struct{}{} From d29b92b750e8905eab2e83927889ec4d5c5c9785 Mon Sep 17 00:00:00 2001 From: Rahul Date: Mon, 11 Nov 2024 14:50:51 +0530 Subject: [PATCH 3/6] refactor: remove env logging (#3277) --- cmd/collectors/rest/plugins/volume/volume.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/cmd/collectors/rest/plugins/volume/volume.go b/cmd/collectors/rest/plugins/volume/volume.go index cbc7d24c2..caca94235 100644 --- a/cmd/collectors/rest/plugins/volume/volume.go +++ b/cmd/collectors/rest/plugins/volume/volume.go @@ -17,7 +17,6 @@ import ( "github.com/netapp/harvest/v2/pkg/util" "github.com/tidwall/gjson" "log/slog" - "os" "strconv" "time" ) @@ -25,8 +24,6 @@ import ( const HoursInMonth = 24 * 30 const ARWSupportedVersion = "9.10.0" -var enableVolumeLogging bool - type Volume struct { *plugin.AbstractPlugin currentVal int @@ -97,7 +94,6 @@ func (v *Volume) Init() error { if err != nil { return fmt.Errorf("unable to get version %w", err) } - enableVolumeLogging = os.Getenv("ENABLE_VOLUME_LOGGING") != "" return nil } @@ -139,10 +135,6 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]volumeInfo) { var err error - if enableVolumeLogging { - v.SLogger.Info("Size of volumeMap", slog.Int("size", len(volumeMap)), slog.Any("volumeMap", volumeMap)) - } - cloneSplitEstimateMetric := data.GetMetric("clone_split_estimate") if cloneSplitEstimateMetric == nil { if cloneSplitEstimateMetric, err = data.NewMetricFloat64("clone_split_estimate"); err != nil { @@ -156,9 +148,6 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo } if volume.GetLabel("style") == "flexgroup_constituent" { - if enableVolumeLogging { - v.SLogger.Warn("Setting exportable for flexgroup constituent", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", v.includeConstituents)) - } volume.SetExportable(v.includeConstituents) } @@ -166,9 +155,6 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo if vInfo, ok := volumeMap[volume.GetLabel("volume")+volume.GetLabel("svm")]; ok { if vInfo.isObjectStoreVolume { - if enableVolumeLogging { - v.SLogger.Warn("Setting exportable for object store volume", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", false)) - } volume.SetExportable(false) continue } @@ -190,9 +176,6 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo } } else { // The public API does not include node root and temp volumes, while the private CLI does include them. Harvest will exclude them the same as the public API by not exporting them. - if enableVolumeLogging { - v.SLogger.Warn("Setting exportable for excluded volume", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", false)) - } volume.SetExportable(false) } } From b2f6f6029f6d65465f274cdebc1eb82fe9af6c8a Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Mon, 11 Nov 2024 08:02:57 -0500 Subject: [PATCH 4/6] feat: Harvest should request cluster version once (#3274) * feat: Harvest should request cluster version once feat: Improve KeyPerf negotiation * feat: Harvest should request cluster version once feat: Improve KeyPerf negotiation --- cmd/collectors/ems/ems_test.go | 2 +- cmd/collectors/keyperf/keyperf.go | 2 - cmd/collectors/keyperf/keyperf_test.go | 2 +- cmd/collectors/ontap.go | 103 +++++++++ cmd/collectors/power.go | 4 +- .../rest/plugins/aggregate/aggregate.go | 4 +- .../rest/plugins/certificate/certificate.go | 4 +- cmd/collectors/rest/plugins/health/health.go | 4 +- .../metroclustercheck/metroclustercheck.go | 3 +- .../rest/plugins/netroute/netroute.go | 3 +- .../plugins/ontaps3service/ontaps3service.go | 4 +- cmd/collectors/rest/plugins/quota/quota.go | 3 +- .../securityaccount/securityaccount.go | 4 +- cmd/collectors/rest/plugins/shelf/shelf.go | 3 +- .../rest/plugins/snapmirror/snapmirror.go | 4 +- cmd/collectors/rest/plugins/svm/svm.go | 4 +- cmd/collectors/rest/plugins/volume/volume.go | 4 +- .../volumeanalytics/volumeanalytics.go | 4 +- .../rest/plugins/workload/workload.go | 3 +- cmd/collectors/rest/rest.go | 6 +- cmd/collectors/rest/rest_test.go | 2 +- cmd/collectors/restperf/plugins/disk/disk.go | 4 +- .../restperf/plugins/fabricpool/fabricpool.go | 3 +- cmd/collectors/restperf/plugins/fcvi/fcvi.go | 4 +- cmd/collectors/restperf/plugins/nic/nic.go | 4 +- .../restperf/plugins/nic/nic_test.go | 3 +- .../restperf/plugins/volume/volume.go | 4 +- .../restperf/plugins/volume/volume_test.go | 3 +- .../restperf/plugins/volumetag/volumetag.go | 4 +- .../volumetopclients/volumetopclients.go | 4 +- cmd/collectors/restperf/restperf_test.go | 2 +- .../storagegrid/plugins/bucket/bucket.go | 5 +- .../storagegrid/plugins/joinrest/joinrest.go | 9 +- cmd/collectors/storagegrid/rest/client.go | 8 +- cmd/collectors/storagegrid/storagegrid.go | 4 +- .../storagegrid/storagegrid_test.go | 2 +- cmd/collectors/zapi/collector/zapi.go | 11 +- .../zapi/plugins/aggregate/aggregate.go | 7 +- .../zapi/plugins/certificate/certificate.go | 4 +- cmd/collectors/zapi/plugins/qtree/qtree.go | 4 +- .../zapi/plugins/qtree/qtree_test.go | 3 +- .../zapi/plugins/security/security.go | 4 +- cmd/collectors/zapi/plugins/shelf/shelf.go | 4 +- .../zapi/plugins/snapmirror/snapmirror.go | 5 +- cmd/collectors/zapi/plugins/svm/svm.go | 4 +- .../zapi/plugins/systemnode/systemnode.go | 4 +- cmd/collectors/zapi/plugins/volume/volume.go | 4 +- .../zapi/plugins/workload/workload.go | 3 +- cmd/collectors/zapiperf/plugins/disk/disk.go | 4 +- .../zapiperf/plugins/fabricpool/fabricpool.go | 3 +- cmd/collectors/zapiperf/plugins/fcvi/fcvi.go | 4 +- .../zapiperf/plugins/flexcache/flexcache.go | 4 +- cmd/collectors/zapiperf/plugins/nic/nic.go | 4 +- .../zapiperf/plugins/volume/volume.go | 4 +- .../zapiperf/plugins/volumetag/volumetag.go | 4 +- cmd/collectors/zapiperf/zapiperf_test.go | 2 +- cmd/poller/collector/collector.go | 5 +- cmd/poller/plugin/aggregator/aggregator.go | 5 +- .../plugin/aggregator/aggregator_test.go | 11 +- cmd/poller/plugin/changelog/changelog.go | 5 +- cmd/poller/plugin/changelog/changelog_test.go | 3 +- cmd/poller/plugin/labelagent/label_agent.go | 5 +- .../plugin/labelagent/label_agent_test.go | 5 +- cmd/poller/plugin/max/max.go | 5 +- cmd/poller/plugin/metricagent/metric_agent.go | 5 +- .../plugin/metricagent/metric_agent_test.go | 3 +- cmd/poller/plugin/plugin.go | 5 +- cmd/poller/plugin/test/plugin_test.go | 6 +- cmd/poller/poller.go | 203 ++++++++++-------- cmd/poller/poller_test.go | 66 +++--- cmd/tools/generate/generate.go | 2 +- cmd/tools/rest/client.go | 23 +- cmd/tools/rest/rest.go | 2 +- cmd/tools/template/template.go | 9 +- cmd/tools/zapi/zapi.go | 2 +- integration/test/counter_test.go | 2 +- pkg/api/ontapi/zapi/client.go | 33 ++- pkg/api/ontapi/zapi/system.go | 98 +++++---- pkg/api/ontapi/zapi/system_test.go | 24 +-- pkg/conf/remotes.go | 23 +- pkg/errs/errors.go | 1 - 81 files changed, 524 insertions(+), 348 deletions(-) create mode 100644 cmd/collectors/ontap.go diff --git a/cmd/collectors/ems/ems_test.go b/cmd/collectors/ems/ems_test.go index 10fb84a2b..d3e9c2db7 100644 --- a/cmd/collectors/ems/ems_test.go +++ b/cmd/collectors/ems/ems_test.go @@ -54,7 +54,7 @@ func NewEms() *Ems { opts.HomePath = homePath opts.IsTest = true - ac := collector.New("Ems", "Ems", opts, emsParams(emsConfigPath), nil) + ac := collector.New("Ems", "Ems", opts, emsParams(emsConfigPath), nil, conf.Remote{}) e := &Ems{} if err := e.Init(ac); err != nil { slog.Error("", slogx.Err(err)) diff --git a/cmd/collectors/keyperf/keyperf.go b/cmd/collectors/keyperf/keyperf.go index bd3516e2d..9c7018410 100644 --- a/cmd/collectors/keyperf/keyperf.go +++ b/cmd/collectors/keyperf/keyperf.go @@ -68,8 +68,6 @@ func (kp *KeyPerf) Init(a *collector.AbstractCollector) error { return err } - kp.Remote = kp.Client.Remote() - if kp.Prop.TemplatePath, err = kp.LoadTemplate(); err != nil { return err } diff --git a/cmd/collectors/keyperf/keyperf_test.go b/cmd/collectors/keyperf/keyperf_test.go index 5cf51530d..c534edc54 100644 --- a/cmd/collectors/keyperf/keyperf_test.go +++ b/cmd/collectors/keyperf/keyperf_test.go @@ -187,7 +187,7 @@ func newKeyPerf(object string, path string) *KeyPerf { opts.HomePath = "testdata" opts.IsTest = true - ac := collector.New("KeyPerf", object, opts, params(object, path), nil) + ac := collector.New("KeyPerf", object, opts, params(object, path), nil, conf.Remote{}) kp := KeyPerf{} err = kp.Init(ac) if err != nil { diff --git a/cmd/collectors/ontap.go b/cmd/collectors/ontap.go new file mode 100644 index 000000000..05c313f61 --- /dev/null +++ b/cmd/collectors/ontap.go @@ -0,0 +1,103 @@ +package collectors + +import ( + "errors" + "github.com/netapp/harvest/v2/cmd/tools/rest" + "github.com/netapp/harvest/v2/pkg/api/ontapi/zapi" + "github.com/netapp/harvest/v2/pkg/auth" + "github.com/netapp/harvest/v2/pkg/conf" + "github.com/netapp/harvest/v2/pkg/errs" + "net/http" + "time" +) + +func GatherClusterInfo(pollerName string, cred *auth.Credentials) (conf.Remote, error) { + + var ( + err error + ) + + remoteZapi, err := checkZapi(pollerName, cred) + if err != nil { + return conf.Remote{}, err + } + + remoteRest, err := checkRest(pollerName, cred) + if err != nil { + return remoteZapi, err + } + + remoteRest.ZAPIsExist = remoteZapi.ZAPIsExist + + return remoteRest, nil +} + +func checkRest(pollerName string, cred *auth.Credentials) (conf.Remote, error) { + + var ( + poller *conf.Poller + client *rest.Client + err error + ) + + // connect to the cluster + if poller, err = conf.PollerNamed(pollerName); err != nil { + return conf.Remote{}, err + } + + timeout, _ := time.ParseDuration(rest.DefaultTimeout) + client, err = rest.New(poller, timeout, cred) + if err != nil { + return conf.Remote{}, err + } + + if err := client.Init(5, conf.Remote{}); err != nil { + return conf.Remote{}, err + } + + return client.Remote(), nil +} + +func checkZapi(pollerName string, cred *auth.Credentials) (conf.Remote, error) { + + var ( + poller *conf.Poller + client *zapi.Client + err error + zapisExist bool + ) + + // connect to the cluster and retrieve the system version + if poller, err = conf.PollerNamed(pollerName); err != nil { + return conf.Remote{}, err + } + if client, err = zapi.New(poller, cred); err != nil { + return conf.Remote{}, err + } + + zapisExist = true + err = client.Init(2, conf.Remote{}) + + if err != nil { + + returnErr := true + + var he errs.HarvestError + if errors.As(err, &he) { + switch { + case he.ErrNum == errs.ErrNumZAPISuspended, he.StatusCode == http.StatusBadRequest: + zapisExist = false + returnErr = false + } + } + + if returnErr { + return conf.Remote{}, err + } + } + + remote := client.Remote() + remote.ZAPIsExist = zapisExist + + return remote, nil +} diff --git a/cmd/collectors/power.go b/cmd/collectors/power.go index bdd39e687..95cceb758 100644 --- a/cmd/collectors/power.go +++ b/cmd/collectors/power.go @@ -440,7 +440,7 @@ type Sensor struct { hasREST bool } -func (s *Sensor) Init() error { +func (s *Sensor) Init(remote conf.Remote) error { var err error if err := s.InitAbc(); err != nil { @@ -455,7 +455,7 @@ func (s *Sensor) Init() error { s.hasREST = true - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, remote); err != nil { var re *errs.RestError if errors.As(err, &re) && re.StatusCode == http.StatusNotFound { s.SLogger.Warn("Cluster does not support REST. Power plugin disabled") diff --git a/cmd/collectors/rest/plugins/aggregate/aggregate.go b/cmd/collectors/rest/plugins/aggregate/aggregate.go index c747c2ac7..3dd974c48 100644 --- a/cmd/collectors/rest/plugins/aggregate/aggregate.go +++ b/cmd/collectors/rest/plugins/aggregate/aggregate.go @@ -36,7 +36,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Aggregate{AbstractPlugin: p} } -func (a *Aggregate) Init() error { +func (a *Aggregate) Init(remote conf.Remote) error { if err := a.InitAbc(); err != nil { return fmt.Errorf("failed to initialize AbstractPlugin: %w", err) } @@ -48,7 +48,7 @@ func (a *Aggregate) Init() error { } a.client = client - if err := a.client.Init(5); err != nil { + if err := a.client.Init(5, remote); err != nil { return fmt.Errorf("failed to initialize REST client: %w", err) } diff --git a/cmd/collectors/rest/plugins/certificate/certificate.go b/cmd/collectors/rest/plugins/certificate/certificate.go index d6bf7e001..7c8ed08f6 100644 --- a/cmd/collectors/rest/plugins/certificate/certificate.go +++ b/cmd/collectors/rest/plugins/certificate/certificate.go @@ -30,7 +30,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Certificate{AbstractPlugin: p} } -func (c *Certificate) Init() error { +func (c *Certificate) Init(remote conf.Remote) error { var err error @@ -44,7 +44,7 @@ func (c *Certificate) Init() error { return err } - if err := c.client.Init(5); err != nil { + if err := c.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/rest/plugins/health/health.go b/cmd/collectors/rest/plugins/health/health.go index 3318c8d7d..6d488d881 100644 --- a/cmd/collectors/rest/plugins/health/health.go +++ b/cmd/collectors/rest/plugins/health/health.go @@ -58,7 +58,7 @@ var metrics = []string{ "alerts", } -func (h *Health) Init() error { +func (h *Health) Init(remote conf.Remote) error { var err error @@ -89,7 +89,7 @@ func (h *Health) Init() error { return err } - return h.client.Init(5) + return h.client.Init(5, remote) } func (h *Health) InitAllMatrix() error { diff --git a/cmd/collectors/rest/plugins/metroclustercheck/metroclustercheck.go b/cmd/collectors/rest/plugins/metroclustercheck/metroclustercheck.go index 5f4cc41bf..2a55ad684 100644 --- a/cmd/collectors/rest/plugins/metroclustercheck/metroclustercheck.go +++ b/cmd/collectors/rest/plugins/metroclustercheck/metroclustercheck.go @@ -2,6 +2,7 @@ package metroclustercheck import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" "github.com/netapp/harvest/v2/pkg/tree/node" @@ -19,7 +20,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &MetroclusterCheck{AbstractPlugin: p} } -func (m *MetroclusterCheck) Init() error { +func (m *MetroclusterCheck) Init(conf.Remote) error { pluginMetrics := []string{"cluster_status", "node_status", "aggr_status", "volume_status"} pluginLabels := []string{"result", "name", "node", "aggregate", "volume"} diff --git a/cmd/collectors/rest/plugins/netroute/netroute.go b/cmd/collectors/rest/plugins/netroute/netroute.go index 093aa890c..ed6ff3594 100644 --- a/cmd/collectors/rest/plugins/netroute/netroute.go +++ b/cmd/collectors/rest/plugins/netroute/netroute.go @@ -6,6 +6,7 @@ package netroute import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" "github.com/netapp/harvest/v2/pkg/tree/node" @@ -35,7 +36,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &NetRoute{AbstractPlugin: p} } -func (n *NetRoute) Init() error { +func (n *NetRoute) Init(conf.Remote) error { if err := n.InitAbc(); err != nil { return err diff --git a/cmd/collectors/rest/plugins/ontaps3service/ontaps3service.go b/cmd/collectors/rest/plugins/ontaps3service/ontaps3service.go index cc1555472..15ba7294d 100644 --- a/cmd/collectors/rest/plugins/ontaps3service/ontaps3service.go +++ b/cmd/collectors/rest/plugins/ontaps3service/ontaps3service.go @@ -29,7 +29,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &OntapS3Service{AbstractPlugin: p} } -func (o *OntapS3Service) Init() error { +func (o *OntapS3Service) Init(remote conf.Remote) error { var err error if err := o.InitAbc(); err != nil { @@ -49,7 +49,7 @@ func (o *OntapS3Service) Init() error { return err } - if err := o.client.Init(5); err != nil { + if err := o.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/rest/plugins/quota/quota.go b/cmd/collectors/rest/plugins/quota/quota.go index 66583ec75..2501d5a1e 100644 --- a/cmd/collectors/rest/plugins/quota/quota.go +++ b/cmd/collectors/rest/plugins/quota/quota.go @@ -2,6 +2,7 @@ package quota import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" "github.com/netapp/harvest/v2/pkg/util" @@ -17,7 +18,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Quota{AbstractPlugin: p} } -func (q *Quota) Init() error { +func (q *Quota) Init(conf.Remote) error { if err := q.InitAbc(); err != nil { return err } diff --git a/cmd/collectors/rest/plugins/securityaccount/securityaccount.go b/cmd/collectors/rest/plugins/securityaccount/securityaccount.go index b0dd58fc8..923dfca4e 100644 --- a/cmd/collectors/rest/plugins/securityaccount/securityaccount.go +++ b/cmd/collectors/rest/plugins/securityaccount/securityaccount.go @@ -28,7 +28,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &SecurityAccount{AbstractPlugin: p} } -func (s *SecurityAccount) Init() error { +func (s *SecurityAccount) Init(remote conf.Remote) error { var err error if err := s.InitAbc(); err != nil { @@ -47,7 +47,7 @@ func (s *SecurityAccount) Init() error { return fmt.Errorf("failed to connect err=%w", err) } - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/rest/plugins/shelf/shelf.go b/cmd/collectors/rest/plugins/shelf/shelf.go index 2d2e4940f..1d78750cf 100644 --- a/cmd/collectors/rest/plugins/shelf/shelf.go +++ b/cmd/collectors/rest/plugins/shelf/shelf.go @@ -4,6 +4,7 @@ package shelf import ( "github.com/netapp/harvest/v2/cmd/collectors" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/util" ) @@ -16,7 +17,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Shelf{AbstractPlugin: p} } -func (my *Shelf) Init() error { +func (my *Shelf) Init(conf.Remote) error { return my.InitAbc() } diff --git a/cmd/collectors/rest/plugins/snapmirror/snapmirror.go b/cmd/collectors/rest/plugins/snapmirror/snapmirror.go index 2ca13a577..0b133876a 100644 --- a/cmd/collectors/rest/plugins/snapmirror/snapmirror.go +++ b/cmd/collectors/rest/plugins/snapmirror/snapmirror.go @@ -40,7 +40,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &SnapMirror{AbstractPlugin: p} } -func (m *SnapMirror) Init() error { +func (m *SnapMirror) Init(remote conf.Remote) error { var err error @@ -54,7 +54,7 @@ func (m *SnapMirror) Init() error { return err } - if err := m.client.Init(5); err != nil { + if err := m.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/rest/plugins/svm/svm.go b/cmd/collectors/rest/plugins/svm/svm.go index d05887b93..3d04a8c58 100644 --- a/cmd/collectors/rest/plugins/svm/svm.go +++ b/cmd/collectors/rest/plugins/svm/svm.go @@ -48,7 +48,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &SVM{AbstractPlugin: p} } -func (s *SVM) Init() error { +func (s *SVM) Init(remote conf.Remote) error { var err error @@ -62,7 +62,7 @@ func (s *SVM) Init() error { return err } - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, remote); err != nil { return err } s.nsswitchInfo = make(map[string]Nsswitch) diff --git a/cmd/collectors/rest/plugins/volume/volume.go b/cmd/collectors/rest/plugins/volume/volume.go index caca94235..74537dc11 100644 --- a/cmd/collectors/rest/plugins/volume/volume.go +++ b/cmd/collectors/rest/plugins/volume/volume.go @@ -49,7 +49,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Volume{AbstractPlugin: p} } -func (v *Volume) Init() error { +func (v *Volume) Init(remote conf.Remote) error { var err error @@ -72,7 +72,7 @@ func (v *Volume) Init() error { return err } - if err := v.client.Init(5); err != nil { + if err := v.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/rest/plugins/volumeanalytics/volumeanalytics.go b/cmd/collectors/rest/plugins/volumeanalytics/volumeanalytics.go index 197e50464..e0444def4 100644 --- a/cmd/collectors/rest/plugins/volumeanalytics/volumeanalytics.go +++ b/cmd/collectors/rest/plugins/volumeanalytics/volumeanalytics.go @@ -38,7 +38,7 @@ var metrics = []string{ "dir_subdir_count", } -func (v *VolumeAnalytics) Init() error { +func (v *VolumeAnalytics) Init(remote conf.Remote) error { var err error @@ -67,7 +67,7 @@ func (v *VolumeAnalytics) Init() error { return err } - if err := v.client.Init(5); err != nil { + if err := v.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/rest/plugins/workload/workload.go b/cmd/collectors/rest/plugins/workload/workload.go index 67c70365e..9b2488d97 100644 --- a/cmd/collectors/rest/plugins/workload/workload.go +++ b/cmd/collectors/rest/plugins/workload/workload.go @@ -3,6 +3,7 @@ package workload import ( "github.com/netapp/harvest/v2/cmd/collectors" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" "github.com/netapp/harvest/v2/pkg/util" @@ -22,7 +23,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Workload{AbstractPlugin: p} } -func (w *Workload) Init() error { +func (w *Workload) Init(conf.Remote) error { if err := w.InitAbc(); err != nil { return err } diff --git a/cmd/collectors/rest/rest.go b/cmd/collectors/rest/rest.go index 0fd69c96c..96a5bd450 100644 --- a/cmd/collectors/rest/rest.go +++ b/cmd/collectors/rest/rest.go @@ -196,12 +196,12 @@ func (r *Rest) InitClient() error { if r.Options.IsTest { return nil } - if err := r.Client.Init(5); err != nil { + + if err := r.Client.Init(5, r.Remote); err != nil { return err } - r.Client.TraceLogSet(r.Name, r.Params) - r.Remote = r.Client.Remote() + r.Client.TraceLogSet(r.Name, r.Params) return nil } diff --git a/cmd/collectors/rest/rest_test.go b/cmd/collectors/rest/rest_test.go index bb23d1db7..01391086f 100644 --- a/cmd/collectors/rest/rest_test.go +++ b/cmd/collectors/rest/rest_test.go @@ -155,7 +155,7 @@ func newRest(object string, path string, confPath string) *Rest { opts.Poller = pollerName opts.HomePath = "testdata" opts.IsTest = true - ac := collector.New("Rest", object, opts, collectors.Params(object, path), nil) + ac := collector.New("Rest", object, opts, collectors.Params(object, path), nil, conf.Remote{}) r := Rest{} err = r.Init(ac) if err != nil { diff --git a/cmd/collectors/restperf/plugins/disk/disk.go b/cmd/collectors/restperf/plugins/disk/disk.go index c0d291407..4ff4bc2e8 100644 --- a/cmd/collectors/restperf/plugins/disk/disk.go +++ b/cmd/collectors/restperf/plugins/disk/disk.go @@ -108,7 +108,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Disk{AbstractPlugin: p} } -func (d *Disk) Init() error { +func (d *Disk) Init(remote conf.Remote) error { var err error if err := d.InitAbc(); err != nil { @@ -121,7 +121,7 @@ func (d *Disk) Init() error { return err } - if err := d.client.Init(5); err != nil { + if err := d.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go b/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go index b2d968c8b..12a57b603 100644 --- a/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go +++ b/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go @@ -3,6 +3,7 @@ package fabricpool import ( "github.com/netapp/harvest/v2/cmd/collectors" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/util" "strconv" @@ -18,7 +19,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &FabricPool{AbstractPlugin: p} } -func (f *FabricPool) Init() error { +func (f *FabricPool) Init(conf.Remote) error { err := f.InitAbc() if err != nil { return err diff --git a/cmd/collectors/restperf/plugins/fcvi/fcvi.go b/cmd/collectors/restperf/plugins/fcvi/fcvi.go index 8ab00f90e..8a3fd5aa0 100644 --- a/cmd/collectors/restperf/plugins/fcvi/fcvi.go +++ b/cmd/collectors/restperf/plugins/fcvi/fcvi.go @@ -21,7 +21,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &FCVI{AbstractPlugin: p} } -func (f *FCVI) Init() error { +func (f *FCVI) Init(remote conf.Remote) error { var err error if err := f.InitAbc(); err != nil { return err @@ -33,7 +33,7 @@ func (f *FCVI) Init() error { return err } - return f.client.Init(5) + return f.client.Init(5, remote) } func (f *FCVI) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { diff --git a/cmd/collectors/restperf/plugins/nic/nic.go b/cmd/collectors/restperf/plugins/nic/nic.go index 33d2a687c..122edd535 100644 --- a/cmd/collectors/restperf/plugins/nic/nic.go +++ b/cmd/collectors/restperf/plugins/nic/nic.go @@ -46,7 +46,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Nic{AbstractPlugin: p} } -func (n *Nic) Init() error { +func (n *Nic) Init(remote conf.Remote) error { err := n.InitAbc() if err != nil { return err @@ -80,7 +80,7 @@ func (n *Nic) Init() error { return err } - if err := n.client.Init(5); err != nil { + if err := n.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/restperf/plugins/nic/nic_test.go b/cmd/collectors/restperf/plugins/nic/nic_test.go index 7d95b9697..0172dd119 100644 --- a/cmd/collectors/restperf/plugins/nic/nic_test.go +++ b/cmd/collectors/restperf/plugins/nic/nic_test.go @@ -4,6 +4,7 @@ import ( "github.com/netapp/harvest/v2/cmd/poller/options" "github.com/netapp/harvest/v2/cmd/poller/plugin" "github.com/netapp/harvest/v2/cmd/tools/rest" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" "github.com/netapp/harvest/v2/pkg/util" @@ -17,7 +18,7 @@ func runNicTest(t *testing.T, createRestNic func(params *node.Node) plugin.Plugi n := createRestNic(params) // Initialize the plugin - if err := n.Init(); err != nil { + if err := n.Init(conf.Remote{}); err != nil { t.Fatalf("failed to initialize plugin: %v", err) } diff --git a/cmd/collectors/restperf/plugins/volume/volume.go b/cmd/collectors/restperf/plugins/volume/volume.go index c66186073..61438373e 100644 --- a/cmd/collectors/restperf/plugins/volume/volume.go +++ b/cmd/collectors/restperf/plugins/volume/volume.go @@ -24,7 +24,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Volume{AbstractPlugin: p} } -func (v *Volume) Init() error { +func (v *Volume) Init(remote conf.Remote) error { var err error if err := v.InitAbc(); err != nil { return err @@ -55,7 +55,7 @@ func (v *Volume) Init() error { return err } - return v.client.Init(5) + return v.client.Init(5, remote) } func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { diff --git a/cmd/collectors/restperf/plugins/volume/volume_test.go b/cmd/collectors/restperf/plugins/volume/volume_test.go index 513232584..6bd971e87 100644 --- a/cmd/collectors/restperf/plugins/volume/volume_test.go +++ b/cmd/collectors/restperf/plugins/volume/volume_test.go @@ -5,6 +5,7 @@ import ( volume2 "github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/volume" "github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/volume" "github.com/netapp/harvest/v2/cmd/poller/options" + "github.com/netapp/harvest/v2/pkg/conf" "log/slog" "strconv" "testing" @@ -26,7 +27,7 @@ func runVolumeTest(t *testing.T, createVolume func(params *node.Node) plugin.Plu volumesMap := make(map[string]string) // Initialize the plugin - if err := v.Init(); err != nil { + if err := v.Init(conf.Remote{}); err != nil { t.Fatalf("failed to initialize plugin: %v", err) } diff --git a/cmd/collectors/restperf/plugins/volumetag/volumetag.go b/cmd/collectors/restperf/plugins/volumetag/volumetag.go index 501136514..56a4d3e6d 100644 --- a/cmd/collectors/restperf/plugins/volumetag/volumetag.go +++ b/cmd/collectors/restperf/plugins/volumetag/volumetag.go @@ -21,7 +21,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &VolumeTag{AbstractPlugin: p} } -func (v *VolumeTag) Init() error { +func (v *VolumeTag) Init(remote conf.Remote) error { var err error if err := v.InitAbc(); err != nil { return err @@ -33,7 +33,7 @@ func (v *VolumeTag) Init() error { return err } - return v.client.Init(5) + return v.client.Init(5, remote) } func (v *VolumeTag) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { diff --git a/cmd/collectors/restperf/plugins/volumetopclients/volumetopclients.go b/cmd/collectors/restperf/plugins/volumetopclients/volumetopclients.go index 082de6e12..a8c77e508 100644 --- a/cmd/collectors/restperf/plugins/volumetopclients/volumetopclients.go +++ b/cmd/collectors/restperf/plugins/volumetopclients/volumetopclients.go @@ -97,7 +97,7 @@ func (t *TopClients) initMatrix(name string, object string, inputMat map[string] return nil } -func (t *TopClients) Init() error { +func (t *TopClients) Init(remote conf.Remote) error { var err error if err := t.InitAbc(); err != nil { return err @@ -112,7 +112,7 @@ func (t *TopClients) Init() error { return err } - if err := t.client.Init(5); err != nil { + if err := t.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/restperf/restperf_test.go b/cmd/collectors/restperf/restperf_test.go index 172db83bd..a668ad644 100644 --- a/cmd/collectors/restperf/restperf_test.go +++ b/cmd/collectors/restperf/restperf_test.go @@ -353,7 +353,7 @@ func newRestPerf(object string, path string) *RestPerf { opts.HomePath = "testdata" opts.IsTest = true - ac := collector.New("RestPerf", object, opts, params(object, path), nil) + ac := collector.New("RestPerf", object, opts, params(object, path), nil, conf.Remote{}) r := RestPerf{} err = r.Init(ac) if err != nil { diff --git a/cmd/collectors/storagegrid/plugins/bucket/bucket.go b/cmd/collectors/storagegrid/plugins/bucket/bucket.go index b4d34980e..db823d70b 100644 --- a/cmd/collectors/storagegrid/plugins/bucket/bucket.go +++ b/cmd/collectors/storagegrid/plugins/bucket/bucket.go @@ -3,6 +3,7 @@ package bucket import ( "github.com/netapp/harvest/v2/cmd/collectors/storagegrid/rest" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" "github.com/netapp/harvest/v2/pkg/util" @@ -20,7 +21,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Bucket{AbstractPlugin: p} } -func (b *Bucket) Init() error { +func (b *Bucket) Init(remote conf.Remote) error { var err error @@ -34,7 +35,7 @@ func (b *Bucket) Init() error { return err } - if err := b.client.Init(5); err != nil { + if err := b.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/storagegrid/plugins/joinrest/joinrest.go b/cmd/collectors/storagegrid/plugins/joinrest/joinrest.go index 81f5ebb14..f6f9dd7e0 100644 --- a/cmd/collectors/storagegrid/plugins/joinrest/joinrest.go +++ b/cmd/collectors/storagegrid/plugins/joinrest/joinrest.go @@ -3,6 +3,7 @@ package joinrest import ( "github.com/netapp/harvest/v2/cmd/collectors/storagegrid/rest" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" "github.com/netapp/harvest/v2/pkg/util" @@ -40,13 +41,13 @@ plugins: label_prom: policy ` -func (t *JoinRest) Init() error { +func (t *JoinRest) Init(remote conf.Remote) error { var err error if err := t.InitAbc(); err != nil { return err } - if err := t.initClient(); err != nil { + if err := t.initClient(remote); err != nil { return err } @@ -164,14 +165,14 @@ func (t *JoinRest) updateCache(model join, bytes *[]byte) { } } -func (t *JoinRest) initClient() error { +func (t *JoinRest) initClient(remote conf.Remote) error { var err error if t.client, err = rest.NewClient(t.Options.Poller, t.Params.GetChildContentS("client_timeout"), t.Auth); err != nil { return err } - if err := t.client.Init(5); err != nil { + if err := t.client.Init(5, remote); err != nil { return err } t.client.TraceLogSet(t.Name, t.Params) diff --git a/cmd/collectors/storagegrid/rest/client.go b/cmd/collectors/storagegrid/rest/client.go index 1f8887572..cac805eb8 100644 --- a/cmd/collectors/storagegrid/rest/client.go +++ b/cmd/collectors/storagegrid/rest/client.go @@ -268,12 +268,18 @@ func (c *Client) fetch() ([]byte, error) { } // Init is responsible for determining the StorageGrid server version, API version, hostname, and systemId -func (c *Client) Init(retries int) error { +func (c *Client) Init(retries int, remote conf.Remote) error { var ( err error content []byte ) + c.Remote = remote + + if !remote.IsZero() { + return nil + } + for range retries { // Determine which API versions are supported and then request // product version and cluster name - both of which are separate endpoints diff --git a/cmd/collectors/storagegrid/storagegrid.go b/cmd/collectors/storagegrid/storagegrid.go index 0eb215388..d6e74ac43 100644 --- a/cmd/collectors/storagegrid/storagegrid.go +++ b/cmd/collectors/storagegrid/storagegrid.go @@ -437,13 +437,11 @@ func (s *StorageGrid) initClient() error { return nil } - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, s.Remote); err != nil { return err } s.client.TraceLogSet(s.Name, s.Params) - s.Remote = s.client.Remote - return nil } diff --git a/cmd/collectors/storagegrid/storagegrid_test.go b/cmd/collectors/storagegrid/storagegrid_test.go index 9be1cc376..6bb04de4d 100644 --- a/cmd/collectors/storagegrid/storagegrid_test.go +++ b/cmd/collectors/storagegrid/storagegrid_test.go @@ -26,7 +26,7 @@ func newStorageGrid(object string, path string) (*StorageGrid, error) { rest.NewClientFunc = func(_ string, _ string, _ *auth.Credentials) (*rest.Client, error) { return rest.NewDummyClient(), nil } - ac := collector.New("StorageGrid", object, opts, collectors.Params(object, path), nil) + ac := collector.New("StorageGrid", object, opts, collectors.Params(object, path), nil, conf.Remote{}) err := r.Init(ac) if err != nil { return nil, err diff --git a/cmd/collectors/zapi/collector/zapi.go b/cmd/collectors/zapi/collector/zapi.go index a332ebfa8..6d735fead 100644 --- a/cmd/collectors/zapi/collector/zapi.go +++ b/cmd/collectors/zapi/collector/zapi.go @@ -107,7 +107,7 @@ func (z *Zapi) InitVars() error { } z.Client.TraceLogSet(z.Name, z.Params) - if err = z.Client.Init(5); err != nil { // 5 retries before giving up to connect + if err = z.Client.Init(5, z.Remote); err != nil { // 5 retries before giving up to connect return errs.New(errs.ErrConnection, err.Error()) } z.Logger.Debug("connected", slog.String("client", z.Client.Info())) @@ -117,15 +117,6 @@ func (z *Zapi) InitVars() error { model = "7mode" } - // save for ASUP messaging - versionT := z.Client.Version() - z.Remote = conf.Remote{ - Name: z.Client.Name(), - UUID: z.Client.Serial(), - Model: model, - Version: strconv.Itoa(versionT[0]) + "." + strconv.Itoa(versionT[1]) + "." + strconv.Itoa(versionT[2]), - } - templateName := z.Params.GetChildS("objects").GetChildContentS(z.Object) template, path, err := z.ImportSubTemplate(model, templateName, jitter, z.Remote.Version) if err != nil { diff --git a/cmd/collectors/zapi/plugins/aggregate/aggregate.go b/cmd/collectors/zapi/plugins/aggregate/aggregate.go index ead36c95b..1624c20b6 100644 --- a/cmd/collectors/zapi/plugins/aggregate/aggregate.go +++ b/cmd/collectors/zapi/plugins/aggregate/aggregate.go @@ -27,7 +27,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Aggregate{AbstractPlugin: p} } -func (a *Aggregate) Init() error { +func (a *Aggregate) Init(remote conf.Remote) error { var err error @@ -40,7 +40,7 @@ func (a *Aggregate) Init() error { return err } - if err := a.client.Init(5); err != nil { + if err := a.client.Init(5, remote); err != nil { return err } @@ -109,8 +109,7 @@ func (a *Aggregate) getCloudStores() error { ) // aggr-object-store-get-iter Zapi was introduced in 9.2. - version := a.client.Version() - clusterVersion := strconv.Itoa(version[0]) + "." + strconv.Itoa(version[1]) + "." + strconv.Itoa(version[2]) + clusterVersion := a.client.Version() ontapVersion, err := goversion.NewVersion(clusterVersion) if err != nil { a.SLogger.Error( diff --git a/cmd/collectors/zapi/plugins/certificate/certificate.go b/cmd/collectors/zapi/plugins/certificate/certificate.go index d1210cf7d..68518399a 100644 --- a/cmd/collectors/zapi/plugins/certificate/certificate.go +++ b/cmd/collectors/zapi/plugins/certificate/certificate.go @@ -34,7 +34,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Certificate{AbstractPlugin: p} } -func (c *Certificate) Init() error { +func (c *Certificate) Init(remote conf.Remote) error { var err error @@ -47,7 +47,7 @@ func (c *Certificate) Init() error { return err } - if err := c.client.Init(5); err != nil { + if err := c.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapi/plugins/qtree/qtree.go b/cmd/collectors/zapi/plugins/qtree/qtree.go index 23ba04552..80d05662b 100644 --- a/cmd/collectors/zapi/plugins/qtree/qtree.go +++ b/cmd/collectors/zapi/plugins/qtree/qtree.go @@ -38,7 +38,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Qtree{AbstractPlugin: p} } -func (q *Qtree) Init() error { +func (q *Qtree) Init(remote conf.Remote) error { var err error @@ -55,7 +55,7 @@ func (q *Qtree) Init() error { return err } - if err := q.client.Init(5); err != nil { + if err := q.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapi/plugins/qtree/qtree_test.go b/cmd/collectors/zapi/plugins/qtree/qtree_test.go index 1ad397106..77b2ec0ea 100644 --- a/cmd/collectors/zapi/plugins/qtree/qtree_test.go +++ b/cmd/collectors/zapi/plugins/qtree/qtree_test.go @@ -4,6 +4,7 @@ import ( "github.com/netapp/harvest/v2/cmd/poller/options" "github.com/netapp/harvest/v2/cmd/poller/plugin" client "github.com/netapp/harvest/v2/pkg/api/ontapi/zapi" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" "log/slog" @@ -108,7 +109,7 @@ func runQtreeTest(t *testing.T, createQtree func(historicalLabels bool) plugin.P q := createQtree(historicalLabels) // Initialize the plugin - if err := q.Init(); err != nil { + if err := q.Init(conf.Remote{}); err != nil { t.Fatalf("failed to initialize plugin: %v", err) } diff --git a/cmd/collectors/zapi/plugins/security/security.go b/cmd/collectors/zapi/plugins/security/security.go index 4d0353004..54a1eb9c9 100644 --- a/cmd/collectors/zapi/plugins/security/security.go +++ b/cmd/collectors/zapi/plugins/security/security.go @@ -28,7 +28,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Security{AbstractPlugin: p} } -func (s *Security) Init() error { +func (s *Security) Init(remote conf.Remote) error { var err error @@ -41,7 +41,7 @@ func (s *Security) Init() error { return err } - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapi/plugins/shelf/shelf.go b/cmd/collectors/zapi/plugins/shelf/shelf.go index 41ba48bea..23d457c0e 100644 --- a/cmd/collectors/zapi/plugins/shelf/shelf.go +++ b/cmd/collectors/zapi/plugins/shelf/shelf.go @@ -40,7 +40,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Shelf{AbstractPlugin: p} } -func (s *Shelf) Init() error { +func (s *Shelf) Init(remote conf.Remote) error { var err error @@ -53,7 +53,7 @@ func (s *Shelf) Init() error { return err } - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapi/plugins/snapmirror/snapmirror.go b/cmd/collectors/zapi/plugins/snapmirror/snapmirror.go index 68d902cb2..68fef0ba5 100644 --- a/cmd/collectors/zapi/plugins/snapmirror/snapmirror.go +++ b/cmd/collectors/zapi/plugins/snapmirror/snapmirror.go @@ -36,7 +36,8 @@ var flexgroupConstituentName = regexp.MustCompile(`^(.*)__(\d{4})$`) func New(p *plugin.AbstractPlugin) plugin.Plugin { return &SnapMirror{AbstractPlugin: p} } -func (m *SnapMirror) Init() error { + +func (m *SnapMirror) Init(remote conf.Remote) error { var err error if err := m.InitAbc(); err != nil { return err @@ -45,7 +46,7 @@ func (m *SnapMirror) Init() error { m.SLogger.Error("connecting", slogx.Err(err)) return err } - if err := m.client.Init(5); err != nil { + if err := m.client.Init(5, remote); err != nil { return err } m.nodeUpdCounter = 0 diff --git a/cmd/collectors/zapi/plugins/svm/svm.go b/cmd/collectors/zapi/plugins/svm/svm.go index e8eacd387..97fe821e2 100644 --- a/cmd/collectors/zapi/plugins/svm/svm.go +++ b/cmd/collectors/zapi/plugins/svm/svm.go @@ -70,7 +70,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &SVM{AbstractPlugin: p} } -func (s *SVM) Init() error { +func (s *SVM) Init(remote conf.Remote) error { var err error @@ -83,7 +83,7 @@ func (s *SVM) Init() error { return err } - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapi/plugins/systemnode/systemnode.go b/cmd/collectors/zapi/plugins/systemnode/systemnode.go index b04440fdc..6945964a2 100644 --- a/cmd/collectors/zapi/plugins/systemnode/systemnode.go +++ b/cmd/collectors/zapi/plugins/systemnode/systemnode.go @@ -20,7 +20,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &SystemNode{AbstractPlugin: p} } -func (s *SystemNode) Init() error { +func (s *SystemNode) Init(remote conf.Remote) error { var err error @@ -33,7 +33,7 @@ func (s *SystemNode) Init() error { return err } - if err := s.client.Init(5); err != nil { + if err := s.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapi/plugins/volume/volume.go b/cmd/collectors/zapi/plugins/volume/volume.go index 27a5b740a..a9ca97d99 100644 --- a/cmd/collectors/zapi/plugins/volume/volume.go +++ b/cmd/collectors/zapi/plugins/volume/volume.go @@ -36,7 +36,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Volume{AbstractPlugin: p} } -func (v *Volume) Init() error { +func (v *Volume) Init(remote conf.Remote) error { var err error @@ -50,7 +50,7 @@ func (v *Volume) Init() error { return err } - if err := v.client.Init(5); err != nil { + if err := v.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapi/plugins/workload/workload.go b/cmd/collectors/zapi/plugins/workload/workload.go index 67c70365e..9b2488d97 100644 --- a/cmd/collectors/zapi/plugins/workload/workload.go +++ b/cmd/collectors/zapi/plugins/workload/workload.go @@ -3,6 +3,7 @@ package workload import ( "github.com/netapp/harvest/v2/cmd/collectors" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" "github.com/netapp/harvest/v2/pkg/util" @@ -22,7 +23,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Workload{AbstractPlugin: p} } -func (w *Workload) Init() error { +func (w *Workload) Init(conf.Remote) error { if err := w.InitAbc(); err != nil { return err } diff --git a/cmd/collectors/zapiperf/plugins/disk/disk.go b/cmd/collectors/zapiperf/plugins/disk/disk.go index fe2d73059..7a1862f9a 100644 --- a/cmd/collectors/zapiperf/plugins/disk/disk.go +++ b/cmd/collectors/zapiperf/plugins/disk/disk.go @@ -109,7 +109,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Disk{AbstractPlugin: p} } -func (d *Disk) Init() error { +func (d *Disk) Init(remote conf.Remote) error { var err error @@ -122,7 +122,7 @@ func (d *Disk) Init() error { return err } - if err := d.client.Init(5); err != nil { + if err := d.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapiperf/plugins/fabricpool/fabricpool.go b/cmd/collectors/zapiperf/plugins/fabricpool/fabricpool.go index 9ff3497ad..dc8bd95ae 100644 --- a/cmd/collectors/zapiperf/plugins/fabricpool/fabricpool.go +++ b/cmd/collectors/zapiperf/plugins/fabricpool/fabricpool.go @@ -3,6 +3,7 @@ package fabricpool import ( "github.com/netapp/harvest/v2/cmd/collectors" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/util" "strconv" @@ -17,7 +18,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &FabricPool{AbstractPlugin: p} } -func (f *FabricPool) Init() error { +func (f *FabricPool) Init(conf.Remote) error { err := f.InitAbc() if err != nil { return err diff --git a/cmd/collectors/zapiperf/plugins/fcvi/fcvi.go b/cmd/collectors/zapiperf/plugins/fcvi/fcvi.go index 4f7abf5c7..5b654d5d3 100644 --- a/cmd/collectors/zapiperf/plugins/fcvi/fcvi.go +++ b/cmd/collectors/zapiperf/plugins/fcvi/fcvi.go @@ -23,7 +23,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &FCVI{AbstractPlugin: p} } -func (f *FCVI) Init() error { +func (f *FCVI) Init(remote conf.Remote) error { var err error if err := f.InitAbc(); err != nil { return err @@ -33,7 +33,7 @@ func (f *FCVI) Init() error { f.SLogger.Error("connecting", slogx.Err(err)) return err } - return f.client.Init(5) + return f.client.Init(5, remote) } func (f *FCVI) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { diff --git a/cmd/collectors/zapiperf/plugins/flexcache/flexcache.go b/cmd/collectors/zapiperf/plugins/flexcache/flexcache.go index 4c14781bd..541331dba 100644 --- a/cmd/collectors/zapiperf/plugins/flexcache/flexcache.go +++ b/cmd/collectors/zapiperf/plugins/flexcache/flexcache.go @@ -25,7 +25,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &FlexCache{AbstractPlugin: p} } -func (f *FlexCache) Init() error { +func (f *FlexCache) Init(remote conf.Remote) error { var err error @@ -38,7 +38,7 @@ func (f *FlexCache) Init() error { return err } - if err := f.client.Init(5); err != nil { + if err := f.client.Init(5, remote); err != nil { return err } return nil diff --git a/cmd/collectors/zapiperf/plugins/nic/nic.go b/cmd/collectors/zapiperf/plugins/nic/nic.go index 7467b3990..3dcc2db3f 100644 --- a/cmd/collectors/zapiperf/plugins/nic/nic.go +++ b/cmd/collectors/zapiperf/plugins/nic/nic.go @@ -47,7 +47,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Nic{AbstractPlugin: p} } -func (n *Nic) Init() error { +func (n *Nic) Init(remote conf.Remote) error { var err error if err := n.InitAbc(); err != nil { return err @@ -58,7 +58,7 @@ func (n *Nic) Init() error { return err } - if err := n.client.Init(5); err != nil { + if err := n.client.Init(5, remote); err != nil { return err } diff --git a/cmd/collectors/zapiperf/plugins/volume/volume.go b/cmd/collectors/zapiperf/plugins/volume/volume.go index 5af6eaea5..d70a06f03 100644 --- a/cmd/collectors/zapiperf/plugins/volume/volume.go +++ b/cmd/collectors/zapiperf/plugins/volume/volume.go @@ -30,7 +30,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &Volume{AbstractPlugin: p} } -func (v *Volume) Init() error { +func (v *Volume) Init(remote conf.Remote) error { var err error if err := v.InitAbc(); err != nil { return err @@ -58,7 +58,7 @@ func (v *Volume) Init() error { v.SLogger.Error("connecting", slog.Any("err", err)) return err } - return v.client.Init(5) + return v.client.Init(5, remote) } func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { diff --git a/cmd/collectors/zapiperf/plugins/volumetag/volumetag.go b/cmd/collectors/zapiperf/plugins/volumetag/volumetag.go index 16f32113f..820283462 100644 --- a/cmd/collectors/zapiperf/plugins/volumetag/volumetag.go +++ b/cmd/collectors/zapiperf/plugins/volumetag/volumetag.go @@ -21,7 +21,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { return &VolumeTag{AbstractPlugin: p} } -func (v *VolumeTag) Init() error { +func (v *VolumeTag) Init(remote conf.Remote) error { var err error if err := v.InitAbc(); err != nil { return err @@ -31,7 +31,7 @@ func (v *VolumeTag) Init() error { v.SLogger.Error("connecting", slogx.Err(err)) return err } - return v.client.Init(5) + return v.client.Init(5, remote) } func (v *VolumeTag) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { diff --git a/cmd/collectors/zapiperf/zapiperf_test.go b/cmd/collectors/zapiperf/zapiperf_test.go index 51b735ba6..61ae5dc0c 100644 --- a/cmd/collectors/zapiperf/zapiperf_test.go +++ b/cmd/collectors/zapiperf/zapiperf_test.go @@ -189,7 +189,7 @@ func NewZapiPerf(object, path string) *ZapiPerf { opts.HomePath = homePath opts.IsTest = true - ac := collector.New("Zapiperf", object, opts, params(object, path), nil) + ac := collector.New("Zapiperf", object, opts, params(object, path), nil, conf.Remote{}) z := &ZapiPerf{} if err := z.Init(ac); err != nil { slog.Error("", slogx.Err(err)) diff --git a/cmd/poller/collector/collector.go b/cmd/poller/collector/collector.go index d4bc6d6fc..0b6ae3f90 100644 --- a/cmd/poller/collector/collector.go +++ b/cmd/poller/collector/collector.go @@ -113,7 +113,7 @@ type AbstractCollector struct { Remote conf.Remote } -func New(name, object string, o *options.Options, params *node.Node, credentials *auth.Credentials) *AbstractCollector { +func New(name, object string, o *options.Options, params *node.Node, credentials *auth.Credentials, remote conf.Remote) *AbstractCollector { return &AbstractCollector{ Name: name, Object: object, @@ -122,6 +122,7 @@ func New(name, object string, o *options.Options, params *node.Node, credentials Params: params, countMux: &sync.Mutex{}, Auth: credentials, + Remote: remote, } } @@ -758,7 +759,7 @@ func (c *AbstractCollector) LoadPlugins(params *node.Node, collector Collector, continue } - if err := p.Init(); err != nil { + if err := p.Init(c.Remote); err != nil { slog.Error("init plugin", slogx.Err(err), slog.String("name", name)) return err } diff --git a/cmd/poller/plugin/aggregator/aggregator.go b/cmd/poller/plugin/aggregator/aggregator.go index 6f5044757..784fad294 100644 --- a/cmd/poller/plugin/aggregator/aggregator.go +++ b/cmd/poller/plugin/aggregator/aggregator.go @@ -7,6 +7,7 @@ package aggregator import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" @@ -38,9 +39,9 @@ type rule struct { counts map[string]map[string]float64 } -func (a *Aggregator) Init() error { +func (a *Aggregator) Init(remote conf.Remote) error { - if err := a.AbstractPlugin.Init(); err != nil { + if err := a.AbstractPlugin.Init(remote); err != nil { return err } diff --git a/cmd/poller/plugin/aggregator/aggregator_test.go b/cmd/poller/plugin/aggregator/aggregator_test.go index f8a6ed34e..9373d1b63 100644 --- a/cmd/poller/plugin/aggregator/aggregator_test.go +++ b/cmd/poller/plugin/aggregator/aggregator_test.go @@ -6,6 +6,7 @@ package aggregator import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" "testing" @@ -18,7 +19,7 @@ func newAggregator() *Aggregator { abc := plugin.New("Test", nil, params, nil, "", nil) p := &Aggregator{AbstractPlugin: abc} - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { panic(err) } return p @@ -94,7 +95,7 @@ func TestRuleIncludeAllLabels(t *testing.T) { p.Params = params - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { t.Fatal(err) } @@ -156,7 +157,7 @@ func TestComplexRuleRegex(t *testing.T) { p.Params = params m := newArtificialData() - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { t.Fatal(err) } @@ -313,7 +314,7 @@ func TestRuleSimpleLatencyAggregation(t *testing.T) { p.Params = params - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { t.Fatal(err) } @@ -421,7 +422,7 @@ func TestRuleSimpleLatencyZeroAggregation(t *testing.T) { p.Params = params - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { t.Fatal(err) } diff --git a/cmd/poller/plugin/changelog/changelog.go b/cmd/poller/plugin/changelog/changelog.go index e209f8043..b59744a60 100644 --- a/cmd/poller/plugin/changelog/changelog.go +++ b/cmd/poller/plugin/changelog/changelog.go @@ -2,6 +2,7 @@ package changelog import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/set" "github.com/netapp/harvest/v2/pkg/tree/yaml" @@ -68,10 +69,10 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { } // Init initializes the ChangeLog plugin -func (c *ChangeLog) Init() error { +func (c *ChangeLog) Init(remote conf.Remote) error { // Initialize the abstract plugin - if err := c.AbstractPlugin.Init(); err != nil { + if err := c.AbstractPlugin.Init(remote); err != nil { return err } diff --git a/cmd/poller/plugin/changelog/changelog_test.go b/cmd/poller/plugin/changelog/changelog_test.go index 2f503d5b3..057b90492 100644 --- a/cmd/poller/plugin/changelog/changelog_test.go +++ b/cmd/poller/plugin/changelog/changelog_test.go @@ -3,6 +3,7 @@ package changelog import ( "github.com/netapp/harvest/v2/cmd/poller/options" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" "testing" @@ -31,7 +32,7 @@ func createChangeLog(params, parentParams *node.Node) *ChangeLog { } p.Object = "svm" - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { panic(err) } return p diff --git a/cmd/poller/plugin/labelagent/label_agent.go b/cmd/poller/plugin/labelagent/label_agent.go index da57ad061..49afa29f5 100644 --- a/cmd/poller/plugin/labelagent/label_agent.go +++ b/cmd/poller/plugin/labelagent/label_agent.go @@ -7,6 +7,7 @@ package labelagent import ( "fmt" "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" @@ -39,14 +40,14 @@ func New(p *plugin.AbstractPlugin) *LabelAgent { return &LabelAgent{AbstractPlugin: p} } -func (a *LabelAgent) Init() error { +func (a *LabelAgent) Init(remote conf.Remote) error { var ( err error count int ) - if err := a.AbstractPlugin.Init(); err != nil { + if err := a.AbstractPlugin.Init(remote); err != nil { return err } diff --git a/cmd/poller/plugin/labelagent/label_agent_test.go b/cmd/poller/plugin/labelagent/label_agent_test.go index 0f146d513..81ead6397 100644 --- a/cmd/poller/plugin/labelagent/label_agent_test.go +++ b/cmd/poller/plugin/labelagent/label_agent_test.go @@ -6,6 +6,7 @@ package labelagent import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" "testing" @@ -67,7 +68,7 @@ func newLabelAgent() *LabelAgent { abc := plugin.New("Test", nil, params, nil, "", nil) p := &LabelAgent{AbstractPlugin: abc} - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { panic(err) } return p @@ -93,7 +94,7 @@ func TestSplitRegexQtree(t *testing.T) { abc := plugin.New("Test", nil, params, nil, "", nil) p := &LabelAgent{AbstractPlugin: abc} - err := p.Init() + err := p.Init(conf.Remote{}) if err != nil { panic(err) } diff --git a/cmd/poller/plugin/max/max.go b/cmd/poller/plugin/max/max.go index d3a46948c..62ac94ec2 100644 --- a/cmd/poller/plugin/max/max.go +++ b/cmd/poller/plugin/max/max.go @@ -6,6 +6,7 @@ package max import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" @@ -36,9 +37,9 @@ type rule struct { counts map[string]map[string]int } -func (m *Max) Init() error { +func (m *Max) Init(remote conf.Remote) error { - if err := m.AbstractPlugin.Init(); err != nil { + if err := m.AbstractPlugin.Init(remote); err != nil { return err } diff --git a/cmd/poller/plugin/metricagent/metric_agent.go b/cmd/poller/plugin/metricagent/metric_agent.go index 30ce39b30..07f08eb26 100644 --- a/cmd/poller/plugin/metricagent/metric_agent.go +++ b/cmd/poller/plugin/metricagent/metric_agent.go @@ -6,6 +6,7 @@ package metricagent import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/slogx" @@ -25,14 +26,14 @@ func New(p *plugin.AbstractPlugin) *MetricAgent { return &MetricAgent{AbstractPlugin: p} } -func (a *MetricAgent) Init() error { +func (a *MetricAgent) Init(remote conf.Remote) error { var ( err error count int ) - if err := a.AbstractPlugin.Init(); err != nil { + if err := a.AbstractPlugin.Init(remote); err != nil { return err } diff --git a/cmd/poller/plugin/metricagent/metric_agent_test.go b/cmd/poller/plugin/metricagent/metric_agent_test.go index 8d6bd785a..532c8b39c 100644 --- a/cmd/poller/plugin/metricagent/metric_agent_test.go +++ b/cmd/poller/plugin/metricagent/metric_agent_test.go @@ -6,6 +6,7 @@ package metricagent import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" "testing" @@ -33,7 +34,7 @@ func newAgent() *MetricAgent { abc := plugin.New("Test", nil, params, nil, "", nil) p := &MetricAgent{AbstractPlugin: abc} - if err := p.Init(); err != nil { + if err := p.Init(conf.Remote{}); err != nil { panic(err) } return p diff --git a/cmd/poller/plugin/plugin.go b/cmd/poller/plugin/plugin.go index ea69207ae..a0d0924f4 100644 --- a/cmd/poller/plugin/plugin.go +++ b/cmd/poller/plugin/plugin.go @@ -29,6 +29,7 @@ import ( "fmt" "github.com/netapp/harvest/v2/cmd/poller/options" "github.com/netapp/harvest/v2/pkg/auth" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" @@ -44,7 +45,7 @@ const DefaultPollInterval = 3 * time.Minute // Plugin defines the methods of a plugin type Plugin interface { GetName() string - Init() error + Init(conf.Remote) error Run(map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) } @@ -130,7 +131,7 @@ func (p *AbstractPlugin) GetName() string { } // Init initializes the plugin by calling InitAbc -func (p *AbstractPlugin) Init() error { +func (p *AbstractPlugin) Init(conf.Remote) error { return p.InitAbc() } diff --git a/cmd/poller/plugin/test/plugin_test.go b/cmd/poller/plugin/test/plugin_test.go index c17998fcd..26e4a06ee 100644 --- a/cmd/poller/plugin/test/plugin_test.go +++ b/cmd/poller/plugin/test/plugin_test.go @@ -4,6 +4,7 @@ import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" "github.com/netapp/harvest/v2/cmd/poller/plugin/aggregator" "github.com/netapp/harvest/v2/cmd/poller/plugin/labelagent" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree" "github.com/netapp/harvest/v2/pkg/tree/node" @@ -12,6 +13,7 @@ import ( func TestMultipleRule(t *testing.T) { var Plugins []plugin.Plugin + remote := conf.Remote{} defaultTemplate, _ := tree.ImportYaml("testdata/sample.yaml") p := defaultTemplate.GetChildS("plugins") @@ -35,7 +37,7 @@ func TestMultipleRule(t *testing.T) { } abc := plugin.New("Test", nil, params, nil, "", nil) lb = &labelagent.LabelAgent{AbstractPlugin: abc} - if err := lb.Init(); err != nil { + if err := lb.Init(remote); err != nil { t.Fatal(err) } Plugins = append(Plugins, lb) @@ -49,7 +51,7 @@ func TestMultipleRule(t *testing.T) { abc := plugin.New("Test", nil, params, nil, "", nil) ag := &aggregator.Aggregator{AbstractPlugin: abc} - if err := ag.Init(); err != nil { + if err := ag.Init(remote); err != nil { t.Fatal(err) } Plugins = append(Plugins, ag) diff --git a/cmd/poller/poller.go b/cmd/poller/poller.go index 7bcdf8f82..7c7a65b6c 100644 --- a/cmd/poller/poller.go +++ b/cmd/poller/poller.go @@ -31,6 +31,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/netapp/harvest/v2/cmd/collectors" _ "github.com/netapp/harvest/v2/cmd/collectors/ems" _ "github.com/netapp/harvest/v2/cmd/collectors/keyperf" _ "github.com/netapp/harvest/v2/cmd/collectors/restperf" @@ -48,7 +49,6 @@ import ( "github.com/netapp/harvest/v2/cmd/poller/plugin" "github.com/netapp/harvest/v2/cmd/poller/schedule" "github.com/netapp/harvest/v2/cmd/tools/rest" - "github.com/netapp/harvest/v2/pkg/api/ontapi/zapi" "github.com/netapp/harvest/v2/pkg/auth" "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/errs" @@ -92,10 +92,6 @@ var ( opts *options.Options ) -const ( - NoUpgrade = "HARVEST_NO_COLLECTOR_UPGRADE" -) - // init with default configuration that logs to the console and harvest.log var logger = slog.Default() @@ -134,6 +130,7 @@ type Poller struct { hasPromExporter bool maxRssBytes uint64 startTime time.Time + remote conf.Remote } // Init starts Poller, reads parameters, opens zeroLog handler, initializes metadata, @@ -304,6 +301,8 @@ func (p *Poller) Init() error { return errs.New(errs.ErrNoCollector, "no collectors") } + p.negotiateONTAPAPI(filteredCollectors) + objectsToCollectors := make(map[string][]objectCollector) for _, c := range filteredCollectors { _, ok := util.IsCollector[c.Name] @@ -424,8 +423,8 @@ func uniquifyObjectCollectors(objectsToCollectors map[string][]objectCollector) specialCaseQtree(objectsToCollectors) - for _, collectors := range objectsToCollectors { - uniqueOCs = append(uniqueOCs, nonOverlappingCollectors(collectors)...) + for _, col := range objectsToCollectors { + uniqueOCs = append(uniqueOCs, nonOverlappingCollectors(col)...) } return uniqueOCs @@ -569,7 +568,6 @@ func (p *Poller) Run() { upe := 0 // up exporters // update status of collectors - var remote conf.Remote for _, c := range p.collectors { code, _, msg := c.GetStatus() @@ -588,13 +586,11 @@ func (p *Poller) Run() { instance.SetLabel("reason", strings.ReplaceAll(msg, "\"", "")) } } - - remote = c.GetRemote() } // add remote version and name to metadata - p.status.GetInstance("remote").SetLabel("version", remote.Version) - p.status.GetInstance("remote").SetLabel("name", remote.Name) + p.status.GetInstance("remote").SetLabel("version", p.remote.Version) + p.status.GetInstance("remote").SetLabel("name", p.remote.Name) // update status of exporters for _, ee := range p.exporters { @@ -640,10 +636,14 @@ func (p *Poller) Run() { if upc != upCollectors || upe != upExporters { logger.Info( "updated status", - slog.Int("upCollectors", upc), - slog.Int("collectorsTotal", len(p.collectors)), - slog.Int("upExporters", upe), - slog.Int("exportersTotal", len(p.exporters)), + slog.Group("collectors", + slog.Int("up", upc), + slog.Int("total", len(p.collectors)), + ), + slog.Group("exporters", + slog.Int("up", upe), + slog.Int("total", len(p.exporters)), + ), ) } upCollectors = upc @@ -711,7 +711,7 @@ func (p *Poller) readObjects(c conf.Collector) ([]objectCollector, error) { template, subTemplate *node.Node ) - c = p.upgradeCollector(c) + c = p.upgradeCollector(c, p.remote) class = c.Name // throw warning for deprecated collectors if r, d := deprecatedCollectors[strings.ToLower(class)]; d { @@ -803,7 +803,7 @@ type objectCollector struct { // dynamically load and initialize a collector func (p *Poller) loadCollectorObject(ocs []objectCollector) error { - var collectors []collector.Collector + var cols []collector.Collector logger.Debug("Starting collectors", slog.Int("collectors", len(ocs))) @@ -833,7 +833,7 @@ func (p *Poller) loadCollectorObject(ocs []objectCollector) error { logger.Debug("ignoring collector", slog.String("collector", oc.class), slog.String("object", oc.object)) continue } - collectors = append(collectors, col) + cols = append(cols, col) logger.Debug( "initialized collector-object", slog.String("collector", oc.class), @@ -842,9 +842,9 @@ func (p *Poller) loadCollectorObject(ocs []objectCollector) error { } } - p.collectors = append(p.collectors, collectors...) + p.collectors = append(p.collectors, cols...) // link each collector with requested exporter & update metadata - for _, col := range collectors { + for _, col := range cols { if col == nil { logger.Warn("ignoring nil collector") continue @@ -879,23 +879,24 @@ func (p *Poller) loadCollectorObject(ocs []objectCollector) error { return nil } -func nonOverlappingCollectors(collectors []objectCollector) []objectCollector { - if len(collectors) == 0 { +func nonOverlappingCollectors(objectCollectors []objectCollector) []objectCollector { + if len(objectCollectors) == 0 { return []objectCollector{} } - if len(collectors) == 1 { - return collectors + if len(objectCollectors) == 1 { + return objectCollectors } unique := make([]objectCollector, 0) - conflicts := map[string]string{ - "Zapi": "Rest", - "ZapiPerf": "RestPerf", - "Rest": "Zapi", - "RestPerf": "ZapiPerf", + conflicts := map[string][]string{ + "Zapi": {"Rest"}, + "ZapiPerf": {"RestPerf", "KeyPerf"}, + "Rest": {"Zapi"}, + "RestPerf": {"ZapiPerf", "KeyPerf"}, + "KeyPerf": {"ZapiPerf", "RestPerf"}, } - for _, c := range collectors { + for _, c := range objectCollectors { conflict, ok := conflicts[c.class] if ok { if collectorContains(unique, conflict, c.class) { @@ -907,12 +908,14 @@ func nonOverlappingCollectors(collectors []objectCollector) []objectCollector { return unique } -func collectorContains(unique []objectCollector, searches ...string) bool { +func collectorContains(unique []objectCollector, conflicts []string, search string) bool { for _, o := range unique { - for _, s := range searches { - if o.class == s { - return true - } + if o.class == search { + return true + } + has := slices.Contains(conflicts, o.class) + if has { + return true } } return false @@ -988,7 +991,7 @@ func (p *Poller) newCollector(class string, object string, template *node.Node) if !ok { return nil, errs.New(errs.ErrNoCollector, "no collectors") } - delegate := collector.New(class, object, p.options, template.Copy(), p.auth) + delegate := collector.New(class, object, p.options, template.Copy(), p.auth, p.remote) err = col.Init(delegate) return col, err } @@ -1328,67 +1331,53 @@ func (p *Poller) createClient() { // upgradeCollector checks if the collector c should be upgraded to a REST collector. // ZAPI collectors should be upgraded to REST collectors when the cluster no longer speaks Zapi -func (p *Poller) upgradeCollector(c conf.Collector) conf.Collector { +func (p *Poller) upgradeCollector(c conf.Collector, remote conf.Remote) conf.Collector { // If REST is desired, use REST // If ZAPI is desired, check that the cluster speaks ZAPI and if so, use ZAPI, otherwise use REST + // If KeyPerf is desired, negotiate the API // EMS and StorageGRID are ignored - if !strings.HasPrefix(c.Name, "Zapi") { + if _, ok := util.IsONTAPCollector[c.Name]; !ok { return c } - return p.negotiateAPI(c, p.doZAPIsExist) -} + isKeyPerf := remote.IsKeyPerf() + replaced := c.Name -// Harvest will upgrade ZAPI conversations to REST in two cases: -// - if ONTAP returns a ZAPI error with errno=61253 -// - if ONTAP returns an HTTP status code of 400 -func (p *Poller) negotiateAPI(c conf.Collector, checkZAPIs func() error) conf.Collector { - var switchToRest bool - err := checkZAPIs() + if strings.HasPrefix(replaced, "Zapi") { - if err != nil { - var he errs.HarvestError - if errors.As(err, &he) { - if he.ErrNum == errs.ErrNumZAPISuspended { - logger.Warn("ZAPIs suspended. Use REST", slog.String("collector", c.Name)) - switchToRest = true + if remote.ZAPIsExist { + switch replaced { + case "Zapi": + return c + case "ZapiPerf": + if isKeyPerf { + replaced = "RestPerf" + } else { + return c + } } + } - if he.StatusCode == http.StatusBadRequest { - logger.Warn("ZAPIs EOA. Use REST", slog.String("collector", c.Name)) - switchToRest = true - } + replaced = strings.ReplaceAll(replaced, "Zapi", "Rest") + if isKeyPerf { + replaced = strings.ReplaceAll(replaced, "RestPerf", "KeyPerf") } - if switchToRest { - upgradeCollector := strings.ReplaceAll(c.Name, "Zapi", "Rest") - return conf.Collector{ - Name: upgradeCollector, - Templates: c.Templates, - } + return conf.Collector{ + Name: replaced, + Templates: c.Templates, } - logger.Error("Failed to negotiateAPI", slogx.Err(err), slog.String("collector", c.Name)) } - return c -} - -func (p *Poller) doZAPIsExist() error { - var ( - poller *conf.Poller - connection *zapi.Client - err error - ) - - // connect to the cluster and retrieve the system version - if poller, err = conf.PollerNamed(opts.Poller); err != nil { - return err + if isKeyPerf { + replaced := strings.ReplaceAll(c.Name, "RestPerf", "KeyPerf") + return conf.Collector{ + Name: replaced, + Templates: c.Templates, + } } - if connection, err = zapi.New(poller, p.auth); err != nil { - return err - } - return connection.Init(2) + return c } // set the poller's confPath using the following precedence: @@ -1460,29 +1449,29 @@ func (p *Poller) sendHarvestVersion() error { if !p.targetIsOntap() { return nil } - // connect to the cluster and retrieve the system version - if poller, err = conf.PollerNamed(opts.Poller); err != nil { - return err - } - timeout, _ := time.ParseDuration(rest.DefaultTimeout) - if connection, err = rest.New(poller, timeout, p.auth); err != nil { - return err - } - err = connection.Init(2) - if err != nil { - return err + if !p.remote.HasREST { + return nil } - // Check if the cluster is running ONTAP 9.11.1 or later - // If it is, send a harvestTag to the cluster to indicate that Harvest is running + // If the cluster is running ONTAP 9.11.1 or later, + // send a harvestTag to the cluster to indicate that Harvest is running. // Otherwise, do nothing - ontapVersion, err := goversion.NewVersion(connection.Remote().Version) + ontapVersion, err := goversion.NewVersion(p.remote.Version) if err != nil { return err } if ontapVersion.LessThan(goversion.Must(goversion.NewVersion("9.11.1"))) { + return nil + } + + // connect to the cluster + if poller, err = conf.PollerNamed(opts.Poller); err != nil { + return err + } + timeout, _ := time.ParseDuration(rest.DefaultTimeout) + if connection, err = rest.New(poller, timeout, p.auth); err != nil { return err } @@ -1502,6 +1491,30 @@ func (p *Poller) sendHarvestVersion() error { return nil } +func (p *Poller) negotiateONTAPAPI(cols []conf.Collector) { + anyONTAP := false + for _, c := range cols { + if _, ok := util.IsONTAPCollector[c.Name]; ok { + anyONTAP = true + break + } + } + + if !anyONTAP { + return + } + + remote, err := collectors.GatherClusterInfo(opts.Poller, p.auth) + if err != nil { + logger.Error("Failed to gather cluster info", slogx.Err(err)) + return + } + + slog.Info("Cluster info", slog.Any("remote", remote)) + + p.remote = remote +} + func startPoller(_ *cobra.Command, _ []string) { poller := &Poller{} poller.options = opts diff --git a/cmd/poller/poller_test.go b/cmd/poller/poller_test.go index 7f3f9a4d0..813168186 100644 --- a/cmd/poller/poller_test.go +++ b/cmd/poller/poller_test.go @@ -1,12 +1,10 @@ package main import ( - "errors" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/tree/node" - "os" "strings" "testing" ) @@ -132,29 +130,35 @@ func TestCollectorUpgrade(t *testing.T) { poller := Poller{params: &conf.Poller{}} type test struct { - name string - clusterVersion string - askFor string - wantCollector string - setEnvVar bool - check func() error + name string + askFor string + wantCollector string + remote conf.Remote } - zapisExist := func() error { return nil } - zapisDoNotExist := func() error { return errors.New("boom") } + ontap911 := conf.Remote{Version: "9.11.1", ZAPIsExist: true} + ontap917 := conf.Remote{Version: "9.17.1", ZAPIsExist: false} + keyPerf := conf.Remote{Version: "9.17.1", ZAPIsExist: false, IsDisaggregated: true} + keyPerfWithZapi := conf.Remote{Version: "9.17.1", ZAPIsExist: true, IsDisaggregated: true} tests := []test{ - {name: "9.11 use ZAPI", clusterVersion: "9.11.1", askFor: "Zapi", wantCollector: "Zapi"}, - {name: "9.11 use REST", clusterVersion: "9.11.1", askFor: "Rest", wantCollector: "Rest"}, - {name: "9.12 upgrade", clusterVersion: "9.12.1", askFor: "Zapi", wantCollector: "Zapi"}, - {name: "9.12 w/ envar", clusterVersion: "9.12.1", askFor: "Zapi", wantCollector: "Zapi", setEnvVar: true}, - {name: "9.12 REST", clusterVersion: "9.12.3", askFor: "Rest", wantCollector: "Rest", setEnvVar: true}, - {name: "9.13 RestPerf", clusterVersion: "9.13.1", askFor: "ZapiPerf", wantCollector: "ZapiPerf"}, - {name: "9.13 REST w/ envar", clusterVersion: "9.13.1", askFor: "Rest", wantCollector: "Rest", setEnvVar: true}, - {name: "9.13 REST w/ envar", clusterVersion: "9.13.1", askFor: "Zapi", wantCollector: "Zapi", setEnvVar: true}, - {name: "9.13 REST w/ envar", clusterVersion: "9.13.1", askFor: "Rest", wantCollector: "Rest", setEnvVar: true, - check: zapisDoNotExist}, - {name: "9.13 REST", clusterVersion: "9.13.1", askFor: "Rest", wantCollector: "Rest"}, + {name: "9.11 w/ ZAPI", remote: ontap911, askFor: "Zapi", wantCollector: "Zapi"}, + {name: "9.11 w/ ZAPI", remote: ontap911, askFor: "ZapiPerf", wantCollector: "ZapiPerf"}, + {name: "9.11 w/ ZAPI", remote: ontap911, askFor: "Rest", wantCollector: "Rest"}, + {name: "9.11 w/ ZAPI", remote: ontap911, askFor: "KeyPerf", wantCollector: "KeyPerf"}, + + {name: "9.17 no ZAPI", remote: ontap917, askFor: "Zapi", wantCollector: "Rest"}, + {name: "9.17 no ZAPI", remote: ontap917, askFor: "ZapiPerf", wantCollector: "RestPerf"}, + {name: "9.17 no ZAPI", remote: ontap917, askFor: "KeyPerf", wantCollector: "KeyPerf"}, + + {name: "KeyPerf", remote: keyPerf, askFor: "Zapi", wantCollector: "Rest"}, + {name: "KeyPerf", remote: keyPerf, askFor: "Rest", wantCollector: "Rest"}, + {name: "KeyPerf", remote: keyPerf, askFor: "ZapiPerf", wantCollector: "KeyPerf"}, + {name: "KeyPerf", remote: keyPerf, askFor: "RestPerf", wantCollector: "KeyPerf"}, + + {name: "KeyPerf w/ ZAPI", remote: keyPerfWithZapi, askFor: "Zapi", wantCollector: "Zapi"}, + {name: "KeyPerf w/ ZAPI", remote: keyPerfWithZapi, askFor: "ZapiPerf", wantCollector: "KeyPerf"}, + {name: "KeyPerf w/ ZAPI", remote: keyPerfWithZapi, askFor: "RestPerf", wantCollector: "KeyPerf"}, } for _, tt := range tests { @@ -162,15 +166,8 @@ func TestCollectorUpgrade(t *testing.T) { collector := conf.Collector{ Name: tt.askFor, } - if tt.setEnvVar { - _ = os.Setenv(NoUpgrade, "1") - } else { - _ = os.Unsetenv(NoUpgrade) - } - if tt.check == nil { - tt.check = zapisExist - } - newCollector := poller.negotiateAPI(collector, tt.check) + + newCollector := poller.upgradeCollector(collector, tt.remote) if newCollector.Name != tt.wantCollector { t.Errorf("got = [%s] want [%s]", newCollector.Name, tt.wantCollector) } @@ -193,6 +190,9 @@ func Test_nonOverlappingCollectors(t *testing.T) { args: ocs("Zapi", "Rest", "Rest", "Rest", "Rest", "Rest", "Zapi", "Zapi", "Zapi", "Zapi", "Zapi"), want: ocs("Zapi")}, {name: "non ontap", args: ocs("Rest", "SG"), want: ocs("Rest", "SG")}, + {name: "no overlap", args: ocs("Rest", "KeyPerf"), want: ocs("Rest", "KeyPerf")}, + {name: "overlap", args: ocs("RestPerf", "KeyPerf"), want: ocs("RestPerf")}, + {name: "overlap", args: ocs("KeyPerf", "KeyPerf"), want: ocs("KeyPerf")}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -227,6 +227,12 @@ func Test_uniquifyObjectCollectors(t *testing.T) { want: []objectCollector{{class: "Rest", object: "Qtree"}, {class: "Rest", object: "Quota"}}}, {name: "qtree-zapi-disable-quota", args: objectCollectorMap("Qtree: Zapi, Rest", "Quota: Rest"), want: []objectCollector{{class: "Zapi", object: "Qtree"}}}, + {name: "volume-restperf", args: objectCollectorMap("Volume: RestPerf, KeyPerf"), + want: []objectCollector{{class: "RestPerf", object: "Volume"}}}, + {name: "volume-keyperf", args: objectCollectorMap("Volume: KeyPerf, RestPerf"), + want: []objectCollector{{class: "KeyPerf", object: "Volume"}}}, + {name: "multi-keyperf", args: objectCollectorMap("Volume: RestPerf", "Aggregate: KeyPerf"), + want: []objectCollector{{class: "RestPerf", object: "Volume"}, {class: "KeyPerf", object: "Aggregate"}}}, } for _, tt := range tests { diff --git a/cmd/tools/generate/generate.go b/cmd/tools/generate/generate.go index 128b32f96..daa9209b4 100644 --- a/cmd/tools/generate/generate.go +++ b/cmd/tools/generate/generate.go @@ -583,7 +583,7 @@ func BuildMetrics(dir, configPath, pollerName string) (map[string]Counter, conf. fmt.Printf("error creating new client %+v\n", err) os.Exit(1) } - if err = restClient.Init(2); err != nil { + if err = restClient.Init(2, conf.Remote{}); err != nil { fmt.Printf("error init rest client %+v\n", err) os.Exit(1) } diff --git a/cmd/tools/rest/client.go b/cmd/tools/rest/client.go index 678d4a9b7..e520640a1 100644 --- a/cmd/tools/rest/client.go +++ b/cmd/tools/rest/client.go @@ -344,18 +344,31 @@ func (c *Client) UpdateClusterInfo(retries int) error { } results := gjson.ParseBytes(content) + c.remote.Model = "cdot" c.remote.Name = results.Get("name").String() c.remote.UUID = results.Get("uuid").String() - c.remote.Version = - results.Get("version.generation").String() + "." + - results.Get("version.major").String() + "." + - results.Get("version.minor").String() + c.remote.Version = results.Get("version.generation").String() + "." + + results.Get("version.major").String() + "." + + results.Get("version.minor").String() + c.remote.Release = results.Get("version.full").String() + c.remote.IsSanOptimized = results.Get("san_optimized").Bool() + c.remote.IsDisaggregated = results.Get("disaggregated").Bool() + c.remote.IsClustered = true + c.remote.HasREST = true + return nil } + return err } -func (c *Client) Init(retries int) error { +func (c *Client) Init(retries int, remote conf.Remote) error { + c.remote = remote + + if !remote.IsZero() { + return nil + } + return c.UpdateClusterInfo(retries) } diff --git a/cmd/tools/rest/rest.go b/cmd/tools/rest/rest.go index 7b5d958c2..ff347ae06 100644 --- a/cmd/tools/rest/rest.go +++ b/cmd/tools/rest/rest.go @@ -173,7 +173,7 @@ func fetchData(poller *conf.Poller, timeout time.Duration) (*Results, error) { } // Init is called to get the cluster version - err = client.Init(1) + err = client.Init(1, conf.Remote{}) if err != nil { var re *errs.RestError if errors.As(err, &re) { diff --git a/cmd/tools/template/template.go b/cmd/tools/template/template.go index 93982ff5b..11ccd5f11 100644 --- a/cmd/tools/template/template.go +++ b/cmd/tools/template/template.go @@ -9,6 +9,7 @@ import ( "github.com/netapp/harvest/v2/cmd/poller/plugin/labelagent" max2 "github.com/netapp/harvest/v2/cmd/poller/plugin/max" "github.com/netapp/harvest/v2/cmd/poller/plugin/metricagent" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/tree" "github.com/netapp/harvest/v2/pkg/tree/node" @@ -291,7 +292,7 @@ func readMax(template *node.Node, model *Model) error { if len(children) != 0 { abc := plugin.AbstractPlugin{Params: children[0]} mm := max2.New(&abc) - err := mm.Init() + err := mm.Init(conf.Remote{}) if err != nil { return err } @@ -308,7 +309,7 @@ func readMetricAgent(template *node.Node, model *Model) error { } abc := plugin.AbstractPlugin{Params: children[0]} ma := metricagent.New(&abc) - err := ma.Init() + err := ma.Init(conf.Remote{}) if err != nil { return err } @@ -321,7 +322,7 @@ func readAggregator(template *node.Node, model *Model) error { if len(children) != 0 { abc := plugin.AbstractPlugin{Params: children[0]} agg := aggregator.New(&abc) - err := agg.Init() + err := agg.Init(conf.Remote{}) if err != nil { return err } @@ -339,7 +340,7 @@ func readLabelAgent(template *node.Node, model *Model) error { } abc := plugin.AbstractPlugin{Params: children[0]} la := labelagent.New(&abc) - err := la.Init() + err := la.Init(conf.Remote{}) if err != nil { return err } diff --git a/cmd/tools/zapi/zapi.go b/cmd/tools/zapi/zapi.go index 23aacd311..5363e68e4 100644 --- a/cmd/tools/zapi/zapi.go +++ b/cmd/tools/zapi/zapi.go @@ -143,7 +143,7 @@ func doCmd(cmd string) { log.Fatal(err) } - if err = connection.Init(2); err != nil { + if err = connection.Init(2, conf.Remote{}); err != nil { log.Fatal(err) } diff --git a/integration/test/counter_test.go b/integration/test/counter_test.go index 311f12955..b415ac323 100644 --- a/integration/test/counter_test.go +++ b/integration/test/counter_test.go @@ -70,7 +70,7 @@ func TestCounters(t *testing.T) { os.Exit(1) } - if err = client.Init(5); err != nil { + if err = client.Init(5, conf.Remote{}); err != nil { slog.Error("client init failed", slogx.Err(err)) os.Exit(1) } diff --git a/pkg/api/ontapi/zapi/client.go b/pkg/api/ontapi/zapi/client.go index e1876e897..c9cbcab33 100644 --- a/pkg/api/ontapi/zapi/client.go +++ b/pkg/api/ontapi/zapi/client.go @@ -32,13 +32,13 @@ type Client struct { client *http.Client request *http.Request buffer *bytes.Buffer - system *system apiVersion string vfiler string Logger *slog.Logger logZapi bool // used to log ZAPI request/response auth *auth.Credentials Metadata *util.Metadata + remote conf.Remote } type Response struct { @@ -144,8 +144,15 @@ func parseClientTimeout(clientTimeout string) (time.Duration, error) { // Init connects to the cluster and retrieves system info // it will give up after retries -func (c *Client) Init(retries int) error { +func (c *Client) Init(retries int, remote conf.Remote) error { var err error + + c.remote = remote + + if !remote.IsZero() { + return nil + } + for range retries { if err = c.getSystem(); err == nil { break @@ -156,32 +163,32 @@ func (c *Client) Init(retries int) error { // Name returns the name of the Cluster func (c *Client) Name() string { - return c.system.name + return c.remote.Name } // IsClustered returns true if ONTAP is clustered or false if it's a 7-mode system func (c *Client) IsClustered() bool { - return c.system.clustered + return c.remote.IsClustered } // Version returns version of the ONTAP server (generation, major and minor) -func (c *Client) Version() [3]int { - return c.system.version +func (c *Client) Version() string { + return c.remote.Version } // Release returns string with long release info of the ONTAP system func (c *Client) Release() string { - return c.system.release + return c.remote.Release } // Serial returns the serial number of the ONTAP system func (c *Client) Serial() string { - return c.system.serial + return c.remote.Serial } // ClusterUUID returns the cluster UUID of a c-mode system and system-id for 7-mode func (c *Client) ClusterUUID() string { - return c.system.clusterUUID + return c.remote.UUID } // Info returns a string with details about the ONTAP system identity @@ -192,7 +199,7 @@ func (c *Client) Info() string { } else { model = "7MODE" } - version = fmt.Sprintf("(%s version %d.%d.%d)", model, c.system.version[0], c.system.version[1], c.system.version[2]) + version = fmt.Sprintf("(%s version %s)", model, c.remote.Version) return fmt.Sprintf("%s %s (serial %s) (%s)", c.Name(), version, c.Serial(), c.Release()) } @@ -579,10 +586,14 @@ func (c *Client) SetTimeout(timeout string) { c.client.Timeout = newTimeout } +func (c *Client) Remote() conf.Remote { + return c.remote +} + // NewTestClient It's used for unit test only func NewTestClient() *Client { return &Client{ - system: &system{name: "testCluster", clustered: true}, + remote: conf.Remote{Name: "testCluster", IsClustered: true}, request: &http.Request{}, Metadata: &util.Metadata{}, } diff --git a/pkg/api/ontapi/zapi/system.go b/pkg/api/ontapi/zapi/system.go index aada83593..7ea0f59b0 100644 --- a/pkg/api/ontapi/zapi/system.go +++ b/pkg/api/ontapi/zapi/system.go @@ -4,112 +4,99 @@ package zapi import ( "errors" "fmt" + "github.com/netapp/harvest/v2/pkg/conf" "github.com/netapp/harvest/v2/pkg/tree/node" "regexp" "strconv" ) -type system struct { - name string - serial string - clusterUUID string - release string - version [3]int - clustered bool -} - // See system_test.go for examples -func (s *system) parse7mode(release string) error { +func parse7mode(release string) (int, int, int, error) { // NetApp Release 8.2P4 7-Mode: Tue Oct 1 11:24:04 PDT 2013 r := regexp.MustCompile(`NetApp Release (\d+)\.(\d+)\w(\d+)`) matches := r.FindStringSubmatch(release) if len(matches) == 4 { - setInt(&s.version[0], matches[1]) - setInt(&s.version[1], matches[2]) - setInt(&s.version[2], matches[3]) - return nil + return toInt(matches[1]), toInt(matches[2]), toInt(matches[3]), nil } r = regexp.MustCompile(`NetApp Release (\d+)\.(\d+)\.(\d+)`) matches = r.FindStringSubmatch(release) if len(matches) == 4 { - setInt(&s.version[0], matches[1]) - setInt(&s.version[1], matches[2]) - setInt(&s.version[2], matches[3]) - return nil + return toInt(matches[1]), toInt(matches[2]), toInt(matches[3]), nil } r = regexp.MustCompile(`NetApp Release (\d+)\.(\d+)\.(\d+)\.(\d+)`) matches = r.FindStringSubmatch(release) if len(matches) == 5 { // 7.0.0.1 becomes 7.0.0 - setInt(&s.version[0], matches[1]) - setInt(&s.version[1], matches[2]) - setInt(&s.version[2], matches[3]) - return nil + return toInt(matches[1]), toInt(matches[2]), toInt(matches[3]), nil } - return fmt.Errorf("no valid version tuple found for=[%s]", release) + return 0, 0, 0, fmt.Errorf("no valid version tuple found for=[%s]", release) } -func setInt(i *int, s string) { +func toInt(s string) int { value, err := strconv.Atoi(s) if err != nil { - return + return 0 } - *i = value + return value } // getSystem connects to ONTAP system and retrieves its identity and version // this works for Clustered and 7-mode systems func (c *Client) getSystem() error { var ( - s system - response *node.Node - err error + r conf.Remote + release string + isClustered bool + versionT [3]int + response *node.Node + err error ) - s = system{} + r = conf.Remote{} // fetch system version and model if response, err = c.InvokeRequestString("system-get-version"); err != nil { return err } - s.release = response.GetChildContentS("version") + release = response.GetChildContentS("version") if version := response.GetChildS("version-tuple"); version != nil { if tuple := version.GetChildS("system-version-tuple"); tuple != nil { for i, v := range []string{"generation", "major", "minor"} { if n, err := strconv.ParseInt(tuple.GetChildContentS(v), 0, 16); err == nil { - s.version[i] = int(n) + versionT[i] = int(n) } } } } - // if version tuple is missing try to parse from the release string + // if version tuple is missing, try to parse from the release string, // this is usually the case with 7mode systems - // e.g. NetApp Release 8.2P4 7-Mode: Tue Oct 1 11:24:04 PDT 2013 - if s.version[0] == 0 { - err := s.parse7mode(s.release) + // e.g., NetApp Release 8.2P4 7-Mode: Tue Oct 1 11:24:04 PDT 2013 + if versionT[0] == 0 { + i0, i1, i2, err := parse7mode(release) if err != nil { return err } + versionT[0] = i0 + versionT[1] = i1 + versionT[2] = i2 } - if clustered := response.GetChildContentS("is-clustered"); clustered == "" { + clustered := response.GetChildContentS("is-clustered") + if clustered == "" { return errors.New("missing attribute [is-clustered]") - } else if clustered == "true" { - s.clustered = true - } else { - s.clustered = false } + isClustered = clustered == "true" // fetch system name and serial number request := "cluster-identity-get" - if !s.clustered { + if !isClustered { request = "system-get-info" } @@ -117,21 +104,32 @@ func (c *Client) getSystem() error { return err } - if s.clustered { + if isClustered { if attrs := response.GetChildS("attributes"); attrs != nil { if info := attrs.GetChildS("cluster-identity-info"); info != nil { - s.name = info.GetChildContentS("cluster-name") - s.clusterUUID = info.GetChildContentS("cluster-uuid") + r.Name = info.GetChildContentS("cluster-name") + r.UUID = info.GetChildContentS("cluster-uuid") } } } else { if info := response.GetChildS("system-info"); info != nil { - s.name = info.GetChildContentS("system-name") - s.serial = info.GetChildContentS("system-serial-number") - // There is no uuid for non cluster mode, using system-id. - s.clusterUUID = info.GetChildContentS("system-id") + r.Name = info.GetChildContentS("system-name") + r.Serial = info.GetChildContentS("system-serial-number") + // There is no uuid for non-cluster mode, using system-id. + r.UUID = info.GetChildContentS("system-id") } } - c.system = &s + + r.Version = strconv.Itoa(versionT[0]) + "." + strconv.Itoa(versionT[1]) + "." + strconv.Itoa(versionT[2]) + if isClustered { + r.Model = "cdot" + } else { + r.Model = "7mode" + } + r.IsClustered = isClustered + r.ZAPIsExist = true + r.Release = release + c.remote = r + return nil } diff --git a/pkg/api/ontapi/zapi/system_test.go b/pkg/api/ontapi/zapi/system_test.go index 50d4d80c8..ba167b378 100644 --- a/pkg/api/ontapi/zapi/system_test.go +++ b/pkg/api/ontapi/zapi/system_test.go @@ -1,6 +1,7 @@ package zapi import ( + "fmt" "testing" ) @@ -8,22 +9,21 @@ func Test_7modeParsing(t *testing.T) { type test struct { name string release string - want system + want string wantErr bool } tests := []test{ - {name: "issue-376", release: "NetApp Release 8.2P4 7-Mode: Tue Oct 1 11:24:04 PDT 2013", want: system{version: [3]int{8, 2, 4}}}, - {name: "7.0.1", release: "NetApp Release 7.0.0.1: Wed Mar 2 22:20:44 PST 2005", want: system{version: [3]int{7, 0, 0}}}, - {name: "7.0.4", release: "NetApp Release 7.0.4: Sun Feb 5 00:52:53 PST 2006", want: system{version: [3]int{7, 0, 4}}}, - {name: "6.4.1", release: "NetApp Release 6.4R1: Thu Mar 13 23:56:30 PST 2003", want: system{version: [3]int{6, 4, 1}}}, - {name: "7.3.1", release: "NetApp Release 7.3.1: Thu Jan 8 01:31:42 PST 2009 ", want: system{version: [3]int{7, 3, 1}}}, + {name: "issue-376", release: "NetApp Release 8.2P4 7-Mode: Tue Oct 1 11:24:04 PDT 2013", want: "8.2.4"}, + {name: "7.0.1", release: "NetApp Release 7.0.0.1: Wed Mar 2 22:20:44 PST 2005", want: "7.0.0"}, + {name: "7.0.4", release: "NetApp Release 7.0.4: Sun Feb 5 00:52:53 PST 2006", want: "7.0.4"}, + {name: "6.4.1", release: "NetApp Release 6.4R1: Thu Mar 13 23:56:30 PST 2003", want: "6.4.1"}, + {name: "7.3.1", release: "NetApp Release 7.3.1: Thu Jan 8 01:31:42 PST 2009 ", want: "7.3.1"}, {name: "fail", release: "cromulent house", wantErr: true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - s := system{} - err := s.parse7mode(tt.release) + v0, v1, v2, err := parse7mode(tt.release) if err != nil { if tt.wantErr { return @@ -31,11 +31,9 @@ func Test_7modeParsing(t *testing.T) { t.Errorf("got error=%v, want %v", err, tt.want) } - if s.version[0] == 0 { - t.Errorf("got zero version=%v, want %v", s.version, tt.want.version) - } - if s.version[0] != tt.want.version[0] || s.version[1] != tt.want.version[1] || s.version[2] != tt.want.version[2] { - t.Errorf("got version=%v, want %v", s.version, tt.want.version) + got := fmt.Sprintf("%d.%d.%d", v0, v1, v2) + if got != tt.want { + t.Errorf("got version=%v, want %v", got, tt.want) } }) } diff --git a/pkg/conf/remotes.go b/pkg/conf/remotes.go index eac95f8a1..bc961631b 100644 --- a/pkg/conf/remotes.go +++ b/pkg/conf/remotes.go @@ -1,8 +1,23 @@ package conf type Remote struct { - Name string - Model string - UUID string - Version string + Name string + Model string + UUID string + Version string + Release string + Serial string + IsSanOptimized bool + IsDisaggregated bool + ZAPIsExist bool + HasREST bool + IsClustered bool +} + +func (r Remote) IsZero() bool { + return r.Name == "" && r.Model == "" && r.UUID == "" +} + +func (r Remote) IsKeyPerf() bool { + return r.IsDisaggregated && !r.IsSanOptimized } diff --git a/pkg/errs/errors.go b/pkg/errs/errors.go index b9b8f4c49..a38b600b5 100644 --- a/pkg/errs/errors.go +++ b/pkg/errs/errors.go @@ -26,7 +26,6 @@ const ( ErrNoCollector = harvestError("no collectors") ErrNoInstance = harvestError("no instances") ErrNoMetric = harvestError("no metrics") - ErrPanic = harvestError("goroutine panic") ErrPermissionDenied = harvestError("Permission denied") ErrResponseNotFound = harvestError("response not found") ErrWrongTemplate = harvestError("wrong template") From e7c47189649e4c6654c0b581ff75f52ce367f03e Mon Sep 17 00:00:00 2001 From: hardikl Date: Mon, 11 Nov 2024 15:13:16 +0530 Subject: [PATCH 5/6] fix: correct he mtu unit in network dashboard --- grafana/dashboards/cmode/network.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grafana/dashboards/cmode/network.json b/grafana/dashboards/cmode/network.json index e39d1c769..3df2b900e 100644 --- a/grafana/dashboards/cmode/network.json +++ b/grafana/dashboards/cmode/network.json @@ -610,7 +610,7 @@ "properties": [ { "id": "unit", - "value": "bps" + "value": "bytes" } ] }, From e19d978f4faa77f13791c5f55621317f9a5d9d75 Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Mon, 11 Nov 2024 08:22:20 -0500 Subject: [PATCH 6/6] feat: enable iface and recvcheck linters --- .golangci.yml | 2 ++ integration/go.mod | 6 +++--- integration/go.sum | 12 ++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 589b2245b..41fd4c815 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,6 +21,7 @@ linters: - gosec - gosimple - govet + - iface - ineffassign - intrange - makezero @@ -32,6 +33,7 @@ linters: - perfsprint - prealloc - reassign + - recvcheck - revive - sloglint - staticcheck diff --git a/integration/go.mod b/integration/go.mod index 17837796c..56bfbe59b 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -10,7 +10,7 @@ require ( github.com/carlmjohnson/requests v0.24.2 github.com/netapp/harvest/v2 v2.0.0-20241001142758-f137ab714dd8 github.com/tidwall/gjson v1.18.0 - golang.org/x/text v0.19.0 + golang.org/x/text v0.20.0 ) require ( @@ -35,8 +35,8 @@ require ( github.com/tklauser/numcpus v0.8.0 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect golang.org/x/net v0.29.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/term v0.26.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/integration/go.sum b/integration/go.sum index cc1104683..bf7d1f3f4 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -65,12 +65,12 @@ golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=