blob: af389d6b31fbb39a9bbd45f31fb5f7deb4f4444b [file] [log] [blame]
Jian Li7b8c3682019-05-12 13:57:15 +09001/*
2 * Copyright 2019-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.openstacknetworking.cli;
17
18import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.lifecycle.Service;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.openstacknetworking.api.OpenstackHaService;
22
23/**
24 * Shows openstack HA status.
25 */
26@Service
27@Command(scope = "onos", name = "openstack-ha-show",
28 description = "Show openstack active-standby HA status.")
29public class OpenstackHaShowCommand extends AbstractShellCommand {
30
31 private static final String FORMAT = "%-20s%-30s";
32
33 @Override
34 protected void doExecute() {
35 OpenstackHaService service = get(OpenstackHaService.class);
36
37 print(FORMAT, "Status", "Active Node IP");
38
39 print(FORMAT,
40 service.isActive() ? "Active" : "Standby",
41 service.getActiveIp() == null ? "None" : service.getActiveIp().toString());
42 }
43}