-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
882 changed files
with
339 additions
and
433,236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.git | ||
.github | ||
deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Test | ||
on: [pull_request] | ||
jobs: | ||
test_container: | ||
name: Build a container test image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v2 | ||
- name: Docker | ||
run: docker build . --file Dockerfile --tag talos-vmtoolsd:test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/talos-vmtoolsd | ||
/.idea | ||
TODO.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
vmtoolsd "github.com/mologie/talos-vmtoolsd" | ||
"github.com/mologie/talos-vmtoolsd/internal/nanotoolbox" | ||
"github.com/mologie/talos-vmtoolsd/internal/talosapi" | ||
|
@@ -20,6 +22,11 @@ func main() { | |
DisableHTMLEscape: true, | ||
}) | ||
|
||
// Debug flags | ||
talosTestQuery := "" | ||
flag.StringVar(&talosTestQuery, "test-apid-query", "", "query apid") | ||
flag.Parse() | ||
|
||
// Apply log level, default to "info" | ||
if levelStr, ok := os.LookupEnv("LOG_LEVEL"); ok { | ||
if level, err := logrus.ParseLevel(levelStr); err != nil { | ||
|
@@ -32,7 +39,7 @@ func main() { | |
} | ||
|
||
l.Infof("talos-vmtoolsd version %v\n"+ | ||
"Copyright 2020-2021 Oliver Kuckertz <[email protected]>\n"+ | ||
"Copyright 2020-2022 Oliver Kuckertz <[email protected]>\n"+ | ||
"This program is free software and available under the Apache 2.0 license.", | ||
vmtoolsd.Version) | ||
|
||
|
@@ -55,10 +62,7 @@ func main() { | |
l.Fatal("error: TALOS_HOST is required to point to a node's internal IP") | ||
} | ||
|
||
// Wires up VMware Toolbox commands to Talos apid. | ||
vmguestmsg.DefaultLogger = l.WithField("module", "vmware-guestinfo") | ||
rpcIn, rpcOut := nanotoolbox.NewHypervisorChannelPair() | ||
svc := nanotoolbox.NewService(l, rpcIn, rpcOut) | ||
// Connect to Talos apid | ||
api, err := talosapi.NewLocalClient(l, configPath, k8sHost) | ||
if err != nil { | ||
l.WithError(err).Fatal("could not connect to apid") | ||
|
@@ -68,6 +72,21 @@ func main() { | |
l.WithError(err).Warn("failed to close API client during process shutdown") | ||
} | ||
}() | ||
|
||
// Manual test query mode for Talos apid client | ||
if talosTestQuery != "" { | ||
if err := testQuery(api, talosTestQuery); err != nil { | ||
l.WithField("test_query", talosTestQuery).WithError(err).Fatal("test query failed") | ||
os.Exit(1) | ||
} else { | ||
os.Exit(0) | ||
} | ||
} | ||
|
||
// Wires up VMware Toolbox commands to Talos apid. | ||
vmguestmsg.DefaultLogger = l.WithField("module", "vmware-guestinfo") | ||
rpcIn, rpcOut := nanotoolbox.NewHypervisorChannelPair() | ||
svc := nanotoolbox.NewService(l, rpcIn, rpcOut) | ||
tboxcmds.RegisterGuestInfoCommands(svc, api) | ||
tboxcmds.RegisterPowerDelegate(svc, api) | ||
tboxcmds.RegisterVixCommand(svc, api) | ||
|
@@ -87,3 +106,27 @@ func main() { | |
svc.Wait() | ||
l.Info("graceful shutdown done, fair winds!") | ||
} | ||
|
||
func testQuery(api *talosapi.LocalClient, query string) error { | ||
w := os.Stdout | ||
switch query { | ||
case "net-interfaces": | ||
for idx, intf := range api.NetInterfaces() { | ||
for _, addr := range intf.Addrs { | ||
_, _ = fmt.Fprintf(w, "%d: name=%s mac=%s addr=%s\n", idx, intf.Name, intf.MAC, addr) | ||
} | ||
} | ||
return nil | ||
case "hostname": | ||
_, _ = fmt.Fprintln(w, api.Hostname()) | ||
return nil | ||
case "os-version": | ||
_, _ = fmt.Fprintln(w, api.OSVersion()) | ||
return nil | ||
case "os-version-short": | ||
_, _ = fmt.Fprintln(w, api.OSVersionShort()) | ||
return nil | ||
default: | ||
return fmt.Errorf("unknown test query %q", query) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.