Fix linting issues

This commit is contained in:
WestleyR
2021-09-06 12:03:04 -07:00
parent 31e9929984
commit 4edc16953e
71 changed files with 470 additions and 363 deletions

23
.github/workflows/lint.yaml vendored Normal file
View File

@@ -0,0 +1,23 @@
on:
push:
branches:
- main
pull_request:
name: golangci-lint
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.31
skip-build-cache: true
skip-pkg-cache: true
args: --build-tags "containers_image_openpgp containers_image_ostree"

4
.gitignore vendored
View File

@@ -1,10 +1,12 @@
# project data
/.idea
/.tools
/vendor/
/vendor
# binaries
/warewulfd
/wwbuild
/wwclient
/wwctl
/bash_completion
/man_page

View File

@@ -15,14 +15,27 @@ import (
func main() {
if os.Args[0] == "/warewulf/bin/wwclient" {
os.Chdir("/")
err := os.Chdir("/")
if err != nil {
wwlog.Printf(wwlog.ERROR, "failed to change dir: %s", err)
os.Exit(1)
}
log.Printf("Updating live file system LIVE, cancel now if this is in error")
time.Sleep(5000 * time.Millisecond)
} else {
fmt.Printf("Called via: %s\n", os.Args[0])
fmt.Printf("Runtime overlay is being put in '/warewulf/wwclient-test' rather than '/'\n")
os.MkdirAll("/warewulf/wwclient-test", 0755)
os.Chdir("/warewulf/wwclient-test")
err := os.MkdirAll("/warewulf/wwclient-test", 0755)
if err != nil {
wwlog.Printf(wwlog.ERROR, "failed to create dir: %s", err)
os.Exit(1)
}
err = os.Chdir("/warewulf/wwclient-test")
if err != nil {
wwlog.Printf(wwlog.ERROR, "failed to change dir: %s", err)
os.Exit(1)
}
}
conf, err := warewulfconf.New()

View File

@@ -7,5 +7,6 @@ import (
func main() {
root := wwctl.GetRootCommand()
//nolint:errcheck
root.Execute()
}

2
go.mod
View File

@@ -9,7 +9,7 @@ require (
github.com/manifoldco/promptui v0.8.0
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6
github.com/opencontainers/umoci v0.4.6
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.1.1
gopkg.in/yaml.v2 v2.4.0
)

33
go.sum
View File

@@ -42,7 +42,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 h1:ygIc8M6trr62pF5DucadTWGdEB4mEyvzi0e2nbcmcyA=
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
@@ -51,7 +50,6 @@ github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JP
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
github.com/Microsoft/hcsshim v0.8.7-0.20190325164909-8abdbb8205e4/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ=
github.com/Microsoft/hcsshim v0.8.9 h1:VrfodqvztU8YSOvygU+DN1BGaSGxmrNfqOv5oOuX2Bk=
github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg38RRsjT5y8=
github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg=
github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00=
@@ -142,7 +140,6 @@ github.com/containerd/containerd v1.2.10/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtM
github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.3.1-0.20191213020239-082f7e3aed57/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.3.2 h1:ForxmXkA6tPIvffbrDAcPUIB32QgXkt2XFj+F0UxetA=
github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.0-beta.2.0.20200729163537-40b22ef07410/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
@@ -151,7 +148,6 @@ github.com/containerd/containerd v1.5.0-beta.1/go.mod h1:5HfvG1V2FsKesEGQ17k5/T7
github.com/containerd/containerd v1.5.0-beta.3/go.mod h1:/wr9AVtEM7x9c+n0+stptlo/uBBoBORwEx6ardVcmKU=
github.com/containerd/containerd v1.5.0-beta.4 h1:zjz4MOAOFgdBlwid2nNUlJ3YLpVi/97L36lfMYJex60=
github.com/containerd/containerd v1.5.0-beta.4/go.mod h1:GmdgZd2zA2GYIBZ0w09ZvgqEq8EfBp/m3lcVZIvPHhI=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc h1:TP+534wVlf61smEIq1nwLLAjQVEK2EADoW3CX9AuT+8=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
@@ -192,11 +188,9 @@ github.com/containers/image/v5 v5.7.0/go.mod h1:8aOy+YaItukxghRORkvhq5ibWttHErzD
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc=
github.com/containers/ocicrypt v1.0.3 h1:vYgl+RZ9Q3DPMuTfxmN+qp0X2Bj52uuY2vnt6GzVe1c=
github.com/containers/ocicrypt v1.0.3/go.mod h1:CUBa+8MRNL/VkpxYIpaMtgn1WgXGyvPQj8jcy0EVG6g=
github.com/containers/ocicrypt v1.1.0 h1:A6UzSUFMla92uxO43O6lm86i7evMGjTY7wTKB2DyGPY=
github.com/containers/ocicrypt v1.1.0/go.mod h1:b8AOe0YR67uU8OqfVNcznfFpAzu3rdgUV4GP9qXPfu4=
github.com/containers/storage v1.23.6 h1:3rcZ1KTNv8q7SkZ75gcrFGYqTeiuI04Zg7m9X1sCg/s=
github.com/containers/storage v1.23.6/go.mod h1:haFs0HRowKwyzvWEx9EgI3WsL8XCSnBDb5f8P5CAxJY=
github.com/containers/storage v1.30.0 h1:KS6zmoPyy0Qcx1HCCiseQ0ysSckRvtiuoVpIGh9iwQA=
github.com/containers/storage v1.30.0/go.mod h1:M/xn0pg6ReYFrLtWl5YELI/a4Xjq+Z3e5GJxQrJCcDI=
@@ -302,11 +296,9 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -330,7 +322,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
@@ -342,7 +333,6 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
@@ -430,7 +420,6 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.10.9/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.1 h1:bPb7nMRdOZYDrpPMTA3EInUQrdgoBinqUuSwlGdKDdE=
github.com/klauspost/compress v1.11.1/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.12.1 h1:/+xsCsk06wE38cyiqOR/o7U2fSftcH72xD+BQXmja/g=
@@ -477,7 +466,6 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/mattn/go-shellwords v1.0.11/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
@@ -549,7 +537,6 @@ github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5X
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v1.0.0-rc91 h1:Tp8LWs5G8rFpzTsbRjAtQkPVexhCu0bnANE5IfIhJ6g=
github.com/opencontainers/runc v1.0.0-rc91/go.mod h1:3Sm6Dt7OT8z88EbdQqqcRN2oCT54jbi72tT/HqgflT8=
github.com/opencontainers/runc v1.0.0-rc93 h1:x2UMpOOVf3kQ8arv/EsDGwim8PTNqzL1/EYDr/+scOM=
github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0=
@@ -557,7 +544,6 @@ github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.m
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.3-0.20200520003142-237cc4f519e2 h1:9mv9SC7GWmRWE0J/+oD8w3GsN2KYGKtg6uwLN7hfP5E=
github.com/opencontainers/runtime-spec v1.0.3-0.20200520003142-237cc4f519e2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d h1:pNa8metDkwZjb9g4T8s+krQ+HRgZAkqnXml+wNir/+s=
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
@@ -587,14 +573,12 @@ github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8=
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -602,7 +586,6 @@ github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7q
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo=
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
@@ -611,7 +594,6 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.0-20190522114515-bc1a522cf7b1/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE=
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
@@ -642,7 +624,6 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
@@ -679,7 +660,6 @@ github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRci
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -698,7 +678,6 @@ github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPf
github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
@@ -760,7 +739,6 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -826,7 +804,6 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM=
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
@@ -844,7 +821,6 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -903,7 +879,6 @@ golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -919,7 +894,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
@@ -927,7 +901,6 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e h1:EHBhcS0mlXEAVwNyO2dLfjToGsyY4j24pTs2ScHnX7s=
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -971,7 +944,6 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1012,7 +984,6 @@ google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a h1:pOwg4OoaRYScjmR4LlLgdtnyoHYTSAVhhqe5uPdpII8=
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
@@ -1026,7 +997,6 @@ google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
@@ -1040,7 +1010,6 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
@@ -1061,7 +1030,6 @@ gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4=
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w=
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
@@ -1072,7 +1040,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

View File

@@ -11,6 +11,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -78,9 +79,7 @@ func Configure(show bool) error {
os.Exit(1)
}
for _, node := range nodes {
d.Nodes = append(d.Nodes, node)
}
d.Nodes = append(d.Nodes, nodes...)
if controller.Dhcp.Template == "" {
templateFile = "/etc/warewulf/dhcp/default-dhcpd.conf"
@@ -119,8 +118,10 @@ func Configure(show bool) error {
}
fmt.Printf("Enabling and restarting the DHCP services\n")
util.SystemdStart(controller.Dhcp.SystemdName)
err = util.SystemdStart(controller.Dhcp.SystemdName)
if err != nil {
return errors.Wrap(err, "failed to start")
}
} else {
err = tmpl.Execute(os.Stdout, d)
if err != nil {

View File

@@ -7,6 +7,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -62,9 +63,15 @@ func Configure(show bool) error {
fmt.Printf("Enabling and restarting the NFS services\n")
if controller.Nfs.SystemdName == "" {
util.SystemdStart("nfs-server")
err := util.SystemdStart("nfs-server")
if err != nil {
return errors.Wrap(err, "failed to start nfs-server")
}
} else {
util.SystemdStart(controller.Nfs.SystemdName)
err := util.SystemdStart(controller.Nfs.SystemdName)
if err != nil {
return errors.Wrap(err, "failed to start")
}
}
} else {

View File

@@ -9,6 +9,7 @@ import (
"github.com/hpcng/warewulf/internal/app/wwctl/configure/nfs"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/ssh"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/tftp"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -39,31 +40,46 @@ func GetCommand() *cobra.Command {
}
func CobraRunE(cmd *cobra.Command, args []string) error {
if SetDoAll {
fmt.Printf("################################################################################\n")
fmt.Printf("Configuring: DHCP\n")
dhcp.Configure(false)
err := dhcp.Configure(false)
if err != nil {
return errors.Wrap(err, "failed to configure dhcp")
}
fmt.Printf("################################################################################\n")
fmt.Printf("Configuring: TFTP\n")
tftp.Configure(false)
err = tftp.Configure(false)
if err != nil {
return errors.Wrap(err, "failed to configure tftp")
}
fmt.Printf("################################################################################\n")
fmt.Printf("Configuring: /etc/hosts\n")
hosts.Configure(false)
err = hosts.Configure(false)
if err != nil {
return errors.Wrap(err, "failed to configure hosts")
}
fmt.Printf("################################################################################\n")
fmt.Printf("Configuring: NFS\n")
nfs.Configure(false)
err = nfs.Configure(false)
if err != nil {
return errors.Wrap(err, "failed to configure nfs")
}
fmt.Printf("################################################################################\n")
fmt.Printf("Configuring: SSH\n")
ssh.Configure(false)
err = ssh.Configure(false)
if err != nil {
return errors.Wrap(err, "failed to configure ssh")
}
} else {
//nolint:errcheck
cmd.Help()
os.Exit(0)
}
return nil
}

View File

@@ -7,6 +7,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -15,7 +16,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
func Configure(show bool) error {
if os.Getuid() == 0 {
fmt.Printf("Updating system keys\n")
@@ -27,28 +27,40 @@ func Configure(show bool) error {
if !util.IsFile("/etc/warewulf/keys/ssh_host_rsa_key") {
fmt.Printf("Setting up key: ssh_host_rsa_key\n")
util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", "/etc/warewulf/keys/ssh_host_rsa_key", "-C", "", "-N", "")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", "/etc/warewulf/keys/ssh_host_rsa_key", "-C", "", "-N", "")
if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command")
}
} else {
fmt.Printf("Skipping, key already exists: ssh_host_rsa_key\n")
}
if !util.IsFile("/etc/warewulf/keys/ssh_host_dsa_key") {
fmt.Printf("Setting up key: ssh_host_dsa_key\n")
util.ExecInteractive("ssh-keygen", "-q", "-t", "dsa", "-f", "/etc/warewulf/keys/ssh_host_dsa_key", "-C", "", "-N", "")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "dsa", "-f", "/etc/warewulf/keys/ssh_host_dsa_key", "-C", "", "-N", "")
if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command")
}
} else {
fmt.Printf("Skipping, key already exists: ssh_host_dsa_key\n")
}
if !util.IsFile("/etc/warewulf/keys/ssh_host_ecdsa_key") {
fmt.Printf("Setting up key: ssh_host_ecdsa_key\n")
util.ExecInteractive("ssh-keygen", "-q", "-t", "ecdsa", "-f", "/etc/warewulf/keys/ssh_host_ecdsa_key", "-C", "", "-N", "")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ecdsa", "-f", "/etc/warewulf/keys/ssh_host_ecdsa_key", "-C", "", "-N", "")
if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command")
}
} else {
fmt.Printf("Skipping, key already exists: ssh_host_ecdsa_key\n")
}
if !util.IsFile("/etc/warewulf/keys/ssh_host_ed25519_key") {
fmt.Printf("Setting up key: ssh_host_ed25519_key\n")
util.ExecInteractive("ssh-keygen", "-q", "-t", "ed25519", "-f", "/etc/warewulf/keys/ssh_host_ed25519_key", "-C", "", "-N", "")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ed25519", "-f", "/etc/warewulf/keys/ssh_host_ed25519_key", "-C", "", "-N", "")
if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command")
}
} else {
fmt.Printf("Skipping, key already exists: ssh_host_ed25519_key\n")
}
@@ -68,8 +80,14 @@ func Configure(show bool) error {
if !util.IsFile(authorizedKeys) {
fmt.Printf("Setting up: %s\n", authorizedKeys)
util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", rsaPriv, "-C", "", "-N", "")
util.CopyFile(rsaPub, authorizedKeys)
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", rsaPriv, "-C", "", "-N", "")
if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command")
}
err := util.CopyFile(rsaPub, authorizedKeys)
if err != nil {
return errors.Wrap(err, "failed to copy keys")
}
} else {
fmt.Printf("Skipping, authorized_keys already exists: %s\n", authorizedKeys)
}

View File

@@ -7,13 +7,14 @@ import (
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
var containers []string
if BuildAll == true {
if BuildAll {
containers, _ = container.ListSources()
} else {
containers = args
@@ -25,7 +26,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
for _, c := range containers {
if container.ValidSource(c) == false {
if !container.ValidSource(c) {
wwlog.Printf(wwlog.ERROR, "VNFS name does not exist: %s\n", c)
os.Exit(1)
}
@@ -34,12 +35,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", c, err)
os.Exit(1)
} else {
//fmt.Printf("%-20s: %s\n", c, output)
}
}
if SetDefault == true {
if SetDefault {
if len(containers) != 1 {
wwlog.Printf(wwlog.ERROR, "Can only set default for one container\n")
} else {
@@ -56,70 +55,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if profile.Id.Get() == "default" {
wwlog.Printf(wwlog.DEBUG, "Found profile default, setting container name to: %s\n", containers[0])
profile.ContainerName.Set(containers[0])
nodeDB.ProfileUpdate(profile)
err := nodeDB.ProfileUpdate(profile)
if err != nil {
return errors.Wrap(err, "failed to update node profile")
}
}
nodeDB.Persist()
}
err = nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
fmt.Printf("Set default profile to container: %s\n", containers[0])
}
}
/*
var nodes []node.NodeInfo
set := make(map[string]int)
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
os.Exit(1)
}
if len(args) == 1 && ByNode == true {
var err error
nodes, err = n.SearchByName(args[0])
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not find nodes for search term: %s\n", args[0])
os.Exit(1)
}
for _, node := range nodes {
if node.Vnfs.Defined() == true {
set[node.Vnfs.Get()]++
}
}
} else if BuildAll == true {
var err error
nodes, err = n.FindAllNodes()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not get list of nodes: %s\n", err)
os.Exit(1)
}
for _, node := range nodes {
if node.Vnfs.Defined() == true {
wwlog.Printf(wwlog.VERBOSE, "Adding VNFS to list: %s (%s)\n", node.Vnfs.Get(), node.Id.Get())
set[node.Vnfs.Get()]++
}
}
} else if len(args) == 1 {
set[args[0]]++
} else {
cmd.Usage()
os.Exit(1)
}
for v := range set {
fmt.Printf("Building VNFS: %s\n", v)
err := container.Build(v, BuildForce)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
*/
return nil
}

View File

@@ -29,7 +29,7 @@ ARG_LOOP:
}
}
if container.ValidSource(arg) == false {
if !container.ValidSource(arg) {
wwlog.Printf(wwlog.ERROR, "Container name is not a valid source: %s\n", arg)
continue
}

View File

@@ -12,11 +12,11 @@ import (
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
if os.Getpid() != 1 {
wwlog.Printf(wwlog.ERROR, "PID is not 1: %d\n", os.Getpid())
os.Exit(1)
@@ -24,15 +24,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
containerName := args[0]
if container.ValidSource(containerName) == false {
if !container.ValidSource(containerName) {
wwlog.Printf(wwlog.ERROR, "Unknown Warewulf container: %s\n", containerName)
os.Exit(1)
}
containerPath := container.RootFsDir(containerName)
syscall.Mount("", "/", "", syscall.MS_PRIVATE, "")
syscall.Mount("/dev", path.Join(containerPath, "/dev"), "", syscall.MS_BIND, "")
err := syscall.Mount("", "/", "", syscall.MS_PRIVATE, "")
if err != nil {
return errors.Wrap(err, "failed to mount")
}
err = syscall.Mount("/dev", path.Join(containerPath, "/dev"), "", syscall.MS_BIND, "")
if err != nil {
return errors.Wrap(err, "failed to mount /dev")
}
for _, b := range binds {
var source string
@@ -54,18 +61,31 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
syscall.Chroot(containerPath)
os.Chdir("/")
err = syscall.Chroot(containerPath)
if err != nil {
return errors.Wrap(err, "failed to chroot")
}
syscall.Mount("rootfs", "rootfs", "", syscall.MS_BIND, "")
syscall.Mount("/proc", "/proc", "proc", 0, "")
err = os.Chdir("/")
if err != nil {
return errors.Wrap(err, "failed to chdir")
}
err = syscall.Mount("rootfs", "rootfs", "", syscall.MS_BIND, "")
if err != nil {
return errors.Wrap(err, "failed to mount rootfs")
}
err = syscall.Mount("/proc", "/proc", "proc", 0, "")
if err != nil {
return errors.Wrap(err, "failed to mount proc")
}
ps1string := fmt.Sprintf("[%s] Warewulf> ", containerName)
os.Setenv("PS1", ps1string)
os.Setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin")
os.Setenv("HISTFILE", "/dev/null")
err := syscall.Exec(args[1], args[1:], os.Environ())
err = syscall.Exec(args[1], args[1:], os.Environ())
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)

View File

@@ -19,7 +19,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
containerName := args[0]
var allargs []string
if container.ValidSource(containerName) == false {
if !container.ValidSource(containerName) {
wwlog.Printf(wwlog.ERROR, "Unknown Warewulf container: %s\n", containerName)
os.Exit(1)
}
@@ -49,8 +49,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", containerName, err)
os.Exit(1)
} else {
//fmt.Printf("%s\n", output)
}
return nil

View File

@@ -13,6 +13,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -77,22 +78,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("Setting VNFS name: %s\n", name)
}
if container.ValidName(name) == false {
if !container.ValidName(name) {
wwlog.Printf(wwlog.ERROR, "VNFS name contains illegal characters: %s\n", name)
os.Exit(1)
}
fullPath := container.SourceDir(name)
if util.IsDir(fullPath) == true {
if SetForce == true {
if util.IsDir(fullPath) {
if SetForce {
fmt.Printf("Overwriting existing VNFS\n")
err := os.RemoveAll(fullPath)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} else if SetUpdate == true {
} else if SetUpdate {
fmt.Printf("Updating existing VNFS\n")
} else {
wwlog.Printf(wwlog.ERROR, "VNFS Name exists, specify --force, --update, or choose a different name: %s\n", name)
@@ -132,11 +133,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", name, err)
os.Exit(1)
} else {
//fmt.Printf("%s: %s\n", name, output)
}
if SetDefault == true {
if SetDefault {
nodeDB, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
@@ -150,13 +149,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if profile.Id.Get() == "default" {
wwlog.Printf(wwlog.DEBUG, "Found profile default, setting container name to: %s\n", name)
profile.ContainerName.Set(name)
nodeDB.ProfileUpdate(profile)
err := nodeDB.ProfileUpdate(profile)
if err != nil {
return errors.Wrap(err, "failed to update profile")
}
}
nodeDB.Persist()
fmt.Printf("Set default profile to container: %s\n", name)
warewulfd.DaemonReload()
}
err = nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
fmt.Printf("Set default profile to container: %s\n", name)
err = warewulfd.DaemonReload()
if err != nil {
return errors.Wrap(err, "failed to reload warewulf daemon")
}
}
return nil

View File

@@ -18,7 +18,6 @@ var (
"transform containers into bootable Warewulf VNFS images.",
Aliases: []string{"vnfs"},
}
test bool
)
func init() {

View File

@@ -8,11 +8,11 @@ import (
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
for _, arg := range args {
output, err := kernel.Build(arg, OptRoot)
if err != nil {
@@ -23,7 +23,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetDefault == true {
if SetDefault {
if len(args) != 1 {
wwlog.Printf(wwlog.ERROR, "Can only set default for one kernel version\n")
} else {
@@ -40,13 +40,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if profile.Id.Get() == "default" {
wwlog.Printf(wwlog.DEBUG, "Found profile default, setting kernel version to: %s\n", args[0])
profile.KernelVersion.Set(args[0])
nodeDB.ProfileUpdate(profile)
err := nodeDB.ProfileUpdate(profile)
if err != nil {
return errors.Wrap(err, "failed to update node profile")
}
}
nodeDB.Persist()
}
err = nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
fmt.Printf("Set default kernel version to: %s\n", args[0])
warewulfd.DaemonReload()
err = warewulfd.DaemonReload()
if err != nil {
return errors.Wrap(err, "failed to reload warewulf daemon")
}
}
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -133,7 +134,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetDiscoverable == true {
if SetDiscoverable {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to discoverable\n", n.Id.Get())
n.Discoverable.SetB(true)
@@ -146,7 +147,5 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
nodeDB.Persist()
return nil
return errors.Wrap(nodeDB.Persist(), "failed to persist nodedb")
}

View File

@@ -28,6 +28,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}

View File

@@ -7,6 +7,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -56,7 +57,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if SetYes {
nodeDB.Persist()
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
} else {
q := fmt.Sprintf("Are you sure you want to delete %d nodes(s)", count)
@@ -68,7 +72,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
result, _ := prompt.Run()
if result == "y" || result == "yes" {
nodeDB.Persist()
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
}
}

View File

@@ -40,7 +40,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if node.ContainerName.Get() != "" {
vnfsImage := container.ImageFile(node.ContainerName.Get())
if util.IsFile(vnfsImage) == true {
if util.IsFile(vnfsImage) {
vnfs_good = true
} else {
status = false
@@ -52,13 +52,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if node.KernelVersion.Get() != "" {
if util.IsFile(kernel.KernelImage(node.KernelVersion.Get())) == true {
if util.IsFile(kernel.KernelImage(node.KernelVersion.Get())) {
kernel_good = true
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not found: %s, %s\n", node.Id.Get(), node.KernelVersion.Get())
}
if util.IsFile(kernel.KmodsImage(node.KernelVersion.Get())) == true {
if util.IsFile(kernel.KmodsImage(node.KernelVersion.Get())) {
kmods_good = true
} else {
status = false
@@ -70,7 +70,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if node.SystemOverlay.Get() != "" {
if util.IsFile(config.SystemOverlayImage(node.Id.Get())) == true {
if util.IsFile(config.SystemOverlayImage(node.Id.Get())) {
systemo_good = true
} else {
status = false
@@ -82,7 +82,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if node.RuntimeOverlay.Get() != "" {
if util.IsFile(config.RuntimeOverlayImage(node.Id.Get())) == true {
if util.IsFile(config.RuntimeOverlayImage(node.Id.Get())) {
runtimeo_good = true
} else {
status = false

View File

@@ -29,6 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -43,7 +44,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
results := make(chan power.IPMI, jobcount)
for _, node := range nodes {
if node.IpmiIpaddr.Get() == "" {
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.Id.Get())
continue
@@ -70,8 +70,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
batchpool.Submit(func() {
if fullFlag {
//nolint:errcheck
ipmiCmd.SensorList()
} else {
//nolint:errcheck
ipmiCmd.SDRList()
}
results <- ipmiCmd
@@ -84,7 +86,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
close(results)
for result := range results {
out, err := result.Result()
if err != nil {
@@ -94,7 +95,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
fmt.Printf("%s:\n%s\n", result.NodeName, out)
}
return returnErr

View File

@@ -11,6 +11,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -34,6 +35,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -45,17 +47,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if SetContainer != "" {
if container.ValidSource(SetContainer) == true {
if container.ValidSource(SetContainer) {
imageFile := container.ImageFile(SetContainer)
if util.IsFile(imageFile) == false {
if !util.IsFile(imageFile) {
wwlog.Printf(wwlog.ERROR, "Container has not been built: %s\n", SetContainer)
if SetForce == false {
if !SetForce {
os.Exit(1)
}
}
} else {
wwlog.Printf(wwlog.ERROR, "Container does not exist: %s\n", SetContainer)
if SetForce == false {
if !SetForce {
os.Exit(1)
}
}
@@ -185,12 +187,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
n.IpmiInterface.Set(SetIpmiInterface)
}
if SetDiscoverable == true {
if SetDiscoverable {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to discoverable\n", n.Id.Get())
n.Discoverable.SetB(true)
}
if SetUndiscoverable == true {
if SetUndiscoverable {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to undiscoverable\n", n.Id.Get())
n.Discoverable.SetB(false)
}
@@ -214,7 +216,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetNetDevDel == true {
if SetNetDevDel {
if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
os.Exit(1)
@@ -301,7 +303,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
n.NetDevs[SetNetDev].Type.Set(SetType)
}
if SetNetDevDefault == true {
if SetNetDevDefault {
if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
os.Exit(1)
@@ -334,7 +336,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
n.Keys[SetKey].Set(SetValue)
}
if SetKeyDel == true {
if SetKeyDel {
if SetKey == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--key/-k' option\n")
os.Exit(1)
@@ -356,9 +358,16 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetYes == true {
nodeDB.Persist()
warewulfd.DaemonReload()
if SetYes {
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
err = warewulfd.DaemonReload()
if err != nil {
return errors.Wrap(err, "failed to reload warewulf daemon")
}
} else {
q := fmt.Sprintf("Are you sure you want to modify %d nodes(s)", len(nodes))
@@ -370,8 +379,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
result, _ := prompt.Run()
if result == "y" || result == "yes" {
nodeDB.Persist()
warewulfd.DaemonReload()
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
err = warewulfd.DaemonReload()
if err != nil {
return errors.Wrap(err, "failed to reload warewulf daemon")
}
}
}

View File

@@ -18,7 +18,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if len(args) > 0 && BuildAll == false {
if len(args) > 0 && !BuildAll {
nodes, err := n.FindAllNodes()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not get node list: %s\n", err)
@@ -26,7 +26,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
if SystemOverlay && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
@@ -42,7 +42,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
wwlog.Printf(wwlog.DEBUG, "Checking on system overlay update\n")
if SystemOverlay == true || BuildAll == true {
if SystemOverlay || BuildAll {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
err := overlay.BuildSystemOverlay(updateNodes)
if err != nil {
@@ -51,7 +51,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
wwlog.Printf(wwlog.DEBUG, "Checking on system overlay update\n")
if SystemOverlay == false || BuildAll == true {
if !SystemOverlay || BuildAll {
wwlog.Printf(wwlog.INFO, "Updating Runtime Overlays...\n")
err := overlay.BuildRuntimeOverlay(updateNodes)
if err != nil {

View File

@@ -24,20 +24,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if SystemOverlay == true {
if SystemOverlay {
overlaySourceDir = config.SystemOverlaySource(overlayName)
} else {
overlaySourceDir = config.RuntimeOverlaySource(overlayName)
}
if util.IsDir(overlaySourceDir) == false {
if !util.IsDir(overlaySourceDir) {
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", overlayName)
os.Exit(1)
}
overlayFile := path.Join(overlaySourceDir, fileName)
if util.IsFile(overlayFile) == false {
if !util.IsFile(overlayFile) {
wwlog.Printf(wwlog.ERROR, "File does not exist within overlay: %s:%s\n", overlayName, fileName)
os.Exit(1)
}
@@ -48,7 +48,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if NoOverlayUpdate == false {
if !NoOverlayUpdate {
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
@@ -64,14 +64,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.Get() == overlayName {
if SystemOverlay && node.SystemOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
}
}
if SystemOverlay == true {
if SystemOverlay {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
return overlay.BuildSystemOverlay(updateNodes)
} else {

View File

@@ -11,11 +11,12 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
//nolint:errcheck
cmd.Help()
os.Exit(1)
}
if SystemOverlay == true {
if SystemOverlay {
err := overlay.SystemOverlayInit(args[0])
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -31,7 +32,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.INFO, "Created new runtime overlay: %s\n", args[0])
}
if NoOverlayUpdate == false {
if !NoOverlayUpdate {
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
@@ -47,14 +48,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
if SystemOverlay && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
if SystemOverlay == true {
if SystemOverlay {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
return overlay.BuildSystemOverlay(updateNodes)
} else {

View File

@@ -16,7 +16,7 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
var overlayPath string
if SystemOverlay == true {
if SystemOverlay {
overlayPath = config.SystemOverlaySource(args[0])
} else {
overlayPath = config.RuntimeOverlaySource(args[0])
@@ -27,13 +27,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if util.IsDir(overlayPath) == false {
if !util.IsDir(overlayPath) {
wwlog.Printf(wwlog.ERROR, "Overlay name does not exist: '%s'\n", args[0])
os.Exit(1)
}
if len(args) == 1 {
if Force == true {
if Force {
err := os.RemoveAll(overlayPath)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Failed deleting overlay: %s\n", args[0])
@@ -54,12 +54,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for i := 1; i < len(args); i++ {
removePath := path.Join(overlayPath, args[i])
if util.IsDir(removePath) == false && util.IsFile(removePath) == false {
if !util.IsDir(removePath) && !util.IsFile(removePath) {
wwlog.Printf(wwlog.ERROR, "Path to remove doesn't exist in overlay: %s\n", removePath)
os.Exit(1)
}
if Force == true {
if Force {
err := os.RemoveAll(removePath)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Failed deleting file from overlay: %s:%s\n", args[0], args[i])
@@ -75,7 +75,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if Parents == true {
if Parents {
// Cleanup any empty directories left behind...
i := path.Dir(removePath)
for i != overlayPath {
@@ -94,7 +94,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if NoOverlayUpdate == false {
if !NoOverlayUpdate {
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
@@ -110,14 +110,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
if SystemOverlay && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
if SystemOverlay == true {
if SystemOverlay {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
return overlay.BuildSystemOverlay(updateNodes)
} else {

View File

@@ -22,13 +22,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
editor = "vi"
}
if SystemOverlay == true {
if SystemOverlay {
overlaySourceDir = config.SystemOverlaySource(args[0])
} else {
overlaySourceDir = config.RuntimeOverlaySource(args[0])
}
if util.IsDir(overlaySourceDir) == false {
if !util.IsDir(overlaySourceDir) {
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", args[0])
os.Exit(1)
}
@@ -37,21 +37,21 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.DEBUG, "Will edit overlay file: %s\n", overlayFile)
if CreateDirs == true {
if CreateDirs {
err := os.MkdirAll(path.Dir(overlayFile), 0755)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not create directory: %s\n", path.Dir(overlayFile))
os.Exit(1)
}
} else {
if util.IsDir(path.Dir(overlayFile)) == false {
if !util.IsDir(path.Dir(overlayFile)) {
wwlog.Printf(wwlog.ERROR, "Can not create file, parent directory does not exist, try adding the\n")
wwlog.Printf(wwlog.ERROR, "'--parents' option to create the directory.\n")
os.Exit(1)
}
}
if util.IsFile(overlayFile) == false && filepath.Ext(overlayFile) == ".ww" {
if !util.IsFile(overlayFile) && filepath.Ext(overlayFile) == ".ww" {
wwlog.Printf(wwlog.WARN, "This is a new file, creating some default content\n")
w, err := os.OpenFile(overlayFile, os.O_RDWR|os.O_CREATE, os.FileMode(PermMode))
@@ -95,7 +95,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
NoOverlayUpdate = true
}
if NoOverlayUpdate == false {
if !NoOverlayUpdate {
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
@@ -111,14 +111,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
if SystemOverlay && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
if SystemOverlay == true {
if SystemOverlay {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
return overlay.BuildSystemOverlay(updateNodes)
} else {

View File

@@ -24,7 +24,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
dest = source
}
if SystemOverlay == true {
if SystemOverlay {
wwlog.Printf(wwlog.VERBOSE, "Importing '%s' into system overlay '%s:%s'\n", source, overlayName, dest)
overlaySource = config.SystemOverlaySource(overlayName)
} else {
@@ -32,7 +32,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlaySource = config.RuntimeOverlaySource(overlayName)
}
if util.IsDir(overlaySource) == false {
if !util.IsDir(overlaySource) {
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", overlayName)
os.Exit(1)
}
@@ -44,7 +44,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if NoOverlayUpdate == false {
if !NoOverlayUpdate {
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
@@ -60,14 +60,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.Get() == overlayName {
if SystemOverlay && node.SystemOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
}
}
if SystemOverlay == true {
if SystemOverlay {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
return overlay.BuildSystemOverlay(updateNodes)
} else {

View File

@@ -25,15 +25,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if SystemOverlay == true {
if ListLong == false {
if SystemOverlay {
if !ListLong {
fmt.Printf("%-30s %-12s %-12s\n", "SYSTEM OVERLAY NAME", "NODES", "FILES/DIRS")
} else {
fmt.Printf("%-10s %5s %-5s %-18s %s\n", "PERM MODE", "UID", "GID", "SYSTEM-OVERLAY", "FILE PATH")
}
o, err = overlay.FindSystemOverlays()
} else {
if ListLong == false {
if !ListLong {
fmt.Printf("%-30s %-12s %-12s\n", "RUNTIME OVERLAY NAME", "NODES", "FILES/DIRS")
} else {
fmt.Printf("%-10s %5s %-5s %-18s %s\n", "PERM MODE", "UID", "GID", "RUNTIME-OVERLAY", "FILE PATH")
@@ -52,7 +52,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
for _, node := range nodeList {
if SystemOverlay == true {
if SystemOverlay {
if node.SystemOverlay.Get() != "" {
set[node.SystemOverlay.Get()]++
}
@@ -73,17 +73,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SystemOverlay == true {
if SystemOverlay {
path = config.SystemOverlaySource(o[overlay])
} else {
path = config.RuntimeOverlaySource(o[overlay])
}
if util.IsDir(path) == true {
if util.IsDir(path) {
files := util.FindFiles(path)
wwlog.Printf(wwlog.DEBUG, "Iterating overlay path: %s\n", path)
if ListContents == true {
if ListContents {
var fileCount int
for file := range files {
fmt.Printf("%-30s %-12d /%-12s\n", name, set[name], files[file])
@@ -92,7 +92,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if fileCount == 0 {
fmt.Printf("%-30s %-12d %-12d\n", name, set[name], 0)
}
} else if ListLong == true {
} else if ListLong {
for file := range files {
s, err := os.Stat(files[file])
if err != nil {
@@ -120,19 +120,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for overlay := range set {
var overlayPath string
if SystemOverlay == true {
if SystemOverlay {
overlayPath = config.SystemOverlaySource(overlay)
} else {
overlayPath = config.SystemOverlaySource(overlay)
}
if util.IsDir(overlayPath) == false {
if !util.IsDir(overlayPath) {
fmt.Printf("%-30s %-12d 0\n", "("+overlay+")", set[overlay])
unconfigured = true
}
}
if unconfigured == true {
if unconfigured {
fmt.Printf("\n")
wwlog.Printf(wwlog.WARN, "There are unconfigured overlays present, run the following command to\n")
wwlog.Printf(wwlog.WARN, "create a new overlay:\n")

View File

@@ -15,15 +15,14 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
var overlaySourceDir string
// mode := uint32(strconv.ParseUint(PermMode, 8, 32))
if SystemOverlay == true {
if SystemOverlay {
overlaySourceDir = config.SystemOverlaySource(args[0])
} else {
overlaySourceDir = config.RuntimeOverlaySource(args[0])
}
if util.IsDir(overlaySourceDir) == false {
if !util.IsDir(overlaySourceDir) {
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", args[0])
os.Exit(1)
}
@@ -40,7 +39,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("Created directory within overlay: %s:%s\n", args[0], args[1])
if NoOverlayUpdate == false {
if !NoOverlayUpdate {
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
@@ -56,14 +55,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
if SystemOverlay && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
if SystemOverlay == true {
if SystemOverlay {
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
return overlay.BuildSystemOverlay(updateNodes)
} else {

View File

@@ -19,7 +19,6 @@ var (
Short: "Warewulf Overlay Management",
Long: "Management interface for Warewulf overlays",
}
test bool
)
func init() {

View File

@@ -17,20 +17,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlayName := args[0]
fileName := args[1]
if SystemOverlay == true {
if SystemOverlay {
overlaySourceDir = config.SystemOverlaySource(overlayName)
} else {
overlaySourceDir = config.RuntimeOverlaySource(overlayName)
}
if util.IsDir(overlaySourceDir) == false {
if !util.IsDir(overlaySourceDir) {
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", overlayName)
os.Exit(1)
}
overlayFile := path.Join(overlaySourceDir, fileName)
if util.IsFile(overlayFile) == false {
if !util.IsFile(overlayFile) {
wwlog.Printf(wwlog.ERROR, "File does not exist within overlay: %s:%s\n", overlayName, fileName)
os.Exit(1)
}

View File

@@ -29,6 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -67,6 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
batchpool.Submit(func() {
//nolint:errcheck
ipmiCmd.PowerCycle()
results <- ipmiCmd
})

View File

@@ -29,6 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -67,6 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
batchpool.Submit(func() {
//nolint:errcheck
ipmiCmd.PowerOff()
results <- ipmiCmd
})

View File

@@ -29,6 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -67,6 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
batchpool.Submit(func() {
//nolint:errcheck
ipmiCmd.PowerOn()
results <- ipmiCmd
})

View File

@@ -29,6 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -67,6 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
batchpool.Submit(func() {
//nolint:errcheck
ipmiCmd.PowerReset()
results <- ipmiCmd
})

View File

@@ -16,7 +16,6 @@ var (
Short: "Warewulf node power management",
Long: "This command can control the power state of nodes.",
}
test bool
)
func init() {

View File

@@ -29,6 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -67,6 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
batchpool.Submit(func() {
//nolint:errcheck
ipmiCmd.PowerSoft()
results <- ipmiCmd
})

View File

@@ -29,6 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -67,6 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
batchpool.Submit(func() {
//nolint:errcheck
ipmiCmd.PowerStatus()
results <- ipmiCmd
})

View File

@@ -5,6 +5,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -23,7 +24,5 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
nodeDB.Persist()
return nil
return errors.Wrap(nodeDB.Persist(), "failed to persist nodedb")
}

View File

@@ -8,6 +8,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -39,7 +40,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if np == r {
wwlog.Printf(wwlog.VERBOSE, "Removing profile from node %s: %s\n", n.Id.Get(), r)
n.Profiles = util.SliceRemoveElement(n.Profiles, r)
nodeDB.NodeUpdate(n)
err := nodeDB.NodeUpdate(n)
if err != nil {
return errors.Wrap(err, "failed to update node")
}
}
}
}
@@ -71,7 +75,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if SetYes {
nodeDB.Persist()
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
} else {
q := fmt.Sprintf("Are you sure you want to delete %d profile(s)", count)
@@ -83,7 +90,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
result, _ := prompt.Run()
if result == "y" || result == "yes" {
nodeDB.Persist()
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
}
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -32,6 +33,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
profiles = node.FilterByName(profiles, args)
} else {
//nolint:errcheck
cmd.Usage()
os.Exit(1)
}
@@ -43,17 +45,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if SetContainer != "" {
if container.ValidSource(SetContainer) == true {
if container.ValidSource(SetContainer) {
imageFile := container.ImageFile(SetContainer)
if util.IsFile(imageFile) == false {
if !util.IsFile(imageFile) {
wwlog.Printf(wwlog.ERROR, "Container has not been built: %s\n", SetContainer)
if SetForce == false {
if !SetForce {
os.Exit(1)
}
}
} else {
wwlog.Printf(wwlog.ERROR, "Container name does not exist: %s\n", SetContainer)
if SetForce == false {
if !SetForce {
os.Exit(1)
}
}
@@ -63,81 +65,81 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.VERBOSE, "Modifying profile: %s\n", p.Id.Get())
if SetComment != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting comment to: %s\n", p.Id, SetComment)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting comment to: %s\n", p.Id, SetComment)
p.Comment.Set(SetComment)
}
if SetClusterName != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting cluster name to: %s\n", p.Id, SetClusterName)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting cluster name to: %s\n", p.Id, SetClusterName)
p.ClusterName.Set(SetClusterName)
}
if SetContainer != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Container name to: %s\n", p.Id, SetContainer)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting Container name to: %s\n", p.Id, SetContainer)
p.ContainerName.Set(SetContainer)
}
if SetInit != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting init command to: %s\n", p.Id, SetInit)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting init command to: %s\n", p.Id, SetInit)
p.Init.Set(SetInit)
}
if SetRoot != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting root to: %s\n", p.Id, SetRoot)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting root to: %s\n", p.Id, SetRoot)
p.Root.Set(SetRoot)
}
if SetKernel != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel to: %s\n", p.Id, SetKernel)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting Kernel to: %s\n", p.Id, SetKernel)
p.KernelVersion.Set(SetKernel)
}
if SetKernelArgs != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel args to: %s\n", p.Id, SetKernelArgs)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting Kernel args to: %s\n", p.Id, SetKernelArgs)
p.KernelArgs.Set(SetKernelArgs)
}
if SetIpxe != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting iPXE template to: %s\n", p.Id, SetIpxe)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting iPXE template to: %s\n", p.Id, SetIpxe)
p.Ipxe.Set(SetIpxe)
}
if SetRuntimeOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting runtime overlay to: %s\n", p.Id, SetRuntimeOverlay)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting runtime overlay to: %s\n", p.Id, SetRuntimeOverlay)
p.RuntimeOverlay.Set(SetRuntimeOverlay)
}
if SetSystemOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting system overlay to: %s\n", p.Id, SetSystemOverlay)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting system overlay to: %s\n", p.Id, SetSystemOverlay)
p.SystemOverlay.Set(SetSystemOverlay)
}
if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiNetmask)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting IPMI username to: %s\n", p.Id, SetIpmiNetmask)
p.IpmiNetmask.Set(SetIpmiNetmask)
}
if SetIpmiGateway != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiGateway)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting IPMI username to: %s\n", p.Id, SetIpmiGateway)
p.IpmiGateway.Set(SetIpmiGateway)
}
if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiUsername)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting IPMI username to: %s\n", p.Id, SetIpmiUsername)
p.IpmiUserName.Set(SetIpmiUsername)
}
if SetIpmiPassword != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiPassword)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting IPMI username to: %s\n", p.Id, SetIpmiPassword)
p.IpmiPassword.Set(SetIpmiPassword)
}
if SetIpmiInterface != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiInterface)
wwlog.Printf(wwlog.VERBOSE, "Profile: %v, Setting IPMI username to: %s\n", p.Id, SetIpmiInterface)
p.IpmiInterface.Set(SetIpmiInterface)
}
if SetNetDevDel == true {
if SetNetDevDel {
if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
os.Exit(1)
@@ -227,7 +229,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
p.NetDevs[SetNetDev].Type.Set(SetType)
}
if SetNetDevDefault == true {
if SetNetDevDefault {
if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
os.Exit(1)
@@ -260,7 +262,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
p.Keys[SetKey].Set(SetValue)
}
if SetKeyDel == true {
if SetKeyDel {
if SetKey == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--key/-k' option\n")
os.Exit(1)
@@ -283,9 +285,16 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if len(profiles) > 0 {
if SetYes == true {
nodeDB.Persist()
warewulfd.DaemonReload()
if SetYes {
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
err = warewulfd.DaemonReload()
if err != nil {
return errors.Wrap(err, "failed to reload warewulf daemon")
}
} else {
q := fmt.Sprintf("Are you sure you want to modify %d profile(s)", len(profiles))
@@ -297,8 +306,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
result, _ := prompt.Run()
if result == "y" || result == "yes" {
nodeDB.Persist()
warewulfd.DaemonReload()
err := nodeDB.Persist()
if err != nil {
return errors.Wrap(err, "failed to persist nodedb")
}
err = warewulfd.DaemonReload()
if err != nil {
return errors.Wrap(err, "failed to reload daemon")
}
}
}
} else {

View File

@@ -48,9 +48,9 @@ func GetRootCommand() *cobra.Command {
}
func rootPersistentPreRunE(cmd *cobra.Command, args []string) error {
if debugArg == true {
if debugArg {
wwlog.SetLevel(wwlog.DEBUG)
} else if verboseArg == true {
} else if verboseArg {
wwlog.SetLevel(wwlog.VERBOSE)
} else {
wwlog.SetLevel(wwlog.INFO)

View File

@@ -2,10 +2,10 @@ package restart
import (
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
warewulfd.DaemonStop()
return warewulfd.DaemonStart()
return errors.Wrap(warewulfd.DaemonStop(), "failed to stop warewulf daemon")
}

View File

@@ -15,7 +15,6 @@ var (
Short: "Warewulf server process commands",
Long: "This command will allow you to control the Warewulf daemon process.",
}
test bool
)
func init() {

View File

@@ -6,8 +6,7 @@ import (
)
func CobraRunE(cmd *cobra.Command, args []string) error {
if SetForeground == true {
if SetForeground {
return warewulfd.RunServer()
} else {
return warewulfd.DaemonStart()

View File

@@ -2,10 +2,10 @@ package status
import (
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
warewulfd.DaemonStatus()
return nil
return errors.Wrap(warewulfd.DaemonStatus(), "failed to start daemon")
}

View File

@@ -2,10 +2,10 @@ package stop
import (
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
warewulfd.DaemonStop()
return nil
return errors.Wrap(warewulfd.DaemonStop(), "failed to stop warewulf daemon")
}

View File

@@ -30,7 +30,7 @@ func SystemOverlaySource(overlayName string) string {
return ""
}
if util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") == false {
if !util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") {
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", overlayName)
return ""
}
@@ -44,7 +44,7 @@ func RuntimeOverlaySource(overlayName string) string {
return ""
}
if util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") == false {
if !util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") {
wwlog.Printf(wwlog.ERROR, "Runtime overlay name contains illegal characters: %s\n", overlayName)
return ""
}
@@ -58,7 +58,7 @@ func SystemOverlayImage(nodeName string) string {
return ""
}
if util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") == false {
if !util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") {
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", nodeName)
return ""
}
@@ -72,7 +72,7 @@ func RuntimeOverlayImage(nodeName string) string {
return ""
}
if util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") == false {
if !util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") {
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", nodeName)
return ""
}

View File

@@ -17,11 +17,11 @@ func Build(name string, buildForce bool) error {
rootfsPath := RootFsDir(name)
imagePath := ImageFile(name)
if ValidSource(name) == false {
if !ValidSource(name) {
return errors.New("Container does not exist")
}
if buildForce == false {
if !buildForce {
wwlog.Printf(wwlog.DEBUG, "Checking if there have been any updates to the VNFS directory\n")
if util.PathIsNewer(rootfsPath, imagePath) {
wwlog.Printf(wwlog.INFO, "Skipping (VNFS is current)\n")

View File

@@ -22,7 +22,7 @@ func ImportDocker(uri string, name string, sCtx *types.SystemContext) error {
return err
}
if ValidName(name) == false {
if !ValidName(name) {
return errors.New("VNFS name contains illegal characters: " + name)
}

View File

@@ -13,7 +13,7 @@ import (
)
func ValidName(name string) bool {
if util.ValidString(name, "^[\\w\\-\\.\\:]+$") == false {
if !util.ValidString(name, "^[\\w\\-\\.\\:]+$") {
wwlog.Printf(wwlog.WARN, "VNFS name has illegal characters: %s\n", name)
return false
}
@@ -57,11 +57,11 @@ func ListSources() ([]string, error) {
for _, source := range sources {
wwlog.Printf(wwlog.VERBOSE, "Found VNFS source: %s\n", source.Name())
if ValidName(source.Name()) == false {
if !ValidName(source.Name()) {
continue
}
if ValidSource(source.Name()) == false {
if !ValidSource(source.Name()) {
continue
}
@@ -74,11 +74,11 @@ func ListSources() ([]string, error) {
func ValidSource(name string) bool {
fullPath := RootFsDir(name)
if ValidName(name) == false {
if !ValidName(name) {
return false
}
if util.IsDir(fullPath) == false {
if !util.IsDir(fullPath) {
wwlog.Printf(wwlog.VERBOSE, "Location is not a VNFS source directory: %s\n", name)
return false
}

View File

@@ -72,15 +72,21 @@ func ListKernels() ([]string, error) {
}
func Build(kernelVersion string, root string) (string, error) {
kernelImage := path.Join(root, "/boot/vmlinuz-"+kernelVersion)
kernelDrivers := path.Join(root, "/lib/modules/"+kernelVersion)
kernelDestination := KernelImage(kernelVersion)
driversDestination := KmodsImage(kernelVersion)
// Create the destination paths just in case it doesn't exist
os.MkdirAll(path.Dir(kernelDestination), 0755)
os.MkdirAll(path.Dir(driversDestination), 0755)
err := os.MkdirAll(path.Dir(kernelDestination), 0755)
if err != nil {
return "", fmt.Errorf("failed to create kernal dest: %s", err)
}
err = os.MkdirAll(path.Dir(driversDestination), 0755)
if err != nil {
return "", fmt.Errorf("failed to create driver dest: %s", err)
}
if !util.IsFile(kernelImage) {
return "", errors.New("Could not locate kernel image")

View File

@@ -61,7 +61,7 @@ func (ent *Entry) SetAlt(val string, from string) {
}
func (ent *Entry) SetAltB(val bool, from string) {
if val == true {
if val {
ent.altbool = val
ent.from = from
}

View File

@@ -68,6 +68,7 @@ func NewPuller(opts ...pullerOpt) (*puller, error) {
// stripScheme prepares the docker uri for external library parsing and returns an error
// if it detects a malformed schema
//nolint:deadcode,unused
func stripScheme(uri string) (string, error) {
if !strings.HasPrefix(uri, "docker://") {
return "", fmt.Errorf("unsupported uri schema: %q", uri)

View File

@@ -26,7 +26,7 @@ func templateContainerFileInclude(containername string, filepath string) string
return ""
}
if container.ValidSource(containername) == false {
if !container.ValidSource(containername) {
wwlog.Printf(wwlog.WARN, "Template required VNFS does not exist: %s\n", containername)
return ""
}

View File

@@ -13,12 +13,11 @@ import (
"strings"
"text/template"
"github.com/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
)
type TemplateStruct struct {
@@ -86,7 +85,7 @@ func findAllOverlays(overlayType string) ([]string, error) {
for _, file := range files {
wwlog.Printf(wwlog.DEBUG, "Evaluating overlay source: %s\n", file.Name())
if file.IsDir() == true {
if file.IsDir() {
ret = append(ret, file.Name())
}
}
@@ -108,7 +107,7 @@ func overlayInit(name string, overlayType string) error {
os.Exit(1)
}
if util.IsDir(path) == true {
if util.IsDir(path) {
return errors.New("Overlay already exists: " + name)
}
@@ -180,15 +179,15 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
}
t.AllNodes = allNodes
if overlayType == "runtime" && n.RuntimeOverlay.Defined() == false {
if overlayType == "runtime" && !n.RuntimeOverlay.Defined() {
wwlog.Printf(wwlog.WARN, "Undefined runtime overlay, skipping node: %s\n", n.Id.Get())
}
if overlayType == "system" && n.SystemOverlay.Defined() == false {
if overlayType == "system" && !n.SystemOverlay.Defined() {
wwlog.Printf(wwlog.WARN, "Undefined system overlay, skipping node: %s\n", n.Id.Get())
}
wwlog.Printf(wwlog.DEBUG, "Checking to see if overlay directory exists: %s\n", OverlayDir)
if util.IsDir(OverlayDir) == false {
if !util.IsDir(OverlayDir) {
wwlog.Printf(wwlog.WARN, "%-35s: Skipped (runtime overlay template not found)\n", n.Id.Get())
continue
}
@@ -269,7 +268,7 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
return err
}
} else if b, _ := regexp.MatchString(`\.ww[a-zA-Z0-9\-\._]*$`, location); b == true {
} else if b, _ := regexp.MatchString(`\.ww[a-zA-Z0-9\-\._]*$`, location); b {
wwlog.Printf(wwlog.DEBUG, "Ignoring WW template file: %s\n", location)
} else {
wwlog.Printf(wwlog.DEBUG, "Found file: %s\n", location)
@@ -279,11 +278,13 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
return err
}
}
return nil
})
if err != nil {
return errors.Wrap(err, "failed to open dir")
}
if err != nil {
wwlog.Printf(wwlog.ERROR, "Error with filepath walk: %s\n", err)

View File

@@ -98,6 +98,7 @@ func getResource(path string) ([]byte, error) {
//
// Return the available resources in a slice.
//
//nolint:unused,deadcode
func getResources() []EmbeddedResource {
i := 0
ret := make([]EmbeddedResource, len(RESOURCES))

View File

@@ -4,14 +4,21 @@ import (
"io/ioutil"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
)
func WriteData(source string, dest string) error {
bytes, err := getResource(source)
if err != nil {
return errors.Wrap(err, "failed to get resource")
}
err = ioutil.WriteFile(dest, bytes, 0644)
if err != nil {
// TODO: remove log message if appropriate
wwlog.Printf(wwlog.ERROR, "Failed writing %s to: %s\n", dest, err)
return err
return errors.Wrap(err, "failed to write to file")
}
return nil
}

View File

@@ -15,6 +15,7 @@ import (
"time"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
)
func DirModTime(path string) (time.Time, error) {
@@ -73,7 +74,10 @@ func CopyFile(source string, dest string) error {
return err
}
finfo, _ := sourceFD.Stat()
finfo, err := sourceFD.Stat()
if err != nil {
return errors.Wrap(err, "failed to stat source")
}
destFD, err := os.OpenFile(dest, os.O_RDWR|os.O_CREATE, finfo.Mode())
if err != nil {
@@ -85,9 +89,9 @@ func CopyFile(source string, dest string) error {
return err
}
CopyUIDGID(source, dest)
err = CopyUIDGID(source, dest)
if err != nil {
return err
return errors.Wrap(err, "failed to copy")
}
sourceFD.Close()
@@ -293,8 +297,14 @@ func SystemdStart(systemdName string) error {
enableCmd := fmt.Sprintf("systemctl enable %s", systemdName)
wwlog.Printf(wwlog.DEBUG, "Setting up Systemd service: %s\n", systemdName)
ExecInteractive("/bin/sh", "-c", startCmd)
ExecInteractive("/bin/sh", "-c", enableCmd)
err := ExecInteractive("/bin/sh", "-c", startCmd)
if err != nil {
return errors.Wrap(err, "failed to run start cmd")
}
err = ExecInteractive("/bin/sh", "-c", enableCmd)
if err != nil {
return errors.Wrap(err, "failed to run enable cmd")
}
return nil
}
@@ -312,7 +322,6 @@ func CopyUIDGID(source string, dest string) error {
UID = int(stat.Uid)
GID = int(stat.Gid)
}
wwlog.Printf(wwlog.DEBUG, "Chown %d:%d '%s'\n", UID, GID, dest)
err = os.Chown(dest, UID, GID)
return err

View File

@@ -48,7 +48,7 @@ type NfsConf struct {
func init() {
//TODO: Check to make sure nodes.conf is found
if util.IsFile(ConfigFile) == false {
if !util.IsFile(ConfigFile) {
wwlog.Printf(wwlog.ERROR, "Configuration file not found: %s\n", ConfigFile)
// fail silently as this also called by bash_completion
return

View File

@@ -8,7 +8,6 @@ import (
)
func ContainerSend(w http.ResponseWriter, req *http.Request) {
node, err := getSanity(req)
if err != nil {
w.WriteHeader(404)
@@ -16,7 +15,7 @@ func ContainerSend(w http.ResponseWriter, req *http.Request) {
return
}
if node.ContainerName.Defined() == true {
if node.ContainerName.Defined() {
containerImage := container.ImageFile(node.ContainerName.Get())
err = sendFile(w, containerImage, node.Id.Get())
@@ -30,6 +29,4 @@ func ContainerSend(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(503)
log.Printf("ERROR: No Container set for node %s\n", node.Id.Get())
}
return
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
)
const (
@@ -18,10 +19,11 @@ const (
)
func DaemonStart() error {
if os.Getenv("WAREWULFD_BACKGROUND") == "1" {
RunServer()
err := RunServer()
if err != nil {
return errors.Wrap(err, "failed to run server")
}
} else {
os.Setenv("WAREWULFD_BACKGROUND", "1")
@@ -38,7 +40,10 @@ func DaemonStart() error {
cmd := exec.Command(os.Args[0], "server", "start")
cmd.Stdout = f
cmd.Stderr = f
cmd.Start()
err = cmd.Start()
if err != nil {
return errors.Wrap(err, "failed to start command")
}
pid := cmd.Process.Pid
fmt.Fprintf(p, "%d", pid)
@@ -51,8 +56,7 @@ func DaemonStart() error {
}
func DaemonStatus() error {
if util.IsFile(WAREWULFD_PIDFILE) == false {
if !util.IsFile(WAREWULFD_PIDFILE) {
wwlog.Printf(wwlog.INFO, "Warewulf daemon process not running (%s)\n", WAREWULFD_PIDFILE)
return nil
}
@@ -81,7 +85,7 @@ func DaemonStatus() error {
}
func DaemonReload() error {
if util.IsFile(WAREWULFD_PIDFILE) == false {
if !util.IsFile(WAREWULFD_PIDFILE) {
wwlog.Printf(wwlog.INFO, "Warewulf daemon process not running (%s)\n", WAREWULFD_PIDFILE)
return nil
}
@@ -109,8 +113,7 @@ func DaemonReload() error {
}
func DaemonStop() error {
if util.IsFile(WAREWULFD_PIDFILE) == false {
if !util.IsFile(WAREWULFD_PIDFILE) {
wwlog.Printf(wwlog.INFO, "Warewulf daemon process not running (%s)\n", WAREWULFD_PIDFILE)
return nil
}

View File

@@ -102,7 +102,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
}
}
if unconfiguredNode == true {
if unconfiguredNode {
log.Printf("UNCONFIGURED NODE: %15s\n", hwaddr)
tmpl, err := template.ParseFiles("/etc/warewulf/ipxe/unconfigured.ipxe")
@@ -155,5 +155,4 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
log.Printf("SEND: %15s: %s\n", nodeobj.Id.Get(), ipxeTemplate)
}
return
}

View File

@@ -8,7 +8,6 @@ import (
)
func KernelSend(w http.ResponseWriter, req *http.Request) {
node, err := getSanity(req)
if err != nil {
w.WriteHeader(404)
@@ -16,7 +15,7 @@ func KernelSend(w http.ResponseWriter, req *http.Request) {
return
}
if node.KernelVersion.Defined() == true {
if node.KernelVersion.Defined() {
fileName := kernel.KernelImage(node.KernelVersion.Get())
err := sendFile(w, fileName, node.Id.Get())
@@ -30,6 +29,4 @@ func KernelSend(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(503)
log.Printf("ERROR: No 'kernel version' set for node %s\n", node.Id.Get())
}
return
}

View File

@@ -16,7 +16,7 @@ func KmodsSend(w http.ResponseWriter, req *http.Request) {
return
}
if node.KernelVersion.Defined() == true {
if node.KernelVersion.Defined() {
fileName := kernel.KmodsImage(node.KernelVersion.Get())
err := sendFile(w, fileName, node.Id.Get())
@@ -30,6 +30,4 @@ func KmodsSend(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(503)
log.Printf("ERROR: No 'kernel version' set for node %s\n", node.Id.Get())
}
return
}

View File

@@ -19,9 +19,7 @@ var (
)
func LoadNodeDB() error {
var TmpMap map[string]node.NodeInfo
TmpMap = make(map[string]node.NodeInfo)
TmpMap := make(map[string]node.NodeInfo)
wwlog.Printf(wwlog.INFO, "Loading the node Database\n")

View File

@@ -40,7 +40,7 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
return
}
if conf.Warewulf.Secure == true {
if conf.Warewulf.Secure {
if port >= 1024 {
log.Panicf("DENIED: Connection coming from non-privledged port: %s\n", req.RemoteAddr)
w.WriteHeader(401)
@@ -55,7 +55,7 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
return
}
if node.Id.Defined() == false {
if node.Id.Defined() {
log.Printf("UNKNOWN: %15s: %s\n", remote[0], req.URL.Path)
w.WriteHeader(404)
return
@@ -63,7 +63,7 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
log.Printf("REQ: %15s: %s\n", node.Id.Get(), req.URL.Path)
}
if node.RuntimeOverlay.Defined() == true {
if node.RuntimeOverlay.Defined() {
fileName := config.RuntimeOverlayImage(node.Id.Get())
err := sendFile(w, fileName, node.Id.Get())
@@ -76,6 +76,4 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(503)
log.Printf("ERROR: No 'runtime system-overlay' set for node %s\n", node.Id.Get())
}
return
}

View File

@@ -15,7 +15,7 @@ func SystemOverlaySend(w http.ResponseWriter, req *http.Request) {
return
}
if node.SystemOverlay.Defined() == true {
if node.SystemOverlay.Defined() {
fileName := config.SystemOverlayImage(node.Id.Get())
err := sendFile(w, fileName, node.Id.Get())
@@ -28,6 +28,4 @@ func SystemOverlaySend(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(503)
log.Printf("ERROR: No 'system system-overlay' set for node %s\n", node.Id.Get())
}
return
}

View File

@@ -8,9 +8,8 @@ import (
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/pkg/errors"
)
func getSanity(req *http.Request) (node.NodeInfo, error) {
@@ -30,14 +29,17 @@ func getSanity(req *http.Request) (node.NodeInfo, error) {
}
func sendFile(w http.ResponseWriter, filename string, sendto string) error {
fd, err := os.Open(filename)
if err != nil {
return err
}
defer fd.Close()
FileHeader := make([]byte, 512)
fd.Read(FileHeader)
_, err = fd.Read(FileHeader)
if err != nil {
return errors.Wrap(err, "failed to read header")
}
FileContentType := http.DetectContentType(FileHeader)
FileStat, _ := fd.Stat()
FileSize := strconv.FormatInt(FileStat.Size(), 10)
@@ -46,9 +48,15 @@ func sendFile(w http.ResponseWriter, filename string, sendto string) error {
w.Header().Set("Content-Type", FileContentType)
w.Header().Set("Content-Length", FileSize)
fd.Seek(0, 0)
io.Copy(w, fd)
_, err = fd.Seek(0, 0)
if err != nil {
return errors.Wrap(err, "failed to seek")
}
_, err = io.Copy(w, fd)
if err != nil {
return errors.Wrap(err, "failed to copy")
}
fd.Close()
return nil
}