Revision 71e52c4a
b/res/layout/list_loadbalancer_item.xml | ||
---|---|---|
2 | 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | 3 |
android:orientation="horizontal" android:layout_width="fill_parent" |
4 | 4 |
android:layout_height="64dip"> |
5 |
<ImageView android:src="@drawable/deny_rule" android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/load_balancer_status"></ImageView> |
|
5 | 6 |
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" |
6 | 7 |
android:orientation="vertical" android:layout_width="fill_parent" |
7 | 8 |
android:layout_height="fill_parent"> |
b/res/layout/view_loadbalancer.xml | ||
---|---|---|
19 | 19 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
20 | 20 |
android:paddingLeft="5dip" android:text="ID: " android:singleLine="false" |
21 | 21 |
android:textStyle="bold" android:id="@+id/id_label"/> |
22 |
<TextView android:id="@+id/view_lb_id" |
|
23 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
24 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" |
|
25 |
android:gravity="fill_horizontal" android:textColor="#fff" android:layout_marginLeft="22dip" android:textSize="20.0sp" android:textStyle="bold" android:paddingLeft="5dip"/> |
|
22 |
<TextView android:layout_marginRight="30dip" android:layout_width="fill_parent" android:id="@+id/view_lb_id" android:layout_height="wrap_content" android:scrollHorizontally="true" android:layout_marginLeft="22dip" android:gravity="fill_horizontal" android:textColor="#fff" android:paddingLeft="5dip" android:textSize="20.0sp" android:textStyle="bold"></TextView> |
|
26 | 23 |
</LinearLayout> |
27 | 24 |
<!-- Name --> |
28 | 25 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
b/res/layout/viewobject.xml | ||
---|---|---|
18 | 18 |
android:text="Container Name" |
19 | 19 |
android:singleLine="false" |
20 | 20 |
/> |
21 |
<TextView android:id="@+id/view_container_name" |
|
22 |
android:layout_height="wrap_content" |
|
23 |
android:layout_width="fill_parent" |
|
24 |
android:layout_marginLeft="22dip" |
|
25 |
android:layout_marginRight="30dip" |
|
26 |
android:scrollHorizontally="true" |
|
27 |
android:gravity="fill_horizontal" |
|
28 |
android:textStyle="bold" |
|
29 |
android:textSize="20.0sp" |
|
30 |
android:textColor="#fff" |
|
31 |
android:layout_marginBottom="15dip" |
|
32 |
/> |
|
21 |
<HorizontalScrollView android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/HorizontalScrollView1" android:layout_marginLeft="22dip" android:layout_marginRight="30dip"> |
|
22 |
<TextView android:id="@+id/view_container_name" android:layout_width="fill_parent" android:layout_marginLeft="22dip" android:layout_marginBottom="15dip" android:scrollHorizontally="true" android:layout_height="wrap_content" android:gravity="fill_horizontal" android:layout_marginRight="30dip" android:textColor="#fff" android:lines="1" android:textSize="20.0sp" android:textStyle="bold" android:fadeScrollbars="true"></TextView> |
|
23 |
</HorizontalScrollView> |
|
33 | 24 |
|
34 | 25 |
<!-- File Size --> |
35 | 26 |
<TextView |
b/src/com/rackspace/cloud/loadbalancer/api/client/LoadBalancer.java | ||
---|---|---|
69 | 69 |
* null |
70 | 70 |
*/ |
71 | 71 |
if(protocol != null){ |
72 |
this.protocol = protocol.toUpperCase();
|
|
72 |
this.protocol = protocol; |
|
73 | 73 |
} else { |
74 | 74 |
this.protocol = ""; |
75 | 75 |
} |
b/src/com/rackspace/cloud/loadbalancer/api/client/LoadBalancerManager.java | ||
---|---|---|
45 | 45 |
this.context = context; |
46 | 46 |
} |
47 | 47 |
|
48 |
public LoadBalancer getLoadBalancerById(long id) throws LoadBalancersException { |
|
48 |
public LoadBalancer getLoadBalancerById(long id) |
|
49 |
throws LoadBalancersException { |
|
49 | 50 |
LoadBalancer loadBalancer = null; |
50 |
//First try DFW |
|
51 |
try{ |
|
52 |
loadBalancer = getLoadBalancerById(id, Account.getLoadBalancerDFWUrl()); |
|
51 |
// First try DFW |
|
52 |
try { |
|
53 |
loadBalancer = getLoadBalancerById(id, |
|
54 |
Account.getLoadBalancerDFWUrl()); |
|
53 | 55 |
loadBalancer.setRegion("DFW"); |
54 |
} catch(LoadBalancersException lbe){
|
|
55 |
//Didn't work |
|
56 |
} catch (LoadBalancersException lbe) {
|
|
57 |
// Didn't work
|
|
56 | 58 |
|
57 | 59 |
} |
58 | 60 |
|
59 |
//Then try ORD |
|
60 |
if(loadBalancer == null){ |
|
61 |
try{ |
|
62 |
loadBalancer = getLoadBalancerById(id, Account.getLoadBalancerORDUrl()); |
|
61 |
// Then try ORD |
|
62 |
if (loadBalancer == null) { |
|
63 |
try { |
|
64 |
loadBalancer = getLoadBalancerById(id, |
|
65 |
Account.getLoadBalancerORDUrl()); |
|
63 | 66 |
loadBalancer.setRegion("ORD"); |
64 |
} |
|
65 |
catch(LoadBalancersException lbe){ |
|
67 |
} catch (LoadBalancersException lbe) { |
|
66 | 68 |
|
67 | 69 |
} |
68 | 70 |
} |
69 | 71 |
|
70 |
//Then try LON |
|
71 |
if(loadBalancer == null){ |
|
72 |
try{ |
|
73 |
loadBalancer = getLoadBalancerById(id, Account.getLoadBalancerLONUrl()); |
|
72 |
// Then try LON |
|
73 |
if (loadBalancer == null) { |
|
74 |
try { |
|
75 |
loadBalancer = getLoadBalancerById(id, |
|
76 |
Account.getLoadBalancerLONUrl()); |
|
74 | 77 |
loadBalancer.setRegion("LON"); |
75 |
} |
|
76 |
catch(LoadBalancersException lbe){ |
|
78 |
} catch (LoadBalancersException lbe) { |
|
77 | 79 |
throw lbe; |
78 | 80 |
} |
79 | 81 |
} |
80 | 82 |
return loadBalancer; |
81 | 83 |
} |
82 | 84 |
|
83 |
private LoadBalancer getLoadBalancerById(long id, String url) throws LoadBalancersException { |
|
85 |
private LoadBalancer getLoadBalancerById(long id, String url) |
|
86 |
throws LoadBalancersException { |
|
84 | 87 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
85 |
HttpGet get = new HttpGet(url + Account.getAccount().getAccountId() + "/loadbalancers/" + id); |
|
88 |
HttpGet get = new HttpGet(url + Account.getAccount().getAccountId() |
|
89 |
+ "/loadbalancers/" + id); |
|
86 | 90 |
LoadBalancer loadBalancer = new LoadBalancer(); |
87 | 91 |
|
88 | 92 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
89 | 93 |
get.addHeader("Accept", "application/xml"); |
90 | 94 |
|
91 |
try {
|
|
92 |
HttpResponse resp = httpclient.execute(get);
|
|
95 |
try { |
|
96 |
HttpResponse resp = httpclient.execute(get); |
|
93 | 97 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
94 | 98 |
String body = responseHandler.handleResponse(resp); |
95 | 99 |
|
96 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) { |
|
100 |
if (resp.getStatusLine().getStatusCode() == 200 |
|
101 |
|| resp.getStatusLine().getStatusCode() == 202) { |
|
97 | 102 |
LoadBalancersXmlParser loadBalancersXMLParser = new LoadBalancersXmlParser(); |
98 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
103 |
SAXParser saxParser = SAXParserFactory.newInstance() |
|
104 |
.newSAXParser(); |
|
99 | 105 |
XMLReader xmlReader = saxParser.getXMLReader(); |
100 | 106 |
xmlReader.setContentHandler(loadBalancersXMLParser); |
101 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
102 |
loadBalancer = loadBalancersXMLParser.getLoadBalancer();
|
|
107 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
108 |
loadBalancer = loadBalancersXMLParser.getLoadBalancer(); |
|
103 | 109 |
} else { |
104 | 110 |
CloudLoadBalancersFaultXMLParser parser = new CloudLoadBalancersFaultXMLParser(); |
105 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
111 |
SAXParser saxParser = SAXParserFactory.newInstance() |
|
112 |
.newSAXParser(); |
|
106 | 113 |
XMLReader xmlReader = saxParser.getXMLReader(); |
107 | 114 |
xmlReader.setContentHandler(parser); |
108 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
109 |
LoadBalancersException cse = parser.getException();
|
|
115 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
116 |
LoadBalancersException cse = parser.getException(); |
|
110 | 117 |
throw cse; |
111 | 118 |
} |
112 | 119 |
} catch (ClientProtocolException e) { |
... | ... | |
133 | 140 |
return loadBalancer; |
134 | 141 |
} |
135 | 142 |
|
136 |
public ArrayList<LoadBalancer> createList() throws LoadBalancersException{ |
|
137 |
|
|
143 |
public ArrayList<LoadBalancer> createList() throws LoadBalancersException {
|
|
144 |
|
|
138 | 145 |
ArrayList<LoadBalancer> loadBalancers = new ArrayList<LoadBalancer>(); |
139 |
|
|
140 |
//if US account |
|
141 |
if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
142 |
loadBalancers.addAll(createSublist(Account.getLoadBalancerORDUrl())); |
|
143 |
for(LoadBalancer loadBalancer: loadBalancers){ |
|
146 |
|
|
147 |
// if US account |
|
148 |
if (Account.getAccount().getAuthServer() |
|
149 |
.equals(Preferences.COUNTRY_US_AUTH_SERVER)) { |
|
150 |
loadBalancers |
|
151 |
.addAll(createSublist(Account.getLoadBalancerORDUrl())); |
|
152 |
for (LoadBalancer loadBalancer : loadBalancers) { |
|
144 | 153 |
loadBalancer.setRegion("ORD"); |
145 | 154 |
} |
146 |
ArrayList<LoadBalancer> DFWloadBalancers = createSublist(Account.getLoadBalancerDFWUrl()); |
|
147 |
for(LoadBalancer loadBalancer: DFWloadBalancers){ |
|
155 |
ArrayList<LoadBalancer> DFWloadBalancers = createSublist(Account |
|
156 |
.getLoadBalancerDFWUrl()); |
|
157 |
for (LoadBalancer loadBalancer : DFWloadBalancers) { |
|
148 | 158 |
loadBalancer.setRegion("DFW"); |
149 | 159 |
} |
150 | 160 |
loadBalancers.addAll(DFWloadBalancers); |
151 | 161 |
} |
152 |
//if UK account |
|
153 |
else if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
|
154 |
loadBalancers.addAll(createSublist(Account.getLoadBalancerLONUrl())); |
|
155 |
for(LoadBalancer loadBalancer: loadBalancers){ |
|
162 |
// if UK account |
|
163 |
else if (Account.getAccount().getAuthServer() |
|
164 |
.equals(Preferences.COUNTRY_UK_AUTH_SERVER)) { |
|
165 |
loadBalancers |
|
166 |
.addAll(createSublist(Account.getLoadBalancerLONUrl())); |
|
167 |
for (LoadBalancer loadBalancer : loadBalancers) { |
|
156 | 168 |
loadBalancer.setRegion("LON"); |
157 | 169 |
} |
158 | 170 |
} |
159 | 171 |
return loadBalancers; |
160 | 172 |
} |
161 | 173 |
|
162 |
public ArrayList<LoadBalancer> createSublist(String regionUrl) throws LoadBalancersException { |
|
174 |
public ArrayList<LoadBalancer> createSublist(String regionUrl) |
|
175 |
throws LoadBalancersException { |
|
163 | 176 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
164 |
HttpGet get = new HttpGet(regionUrl + Account.getAccount().getAccountId() + "/loadbalancers"); |
|
177 |
HttpGet get = new HttpGet(regionUrl |
|
178 |
+ Account.getAccount().getAccountId() + "/loadbalancers"); |
|
165 | 179 |
ArrayList<LoadBalancer> loadBalancers = new ArrayList<LoadBalancer>(); |
166 | 180 |
|
167 | 181 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
168 | 182 |
get.addHeader("Accept", "application/xml"); |
169 | 183 |
|
170 |
try {
|
|
171 |
HttpResponse resp = httpclient.execute(get);
|
|
184 |
try { |
|
185 |
HttpResponse resp = httpclient.execute(get); |
|
172 | 186 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
173 | 187 |
String body = responseHandler.handleResponse(resp); |
174 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) { |
|
188 |
if (resp.getStatusLine().getStatusCode() == 200 |
|
189 |
|| resp.getStatusLine().getStatusCode() == 202) { |
|
175 | 190 |
LoadBalancersXmlParser loadBalancersXMLParser = new LoadBalancersXmlParser(); |
176 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
191 |
SAXParser saxParser = SAXParserFactory.newInstance() |
|
192 |
.newSAXParser(); |
|
177 | 193 |
XMLReader xmlReader = saxParser.getXMLReader(); |
178 | 194 |
xmlReader.setContentHandler(loadBalancersXMLParser); |
179 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
180 |
loadBalancers = loadBalancersXMLParser.getLoadBalancers();
|
|
195 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
196 |
loadBalancers = loadBalancersXMLParser.getLoadBalancers(); |
|
181 | 197 |
} else { |
182 | 198 |
CloudLoadBalancersFaultXMLParser parser = new CloudLoadBalancersFaultXMLParser(); |
183 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
199 |
SAXParser saxParser = SAXParserFactory.newInstance() |
|
200 |
.newSAXParser(); |
|
184 | 201 |
XMLReader xmlReader = saxParser.getXMLReader(); |
185 | 202 |
xmlReader.setContentHandler(parser); |
186 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
187 |
LoadBalancersException cse = parser.getException();
|
|
203 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
204 |
LoadBalancersException cse = parser.getException(); |
|
188 | 205 |
throw cse; |
189 | 206 |
} |
190 | 207 |
} catch (ClientProtocolException e) { |
... | ... | |
211 | 228 |
return loadBalancers; |
212 | 229 |
} |
213 | 230 |
|
214 |
public HttpBundle create(LoadBalancer entity, String regionUrl) throws CloudServersException { |
|
231 |
public HttpBundle create(LoadBalancer entity, String regionUrl) |
|
232 |
throws CloudServersException { |
|
215 | 233 |
HttpResponse resp = null; |
216 | 234 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
217 | 235 |
|
218 |
HttpPost post = new HttpPost(regionUrl + Account.getAccount().getAccountId() + "/loadbalancers"); |
|
236 |
HttpPost post = new HttpPost(regionUrl |
|
237 |
+ Account.getAccount().getAccountId() + "/loadbalancers"); |
|
219 | 238 |
post.addHeader("Content-Type", "application/xml"); |
220 | 239 |
|
221 | 240 |
StringEntity tmp = null; |
... | ... | |
253 | 272 |
return bundle; |
254 | 273 |
} |
255 | 274 |
|
256 |
public HttpBundle delete(LoadBalancer loadBalancer) throws CloudServersException { |
|
275 |
public HttpBundle delete(LoadBalancer loadBalancer) |
|
276 |
throws CloudServersException { |
|
257 | 277 |
HttpResponse resp = null; |
258 | 278 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
259 | 279 |
|
260 |
HttpDelete delete = new HttpDelete(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) + Account.getAccount().getAccountId() |
|
261 |
+ "/loadbalancers/" + loadBalancer.getId()); |
|
280 |
HttpDelete delete = new HttpDelete( |
|
281 |
LoadBalancer.getRegionUrl(loadBalancer.getRegion()) |
|
282 |
+ Account.getAccount().getAccountId() |
|
283 |
+ "/loadbalancers/" + loadBalancer.getId()); |
|
262 | 284 |
delete.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
263 | 285 |
delete.addHeader("Content-Type", "application/xml"); |
264 | 286 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
... | ... | |
266 | 288 |
HttpBundle bundle = new HttpBundle(); |
267 | 289 |
bundle.setCurlRequest(delete); |
268 | 290 |
|
269 |
try {
|
|
291 |
try { |
|
270 | 292 |
resp = httpclient.execute(delete); |
271 | 293 |
bundle.setHttpResponse(resp); |
272 | 294 |
} catch (ClientProtocolException e) { |
... | ... | |
281 | 303 |
CloudServersException cse = new CloudServersException(); |
282 | 304 |
cse.setMessage(e.getLocalizedMessage()); |
283 | 305 |
throw cse; |
284 |
}
|
|
306 |
} |
|
285 | 307 |
return bundle; |
286 | 308 |
} |
287 | 309 |
|
288 |
public HttpBundle update(LoadBalancer loadBalancer, String name, String algorithm, String protocol, String port) throws CloudServersException { |
|
310 |
public HttpBundle update(LoadBalancer loadBalancer, String name, |
|
311 |
String algorithm, String protocol, String port) |
|
312 |
throws CloudServersException { |
|
289 | 313 |
HttpResponse resp = null; |
290 | 314 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
291 | 315 |
|
292 |
HttpPut put = new HttpPut(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) + Account.getAccount().getAccountId() + "/loadbalancers/" + loadBalancer.getId()); |
|
316 |
HttpPut put = new HttpPut(LoadBalancer.getRegionUrl(loadBalancer |
|
317 |
.getRegion()) |
|
318 |
+ Account.getAccount().getAccountId() |
|
319 |
+ "/loadbalancers/" + loadBalancer.getId()); |
|
293 | 320 |
|
294 | 321 |
put.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
295 | 322 |
put.addHeader("Content-Type", "application/xml"); |
296 | 323 |
|
297 |
String xml = "<loadBalancer xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\" " + |
|
298 |
"name=\"" + name + "\" " + |
|
299 |
"algorithm=\"" + algorithm.toUpperCase() + "\" " + |
|
300 |
"protocol=\"" + protocol.toUpperCase() + "\" " + |
|
301 |
"port=\"" + port + "\" />"; |
|
324 |
String xml = "<loadBalancer xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\" " |
|
325 |
+ "name=\"" |
|
326 |
+ name |
|
327 |
+ "\" " |
|
328 |
+ "algorithm=\"" |
|
329 |
+ algorithm.toUpperCase() |
|
330 |
+ "\" " |
|
331 |
+ "protocol=\"" |
|
332 |
+ protocol + "\" " + "port=\"" + port + "\" />"; |
|
302 | 333 |
|
303 | 334 |
StringEntity tmp = null; |
304 | 335 |
try { |
... | ... | |
315 | 346 |
HttpBundle bundle = new HttpBundle(); |
316 | 347 |
bundle.setCurlRequest(put); |
317 | 348 |
|
318 |
try {
|
|
349 |
try { |
|
319 | 350 |
resp = httpclient.execute(put); |
320 | 351 |
bundle.setHttpResponse(resp); |
321 | 352 |
} catch (ClientProtocolException e) { |
... | ... | |
330 | 361 |
CloudServersException cse = new CloudServersException(); |
331 | 362 |
cse.setMessage(e.getLocalizedMessage()); |
332 | 363 |
throw cse; |
333 |
}
|
|
364 |
} |
|
334 | 365 |
return bundle; |
335 | 366 |
} |
336 |
|
|
337 |
public HttpBundle setLogging(LoadBalancer loadBalancer, Boolean setting) throws CloudServersException { |
|
367 |
|
|
368 |
public HttpBundle setLogging(LoadBalancer loadBalancer, Boolean setting) |
|
369 |
throws CloudServersException { |
|
338 | 370 |
HttpResponse resp = null; |
339 | 371 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
340 | 372 |
|
341 |
HttpPut put = new HttpPut(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) + Account.getAccount().getAccountId() + "/loadbalancers/" |
|
342 |
+ loadBalancer.getId() + "/connectionlogging"); |
|
373 |
HttpPut put = new HttpPut(LoadBalancer.getRegionUrl(loadBalancer |
|
374 |
.getRegion()) |
|
375 |
+ Account.getAccount().getAccountId() |
|
376 |
+ "/loadbalancers/" |
|
377 |
+ loadBalancer.getId() |
|
378 |
+ "/connectionlogging"); |
|
343 | 379 |
|
344 | 380 |
put.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
345 | 381 |
put.addHeader("Content-Type", "application/xml"); |
346 | 382 |
|
347 |
String xml = "<connectionLogging xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\" " +
|
|
348 |
"enabled=\"" + setting.toString() + "\" />"; |
|
383 |
String xml = "<connectionLogging xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\" " |
|
384 |
+ "enabled=\"" + setting.toString() + "\" />";
|
|
349 | 385 |
|
350 | 386 |
StringEntity tmp = null; |
351 | 387 |
try { |
... | ... | |
362 | 398 |
HttpBundle bundle = new HttpBundle(); |
363 | 399 |
bundle.setCurlRequest(put); |
364 | 400 |
|
365 |
try {
|
|
401 |
try { |
|
366 | 402 |
resp = httpclient.execute(put); |
367 | 403 |
bundle.setHttpResponse(resp); |
368 | 404 |
} catch (ClientProtocolException e) { |
... | ... | |
377 | 413 |
CloudServersException cse = new CloudServersException(); |
378 | 414 |
cse.setMessage(e.getLocalizedMessage()); |
379 | 415 |
throw cse; |
380 |
}
|
|
416 |
} |
|
381 | 417 |
return bundle; |
382 | 418 |
} |
383 |
|
|
384 |
public HttpBundle setSessionPersistence(LoadBalancer loadBalancer, String setting) throws CloudServersException { |
|
419 |
|
|
420 |
public HttpBundle setSessionPersistence(LoadBalancer loadBalancer, |
|
421 |
String setting) throws CloudServersException { |
|
385 | 422 |
HttpResponse resp = null; |
386 | 423 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
387 | 424 |
|
388 |
HttpPut put = new HttpPut(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) + Account.getAccount().getAccountId() + "/loadbalancers/" |
|
389 |
+ loadBalancer.getId() + "/sessionpersistence"); |
|
425 |
HttpPut put = new HttpPut(LoadBalancer.getRegionUrl(loadBalancer |
|
426 |
.getRegion()) |
|
427 |
+ Account.getAccount().getAccountId() |
|
428 |
+ "/loadbalancers/" |
|
429 |
+ loadBalancer.getId() |
|
430 |
+ "/sessionpersistence"); |
|
390 | 431 |
|
391 | 432 |
put.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
392 | 433 |
put.addHeader("Content-Type", "application/xml"); |
393 | 434 |
|
394 |
String xml = "<sessionPersistence xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\" persistenceType=\"" + setting + "\"/>"; |
|
435 |
String xml = "<sessionPersistence xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\" persistenceType=\"" |
|
436 |
+ setting + "\"/>"; |
|
395 | 437 |
|
396 | 438 |
Log.d("info", "session persist xml is: " + xml); |
397 |
|
|
439 |
|
|
398 | 440 |
StringEntity tmp = null; |
399 | 441 |
try { |
400 | 442 |
tmp = new StringEntity(xml); |
... | ... | |
410 | 452 |
HttpBundle bundle = new HttpBundle(); |
411 | 453 |
bundle.setCurlRequest(put); |
412 | 454 |
|
413 |
try {
|
|
455 |
try { |
|
414 | 456 |
resp = httpclient.execute(put); |
415 | 457 |
bundle.setHttpResponse(resp); |
416 | 458 |
} catch (ClientProtocolException e) { |
... | ... | |
425 | 467 |
CloudServersException cse = new CloudServersException(); |
426 | 468 |
cse.setMessage(e.getLocalizedMessage()); |
427 | 469 |
throw cse; |
428 |
}
|
|
470 |
} |
|
429 | 471 |
return bundle; |
430 | 472 |
} |
431 | 473 |
|
432 |
public HttpBundle disableSessionPersistence(LoadBalancer loadBalancer) throws CloudServersException { |
|
474 |
public HttpBundle disableSessionPersistence(LoadBalancer loadBalancer) |
|
475 |
throws CloudServersException { |
|
433 | 476 |
HttpResponse resp = null; |
434 | 477 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
435 | 478 |
|
436 |
HttpDelete delete = new HttpDelete(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) + Account.getAccount().getAccountId() + "/loadbalancers/" |
|
437 |
+ loadBalancer.getId() + "/sessionpersistence"); |
|
479 |
HttpDelete delete = new HttpDelete( |
|
480 |
LoadBalancer.getRegionUrl(loadBalancer.getRegion()) |
|
481 |
+ Account.getAccount().getAccountId() |
|
482 |
+ "/loadbalancers/" + loadBalancer.getId() |
|
483 |
+ "/sessionpersistence"); |
|
438 | 484 |
|
439 | 485 |
delete.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
440 |
|
|
486 |
|
|
441 | 487 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
442 | 488 |
|
443 | 489 |
HttpBundle bundle = new HttpBundle(); |
444 | 490 |
bundle.setCurlRequest(delete); |
445 | 491 |
|
446 |
try {
|
|
492 |
try { |
|
447 | 493 |
resp = httpclient.execute(delete); |
448 | 494 |
bundle.setHttpResponse(resp); |
449 | 495 |
} catch (ClientProtocolException e) { |
... | ... | |
458 | 504 |
CloudServersException cse = new CloudServersException(); |
459 | 505 |
cse.setMessage(e.getLocalizedMessage()); |
460 | 506 |
throw cse; |
461 |
}
|
|
507 |
} |
|
462 | 508 |
return bundle; |
463 | 509 |
} |
464 | 510 |
|
b/src/com/rackspace/cloud/servers/api/client/Backup.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.Serializable; |
4 | 4 |
|
5 |
import android.util.Log; |
|
6 |
|
|
7 | 5 |
public class Backup implements Serializable { |
8 | 6 |
|
9 | 7 |
/** |
b/src/com/rackspacecloud/android/AddNodesActivity.java | ||
---|---|---|
44 | 44 |
public void onCreate(Bundle savedInstanceState) { |
45 | 45 |
super.onCreate(savedInstanceState); |
46 | 46 |
nodes = (ArrayList<Node>) this.getIntent().getExtras().get("nodes"); |
47 |
possibleNodes = (ArrayList<Server>) this.getIntent().getExtras().get("possibleNodes"); |
|
47 |
//possibleNodes = (ArrayList<Server>) this.getIntent().getExtras().get("possibleNodes");
|
|
48 | 48 |
setContentView(R.layout.addnodes); |
49 | 49 |
restoreState(savedInstanceState); |
50 | 50 |
} |
b/src/com/rackspacecloud/android/BackupServerActivity.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import android.os.AsyncTask; |
13 | 13 |
import android.os.Bundle; |
14 |
import android.util.Log; |
|
15 | 14 |
import android.view.View; |
16 | 15 |
import android.view.View.OnClickListener; |
17 | 16 |
import android.widget.AdapterView; |
b/src/com/rackspacecloud/android/CloudListActivity.java | ||
---|---|---|
31 | 31 |
import android.widget.ProgressBar; |
32 | 32 |
import android.widget.Toast; |
33 | 33 |
|
34 |
/* |
|
35 |
* CloudActivity manages the display and hiding of |
|
36 |
* pDialog. |
|
37 |
* |
|
38 |
* Also provides many accessory methods that are common |
|
39 |
* to Activities |
|
40 |
*/ |
|
34 | 41 |
public class CloudListActivity extends GaListActivity{ |
35 | 42 |
|
36 | 43 |
private Context context; |
... | ... | |
73 | 80 |
|
74 | 81 |
} |
75 | 82 |
|
83 |
@Override |
|
84 |
protected void onStart(){ |
|
85 |
super.onStart(); |
|
86 |
if(isLoading){ |
|
87 |
showDialog(); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
protected void onStop(){ |
|
93 |
super.onStop(); |
|
94 |
if(isLoading){ |
|
95 |
hideDialog(); |
|
96 |
isLoading = true; |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
76 | 100 |
protected final void showAlert(String title, String message) { |
77 | 101 |
try { |
78 | 102 |
AlertDialog alert = new AlertDialog.Builder(this).create(); |
... | ... | |
157 | 181 |
finish(); |
158 | 182 |
} |
159 | 183 |
}); |
160 |
|
|
161 | 184 |
pDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); |
162 | 185 |
pDialog.show(); |
163 | 186 |
pDialog.setContentView(new ProgressBar(this), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); |
... | ... | |
167 | 190 |
protected Context getContext(){ |
168 | 191 |
return context; |
169 | 192 |
} |
170 |
|
|
171 | 193 |
} |
b/src/com/rackspacecloud/android/ContainerObjectsActivity.java | ||
---|---|---|
12 | 12 |
import android.content.Intent; |
13 | 13 |
import android.os.AsyncTask; |
14 | 14 |
import android.os.Bundle; |
15 |
import android.util.Log; |
|
15 | 16 |
import android.view.LayoutInflater; |
16 | 17 |
import android.view.Menu; |
17 | 18 |
import android.view.MenuInflater; |
... | ... | |
40 | 41 |
|
41 | 42 |
private static final int deleteContainer = 0; |
42 | 43 |
private static final int deleteFolder = 1; |
43 |
|
|
44 |
|
|
44 | 45 |
private ContainerObjects[] files; |
45 | 46 |
private static Container container; |
46 | 47 |
public String LOG = "viewFilesActivity"; |
... | ... | |
55 | 56 |
private AddObjectListenerTask task; |
56 | 57 |
private DeleteObjectListenerTask deleteObjTask; |
57 | 58 |
private DeleteContainerListenerTask deleteContainerTask; |
58 |
|
|
59 |
|
|
59 | 60 |
@Override |
60 | 61 |
public void onCreate(Bundle savedInstanceState) { |
61 | 62 |
super.onCreate(savedInstanceState); |
... | ... | |
72 | 73 |
@Override |
73 | 74 |
protected void onSaveInstanceState(Bundle outState) { |
74 | 75 |
super.onSaveInstanceState(outState); |
75 |
|
|
76 |
|
|
76 | 77 |
//files stores all the files in the container |
77 | 78 |
outState.putSerializable("container", files); |
78 |
|
|
79 |
|
|
79 | 80 |
//current path represents where you have "navigated" to |
80 | 81 |
outState.putString("path", currentPath); |
81 |
|
|
82 |
|
|
82 | 83 |
outState.putBoolean("loadingFiles", loadingFiles); |
83 | 84 |
} |
84 | 85 |
|
... | ... | |
86 | 87 |
|
87 | 88 |
protected void restoreState(Bundle state) { |
88 | 89 |
super.restoreState(state); |
89 |
|
|
90 |
|
|
90 | 91 |
/* |
91 | 92 |
* need reference to the app so you can access curDirFiles |
92 | 93 |
* as well as processing status |
93 | 94 |
*/ |
94 | 95 |
app = (AndroidCloudApplication)this.getApplication(); |
95 |
|
|
96 |
|
|
96 | 97 |
if(state != null){ |
97 | 98 |
if(state.containsKey("path")){ |
98 | 99 |
currentPath = state.getString("path"); |
... | ... | |
102 | 103 |
} |
103 | 104 |
|
104 | 105 |
if(state.containsKey("loadingFiles") && state.getBoolean("loadingFiles")){ |
106 |
Log.d("info", "up here"); |
|
105 | 107 |
loadFiles(); |
106 | 108 |
} |
107 |
else{ |
|
108 |
if(state.containsKey("container")){
|
|
109 |
files = (ContainerObjects[]) state.getSerializable("container");
|
|
110 |
if (app.getCurFiles() == null) {
|
|
111 |
displayNoFilesCell();
|
|
112 |
} else {
|
|
113 |
getListView().setDividerHeight(1); // restore divider lines
|
|
114 |
setListAdapter(new FileAdapter());
|
|
109 |
else if(state.containsKey("container")){
|
|
110 |
Log.d("info", "down here");
|
|
111 |
files = (ContainerObjects[]) state.getSerializable("container"); |
|
112 |
if (app.getCurFiles() == null || app.getCurFiles().size() == 0) {
|
|
113 |
displayNoFilesCell(); |
|
114 |
} else { |
|
115 |
getListView().setDividerHeight(1); // restore divider lines |
|
116 |
setListAdapter(new FileAdapter()); |
|
115 | 117 |
|
116 |
} |
|
117 | 118 |
} |
119 |
|
|
118 | 120 |
} |
119 | 121 |
} |
120 | 122 |
else { |
121 | 123 |
currentPath = ""; |
122 | 124 |
loadFiles(); |
123 | 125 |
} |
124 |
|
|
126 |
|
|
125 | 127 |
/* |
126 | 128 |
* if the app is process when we enter the activity |
127 | 129 |
* we must listen for the new curDirFiles list |
... | ... | |
130 | 132 |
task = new AddObjectListenerTask(); |
131 | 133 |
task.execute(); |
132 | 134 |
} |
133 |
|
|
135 |
|
|
134 | 136 |
if(app.isDeletingObject()){ |
135 | 137 |
displayNoFilesCell(); |
136 | 138 |
deleteObjTask = new DeleteObjectListenerTask(); |
137 | 139 |
deleteObjTask.execute(); |
138 | 140 |
} |
139 |
|
|
141 |
|
|
140 | 142 |
if(app.isDeletingContainer()){ |
141 | 143 |
displayNoFilesCell(); |
142 | 144 |
deleteContainerTask = new DeleteContainerListenerTask(); |
... | ... | |
145 | 147 |
|
146 | 148 |
|
147 | 149 |
} |
148 |
|
|
150 |
|
|
149 | 151 |
@Override |
150 | 152 |
protected void onStop(){ |
151 | 153 |
super.onStop(); |
... | ... | |
157 | 159 |
if(task != null){ |
158 | 160 |
task.cancel(true); |
159 | 161 |
} |
160 |
|
|
162 |
|
|
161 | 163 |
if(deleteObjTask != null){ |
162 | 164 |
deleteObjTask.cancel(true); |
163 | 165 |
} |
164 |
|
|
166 |
|
|
165 | 167 |
if(deleteContainerTask != null){ |
166 | 168 |
deleteContainerTask.cancel(true); |
167 | 169 |
} |
... | ... | |
276 | 278 |
if(currentPath.equals("")){ |
277 | 279 |
a[0] = "Empty Container"; |
278 | 280 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.noobjectscell, |
279 |
R.id.no_files_label, a)); |
|
281 |
R.id.no_files_label, a));
|
|
280 | 282 |
} |
281 | 283 |
else{ |
282 | 284 |
a[0] = "No Files"; |
283 | 285 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.nofilescell, |
284 |
R.id.no_files_label, a));
|
|
286 |
R.id.no_files_label, a)); |
|
285 | 287 |
} |
286 | 288 |
getListView().setTextFilterEnabled(true); |
287 | 289 |
getListView().setDividerHeight(0); // hide the dividers so it won't look |
288 |
// like a list row
|
|
290 |
// like a list row |
|
289 | 291 |
getListView().setItemsCanFocus(false); |
290 | 292 |
} |
291 | 293 |
|
... | ... | |
492 | 494 |
@Override |
493 | 495 |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
494 | 496 |
super.onActivityResult(requestCode, resultCode, data); |
495 |
|
|
497 |
|
|
496 | 498 |
if (resultCode == RESULT_OK && requestCode == 56) { |
497 | 499 |
// a sub-activity kicked back, so we want to refresh the server list |
498 | 500 |
loadFiles(); |
499 | 501 |
} |
500 |
|
|
502 |
|
|
501 | 503 |
// deleted file so need to update the list |
502 | 504 |
if (requestCode == 55 && resultCode == 99) { |
503 | 505 |
loadFiles(); |
504 | 506 |
} |
505 |
|
|
507 |
|
|
506 | 508 |
} |
507 | 509 |
|
508 | 510 |
class FileAdapter extends ArrayAdapter<ContainerObjects> { |
... | ... | |
537 | 539 |
return (row); |
538 | 540 |
} |
539 | 541 |
} |
540 |
|
|
542 |
|
|
541 | 543 |
private class LoadFilesTask extends |
542 | 544 |
AsyncTask<String, Void, ArrayList<ContainerObjects>> { |
543 | 545 |
|
544 | 546 |
private CloudServersException exception; |
545 |
|
|
547 |
|
|
546 | 548 |
protected void onPreExecute(){ |
547 | 549 |
showDialog(); |
548 | 550 |
loadingFiles = true; |
... | ... | |
592 | 594 |
protected HttpBundle doInBackground(String... data) { |
593 | 595 |
HttpBundle bundle = null; |
594 | 596 |
try { |
595 |
|
|
597 |
|
|
596 | 598 |
bundle = (new ContainerObjectManager(getContext())).addObject(container.getName(), currentPath, data[0], data[1]); |
597 | 599 |
} catch (CloudServersException e) { |
598 | 600 |
exception = e; |
... | ... | |
628 | 630 |
|
629 | 631 |
private class DeleteObjectTask extends |
630 | 632 |
AsyncTask<Void, Void, HttpBundle> { |
631 |
|
|
633 |
|
|
632 | 634 |
private CloudServersException exception; |
633 |
|
|
635 |
|
|
634 | 636 |
@Override |
635 | 637 |
protected void onPreExecute(){ |
636 | 638 |
showDialog(); |
... | ... | |
638 | 640 |
deleteObjTask = new DeleteObjectListenerTask(); |
639 | 641 |
deleteObjTask.execute(); |
640 | 642 |
} |
641 |
|
|
643 |
|
|
642 | 644 |
@Override |
643 | 645 |
protected HttpBundle doInBackground(Void... arg0) { |
644 | 646 |
HttpBundle bundle = null; |
... | ... | |
650 | 652 |
} |
651 | 653 |
return bundle; |
652 | 654 |
} |
653 |
|
|
655 |
|
|
654 | 656 |
@Override |
655 | 657 |
protected void onPostExecute(HttpBundle bundle) { |
656 | 658 |
app.setDeleteingObject(false); |
... | ... | |
692 | 694 |
deleteContainerTask = new DeleteContainerListenerTask(); |
693 | 695 |
deleteContainerTask.execute(); |
694 | 696 |
} |
695 |
|
|
697 |
|
|
696 | 698 |
@Override |
697 | 699 |
protected HttpBundle doInBackground(String... object) { |
698 | 700 |
HttpBundle bundle = null; |
... | ... | |
740 | 742 |
*/ |
741 | 743 |
private class AddObjectListenerTask extends |
742 | 744 |
AsyncTask<Void, Void, Void> { |
743 |
|
|
745 |
|
|
744 | 746 |
@Override |
745 | 747 |
protected Void doInBackground(Void... arg1) { |
746 | 748 |
|
... | ... | |
764 | 766 |
loadFiles(); |
765 | 767 |
} |
766 | 768 |
} |
767 |
|
|
768 |
|
|
769 |
|
|
770 |
|
|
769 | 771 |
private class DeleteObjectListenerTask extends |
770 | 772 |
AsyncTask<Void, Void, Void> { |
771 |
|
|
773 |
|
|
772 | 774 |
@Override |
773 | 775 |
protected Void doInBackground(Void... arg1) { |
774 | 776 |
|
... | ... | |
793 | 795 |
goUpDirectory(); |
794 | 796 |
} |
795 | 797 |
} |
796 |
|
|
798 |
|
|
797 | 799 |
private class DeleteContainerListenerTask extends |
798 | 800 |
AsyncTask<Void, Void, Void> { |
799 |
|
|
801 |
|
|
800 | 802 |
@Override |
801 | 803 |
protected Void doInBackground(Void... arg1) { |
802 | 804 |
|
b/src/com/rackspacecloud/android/EditLoadBalancerActivity.java | ||
---|---|---|
120 | 120 |
try{ |
121 | 121 |
return (!selectedPort.equals("")) && Integer.valueOf(selectedPort) > 0 && Integer.valueOf(selectedPort) < 65536; |
122 | 122 |
} catch (NumberFormatException nfe){ |
123 |
Log.d("info", "im returning false"); |
|
124 | 123 |
return false; |
125 | 124 |
} |
126 | 125 |
} |
... | ... | |
203 | 202 |
|
204 | 203 |
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
205 | 204 |
if (parent == protocolSpinner) { |
206 |
selectedProtocol = protocols[position].getName();
|
|
205 |
selectedProtocol = Protocol.getProtocols().get(position).getName();
|
|
207 | 206 |
} |
208 | 207 |
|
209 | 208 |
else if (parent == algorithmSpinner){ |
b/src/com/rackspacecloud/android/ListLoadBalancersActivity.java | ||
---|---|---|
16 | 16 |
import android.view.View; |
17 | 17 |
import android.view.ViewGroup; |
18 | 18 |
import android.widget.ArrayAdapter; |
19 |
import android.widget.ImageView; |
|
19 | 20 |
import android.widget.ListView; |
20 | 21 |
import android.widget.TextView; |
21 | 22 |
|
... | ... | |
138 | 139 |
LayoutInflater inflater = getLayoutInflater(); |
139 | 140 |
View row = inflater.inflate(R.layout.list_loadbalancer_item, |
140 | 141 |
parent, false); |
142 |
|
|
143 |
ImageView status = (ImageView) row.findViewById(R.id.load_balancer_status); |
|
144 |
if(loadBalancer.getStatus().equals("DELETED") || loadBalancer.getStatus().equals("PENDING_DELETE")){ |
|
145 |
status.setImageResource(R.drawable.deny_rule); |
|
146 |
} else { |
|
147 |
status.setImageResource(R.drawable.allow_rule); |
|
148 |
} |
|
141 | 149 |
|
142 | 150 |
TextView label = (TextView) row.findViewById(R.id.label); |
143 | 151 |
label.setText(loadBalancer.getName()); |
Also available in: Unified diff