diff --git a/.tflint.hcl b/.tflint.hcl
new file mode 100644
index 0000000000..97cb3c4514
--- /dev/null
+++ b/.tflint.hcl
@@ -0,0 +1,51 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+plugin "google" {
+ enabled = true
+ version = "0.12.1"
+ source = "github.com/terraform-linters/tflint-ruleset-google"
+}
+rule "terraform_deprecated_index" {
+ enabled = true
+}
+rule "terraform_unused_declarations" {
+ enabled = true
+}
+rule "terraform_documented_variables" {
+ enabled = true
+}
+rule "terraform_comment_syntax" {
+ enabled = true
+}
+rule "terraform_documented_outputs" {
+ enabled = true
+}
+rule "terraform_documented_variables" {
+ enabled = true
+}
+rule "terraform_typed_variables" {
+ enabled = true
+}
+rule "terraform_naming_convention" {
+ enabled = true
+}
+rule "terraform_required_version" {
+ enabled = true
+}
+rule "terraform_required_providers" {
+ enabled = true
+}
+rule "terraform_unused_required_providers" {
+ enabled = true
+}
diff --git a/cmd/create.go b/cmd/create.go
index 6081d6eefd..a3e1fcb25a 100644
--- a/cmd/create.go
+++ b/cmd/create.go
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
+// Package cmd defines command line utilities for ghpc
package cmd
import (
diff --git a/cmd/expand.go b/cmd/expand.go
index f49801e45c..de6de0553f 100644
--- a/cmd/expand.go
+++ b/cmd/expand.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package cmd defines command line utilities for ghpc
package cmd
import (
diff --git a/cmd/root.go b/cmd/root.go
index 45949f1201..87b0283f76 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
+// Package cmd defines command line utilities for ghpc
package cmd
import (
@@ -33,10 +34,11 @@ HPC deployments on the Google Cloud Platform.`,
log.Fatalf("cmd.Help function failed: %s", err)
}
},
- Version: "v0.1.0-alpha (private preview)",
+ Version: "v0.1.1-alpha (private preview)",
}
)
+// Execute the root command
func Execute() error {
return rootCmd.Execute()
}
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 74162f40a4..42bd0de651 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package config manages and updates the ghpc input config
package config
import (
@@ -220,8 +221,12 @@ func (bc *BlueprintConfig) checkResourceAndGroupNames() {
// expand expands variables and strings in the yaml config
func (bc BlueprintConfig) expand() {
bc.addSettingsToResources()
- bc.combineLabels()
- bc.applyGlobalVariables()
+ if err := bc.combineLabels(); err != nil {
+ log.Fatal(err)
+ }
+ if err := bc.applyGlobalVariables(); err != nil {
+ log.Fatal(err)
+ }
bc.expandVariables()
}
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 7f168ecf95..fc6f931d95 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -234,7 +234,7 @@ func (s *MySuite) TestApplyGlobalVariables(c *C) {
err := bc.applyGlobalVariables()
c.Assert(err, IsNil)
- // Test no inputs, one required
+ // Test no inputs, one required, doesn't exist in globals
bc.ResourcesInfo["group1"][testResource.Source] = resreader.ResourceInfo{
Inputs: []resreader.VarInfo{requiredVar},
}
@@ -243,6 +243,23 @@ func (s *MySuite) TestApplyGlobalVariables(c *C) {
errorMessages["missingSetting"], testResource.ID, requiredVar.Name)
c.Assert(err, ErrorMatches, expectedErrorStr)
+ // Test no input, one required, exists in globals
+ bc.Config.Vars[requiredVar.Name] = "val"
+ err = bc.applyGlobalVariables()
+ c.Assert(err, IsNil)
+ c.Assert(
+ bc.Config.ResourceGroups[0].Resources[0].Settings[requiredVar.Name],
+ Equals, fmt.Sprintf("((var.%s))", requiredVar.Name))
+
+ // Test one input, one required
+ bc.Config.ResourceGroups[0].Resources[0].Settings[requiredVar.Name] = "val"
+ err = bc.applyGlobalVariables()
+ c.Assert(err, IsNil)
+
+ // Test one input, none required, exists in globals
+ bc.ResourcesInfo["group1"][testResource.Source].Inputs[0].Required = false
+ err = bc.applyGlobalVariables()
+ c.Assert(err, IsNil)
}
func (s *MySuite) TestIsSimpleVariable(c *C) {
diff --git a/pkg/config/expand.go b/pkg/config/expand.go
index 3be2893fc9..58495c8007 100644
--- a/pkg/config/expand.go
+++ b/pkg/config/expand.go
@@ -147,20 +147,25 @@ func applyGlobalVarsInGroup(
globalVars map[string]interface{}) error {
for _, res := range resourceGroup.Resources {
for _, input := range resInfo[res.Source].Inputs {
- if input.Required == true {
- // Exists? Continue
- if _, ok := res.Settings[input.Name]; ok {
- continue
- }
- // Exists at top level? Update and Continue
- if _, ok := globalVars[input.Name]; ok {
- res.Settings[input.Name] = fmt.Sprintf("((var.%s))", input.Name)
- } else {
- return fmt.Errorf("%s: Resource.ID: %s Setting: %s",
- errorMessages["missingSetting"], res.ID, input.Name)
- }
+ // Resource setting exists? Nothing more needs to be done.
+ if _, ok := res.Settings[input.Name]; ok {
+ continue
+ }
+
+ // If it's not set, is there a global we can use?
+ if _, ok := globalVars[input.Name]; ok {
+ res.Settings[input.Name] = fmt.Sprintf("((var.%s))", input.Name)
+ continue
+ }
+
+ if input.Required == true {
+ // It's not explicitly set, and not global is set
+ // Fail if no default has been set
+ return fmt.Errorf("%s: Resource.ID: %s Setting: %s",
+ errorMessages["missingSetting"], res.ID, input.Name)
}
+ // Default exists, the resource will handle it
}
}
return nil
@@ -169,15 +174,14 @@ func applyGlobalVarsInGroup(
// applyGlobalVariables takes any variables defined at the global level and
// applies them to resources settings if not already set.
func (bc *BlueprintConfig) applyGlobalVariables() error {
- var err error
for _, grp := range bc.Config.ResourceGroups {
- err = applyGlobalVarsInGroup(
+ err := applyGlobalVarsInGroup(
grp, bc.ResourcesInfo[grp.Name], bc.Config.Vars)
if err != nil {
- break
+ return err
}
}
- return err
+ return nil
}
type varContext struct {
@@ -217,48 +221,48 @@ func expandSimpleVariable(
errorMessages["varNotFound"], context.varString)
}
return fmt.Sprintf("((var.%s))", varValue), nil
- } else { // Resource variable
+ }
- // Verify resource exists
- refGrpIndex, ok := resToGrp[varSource]
- if !ok {
- return "", fmt.Errorf("%s: resource %s was not found",
- errorMessages["varNotFound"], varSource)
- }
- if refGrpIndex != context.groupIndex {
- log.Fatalf("Unimplemented: references to other groups are not yet supported")
- }
+ // Resource variable
+ // Verify resource exists
+ refGrpIndex, ok := resToGrp[varSource]
+ if !ok {
+ return "", fmt.Errorf("%s: resource %s was not found",
+ errorMessages["varNotFound"], varSource)
+ }
+ if refGrpIndex != context.groupIndex {
+ log.Fatalf("Unimplemented: references to other groups are not yet supported")
+ }
- // Get the resource info
- refGrp := context.yamlConfig.ResourceGroups[refGrpIndex]
- refResIndex := -1
- for i := range refGrp.Resources {
- if refGrp.Resources[i].ID == varSource {
- refResIndex = i
- break
- }
- }
- if refResIndex == -1 {
- log.Fatalf("Could not find resource referenced by variable %s",
- context.varString)
- }
- refRes := refGrp.Resources[refResIndex]
- resInfo := resreader.Factory(refRes.Kind).GetInfo(refRes.Source)
-
- // Verify output exists in resource
- found := false
- for _, output := range resInfo.Outputs {
- if output.Name == varValue {
- found = true
- break
- }
+ // Get the resource info
+ refGrp := context.yamlConfig.ResourceGroups[refGrpIndex]
+ refResIndex := -1
+ for i := range refGrp.Resources {
+ if refGrp.Resources[i].ID == varSource {
+ refResIndex = i
+ break
}
- if !found {
- return "", fmt.Errorf("%s: resource %s did not have output %s",
- errorMessages["noOutput"], refRes.ID, varValue)
+ }
+ if refResIndex == -1 {
+ log.Fatalf("Could not find resource referenced by variable %s",
+ context.varString)
+ }
+ refRes := refGrp.Resources[refResIndex]
+ resInfo := resreader.Factory(refRes.Kind).GetInfo(refRes.Source)
+
+ // Verify output exists in resource
+ found := false
+ for _, output := range resInfo.Outputs {
+ if output.Name == varValue {
+ found = true
+ break
}
- return fmt.Sprintf("((module.%s.%s))", varSource, varValue), nil
}
+ if !found {
+ return "", fmt.Errorf("%s: resource %s did not have output %s",
+ errorMessages["noOutput"], refRes.ID, varValue)
+ }
+ return fmt.Sprintf("((module.%s.%s))", varSource, varValue), nil
}
func expandVariable(
@@ -318,7 +322,7 @@ func updateVariableType(
interfaceSlice[i], err = updateVariableType(
interfaceSlice[i], context, resToGrp)
if err != nil {
- break
+ return interfaceSlice, err
}
}
}
@@ -329,7 +333,7 @@ func updateVariableType(
for k, v := range interfaceMap {
retMap[k], err = updateVariableType(v, context, resToGrp)
if err != nil {
- break
+ return interfaceMap, err
}
}
return retMap, err
@@ -342,14 +346,14 @@ func updateVariables(
context varContext,
interfaceMap map[string]interface{},
resToGrp map[string]int) error {
- var err error
for key, value := range interfaceMap {
- interfaceMap[key], err = updateVariableType(value, context, resToGrp)
+ updatedVal, err := updateVariableType(value, context, resToGrp)
if err != nil {
- break
+ return err
}
+ interfaceMap[key] = updatedVal
}
- return err
+ return nil
}
// handlePrimitives recurses through the data structures in the yaml config and
diff --git a/pkg/config/validate.go b/pkg/config/validate.go
index 7a58e081c0..1f4f86d317 100644
--- a/pkg/config/validate.go
+++ b/pkg/config/validate.go
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-// Package config wraps functionality around the user input config
package config
import (
diff --git a/pkg/resreader/packerreader.go b/pkg/resreader/packerreader.go
index dee1ac977d..18921effae 100644
--- a/pkg/resreader/packerreader.go
+++ b/pkg/resreader/packerreader.go
@@ -42,20 +42,20 @@ func addTfExtension(filename string) {
}
func getHCLFiles(dir string) []string {
- all_files, err := ioutil.ReadDir(dir)
+ allFiles, err := ioutil.ReadDir(dir)
if err != nil {
log.Fatalf("Failed to read packer source directory %s", dir)
}
- var hcl_files []string
- for _, f := range all_files {
+ var hclFiles []string
+ for _, f := range allFiles {
if f.IsDir() {
continue
}
if filepath.Ext(f.Name()) == ".hcl" {
- hcl_files = append(hcl_files, path.Join(dir, f.Name()))
+ hclFiles = append(hclFiles, path.Join(dir, f.Name()))
}
}
- return hcl_files
+ return hclFiles
}
func copyHCLFilesToTmp(dir string) (string, []string) {
diff --git a/pkg/resreader/resreader.go b/pkg/resreader/resreader.go
index d8f4d9d06e..9712456ef7 100644
--- a/pkg/resreader/resreader.go
+++ b/pkg/resreader/resreader.go
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+// Package resreader extracts necessary information from resources
package resreader
import "log"
diff --git a/pkg/resreader/resreader_test.go b/pkg/resreader/resreader_test.go
index 8e32203762..4138f5a7fd 100644
--- a/pkg/resreader/resreader_test.go
+++ b/pkg/resreader/resreader_test.go
@@ -111,12 +111,18 @@ func createTmpResource() {
"Failed to create temp dir for resource in resreader_test, %v", err)
}
mainFile, err := os.Create(path.Join(tmpResourceDir, "main.tf"))
+ if err != nil {
+ log.Fatalf("Failed to create main.tf: %v", err)
+ }
_, err = mainFile.WriteString(testMainTf)
if err != nil {
log.Fatalf("resreader_test: Failed to write main.tf test file. %v", err)
}
varFile, err := os.Create(path.Join(tmpResourceDir, "variables.tf"))
+ if err != nil {
+ log.Fatalf("Failed to create variables.tf: %v", err)
+ }
_, err = varFile.WriteString(testVariablesTf)
if err != nil {
log.Fatalf(
@@ -124,6 +130,9 @@ func createTmpResource() {
}
outFile, err := os.Create(path.Join(tmpResourceDir, "outputs.tf"))
+ if err != nil {
+ log.Fatalf("Failed to create outputs.tf: %v", err)
+ }
_, err = outFile.WriteString(testOutputsTf)
if err != nil {
log.Fatalf("resreader_test: Failed to write outputs.tf test file. %v", err)
diff --git a/pkg/reswriter/templates/main.tf.tmpl b/pkg/reswriter/main.tf.tmpl
similarity index 100%
rename from pkg/reswriter/templates/main.tf.tmpl
rename to pkg/reswriter/main.tf.tmpl
diff --git a/pkg/reswriter/templates/output.tf.tmpl b/pkg/reswriter/output.tf.tmpl
similarity index 100%
rename from pkg/reswriter/templates/output.tf.tmpl
rename to pkg/reswriter/output.tf.tmpl
diff --git a/pkg/reswriter/reswriter.go b/pkg/reswriter/reswriter.go
index 0f4e86dc1d..ed0bf9bac4 100644
--- a/pkg/reswriter/reswriter.go
+++ b/pkg/reswriter/reswriter.go
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+// Package reswriter writes resources to a blueprint directory
package reswriter
import (
@@ -46,7 +47,7 @@ var kinds = map[string]ResWriter{
"packer": new(PackerWriter),
}
-//go:embed templates
+//go:embed *.tmpl
var templatesFS embed.FS
func factory(kind string) ResWriter {
@@ -89,8 +90,7 @@ func getAbsSourcePath(sourcePath string) string {
func getTemplate(filename string) string {
// Create path to template from the embedded template FS
- mainTmplPath := path.Join("templates", filename)
- tmplText, err := templatesFS.ReadFile(mainTmplPath)
+ tmplText, err := templatesFS.ReadFile(filename)
if err != nil {
log.Fatalf("TFWriter: %v", err)
}
diff --git a/pkg/reswriter/reswriter_test.go b/pkg/reswriter/reswriter_test.go
index a16436c0d9..84ad83652f 100644
--- a/pkg/reswriter/reswriter_test.go
+++ b/pkg/reswriter/reswriter_test.go
@@ -271,20 +271,6 @@ func (s *MySuite) TestCreateBlueprintDirectory(c *C) {
c.Assert(err, IsNil)
}
-func (s *MySuite) TestCopySource(c *C) {
- blueprintName := "blueprints_TestCopySource"
- blueprintDir := path.Join(testDir, blueprintName)
- createBlueprintDirectory(blueprintDir)
- copySource(blueprintDir, &resourceGroups)
- _, err := os.Stat(
- path.Join(
- blueprintDir,
- resourceGroups[0].Name,
- "modules",
- resources[0].ResourceName))
- c.Assert(err, IsNil)
-}
-
func (s *MySuite) TestWriteTopLayer_TFWriter(c *C) {
// Shallow copy the struct so we can set the name
blueprintName := "blueprints_TestWriteTopLayer_TFWriter"
diff --git a/pkg/reswriter/templates/terraform.tfvars.tmpl b/pkg/reswriter/terraform.tfvars.tmpl
similarity index 100%
rename from pkg/reswriter/templates/terraform.tfvars.tmpl
rename to pkg/reswriter/terraform.tfvars.tmpl
diff --git a/pkg/reswriter/templates/variables.auto.pkrvars.hcl.tmpl b/pkg/reswriter/variables.auto.pkrvars.hcl.tmpl
similarity index 100%
rename from pkg/reswriter/templates/variables.auto.pkrvars.hcl.tmpl
rename to pkg/reswriter/variables.auto.pkrvars.hcl.tmpl
diff --git a/pkg/reswriter/templates/variables.tf.tmpl b/pkg/reswriter/variables.tf.tmpl
similarity index 100%
rename from pkg/reswriter/templates/variables.tf.tmpl
rename to pkg/reswriter/variables.tf.tmpl
diff --git a/resources/file-system/filestore/README.md b/resources/file-system/filestore/README.md
index ab550a9c48..9a52ef4d30 100644
--- a/resources/file-system/filestore/README.md
+++ b/resources/file-system/filestore/README.md
@@ -19,12 +19,14 @@ limitations under the License.
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.14.0 |
| [google](#requirement\_google) | ~> 3.0 |
+| [random](#requirement\_random) | ~> 3.0 |
## Providers
| Name | Version |
|------|---------|
| [google](#provider\_google) | ~> 3.0 |
+| [random](#provider\_random) | ~> 3.0 |
## Modules
@@ -35,6 +37,7 @@ No modules.
| Name | Type |
|------|------|
| [google_filestore_instance.filestore_instance](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/filestore_instance) | resource |
+| [random_id.resource_name_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
## Inputs
diff --git a/resources/file-system/filestore/main.tf b/resources/file-system/filestore/main.tf
index 3c4ce007be..54f2ce6336 100644
--- a/resources/file-system/filestore/main.tf
+++ b/resources/file-system/filestore/main.tf
@@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+resource "random_id" "resource_name_suffix" {
+ byte_length = 4
+}
resource "google_filestore_instance" "filestore_instance" {
depends_on = [var.network_name]
- name = var.name != null ? var.name : var.deployment_name
+ name = var.name != null ? var.name : "${var.deployment_name}-${random_id.resource_name_suffix.hex}"
zone = var.zone
tier = var.filestore_tier
diff --git a/resources/file-system/filestore/module.json b/resources/file-system/filestore/module.json
index 95b2e7d139..486186e1fe 100644
--- a/resources/file-system/filestore/module.json
+++ b/resources/file-system/filestore/module.json
@@ -78,6 +78,11 @@
"name": "google",
"alias": null,
"version": "~\u003e 3.0"
+ },
+ {
+ "name": "random",
+ "alias": null,
+ "version": "~\u003e 3.0"
}
],
"requirements": [
@@ -88,6 +93,10 @@
{
"name": "google",
"version": "~\u003e 3.0"
+ },
+ {
+ "name": "random",
+ "version": "~\u003e 3.0"
}
],
"resources": [
@@ -97,7 +106,17 @@
"provider": "google",
"source": "hashicorp/google",
"mode": "managed",
- "version": "latest"
+ "version": "latest",
+ "description": null
+ },
+ {
+ "type": "id",
+ "name": "resource_name_suffix",
+ "provider": "random",
+ "source": "hashicorp/random",
+ "mode": "managed",
+ "version": "latest",
+ "description": null
}
]
}
diff --git a/resources/file-system/filestore/versions.tf b/resources/file-system/filestore/versions.tf
index 4b047db9fa..24b8f08a3d 100644
--- a/resources/file-system/filestore/versions.tf
+++ b/resources/file-system/filestore/versions.tf
@@ -20,6 +20,10 @@ terraform {
source = "hashicorp/google"
version = "~> 3.0"
}
+ random = {
+ source = "hashicorp/random"
+ version = "~> 3.0"
+ }
}
required_version = ">= 0.14.0"
diff --git a/resources/scripts/omnia-install/README.md b/resources/scripts/omnia-install/README.md
index dd6bc71a44..8c59b8c321 100644
--- a/resources/scripts/omnia-install/README.md
+++ b/resources/scripts/omnia-install/README.md
@@ -43,6 +43,8 @@ No modules.
| [depends](#input\_depends) | Allows to add explicit dependencies | `list(any)` | `null` | no |
| [deployment\_name](#input\_deployment\_name) | Name of the deployment, used to name the cluster | `string` | n/a | yes |
| [manager\_node](#input\_manager\_node) | Name of the Omnia manager node | `string` | n/a | yes |
+| [project\_id](#input\_project\_id) | Project in which the Omnia cluster has been created | `string` | n/a | yes |
+| [zone](#input\_zone) | The GCP zone where the Omnia cluster is running | `string` | n/a | yes |
## Outputs
diff --git a/resources/scripts/omnia-install/main.tf b/resources/scripts/omnia-install/main.tf
index 6a2d415e75..2ba199749a 100644
--- a/resources/scripts/omnia-install/main.tf
+++ b/resources/scripts/omnia-install/main.tf
@@ -25,6 +25,8 @@ resource "null_resource" "omnia_install" {
environment = {
DEPLOYMENT_NAME = var.deployment_name
MANAGER_NODE = var.manager_node
+ ZONE = var.zone
+ PROJECT_ID = var.project_id
}
}
}
diff --git a/resources/scripts/omnia-install/module.json b/resources/scripts/omnia-install/module.json
index 34f99c8fb3..ec9943d5d5 100644
--- a/resources/scripts/omnia-install/module.json
+++ b/resources/scripts/omnia-install/module.json
@@ -22,6 +22,20 @@
"description": "Name of the Omnia manager node",
"default": null,
"required": true
+ },
+ {
+ "name": "project_id",
+ "type": "string",
+ "description": "Project in which the Omnia cluster has been created",
+ "default": null,
+ "required": true
+ },
+ {
+ "name": "zone",
+ "type": "string",
+ "description": "The GCP zone where the Omnia cluster is running",
+ "default": null,
+ "required": true
}
],
"modules": [],
diff --git a/resources/scripts/omnia-install/scripts/create_inventory.py b/resources/scripts/omnia-install/scripts/create_inventory.py
index c8f7c779c6..8658d34e77 100644
--- a/resources/scripts/omnia-install/scripts/create_inventory.py
+++ b/resources/scripts/omnia-install/scripts/create_inventory.py
@@ -12,27 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import argparse
import json
+import os
import subprocess
-from subprocess import PIPE
from jinja2 import Template
-import os
-import pathlib
-import argparse
## Parse Arguments
parser = argparse.ArgumentParser()
parser.add_argument("--template", type=str, required=True)
parser.add_argument("--outfile", type=str, required=True)
parser.add_argument("--deployment_name", type=str, required=True)
+parser.add_argument("--project_id", type=str, required=True)
+parser.add_argument("--zone", type=str, required=True)
args = parser.parse_args()
## Get cluster information
-gcloud_cmd = ["gcloud", "compute", "instances", "list",
+gcloud_cmd = ["gcloud", "compute", "instances", "list",
+ "--project", args.project_id, "--zones", args.zone,
"--filter", f"labels.ghpc_deployment={args.deployment_name}",
"--format",
"json(name,labels.ghpc_role,networkInterfaces[0].networkIP)"]
-gcloud_process = subprocess.run(gcloud_cmd, stdout=PIPE, stderr=PIPE)
+gcloud_process = subprocess.run(
+ gcloud_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
if gcloud_process.returncode != 0:
print(f"Failed to return omnia VM instance list: {gcloud_process.stderr}")
exit(1)
@@ -52,5 +54,4 @@
template = Template(inventory_tmpl.read())
with open(args.outfile, "w") as inventory_file:
inventory_file.write(
- template.render(omnia_manager=omnia_manager, compute_vms=compute_vms)
- )
+ template.render(omnia_manager=omnia_manager, compute_vms=compute_vms))
diff --git a/resources/scripts/omnia-install/scripts/ghpc-install/scripts/install_omnia.yml b/resources/scripts/omnia-install/scripts/ghpc-install/scripts/install_omnia.yml
index 318f99c8ef..bd4568c2fc 100644
--- a/resources/scripts/omnia-install/scripts/ghpc-install/scripts/install_omnia.yml
+++ b/resources/scripts/omnia-install/scripts/ghpc-install/scripts/install_omnia.yml
@@ -53,7 +53,7 @@
git:
repo: 'https://github.com/dellhpc/omnia.git'
dest: ../omnia
- version: release
+ version: release-1.0
update: false
- name: Copy file with owner and permissions
copy:
diff --git a/resources/scripts/omnia-install/scripts/install_omnia.sh b/resources/scripts/omnia-install/scripts/install_omnia.sh
index eb180dc6e6..6740ef2806 100755
--- a/resources/scripts/omnia-install/scripts/install_omnia.sh
+++ b/resources/scripts/omnia-install/scripts/install_omnia.sh
@@ -22,11 +22,14 @@ mkdir -p ${RUNNER_DIR}/ghpc-install/data
python3 ${RUNNER_DIR}/create_inventory.py \
--deployment_name ${DEPLOYMENT_NAME} \
--template ${RUNNER_DIR}/inventory.tmpl \
- --outfile ${RUNNER_DIR}/ghpc-install/data/inventory
+ --outfile ${RUNNER_DIR}/ghpc-install/data/inventory \
+ --project ${PROJECT_ID} \
+ --zone ${ZONE}
echo "Copying runner data to Omnia Manager..."
-gcloud compute scp --recurse ${RUNNER_DIR}/ghpc-install ${MANAGER_NODE}:
+gcloud compute scp --project ${PROJECT_ID} --zone ${ZONE} \
+ --recurse ${RUNNER_DIR}/ghpc-install ${MANAGER_NODE}:
echo "Applying the Omnia runner..."
-gcloud compute ssh ${MANAGER_NODE} -- \
- "cd ~/ghpc-install/scripts; source install_omnia.sh"
+gcloud compute ssh --project ${PROJECT_ID} --zone ${ZONE} ${MANAGER_NODE} \
+ -- "cd ~/ghpc-install/scripts; source install_omnia.sh"
diff --git a/resources/scripts/omnia-install/variables.tf b/resources/scripts/omnia-install/variables.tf
index e6ce81dee8..4356eef333 100644
--- a/resources/scripts/omnia-install/variables.tf
+++ b/resources/scripts/omnia-install/variables.tf
@@ -29,3 +29,13 @@ variable "manager_node" {
description = "Name of the Omnia manager node"
type = string
}
+
+variable "zone" {
+ description = "The GCP zone where the Omnia cluster is running"
+ type = string
+}
+
+variable "project_id" {
+ description = "Project in which the Omnia cluster has been created"
+ type = string
+}
diff --git a/resources/tests/compute_test.go b/resources/tests/compute_test.go
index 239cf5986c..88e5b639b4 100644
--- a/resources/tests/compute_test.go
+++ b/resources/tests/compute_test.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package restests defines unit tests for terraform resources
package restests
import "testing"
diff --git a/resources/tests/file-system_test.go b/resources/tests/file-system_test.go
index 09b0dd30c9..6fe6ce6866 100644
--- a/resources/tests/file-system_test.go
+++ b/resources/tests/file-system_test.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package restests defines unit tests for terraform resources
package restests
import "testing"
diff --git a/resources/tests/network_test.go b/resources/tests/network_test.go
index d0c2da3261..b2d097d9c6 100644
--- a/resources/tests/network_test.go
+++ b/resources/tests/network_test.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package restests defines unit tests for terraform resources
package restests
import "testing"
diff --git a/resources/tests/scheduler_test.go b/resources/tests/scheduler_test.go
index 7cdb24e3ea..0fb943070e 100644
--- a/resources/tests/scheduler_test.go
+++ b/resources/tests/scheduler_test.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package restests defines unit tests for terraform resources
package restests
import "testing"
diff --git a/resources/tests/utils.go b/resources/tests/utils.go
index c1719077ea..8f830424b4 100644
--- a/resources/tests/utils.go
+++ b/resources/tests/utils.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package restests defines unit tests for terraform resources
package restests
import (
diff --git a/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/README.md b/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/README.md
index 78f61a5474..12a9b181c1 100644
--- a/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/README.md
+++ b/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/README.md
@@ -58,7 +58,7 @@ No resources.
| [shared\_vpc\_host\_project](#input\_shared\_vpc\_host\_project) | Host project of shared VPC | `string` | `null` | no |
| [subnet\_depend](#input\_subnet\_depend) | Used as a dependency between the network and instances | `string` | `""` | no |
| [subnetwork\_name](#input\_subnetwork\_name) | The name of the pre-defined VPC subnet you want the nodes to attach to based on Region. | `string` | `null` | no |
-| [zone](#input\_zone) | Compute Platform zone where the notebook server will be located | `string` | `"us-central1-b"` | no |
+| [zone](#input\_zone) | Compute Platform zone where the notebook server will be located | `string` | n/a | yes |
## Outputs
diff --git a/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/module.json b/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/module.json
index cc982cb910..b155192f9c 100644
--- a/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/module.json
+++ b/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/module.json
@@ -156,8 +156,8 @@
"name": "zone",
"type": "string",
"description": "Compute Platform zone where the notebook server will be located",
- "default": "us-central1-b",
- "required": false
+ "default": null,
+ "required": true
}
],
"modules": [
diff --git a/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/variables.tf b/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/variables.tf
index 3dbdb6264a..d8b39fc657 100644
--- a/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/variables.tf
+++ b/resources/third-party/scheduler/SchedMD-slurm-on-gcp-login-node/variables.tf
@@ -153,5 +153,4 @@ variable "subnetwork_name" {
variable "zone" {
description = "Compute Platform zone where the notebook server will be located"
type = string
- default = "us-central1-b"
}