blob: eec14f58d2e2d9f9d8b30c11253aa9fbb35881fe [file] [log] [blame]
sanghoshin46297d22015-11-03 17:51:24 +09001/*
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 */
Jian Li7f256f52016-01-24 15:08:05 -080016package org.onosproject.openstackswitching.impl;
sanghoshin46297d22015-11-03 17:51:24 +090017
18import org.onosproject.core.ApplicationId;
19import org.onosproject.net.config.Config;
20import org.onosproject.net.config.basics.BasicElementConfig;
21
22/**
23 * Handles configuration for OpenstackSwitching app.
24 */
25public class OpenstackSwitchingConfig extends Config<ApplicationId> {
26 public static final String DONOTPUSH = "do_not_push_flows";
sanghoshinf25d2e02015-11-11 23:07:17 +090027 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";
sanghoshin46297d22015-11-03 17:51:24 +090031
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 /**
sanghoshinf25d2e02015-11-11 23:07:17 +090043 * 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 /**
sanghoshin46297d22015-11-03 17:51:24 +090079 * 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 }
sanghoshinf25d2e02015-11-11 23:07:17 +090087
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 }
sanghoshin46297d22015-11-03 17:51:24 +0900127}