diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-10-19 10:14:31 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-10-19 10:14:31 -0700 |
commit | e9bb60be43af477f17b30ee1f2ba205565b7fa15 (patch) | |
tree | 981fd759a44b751fc45cde774f46fda37c11c257 /framework/src/onos/apps/config | |
parent | 74f3941756a1386cbc1fa99ee73fdc8376a0b6a0 (diff) |
Updated onos src tree to commit id 1e60f97ae50c05b94fcb6a10520738bfb5efdfd1
Diffstat (limited to 'framework/src/onos/apps/config')
7 files changed, 0 insertions, 426 deletions
diff --git a/framework/src/onos/apps/config/pom.xml b/framework/src/onos/apps/config/pom.xml deleted file mode 100644 index 1b95c579..00000000 --- a/framework/src/onos/apps/config/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Copyright 2014 Open Networking Laboratory - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.onosproject</groupId> - <artifactId>onos-apps</artifactId> - <version>1.3.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>onos-app-config</artifactId> - <packaging>bundle</packaging> - - <description>Network configuration application</description> - - <properties> - <onos.app.name>org.onosproject.config</onos.app.name> - </properties> - - <dependencies> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onlab-misc</artifactId> - </dependency> - </dependencies> - -</project> diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java deleted file mode 100644 index e092586a..00000000 --- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.config; - -import java.util.Collections; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Object to store address configuration read from a JSON file. - */ -public class AddressConfiguration { - - private List<AddressEntry> addresses; - - /** - * Gets a list of addresses in the system. - * - * @return the list of addresses - */ - public List<AddressEntry> getAddresses() { - return Collections.unmodifiableList(addresses); - } - - /** - * Sets a list of addresses in the system. - * - * @param addresses the list of addresses - */ - @JsonProperty("addresses") - public void setAddresses(List<AddressEntry> addresses) { - this.addresses = addresses; - } - -} diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java deleted file mode 100644 index 35fc4434..00000000 --- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.config; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * Represents a set of addresses bound to a port. - */ -public class AddressEntry { - private String dpid; - private long portNumber; - private List<String> ipAddresses; - private String macAddress; - private Short vlan; - - public String getDpid() { - return dpid; - } - - @JsonProperty("dpid") - public void setDpid(String strDpid) { - this.dpid = strDpid; - } - - public long getPortNumber() { - return portNumber; - } - - @JsonProperty("port") - public void setPortNumber(long portNumber) { - this.portNumber = portNumber; - } - - public List<String> getIpAddresses() { - return ipAddresses; - } - - @JsonProperty("ips") - public void setIpAddresses(List<String> strIps) { - this.ipAddresses = strIps; - } - - public String getMacAddress() { - return macAddress; - } - - @JsonProperty("mac") - public void setMacAddress(String macAddress) { - this.macAddress = macAddress; - } - - public Short getVlan() { - return vlan; - } - - @JsonProperty("vlan") - public void setVlan(short vlan) { - this.vlan = vlan; - } -} diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java deleted file mode 100644 index 4eb87b4a..00000000 --- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.config; - -import static org.slf4j.LoggerFactory.getLogger; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.Service; -import org.onlab.packet.IpAddress; -import org.onlab.packet.IpPrefix; -import org.onlab.packet.MacAddress; -import org.onlab.packet.VlanId; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.host.HostAdminService; -import org.onosproject.net.host.InterfaceIpAddress; -import org.onosproject.net.host.PortAddresses; -import org.slf4j.Logger; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Simple configuration module to read in supplementary network configuration - * from a file. - */ -@Component(immediate = true) -@Service -public class NetworkConfigReader implements NetworkConfigService { - - private final Logger log = getLogger(getClass()); - - // Current working is /opt/onos/apache-karaf-* - // TODO: Set the path to /opt/onos/config - private static final String CONFIG_DIR = "../config"; - private static final String DEFAULT_CONFIG_FILE = "addresses.json"; - private String configFileName = DEFAULT_CONFIG_FILE; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected HostAdminService hostAdminService; - - @Activate - protected void activate() { - AddressConfiguration config = readNetworkConfig(); - if (config != null) { - applyNetworkConfig(config); - } - log.info("Started network config reader"); - } - - @Deactivate - protected void deactivate() { - log.info("Stopped"); - } - - /** - * Reads the network configuration. - * - * @return the network configuration on success, otherwise null - */ - private AddressConfiguration readNetworkConfig() { - File configFile = new File(CONFIG_DIR, configFileName); - ObjectMapper mapper = new ObjectMapper(); - - try { - log.info("Loading config: {}", configFile.getAbsolutePath()); - AddressConfiguration config = - mapper.readValue(configFile, AddressConfiguration.class); - - return config; - } catch (FileNotFoundException e) { - log.warn("Configuration file not found: {}", configFileName); - } catch (IOException e) { - log.error("Error loading configuration", e); - } - - return null; - } - - /** - * Applies the network configuration. - * - * @param config the network configuration to apply - */ - private void applyNetworkConfig(AddressConfiguration config) { - for (AddressEntry entry : config.getAddresses()) { - ConnectPoint cp = new ConnectPoint( - DeviceId.deviceId(dpidToUri(entry.getDpid())), - PortNumber.portNumber(entry.getPortNumber())); - - Set<InterfaceIpAddress> interfaceIpAddresses = new HashSet<>(); - for (String strIp : entry.getIpAddresses()) { - // Get the IP address and the subnet mask length - try { - String[] splits = strIp.split("/"); - if (splits.length != 2) { - throw new IllegalArgumentException( - "Invalid IP address and prefix length format"); - } - // NOTE: IpPrefix will mask-out the bits after the prefix length. - IpPrefix subnet = IpPrefix.valueOf(strIp); - IpAddress addr = IpAddress.valueOf(splits[0]); - InterfaceIpAddress ia = - new InterfaceIpAddress(addr, subnet); - interfaceIpAddresses.add(ia); - } catch (IllegalArgumentException e) { - log.warn("Bad format for IP address in config: {}", strIp); - } - } - - MacAddress macAddress = null; - if (entry.getMacAddress() != null) { - try { - macAddress = MacAddress.valueOf(entry.getMacAddress()); - } catch (IllegalArgumentException e) { - log.warn("Bad format for MAC address in config: {}", - entry.getMacAddress()); - } - } - - VlanId vlan = null; - if (entry.getVlan() == null) { - vlan = VlanId.NONE; - } else { - try { - vlan = VlanId.vlanId(entry.getVlan()); - } catch (IllegalArgumentException e) { - log.warn("Bad format for VLAN id in config: {}", - entry.getVlan()); - vlan = VlanId.NONE; - } - } - - PortAddresses addresses = new PortAddresses(cp, - interfaceIpAddresses, macAddress, vlan); - hostAdminService.bindAddressesToPort(addresses); - } - } - - private static String dpidToUri(String dpid) { - return "of:" + dpid.replace(":", ""); - } -} diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java deleted file mode 100644 index 1d9a895d..00000000 --- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.config; - -/** - * Service interface exported by the Network Configuration. - * - * @deprecated in Drake; see org.onosproject.net.config - */ -@Deprecated -public interface NetworkConfigService { -} diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java deleted file mode 100644 index 6552f206..00000000 --- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Simple configuration module to read in supplementary network configuration - * from a file. - */ -package org.onosproject.config; diff --git a/framework/src/onos/apps/config/src/main/resources/addresses.json b/framework/src/onos/apps/config/src/main/resources/addresses.json deleted file mode 100644 index a88ed62a..00000000 --- a/framework/src/onos/apps/config/src/main/resources/addresses.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "addresses" : [ - { - "dpid" : "00:00:00:00:00:00:00:a3", - "port" : "1", - "ips" : ["192.168.10.101/24"], - "mac" : "00:00:00:00:00:01", - "vlan" : "1" - }, - { - "dpid" : "00:00:00:00:00:00:00:a5", - "port" : "1", - "ips" : ["192.168.20.101/24"], - "mac" : "00:00:00:00:00:01", - "vlan" : "2" - }, - { - "dpid" : "00:00:00:00:00:00:00:a2", - "port" : "1", - "ips" : ["192.168.30.101/24"], - "mac" : "00:00:00:00:00:01" - }, - { - "dpid" : "00:00:00:00:00:00:00:a6", - "port" : "1", - "ips" : ["192.168.40.101/24"], - "mac" : "00:00:00:00:00:01" - }, - { - "dpid" : "00:00:00:00:00:00:00:a4", - "port" : "4", - "ips" : ["192.168.60.101/24"], - "mac" : "00:00:00:00:00:01" - } - ] -} |