-
Notifications
You must be signed in to change notification settings - Fork 85
Validation Framework
Validation Framework offers an infrastructure and collection of checks for various things in the system. While performing activities on the system, these simple checks can be invoked to ensure that preconditions are met before any operation is performed on the system. The checks include the following
- Network Connectivity
- Service Status
- Storage Connectivity
- System Health
- etc.
There are two ways the validations can be invoked.
- Python APIs (For Python SW Components)
- Command line (For Shell script or programs in other languages)
If validation fails, cortx.utils.validator.error.VError exception is generated. VError has following properties
- rc: Error Code
- desc: Description of the Error
If validation completes successfully no output is generated.
Note: When invoking from command line return code can be checked for errors in validation along with output posted on Standard Error.
All kinds of validations in the framework provides following interface pattern
validate(v_type, args=[])
Below are the list of validation classes and interfaces.
NetworkV().validate('connectivity', [ip1, ip2, ...])
NetworkV().validate('passwordless', [root, node1, node2, ...])
NetworkV().validate('drivers', [driver_name, node-1, node-2])
NetworkV().validate('hca', [provider, node-1, node-2])
Example:
cortx.utils.validator.v_network import NetworkV
ip1 = 192.168.1.1
ip2 = 192.168.1.2
try:
# Perform Network Validation
NetworkV().validate('connectivity', [ip1, ip2])
NetworkV().validate('passwordless', [root, 'srvnode-1', 'srvnode-2', ...])
NetworkV().validate('drivers', [driver_name, node-1, node-2])
NetworkV().validate('hca', [provider, node-1, node-2])
except VError as e:
sys.stderr.write("error(%s): validation failed. %s" %(e.rc, e.desc))
# Abort operation
ConsulV().validate('service', [host, port])
Example:
cortx.utils.validator.v_consul import ConsulV
try:
# Check Consul Service is UP
ConsulV().validate('service', ['localhost', '8500'])
except VError as e:
sys.stderr.write("error(%s): validation failed. %s" %(e.rc, e.desc))
# Abort operation
StorageV().validate('hba', [provider, node1, node2])
StorageV().validate('luns', [v_check, node1, node2])
StorageV().validate('lvms', [node1,node2])
Example:
cortx.utils.validator.v_storage import StorageV
try:
# Check luns and lvms details on given nodes
StorageV().validate('hba', [provider, node1, node2])
# v_check = ["accessible", "size", "mapped"]
StorageV().validate('luns', [v_check, node1, node2])
StorageV().validate('lvms', [node1,node2])
except VError as e:
sys.stderr.write("error(%s): validation failed. %s" %(e.rc, e.desc))
# Abort operation
SaltV().validate('connectivity', [node1, node2])
Example:
cortx.utils.validator.v_salt import SaltV
try:
# Check salt minion connectivity
SaltV().validate('minions', [node1, node2])
except VError as e:
sys.stderr.write("error(%s): validation failed. %s" %(e.rc, e.desc))
# Abort operation
BmcV().validate('accessible', [node, bmc_ip, bmc_user, bmc_pw])
BmcV().validate('stonith', [node, bmc_ip, bmc_user, bmc_pw])
Example:
cortx.utils.validator.v_bmc import BmcV
try:
# Check if BMC is accessible
BmcV().validate('accessible', [node, bmc_ip, bmc_user, bmc_pw])
# Check stonith configuration is correct or not
BmcV().validate('stonith', [node, bmc_ip, bmc_user, bmc_pw])
except VError as e:
sys.stderr.write("error(%s): validation failed. %s" %(e.rc, e.desc))
# Abort operation
ControllerV().validate('accessible', [ip, username, password])
ControllerV().validate('firmware', [ip, username, password, mc_version])
Example:
cortx.utils.validator.v_controller import ControllerV
try:
# Check if controller is accessible
ControllerV().validate('accessible', [ip, username, password])
# Check controller bundle version
ControllerV().validate('firmware', [ip, username, password, mc_version])
except VError as e:
sys.stderr.write("error(%s): validation failed. %s" %(e.rc, e.desc))
# Abort operation
Below are the list of validation commands. Callers must check the return code of the command to know the result. Non Zero return code indicates, validation failed. Output of the command can be referred for the reasons of the failure.
$ validate <domain> <validation type> [<arg> <arg> ....]
Example:
$ validate network connectivity <ip1> <ip2> <ip3> <ip4>
$ validate network passwordless root <node-1> <node-2>
$ validate network drivers <driver_name> <node-1> <node-2>
$ validate network hca <provider> <node-1> <node-2>
$ validate storage hba <provider> <node-1> <node-2>
$ validate storage luns <v_check> <node-1> <node-2>
$ validate storage lvms <node-1> <node-2>
$ validate consul service <host> <port>
$ validate salt minions <node-1> <node-2>
$ validate bmc accessible <node> <bmc_ip> <bmc_user> <bmc_pw>
$ validate bmc stonith <node> <bmc_ip> <bmc_user> <bmc_pw>
$ validate controller accessible <ip> <username> <password>
$ validate controller firmware <ip> <username> <password> <mc_version>