Storage Module Basis (#13)

* Added storage module, base structs, getDevices() func, taskGetStorageDevices (ticks every 30)

* GetDevices now returns a complete description w/ disk partitions

* Added InUse flag to Device, fixed logic bugs

* Added disk space usage for partitions in use by the system

* Cleanup

* Added UsageStat and UsageSplit filling for in use devices

* Changed value of lsblk block usage output to bytes

* Cleanup, small fixes

* Added ExecAndGetLines util func

* Added explicit detection of disk or part block type, ignoring non-suppoorted devices

* Added command line tool dependencies for the project in README file

* Added comment to func ExecAndGetLines

* Removed GetMySQLDbConnectionDetails()

* Added tests to utils module

* Fix invalid argument type for Exec family of tests

* Removed too much verbosity from utils.GetPath when no env file is available, added new argument (path) to Exec family of funcs

* Added new path argument to utils.Exec... test

* Fixed TestExec

* Added spaces trim to Exec result

* Trimming spaces and newlines from result of Exec

* Better visibility for test result log of TestExec

* Added ExampleExecAndStream test

* Added Example tests with failure status for ExecAndStream

* Added branch to test for valid key in GetPath

* Added missing t.Fail() statements in utils_test.go

* Added storage_test.go file, smoke test

* TestGetDevices
This commit is contained in:
Paulo Truta
2021-06-13 12:03:36 +02:00
committed by GitHub
parent 92ac9c2b03
commit 9339e6cf09
9 changed files with 483 additions and 46 deletions
+6 -6
View File
@@ -239,14 +239,14 @@ func GetEdgeAppStatus(ID string) EdgeAppStatus {
func GetEdgeAppServices(ID string) []EdgeAppService {
cmdArgs := []string{"-r", ".services | keys[]", utils.GetPath("edgeAppsPath") + ID + configFilename}
servicesString := utils.Exec("yq", cmdArgs)
servicesString := utils.Exec(utils.GetPath("wsPath"), "yq", cmdArgs)
serviceSlices := strings.Split(servicesString, "\n")
serviceSlices = utils.DeleteEmptySlices(serviceSlices)
var edgeAppServices []EdgeAppService
for _, serviceID := range serviceSlices {
cmdArgs = []string{"-f", utils.GetPath("wsPath") + "/docker-compose.yml", "exec", "-T", serviceID, "echo", "'Service Check'"}
cmdResult := utils.Exec("docker-compose", cmdArgs)
cmdResult := utils.Exec(utils.GetPath("wsPath"), "docker-compose", cmdArgs)
isRunning := false
if cmdResult != "" {
isRunning = true
@@ -268,7 +268,7 @@ func RunEdgeApp(ID string) EdgeAppStatus {
for _, service := range services {
cmdArgs = []string{"-f", utils.GetPath("wsPath") + "/docker-compose.yml", "start", service.ID}
utils.Exec("docker-compose", cmdArgs)
utils.Exec(utils.GetPath("wsPath"), "docker-compose", cmdArgs)
}
@@ -289,7 +289,7 @@ func StopEdgeApp(ID string) EdgeAppStatus {
for _, service := range services {
cmdArgs = []string{"-f", utils.GetPath("wsPath") + "/docker-compose.yml", "stop", service.ID}
utils.Exec("docker-compose", cmdArgs)
utils.Exec(utils.GetPath("wsPath"), "docker-compose", cmdArgs)
}
@@ -326,7 +326,7 @@ func DisableOnline(ID string) MaybeEdgeApp {
log.Println("myedge.app environment file for " + ID + " not found. No need to delete.")
} else {
cmdArgs := []string{envFilePath}
utils.Exec("rm", cmdArgs)
utils.Exec(utils.GetPath("wsPath"), "rm", cmdArgs)
}
buildFrameworkContainers()
@@ -338,7 +338,7 @@ func DisableOnline(ID string) MaybeEdgeApp {
func buildFrameworkContainers() {
cmdArgs := []string{utils.GetPath("wsPath") + "ws", "--build"}
utils.ExecAndStream("sh", cmdArgs)
utils.ExecAndStream(utils.GetPath("wsPath"), "sh", cmdArgs)
time.Sleep(defaultContainerOperationSleepTime)