Handle "name" in openstack.name
[releng/global-jjb.git] / jenkins-admin / create_jenkins_clouds_openstack_yaml.py
index bd94a9e..ea92aa7 100755 (executable)
@@ -58,7 +58,7 @@ jenkins:
         credentialsId: {{ cloud_credential_id }}
         endPointUrl: {{ cloud_url }}
         ignoreSsl: {{ cloud_ignore_ssl }}
-        name: "cattle"
+        name: {{ cloud_name }}
         slaveOptions:
           availabilityZone: {{ availability_zone }}
           bootSource:
@@ -111,16 +111,27 @@ def dir_path(path):
         raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path")
 
 def parse_arguments():
-    parser = argparse.ArgumentParser(description='Create jcasc yaml from path to jenkins config dir.')
-    parser.add_argument('--path', type=dir_path)
-    parser.add_argument('--sandbox', type=bool, default=False, help="Set to True for sandbox yaml generation")
+    parser = argparse.ArgumentParser(
+        description='Create jcasc yaml from path to jenkins config dir.')
+
+
+    parser.add_argument('--path', type=dir_path,
+                        help="Path to jenkins-admin directory")
+    parser.add_argument('--name', type=str,
+                        help="cloud name IE: cattle")
+
+    parser.add_argument(
+        "-s", "--sandbox",
+        help = "Is configuration being created for a sandbox",
+        dest = "sandbox", action = "store_true"
+    )
+
     return parser.parse_args()
 
 parsed_args = parse_arguments()
 path = (parsed_args.path)
 path = ("{}**/*.cfg".format(path))
 
-
 #sandbox switch section
 section_cloud = {}
 name_prefix = "prd"
@@ -169,7 +180,9 @@ for filename in glob.iglob(path, recursive=True):
 # Global cloud config section
 for section in config_parser_merged.sections():
     if section == "cloud":
-        final = (config.items(section))
+        afinal = (config.items(section))
+        name = parsed_args.name
+        final = (*afinal, ("cloud_name", name))
 
 
 for index, _ in enumerate(final):
@@ -213,7 +226,6 @@ for section in config_parser_merged.sections():
         print(j2_template.render(section_all_machines))
 
 
-
 #Footer section
 j2_template = Template(footertemplate)
 print(j2_template.render(section_cloud))