blob: 30b040c5633a00adb9082dd6ea749afa1cd2eee9 [file] [log] [blame]
Hyunsun Moon0e058f22017-04-19 17:00:52 +09001/*
2 * Copyright 2017-present Open Networking Laboratory
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.commands.Command;
19import org.onosproject.cli.AbstractShellCommand;
20import org.onosproject.openstacknode.OpenstackNodeService;
21
22/**
23 * Re-installs flow rules for OpenStack networking.
24 */
25@Command(scope = "onos", name = "openstack-sync-rules",
26 description = "Re-installs flow rules for OpenStack networking")
27public class OpenstackSyncRulesCommand extends AbstractShellCommand {
28
29 @Override
30 protected void execute() {
31 // All handlers in this application reacts the node complete event and
32 // tries to re-configure flow rules for the complete node.
33 OpenstackNodeService nodeService = AbstractShellCommand.get(OpenstackNodeService.class);
34 if (nodeService == null) {
35 error("Failed to re-install flow rules for OpenStack networking.");
36 return;
37 }
38 nodeService.completeNodes().forEach(nodeService::processCompleteState);
39 print("Successfully requested re-installing flow rules.");
40 }
41}