sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | */ |
| 16 | package org.onosproject.openstackswitching; |
| 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 | */ |
| 25 | public class OpenstackSwitchingConfig extends Config<ApplicationId> { |
| 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"; |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Returns the flag whether the app pushes flows or not. |
| 34 | * |
| 35 | * @return the flag or false if not set |
| 36 | */ |
| 37 | public boolean doNotPushFlows() { |
| 38 | String flag = get(DONOTPUSH, "false"); |
| 39 | return Boolean.valueOf(flag); |
| 40 | } |
| 41 | |
| 42 | /** |
sanghoshin | f25d2e0 | 2015-11-11 23:07:17 +0900 | [diff] [blame] | 43 | * Returns the Neutron server IP address. |
| 44 | * |
| 45 | * @return Neutron server IP |
| 46 | */ |
| 47 | public String neutronServer() { |
| 48 | return get(NEUTRON_SERVER, ""); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns the Keystone server IP address. |
| 53 | * |
| 54 | * @return Keystone server IP |
| 55 | */ |
| 56 | public String keystoneServer() { |
| 57 | return get(KEYSTONE_SERVER, ""); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns the username for openstack. |
| 62 | * |
| 63 | * @return username for openstack |
| 64 | */ |
| 65 | public String userName() { |
| 66 | return get(USER_NAME, ""); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Returns the password for openstack. |
| 71 | * |
| 72 | * @return password for openstack |
| 73 | */ |
| 74 | public String password() { |
| 75 | return get(PASSWORD, ""); |
| 76 | } |
| 77 | |
| 78 | /** |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 79 | * Sets the flag whether the app pushes flows or not. |
| 80 | * |
| 81 | * @param flag the flag whether the app pushes flows or not |
| 82 | * @return self |
| 83 | */ |
| 84 | public BasicElementConfig doNotPushFlows(boolean flag) { |
| 85 | return (BasicElementConfig) setOrClear(DONOTPUSH, flag); |
| 86 | } |
sanghoshin | f25d2e0 | 2015-11-11 23:07:17 +0900 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Sets the neutron server IP address. |
| 90 | * |
| 91 | * @param url neutron server IP address |
| 92 | * @return itself |
| 93 | */ |
| 94 | public BasicElementConfig neutronServer(String url) { |
| 95 | return (BasicElementConfig) setOrClear(NEUTRON_SERVER, url); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Sets the keystone server IP address. |
| 100 | * |
| 101 | * @param url keystone server IP address |
| 102 | * @return itself |
| 103 | */ |
| 104 | public BasicElementConfig keystoneServer(String url) { |
| 105 | return (BasicElementConfig) setOrClear(KEYSTONE_SERVER, url); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Sets the username for openstack. |
| 110 | * |
| 111 | * @param username user name for openstack |
| 112 | * @return itself |
| 113 | */ |
| 114 | public BasicElementConfig userName(String username) { |
| 115 | return (BasicElementConfig) setOrClear(USER_NAME, username); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Sets the password for openstack. |
| 120 | * |
| 121 | * @param password password for openstack |
| 122 | * @return itself |
| 123 | */ |
| 124 | public BasicElementConfig password(String password) { |
| 125 | return (BasicElementConfig) setOrClear(PASSWORD, password); |
| 126 | } |
sanghoshin | 46297d2 | 2015-11-03 17:51:24 +0900 | [diff] [blame] | 127 | } |