blob: b63e6d7a0ba311eddef449914407a51073654b56 [file] [log] [blame]
Saritha80cb8542019-12-09 10:39:20 +05301/*
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.diagnosis.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.osgi.service.component.annotations.Reference;
22import org.osgi.service.component.annotations.ReferenceCardinality;
23import org.apache.karaf.system.SystemService;
24
25@Service
26@Command(scope = "onos", name = "restart-node", description = "restart onos")
27public class RestartNodeCommand extends AbstractShellCommand {
28
29 @Reference(cardinality = ReferenceCardinality.MANDATORY)
30 private SystemService systemService;
31
32 @Override
33 protected void doExecute() {
34 systemService = get(SystemService.class);
35 try {
36 systemService.reboot("now", SystemService.Swipe.CACHE);
37 } catch (Exception e) {
38 log.error("error occured because of {} ", e.getMessage());
39 }
40 }
41
42}