diff --git a/cinderclient/v2/services.py b/cinderclient/v2/services.py index b58efa61a..8cefc342b 100644 --- a/cinderclient/v2/services.py +++ b/cinderclient/v2/services.py @@ -62,3 +62,18 @@ class ServiceManager(base.ManagerWithFind): body = {"host": host, "binary": binary, "disabled_reason": reason} result = self._update("/os-services/disable-log-reason", body) return self.resource_class(self, result, resp=result.request_ids) + + def freeze_host(self, host): + """Freeze the service specified by hostname.""" + body = {"host": host} + return self._update("/os-services/freeze", body) + + def thaw_host(self, host): + """Thaw the service specified by hostname.""" + body = {"host": host} + return self._update("/os-services/thaw", body) + + def failover_host(self, host, backend_id): + """Failover a replicated backend by hostname.""" + body = {"host": host, "backend_id": backend_id} + return self._update("/os-services/failover_host", body) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index a73fd5b33..409675e8f 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -1694,11 +1694,21 @@ def do_extend(cs, args): help='Host name. Default=None.') @utils.arg('--binary', metavar='', default=None, help='Service binary. Default=None.') +@utils.arg('--withreplication', + metavar='', + const=True, + nargs='?', + default=False, + help='Enables or disables display of ' + 'Replication info for c-vol services. Default=False.') @utils.service_type('volumev2') def do_service_list(cs, args): """Lists all services. Filter by host and service binary.""" + replication = strutils.bool_from_string(args.withreplication) result = cs.services.list(host=args.host, binary=args.binary) columns = ["Binary", "Host", "Zone", "Status", "State", "Updated_at"] + if replication: + columns.extend(["Replication Status", "Active Backend ID", "Frozen"]) # NOTE(jay-lau-513): we check if the response has disabled_reason # so as not to add the column when the extended ext is not enabled. if result and hasattr(result[0], 'disabled_reason'): @@ -2655,3 +2665,24 @@ def do_snapshot_unmanage(cs, args): """Stop managing a snapshot.""" snapshot = _find_volume_snapshot(cs, args.snapshot) cs.volume_snapshots.unmanage(snapshot.id) + + +@utils.arg('host', metavar='', help='Host name.') +@utils.service_type('volumev2') +def do_freeze_host(cs, args): + cs.services.freeze_host(args.host) + + +@utils.arg('host', metavar='', help='Host name.') +@utils.service_type('volumev2') +def do_thaw_host(cs, args): + cs.services.thaw_host(args.host) + + +@utils.arg('host', metavar='', help='Host name.') +@utils.arg('--backend_id', + metavar='', + help='ID of backend to failover to (Default=None)') +@utils.service_type('volumev2') +def do_failover_host(cs, args): + cs.services.failover_host(args.host, args.backend_id)