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.renderer.openflow.physicalnetwork;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNodeInstance;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalPortInstance;
14 import java.io.BufferedReader;
15 import java.io.FileInputStream;
16 import java.io.IOException;
17 import java.io.InputStreamReader;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 * Created by hj on 11/5/15.
24 private static final Logger log = LoggerFactory.getLogger(Utils.class);
25 protected static PhysicalNodeInstance.NodeType getNodeType(String strType){
28 return PhysicalNodeInstance.NodeType.Switch;
30 return PhysicalNodeInstance.NodeType.Router;
32 return PhysicalNodeInstance.NodeType.Firewall;
34 return PhysicalNodeInstance.NodeType.Loadbalancer;
38 protected static PhysicalPortInstance.PortType getPortType(String strType){
41 return PhysicalPortInstance.PortType.External;
43 return PhysicalPortInstance.PortType.Internal;
45 protected static String readFile(String Path){
46 BufferedReader reader = null;
49 FileInputStream fileInputStream = new FileInputStream(Path);
50 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
51 reader = new BufferedReader(inputStreamReader);
52 String tempString = null;
53 while((tempString = reader.readLine()) != null){
54 laststr += tempString;
57 }catch(IOException e){
58 // TODO Auto-generated catch block
59 log.error("Exception:",e);
64 } catch (IOException e) {
65 // TODO Auto-generated catch block
66 log.error("Exception:",e);