forked from IBM/dbb-zappbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Option to validate system datasets (IBM#471)
* Validate System Datasets Signed-off-by: Dennis Behm <[email protected]>
- Loading branch information
1 parent
27d902a
commit 452864a
Showing
5 changed files
with
215 additions
and
10 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
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,66 @@ | ||
@groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript | ||
import com.ibm.dbb.build.* | ||
import groovy.transform.* | ||
import groovy.cli.commons.* | ||
import java.util.Properties | ||
import com.ibm.jzos.ZFile | ||
|
||
// define script properties | ||
|
||
@Field BuildProperties props = BuildProperties.getInstance() | ||
|
||
validateDatasets(args) | ||
|
||
def validateSystemDatasets(String propertyFiles, String verbose) { | ||
|
||
propertyFiles.split(",").each { propertyFile -> | ||
|
||
// load property file using java.util.Properties | ||
def properties = new Properties() | ||
|
||
// convert to absolute path based on zAppBuild conventions and structure | ||
if (props && !propertyFile.startsWith('/')) propertyFile = "${props.zAppBuildDir}/build-conf/$propertyFile" | ||
|
||
File propFile = new File(propertyFile) | ||
if (propFile.exists()) { | ||
|
||
propFile.withInputStream { properties.load(it) } | ||
properties.each { key,dataset -> | ||
if (dataset) { | ||
if (ZFile.dsExists("'$dataset'")) { | ||
if (verbose.toBoolean()) println "** The dataset $dataset referenced for property $key was found." | ||
} else { | ||
println "*! The dataset $dataset referenced for property $key was not found. Process exits." | ||
System.exit(1) | ||
} | ||
} else { | ||
if (verbose.toBoolean()) println "*! No dataset defined for property $key specified in $propertyFile." | ||
} | ||
} | ||
} else { | ||
println "*!* The specified $propertyFile (in the list [$propertyFiles]) does not exist." | ||
} | ||
} | ||
} | ||
|
||
def validateDatasets(String[] cliArgs) | ||
{ | ||
def cli = new CliBuilder(usage: "DatasetValidationUtilites.groovy [options]", header: '', stopAtNonOption: false) | ||
cli.d(longOpt:'systemDatasetDefinition', args:1, required:true, 'List of property files containing system dataset definitions.') | ||
cli.h(longOpt:'help', 'Flag to print the Help message.') | ||
|
||
def opts = cli.parse(cliArgs) | ||
|
||
// if opt parse fail exit. | ||
if (! opts) { | ||
System.exit(1) | ||
} | ||
|
||
if (opts.help) | ||
{ | ||
cli.usage() | ||
System.exit(0) | ||
} | ||
|
||
validateSystemDatasets(opts.d, "true") | ||
} |
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