def validate_ssh_private_key(cls, ssh_private_key): """ Method to validate ssh public key ssh_public_key: if specified, then the specified public key should be configured for the cluster Args: cls: cephadm instance ssh_private_key: ssh-private-key bootstrap option response: bootstrap command response """ out, _ = cls.shell( args=["ceph", "config-key", "get", "mgr/cephadm/ssh_identity_key"]) log.info(f"Ceph SSH private key file - configured: {ssh_private_key}") if not file_or_path_exists(cls.installer, ssh_private_key): raise BootStrapValidationFailure("Ceph SSH private key file not found") pri_key = fetch_file_content(cls.installer, ssh_private_key) log.info( f"ssh-private-key configured: {out}, ssh-private-key used in cluster: {pri_key}" ) # if pri_key found and out == pri_key, configured and used keys are same. Valid # if pri_key found and out != pri_key, configured and used keys are different, not Valid if pri_key and out != pri_key: raise BootStrapValidationFailure( "ssh private key provided in the configuration is not used in the cluster" ) log.info("ssh-private-key validation is successful")
def validate_log_file_generation(cls): """ Method to verify generation of log files in default log directory Args: cls: cephadm instance object Returns: string """ out, _ = cls.shell(args=["ceph", "fsid"]) fsid = out.strip() log_file_path = "/var/log/ceph" hosts = get_hosts_deployed(cls) retry_count = 3 for node in cls.cluster.get_nodes(): try: if node.hostname not in hosts: continue file = os.path.join(log_file_path, "cephadm.log") fileExists = file_or_path_exists(node, file) if not fileExists: raise BootStrapValidationFailure( f"cephadm.log is not present in the node {node.ip_address}" ) count = 0 fileExists = False while count < retry_count: count += 1 sleep(60) file = os.path.join(log_file_path, fsid, "ceph-volume.log") fileExists = file_or_path_exists(node, file) if fileExists: break if not fileExists: raise BootStrapValidationFailure( f"ceph-volume.log is not present in the node {node.ip_address}" ) log.info(f"Log verification on node {node.ip_address} successful") except CommandFailed as err: log.error("Error: %s" % err) raise BootStrapValidationFailure( f"ceph-volume.log is not present in the node {node.ip_address}" ) log.info("Log file validation successful")
def verify_ceph_public_ssh_key(cls, ssh_key_path): """ Verify ceph configuration file - check ssh ceph.pub file exists Args: cls: cephadm instance object ssh_key_path: ceph configuration directory """ ssh_key = ssh_key_path if ssh_key_path else __DEFAULT_SSH_PATH log.info("Ceph SSH public key file - default: %s , configured: %s" % (__DEFAULT_SSH_PATH, ssh_key_path)) if not file_or_path_exists(cls.installer, ssh_key): raise BootStrapValidationFailure("Ceph SSH public key file not found") log.info("Ceph SSH public key file found")
def verify_ceph_configuration_file(cls, config_path): """ Verify ceph configuration file - check ceph.conf file exists Args: cls: cephadm instance object config_path: ceph configuration directory """ ceph_conf = config_path if config_path else __DEFAULT_CONF_PATH log.info("Ceph configuration file - default: %s , configured: %s" % (__DEFAULT_CONF_PATH, config_path)) if not file_or_path_exists(cls.installer, ceph_conf): raise BootStrapValidationFailure("Ceph configuration file not found") log.info("Ceph configuration file found")
def verify_ceph_admin_keyring_file(cls, keyring_path): """ Verify ceph configuration output directory - check ceph.keyring file exists Args: cls: cephadm instance object keyring_path: ceph configuration directory """ keyring = keyring_path if keyring_path else __DEFAULT_KEYRING_PATH log.info("Ceph keyring - default: %s , configured: %s" % (__DEFAULT_KEYRING_PATH, keyring_path)) if not file_or_path_exists(cls.installer, keyring): raise BootStrapValidationFailure("Ceph keyring not found") log.info("Ceph Keyring found")
def verify_ceph_config_location(cls, ceph_conf_directory): """ Verify ceph configuration output directory - check ceph config directory exists Args: cls: cephadm instance object ceph_conf_directory: ceph configuration directory """ _dir = ceph_conf_directory if ceph_conf_directory else __DEFAULT_CEPH_DIR log.info("Ceph configuration directory - default: %s , configured: %s" % (__DEFAULT_CEPH_DIR, ceph_conf_directory)) if not file_or_path_exists(cls.installer, _dir): raise BootStrapValidationFailure( "ceph configuration directory not found") log.info("Ceph Configuration Directory found")