sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 1 | /* |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 2 | * Copyright 2015-2016 Open Networking Laboratory |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 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 | */ |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 16 | package org.onosproject.openstacknetworking; |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 17 | |
| 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.net.config.Config; |
| 20 | import org.onosproject.net.config.basics.BasicElementConfig; |
| 21 | |
| 22 | /** |
| 23 | * Handles configuration for OpenstackSwitching app. |
| 24 | */ |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 25 | public class OpenstackNetworkingConfig extends Config<ApplicationId> { |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 26 | public static final String DONOTPUSH = "do_not_push_flows"; |
sanghoshin | f25d2e0 | 2015-11-11 23:07:17 +0900 | [diff] [blame] | 27 | public static final String NEUTRON_SERVER = "neutron_server"; |
| 28 | public static final String KEYSTONE_SERVER = "keystone_server"; |
| 29 | public static final String USER_NAME = "user_name"; |
| 30 | public static final String PASSWORD = "password"; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 31 | public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac"; |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Returns the flag whether the app pushes flows or not. |
| 35 | * |
| 36 | * @return the flag or false if not set |
| 37 | */ |
| 38 | public boolean doNotPushFlows() { |
| 39 | String flag = get(DONOTPUSH, "false"); |
| 40 | return Boolean.valueOf(flag); |
| 41 | } |
| 42 | |
| 43 | /** |
sanghoshin | f25d2e0 | 2015-11-11 23:07:17 +0900 | [diff] [blame] | 44 | * Returns the Neutron server IP address. |
| 45 | * |
| 46 | * @return Neutron server IP |
| 47 | */ |
| 48 | public String neutronServer() { |
| 49 | return get(NEUTRON_SERVER, ""); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Returns the Keystone server IP address. |
| 54 | * |
| 55 | * @return Keystone server IP |
| 56 | */ |
| 57 | public String keystoneServer() { |
| 58 | return get(KEYSTONE_SERVER, ""); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Returns the username for openstack. |
| 63 | * |
| 64 | * @return username for openstack |
| 65 | */ |
| 66 | public String userName() { |
| 67 | return get(USER_NAME, ""); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Returns the password for openstack. |
| 72 | * |
| 73 | * @return password for openstack |
| 74 | */ |
| 75 | public String password() { |
| 76 | return get(PASSWORD, ""); |
| 77 | } |
| 78 | |
| 79 | /** |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 80 | * Returns the MacAddress for physical router. |
| 81 | * |
| 82 | * @return physical router mac |
| 83 | */ |
| 84 | public String physicalRouterMac() { |
| 85 | return get(PHYSICAL_ROUTER_MAC, ""); |
| 86 | } |
| 87 | /** |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 88 | * Sets the flag whether the app pushes flows or not. |
| 89 | * |
| 90 | * @param flag the flag whether the app pushes flows or not |
| 91 | * @return self |
| 92 | */ |
| 93 | public BasicElementConfig doNotPushFlows(boolean flag) { |
| 94 | return (BasicElementConfig) setOrClear(DONOTPUSH, flag); |
| 95 | } |
sanghoshin | f25d2e0 | 2015-11-11 23:07:17 +0900 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * Sets the neutron server IP address. |
| 99 | * |
| 100 | * @param url neutron server IP address |
| 101 | * @return itself |
| 102 | */ |
| 103 | public BasicElementConfig neutronServer(String url) { |
| 104 | return (BasicElementConfig) setOrClear(NEUTRON_SERVER, url); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Sets the keystone server IP address. |
| 109 | * |
| 110 | * @param url keystone server IP address |
| 111 | * @return itself |
| 112 | */ |
| 113 | public BasicElementConfig keystoneServer(String url) { |
| 114 | return (BasicElementConfig) setOrClear(KEYSTONE_SERVER, url); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Sets the username for openstack. |
| 119 | * |
| 120 | * @param username user name for openstack |
| 121 | * @return itself |
| 122 | */ |
| 123 | public BasicElementConfig userName(String username) { |
| 124 | return (BasicElementConfig) setOrClear(USER_NAME, username); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Sets the password for openstack. |
| 129 | * |
| 130 | * @param password password for openstack |
| 131 | * @return itself |
| 132 | */ |
| 133 | public BasicElementConfig password(String password) { |
| 134 | return (BasicElementConfig) setOrClear(PASSWORD, password); |
| 135 | } |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 136 | } |