def run(ceph_cluster, **kw): """ Ceph-admin module to manage ceph-osd service Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data check ceph.ceph_admin.osd for test config """ log.info("Running Ceph-admin Monitor test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") log.info("Executing OSD %s service" % command) osd = OSD(cluster=ceph_cluster, **config) try: method = fetch_method(osd, command) method(config) finally: # Get cluster state get_cluster_state(osd, CLUSTER_STATE) return 0
def run(ceph_cluster, **kw): """ Ceph-admin module to manage Crash service Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data check ceph.ceph_admin.crash for test config """ log.info("Running Ceph-admin Crash service test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") log.info("Executing Crash %s service" % command) crash = Crash(cluster=ceph_cluster, **config) try: method = fetch_method(crash, command) method(config) finally: # Get cluster state get_cluster_state(crash) return 0
def run(ceph_cluster, **kw): """ Executing the service operation using cephadm ceph orch remove|restart|start|stop|reconfigure|redeploy <service name>. Args: ceph_cluster kw: command and service are passed from the test case. Example: Testing ceph orch restart mon config: command: restart service: mon Returns: output, error returned by the command. """ config = kw.get("config") # Manage Ceph using ceph-admin orchestration command = config.pop("command") log.info("Executing service %s service" % command) orch = Orch(cluster=ceph_cluster, **config) try: method = fetch_method(orch, command) method(config) finally: # Get cluster state get_cluster_state(orch) return 0
def run(ceph_cluster, **kw): """ Ceph-admin module to manage ceph-iscsi service Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data check ceph.ceph_admin.iscsi for test config """ log.info("Running Ceph-admin Provisioning test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") service = config.pop("service") _monitoring = MONITORING[service] log.info("Executing %s %s service" % (service, command)) monitoring = _monitoring(cluster=ceph_cluster, **config) method = fetch_method(monitoring, command) method(config) return 0
def run(ceph_cluster, **kw): """ Ceph-admin module to manage ceph-metadata service Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data check ceph.ceph_admin.rgw for test config """ log.info("Running Ceph-admin Rados-GW( RGW ) test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") log.info("Executing RGW %s service" % command) rgw = RGW(cluster=ceph_cluster, **config) try: method = fetch_method(rgw, command) method(config) finally: # Get cluster state get_cluster_state(rgw) return 0
def run(ceph_cluster, **kw): """Ceph-admin module to manage ceph-dashboard service. check ceph.ceph_admin.dashboard for test config. Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object. kw: keyword arguments from test data. Returns: value 0 on success. """ log.info("Running Ceph-admin Dashboard test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") log.info("Executing dashboard %s operation" % command) instance = CephAdmin(cluster=ceph_cluster, **config) try: method = fetch_method(dashboard, command) method(instance, config.get("args")) finally: # Get cluster state get_cluster_state(instance) return 0
def run(ceph_cluster, **kw): """ Cephadm Bootstrap, Managing hosts with options and full cluster deployment at single call are supported. Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data - Manage host operations like, - Add hosts with/without labels and IP address - Add/Remove labels to/from existing node - Set Address to node. - Remove hosts host_ops keys are definition names are defined under CephAdmin.HostMixin should be used to call that respective method. supported definition names for host_ops are host_add, attach_label, remove_label, set_address and host_remove. for example., - test: name: Add host desc: Add new host node with IP address module: test_host.py config: command: host service: add | remove | label_add | label_remove | set_address base_cmd_args: nodes: - "node3" attach_address: true add_label: false """ log.info("Running Cephadm Host test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") service = config.pop("service", "") log.info("Executing %s %s" % (service, command)) host = Host(cluster=ceph_cluster, **config) try: method = fetch_method(host, command) method(config) finally: # Get cluster state get_cluster_state(host, CLUSTER_STATE) return 0
def run(ceph_cluster, **kw): """ Cephadm Bootstrap Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data - Bootstrap cluster with default or custom image and returns after cephadm.bootstrap. To use default image, set 'registry'. Example: config: command: bootstrap base_cmd_args: verbose: true args: custom_image: true | false mon-ip: <node_name> mgr-id: <mgr_id> fsid: <id> """ config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build config["overrides"] = kw.get("test_data", {}).get("custom-config") # Manage Ceph using ceph-admin orchestration command = config.pop("command") service = config.pop("service", "") log.info("Executing %s %s" % (service, command)) instance = CephAdmin(cluster=ceph_cluster, **config) if "shell" in command: instance.shell(args=config["args"]) return 0 try: method = fetch_method(instance, command) out, err = method(config) # Verification of arguments # bootstrap response through stdout & stderr are combined here # currently console response coming through stderr. args = config.get("args", {}) verify_bootstrap(instance, args, out + err) finally: # Get cluster state get_cluster_state(instance) return 0
def run(ceph_cluster, **kw): """ Manage Cephadm client-keyring operations, - list - remove client-keyring - set client-keyring Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data for example., config: command: ls | rm | set service: client-keyring args: format: json-pretty base_cmd_args: nodes: - "node3" """ log.info("Running Cephadm client-keyring test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") service = config.pop("service", "") log.info("Executing %s %s" % (service, command)) client_keyring = ClientKeyring(cluster=ceph_cluster, **config) try: method = fetch_method(client_keyring, command) method(config) finally: # Get cluster state get_cluster_state(client_keyring, CLUSTER_STATE) return 0
def run(ceph_cluster, **kw): """ Executing the device operation using cephadm ceph orch device ls ceph orch device zap <hostname> <path> [--force] Args: ceph_cluster kw: command and service are passed from the test case. Example: Testing ceph orch device zap node3:/dev/vdb cconfig: command: zap base_cmd_args: verbose: true pos_args: - "node3" - "/dev/vdb" Returns: output, error returned by the command. """ config = kw.get("config") # Manage Ceph using ceph-admin orchestration command = config.pop("command") log.info("Executing service %s service" % command) device = Device(cluster=ceph_cluster, **config) try: method = fetch_method(device, command) method(config) finally: # Get cluster state get_cluster_state(device) return 0
def run(ceph_cluster, **kw): """ Ceph-admin module to manage monitor service Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data check ceph.ceph_admin.mon for test config """ log.info("Running Ceph-admin Monitor test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build # Manage Ceph using ceph-admin orchestration command = config.pop("command") log.info("Executing MON %s service" % command) monitor = Mon(cluster=ceph_cluster, **config) method = fetch_method(monitor, command) method(config) return 0
def run(ceph_cluster: Ceph, **kwargs) -> int: """ Return the status of the test execution run with the provided keyword arguments. Unlike other test suites, "steps" has been introduced to support workflow style execution along with customization. Args: ceph_cluster: Ceph cluster object kwargs: Key/value pairs of configuration information to be used in the test. Returns: int - 0 when the execution is successful else 1 (for failure). Example: - test: name: cluster deployment desc: Deploy a minimal cluster config: verify_cluster_health: true | false steps: - config: command: bootstrap service: cephadm base_cmd_args: verbose: true args: mon-ip: node1 - config: command: add_hosts service: host args: attach_ip_address: true labels: apply-all-labels - config: command: mon service: mon args: placement: label: mon - config: command: mgr service: mgr args: placement: label: mgr - config: command: apply service: osd args: all-available-devices: true - config: command: shell args: - ceph osd pool create <pool_name> 3 3 replicated """ LOG.info("Starting Ceph cluster deployment.") config = kwargs["config"] config["overrides"] = kwargs.get("test_data", {}).get("custom-config") cephadm = CephAdmin(cluster=ceph_cluster, **config) try: steps = config.get("steps", []) for step in steps: cfg = step["config"] command = cfg.pop("command") if command == "shell": cephadm.shell(**cfg) continue obj = SERVICE_MAP[cfg["service"]](cluster=ceph_cluster, **config) func = fetch_method(obj, command) func(cfg) if config.get("verify_cluster_health"): cephadm.cluster.check_health( rhbuild=config.get("rhbuild"), client=cephadm.installer ) if config.get("verify_log_files"): isvalid = validate_log_file_after_enable(cephadm) if not isvalid: LOG.error("Log file validation failure") return 1 except BaseException as be: # noqa LOG.error(be, exc_info=True) return 1 finally: # Get cluster state get_cluster_state(cephadm) return 0
def run(ceph_cluster, **kw): """ Cephadm Bootstrap, Managing hosts with options and full cluster deployment at single call are supported. Args: ceph_cluster (ceph.ceph.Ceph): Ceph cluster object kw: test data The test data should be framed as per the below support, - Bootstrap cluster with default or custom image and returns after cephadm.bootstrap. To use default image, set 'registry'. Example: config: command: bootstrap base_cmd_args: verbose: true args: custom_image: true | false mon-ip: <node_name> mgr-id: <mgr_id> fsid: <id> - Manage host operations like, - Add hosts with/without labels and IP address - Add/Remove labels to/from existing node - Set Address to node. - Remove hosts host_ops keys are definition names are defined under CephAdmin.HostMixin should be used to call that respective method. supported definition names for host_ops are host_add, attach_label, remove_label, set_address and host_remove. for example., - test: name: Add host desc: Add new host node with IP address module: test_cephadm.py config: command: host service: add | remove | label_add | label_remove | set_address base_cmd_args: nodes: - "node3" attach_address: true add_label: false """ log.info("Running cephadm test") config = kw.get("config") build = config.get("build", config.get("rhbuild")) ceph_cluster.rhcs_version = build if config.get("skip_setup") is True: log.info("Skipping setup of ceph cluster") return 0 # Manage Ceph using ceph-admin orchestration command = config.pop("command") service = config.pop("service", "") log.info("Executing %s %s" % (service, command)) if command in CephAdmin.direct_calls: cephadm = CephAdmin(cluster=ceph_cluster, **config) method = fetch_method(cephadm, command) elif service in Host.SERVICE_NAME: host = Host(cluster=ceph_cluster, **config) method = fetch_method(host, command) else: raise NotImplementedError if "shell" in command: method(args=config["args"]) else: method(config) return 0
def run(ceph_cluster: Ceph, **kwargs) -> int: """ Return the status of the test execution run with the provided keyword arguments. Unlike other test suites, "steps" has been introduced to support workflow style execution along with customization. Args: ceph_cluster: Ceph cluster object kwargs: Key/value pairs of configuration information to be used in the test. Returns: int - 0 when the execution is successful else 1 (for failure). Example: - test: name: cluster deployment desc: Deploy a minimal cluster config: steps: - config: command: bootstrap service: cephadm base_cmd_args: verbose: true args: mon-ip: node1 - config: command: add_hosts service: host args: attach_ip_address: true labels: apply-all-labels - config: command: mon service: mon args: placement: label: mon - config: command: mgr service: mgr args: placement: label: mgr - config: command: apply service: osd args: all-available-devices: true - config: command: shell args: - ceph osd pool create <pool_name> 3 3 replicated """ LOG.info("Starting Ceph cluster deployment.") try: config = kwargs["config"] cephadm = CephAdmin(cluster=ceph_cluster, **config) steps = config.get("steps") for step in steps: cfg = step["config"] if cfg["command"] == "shell": cephadm.shell(args=cfg["args"]) continue obj = SERVICE_MAP[cfg["service"]](cluster=ceph_cluster, **config) func = fetch_method(obj, cfg["command"]) func(cfg) return 0 except BaseException as be: # noqa LOG.error(be, exc_info=True) return 1