This repository has been archived by the owner on Jun 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from StrongMonkey/windows-demo
Windows support
- Loading branch information
Showing
78 changed files
with
4,494 additions
and
32 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
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
Empty file.
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,5 +1,3 @@ | ||
// +build linux freebsd solaris openbsd darwin | ||
|
||
package hostInfo | ||
|
||
import ( | ||
|
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,5 +1,3 @@ | ||
// +build linux freebsd solaris openbsd darwin | ||
|
||
package hostInfo | ||
|
||
import ( | ||
|
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//+build !windows | ||
|
||
package hostInfo | ||
|
||
import ( | ||
"bufio" | ||
"github.com/pkg/errors" | ||
"github.com/rancher/agent/utilities/constants" | ||
"os" | ||
"regexp" | ||
) | ||
|
||
func getKernelVersion() (string, error) { | ||
file, err := os.Open("/proc/version") | ||
defer file.Close() | ||
data := []string{} | ||
if err != nil { | ||
return "", errors.Wrap(err, constants.GetKernelVersionError+"failed to open process version file") | ||
} | ||
scanner := bufio.NewScanner(file) | ||
scanner.Split(bufio.ScanLines) | ||
for scanner.Scan() { | ||
data = append(data, scanner.Text()) | ||
} | ||
version := regexp.MustCompile("\\d+.\\d+.\\d+").FindString(data[0]) | ||
return version, nil | ||
} |
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,7 @@ | ||
//+build windows | ||
|
||
package hostInfo | ||
|
||
func getKernelVersion() (string, error) { | ||
return "", nil | ||
} |
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
Empty file.
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,3 @@ | ||
package hostapi | ||
|
||
const execPath string = "c:\\agent\\src\\github.com\\rancher\\host-api\\host-api.exe" | ||
const execPath string = "c:\\host-api.exe" |
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
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 @@ | ||
//+build !windows | ||
|
||
package utils | ||
|
||
import ( | ||
"github.com/docker/engine-api/types" | ||
) | ||
|
||
func getIP(inspect types.ContainerJSON) string { | ||
return inspect.NetworkSettings.IPAddress | ||
} |
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,51 @@ | ||
//+build windows | ||
|
||
package utils | ||
|
||
import ( | ||
"bufio" | ||
"github.com/Sirupsen/logrus" | ||
"github.com/docker/engine-api/types" | ||
"github.com/rancher/agent/utilities/constants" | ||
"github.com/rancher/agent/utilities/docker" | ||
"golang.org/x/net/context" | ||
"regexp" | ||
"strings" | ||
"time" | ||
) | ||
|
||
func getIP(inspect types.ContainerJSON) string { | ||
containerID := inspect.ID | ||
client := docker.GetClient(constants.DefaultVersion) | ||
execConfig := types.ExecConfig{ | ||
AttachStdout: true, | ||
AttachStdin: true, | ||
AttachStderr: true, | ||
Privileged: true, | ||
Tty: false, | ||
Detach: false, | ||
Cmd: []string{"powershell", "ipconfig"}, | ||
} | ||
ip := "" | ||
// waiting for the DHCP to assign IP address. Testing purpose. May try multiple times until ip address arrives | ||
time.Sleep(time.Duration(2) * time.Second) | ||
execObj, err := client.ContainerExecCreate(context.Background(), containerID, execConfig) | ||
if err != nil { | ||
logrus.Error(err) | ||
return "" | ||
} | ||
hijack, err := client.ContainerExecAttach(context.Background(), execObj.ID, execConfig) | ||
if err != nil { | ||
logrus.Error(err) | ||
return "" | ||
} | ||
scanner := bufio.NewScanner(hijack.Reader) | ||
for scanner.Scan() { | ||
output := scanner.Text() | ||
if strings.Contains(output, "IPv4 Address") { | ||
ip = regexp.MustCompile("(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$").FindString(output) | ||
} | ||
} | ||
hijack.Close() | ||
return ip | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.