2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.nemo.tool.sandbox.models;
11 import org.opendaylight.nemo.tool.sandbox.CmdExecutor;
13 import java.util.ArrayList;
14 import java.util.List;
17 * Created by hj on 12/8/15.
19 public class Firewall extends Host {
20 private static Logger log = LoggerFactory.getLogger(Firewall.class);
21 public Firewall(String name,String uuId) {
22 super(NodeType.FIREWALL, name,uuId);
26 protected List<String> generateCommands() {
27 List<String> commands = new ArrayList<String>(generateHost());
30 commands.add("ip netns exec "+getName()+"echo 1 > /proc/sys/net/ipv4/ip_forward");
32 if(connectors.size()>0) {
33 commands.add("ip netns exec route add default dev "+ connectors.get(0));
39 public void uninstall(){
41 CmdExecutor.sshExecute("ip netns del " + getName());
42 } catch (Exception e) {
43 // TODO Auto-generated catch block