Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | */ |
Thomas Vachuska | 4998caa | 2015-08-26 13:28:38 -0700 | [diff] [blame] | 16 | package org.onosproject.net.config.basics; |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 17 | |
| 18 | import org.onosproject.net.Device; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | |
| 21 | /** |
| 22 | * Basic configuration for network infrastructure devices. |
| 23 | */ |
| 24 | public class BasicDeviceConfig extends BasicElementConfig<DeviceId> { |
| 25 | |
| 26 | public static final String TYPE = "type"; |
| 27 | public static final String DRIVER = "driver"; |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame^] | 28 | public static final String MANAGEMENT_ADDRESS = "managementAddress"; |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Returns the device type. |
| 32 | * |
| 33 | * @return device type override |
| 34 | */ |
| 35 | public Device.Type type() { |
| 36 | return get(TYPE, Device.Type.SWITCH, Device.Type.class); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Sets the device type. |
| 41 | * |
| 42 | * @param type device type override |
| 43 | * @return self |
| 44 | */ |
| 45 | public BasicDeviceConfig type(Device.Type type) { |
| 46 | return (BasicDeviceConfig) setOrClear(TYPE, type); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the device driver name. |
| 51 | * |
| 52 | * @return driver name of null if not set |
| 53 | */ |
| 54 | public String driver() { |
| 55 | return get(DRIVER, subject.toString()); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Sets the driver name. |
| 60 | * |
| 61 | * @param driverName new driver name; null to clear |
| 62 | * @return self |
| 63 | */ |
| 64 | public BasicElementConfig driver(String driverName) { |
| 65 | return (BasicElementConfig) setOrClear(DRIVER, driverName); |
| 66 | } |
| 67 | |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame^] | 68 | /** |
| 69 | * Returns the device management ip (ip:port). |
| 70 | * |
| 71 | * @return device management address (ip:port) or null if not set |
| 72 | */ |
| 73 | public String managementAddress() { |
| 74 | return get(MANAGEMENT_ADDRESS, null); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Sets the driver name. |
| 79 | * |
| 80 | * @param managementAddress new device management address (ip:port); null to clear |
| 81 | * @return self |
| 82 | */ |
| 83 | public BasicElementConfig managementAddress(String managementAddress) { |
| 84 | return (BasicElementConfig) setOrClear(MANAGEMENT_ADDRESS, managementAddress); |
| 85 | } |
| 86 | |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 87 | // TODO: device port meta-data to be configured via BasicPortsConfig |
| 88 | // TODO: device credentials/keys |
| 89 | |
| 90 | } |