blob: 50e3bc640a4c7f94313b641011d44e609a890ab3 [file] [log] [blame]
Charles Chan9797ebb2020-02-14 13:23:57 -08001/*
2 * Copyright 2020-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.segmentrouting.cli;
17
18import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.Completion;
21import org.apache.karaf.shell.api.action.lifecycle.Service;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.cli.net.DeviceIdCompleter;
24import org.onosproject.net.DeviceId;
25import org.onosproject.segmentrouting.phasedrecovery.api.Phase;
26import org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService;
27
28@Service
29@Command(scope = "onos", name = "sr-pr-set", description = "Set recovery phase of given device")
30
31public class PhasedRecoverySetCommand extends AbstractShellCommand {
32 @Argument(index = 0, name = "deviceId",
33 description = "Device ID",
34 required = true, multiValued = false)
35 @Completion(DeviceIdCompleter.class)
36 private String deviceIdStr;
37
38 @Argument(index = 1, name = "phase",
39 description = "Recovery phase",
40 required = true, multiValued = false)
41 @Completion(PhaseCompleter.class)
42 private String phaseStr;
43
44 @Override
45 protected void doExecute() {
46 DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
47 Phase newPhase = Phase.valueOf(phaseStr);
48
49 PhasedRecoveryService prService = get(PhasedRecoveryService.class);
50 prService.setPhase(deviceId, newPhase);
51 }
52}