Revision 403bb53b
b/AndroidManifest.xml | ||
---|---|---|
131 | 131 |
<activity android:name=".EditLoadBalancerActivity"></activity> |
132 | 132 |
<activity android:name=".AddMoreNodesActivity"></activity> |
133 | 133 |
<activity android:name=".AddExternalNodeActivity"></activity> |
134 |
<activity android:name=".SharedVipActivity"></activity> |
|
134 | 135 |
|
135 | 136 |
|
136 | 137 |
|
b/res/layout/addnodes.xml | ||
---|---|---|
4 | 4 |
android:layout_height="fill_parent"> |
5 | 5 |
<RelativeLayout android:layout_width="fill_parent" |
6 | 6 |
android:id="@+id/nodes_relative" android:layout_height="fill_parent"> |
7 |
<ScrollView android:layout_height="wrap_content" |
|
8 |
android:orientation="vertical" android:layout_width="wrap_content" |
|
9 |
android:id="@+id/node_scroll" android:layout_above="@+id/submit_nodes_button"> |
|
10 |
<LinearLayout android:layout_width="fill_parent" |
|
11 |
android:id="@+id/nodes_linear_layout" android:layout_height="fill_parent"> |
|
12 |
<ListView android:layout_weight="1" android:layout_width="fill_parent" |
|
13 |
android:cacheColorHint="@android:color/transparent" |
|
14 |
android:layout_height="417dp" android:id="@android:id/list"></ListView> |
|
15 |
</LinearLayout> |
|
16 |
</ScrollView> |
|
17 |
<LinearLayout android:id="@+id/linearLayout1" |
|
18 |
android:layout_width="wrap_content" android:layout_height="wrap_content" |
|
19 |
android:layout_alignParentRight="true" |
|
20 |
android:layout_alignParentLeft="true" android:layout_below="@+id/node_scroll" |
|
21 |
android:gravity="center_horizontal"> |
|
22 |
<Button android:id="@+id/submit_nodes_button" |
|
23 |
android:layout_marginBottom="15dip" android:layout_height="wrap_content" |
|
24 |
android:layout_marginTop="5dip" android:text="Add Selected Nodes" |
|
25 |
android:layout_width="145dip"></Button> |
|
26 |
<Button android:layout_marginBottom="15dip" |
|
27 |
android:layout_height="wrap_content" android:layout_marginTop="5dip" |
|
28 |
android:id="@+id/add_external_node" android:text="Add External Node" |
|
29 |
android:layout_width="145dip"></Button> |
|
7 |
<LinearLayout android:layout_width="fill_parent" android:layout_marginTop="5dip" android:layout_height="wrap_content" android:gravity="center_horizontal" android:layout_marginBottom="5dip" android:layout_alignParentBottom="true" android:id="@+id/button_row"> |
|
8 |
<Button android:layout_width="130dip" android:text="Add Selected Nodes" android:layout_height="wrap_content" android:id="@+id/submit_nodes_button"></Button> |
|
9 |
<Button android:layout_width="130dip" android:text="Add External Node" android:layout_height="wrap_content" android:id="@+id/add_external_node"></Button> |
|
10 |
</LinearLayout> |
|
11 |
<LinearLayout android:layout_height="fill_parent" android:orientation="vertical" android:layout_width="fill_parent" android:id="@+id/nodes_linear_layout" android:layout_above="@+id/button_row"> |
|
12 |
<ListView android:layout_width="fill_parent" android:id="@android:id/list" android:cacheColorHint="@android:color/transparent" android:layout_height="fill_parent"></ListView> |
|
30 | 13 |
</LinearLayout> |
31 | 14 |
</RelativeLayout> |
32 | 15 |
</LinearLayout> |
b/res/layout/editnodes.xml | ||
---|---|---|
4 | 4 |
android:layout_height="fill_parent"> |
5 | 5 |
<RelativeLayout android:layout_width="fill_parent" |
6 | 6 |
android:id="@+id/nodes_relative" android:layout_height="fill_parent"> |
7 |
<ScrollView android:layout_height="wrap_content" |
|
8 |
android:orientation="vertical" android:layout_width="wrap_content" |
|
9 |
android:id="@+id/node_scroll" android:layout_above="@+id/submit_nodes_button"> |
|
10 |
<LinearLayout android:layout_width="fill_parent" |
|
11 |
android:id="@+id/nodes_linear_layout" android:layout_height="fill_parent"> |
|
12 |
<ListView android:layout_weight="1" android:layout_width="fill_parent" |
|
13 |
android:cacheColorHint="@android:color/transparent" |
|
14 |
android:layout_height="417dp" android:id="@android:id/list"></ListView> |
|
15 |
</LinearLayout> |
|
16 |
</ScrollView> |
|
7 |
<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/nodes_linear_layout"> |
|
8 |
<ListView android:layout_width="fill_parent" android:layout_weight="1" android:id="@android:id/list" android:cacheColorHint="@android:color/transparent" android:layout_height="fill_parent"></ListView> |
|
9 |
</LinearLayout> |
|
17 | 10 |
<LinearLayout android:id="@+id/linearLayout1" |
18 | 11 |
android:layout_width="wrap_content" android:layout_height="wrap_content" |
19 | 12 |
android:layout_alignParentRight="true" |
20 | 13 |
android:layout_alignParentLeft="true" android:layout_below="@+id/node_scroll" |
21 |
android:gravity="center_horizontal"> |
|
14 |
android:gravity="center_horizontal" android:layout_alignParentBottom="true">
|
|
22 | 15 |
<Button android:id="@+id/submit_nodes_button" |
23 |
android:layout_marginBottom="15dip" android:layout_height="wrap_content"
|
|
24 |
android:layout_marginTop="5dip" android:layout_width="145dip" android:text="Add More Nodes"></Button>
|
|
16 |
android:layout_height="wrap_content" |
|
17 |
android:layout_marginTop="5dip" android:text="Add More Nodes" android:layout_marginBottom="5dip" android:layout_width="130dip"></Button>
|
|
25 | 18 |
</LinearLayout> |
26 | 19 |
</RelativeLayout> |
27 | 20 |
</LinearLayout> |
b/res/layout/list_vips.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:orientation="vertical" android:layout_width="fill_parent" |
|
4 |
android:layout_height="fill_parent"> |
|
5 |
<RelativeLayout android:id="@+id/LinearLayout1" xmlns:android="http://schemas.android.com/apk/res/android" |
|
6 |
android:orientation="vertical" android:layout_width="fill_parent" |
|
7 |
android:layout_height="fill_parent"> |
|
8 |
<ListView android:cacheColorHint="@android:color/transparent" android:layout_width="fill_parent" android:id="@+id/android:list" android:layout_height="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_above="@+id/textView1"></ListView> |
|
9 |
<TextView android:layout_width="fill_parent" android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Based on the Protocol / Port you chose for this load balancer, some Virtual IPs may not be selectable in the list below. "></TextView> |
|
10 |
</RelativeLayout> |
|
11 |
</LinearLayout> |
|
12 |
|
|
13 |
|
b/res/layout/sharedvipcell.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout |
|
3 |
xmlns:android="http://schemas.android.com/apk/res/android" |
|
4 |
android:layout_width="fill_parent" android:paddingTop="2.5dip" android:paddingBottom="2.5dip" android:layout_height="64dip" android:orientation="horizontal"> |
|
5 |
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:orientation="vertical"> |
|
6 |
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ip_row" android:layout_marginLeft="5dip"> |
|
7 |
<TextView android:scrollbars="vertical" android:id="@+id/vip_address" android:layout_width="fill_parent" android:maxLines="1" android:layout_height="wrap_content" android:layout_weight="1" android:text="2001:4801:7901:0000:0704:cf69:0000:0005"></TextView> |
|
8 |
</LinearLayout> |
|
9 |
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout1"> |
|
10 |
<TextView android:id="@+id/load_balancer_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dip" android:text="test"></TextView> |
|
11 |
<TextView android:id="@+id/vip_protocol" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:text="HTTP(80)"></TextView> |
|
12 |
</LinearLayout> |
|
13 |
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/type_row"> |
|
14 |
<TextView android:id="@+id/vip_type" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dip" android:text="Type"></TextView> |
|
15 |
</LinearLayout> |
|
16 |
</LinearLayout> |
|
17 |
|
|
18 |
</LinearLayout> |
b/res/layout/updateloadbalancer.xml | ||
---|---|---|
13 | 13 |
android:textStyle="bold" android:singleLine="false" |
14 | 14 |
android:layout_height="wrap_content" android:paddingLeft="5dip" |
15 | 15 |
android:layout_gravity="center_vertical" android:text="Name" |
16 |
android:layout_width="wrap_content" android:textColor="#333"></TextView>
|
|
16 |
android:layout_width="wrap_content"></TextView> |
|
17 | 17 |
<EditText android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginRight="20dip" |
18 | 18 |
android:layout_width="wrap_content" android:id="@+id/edit_lb_name_text"> |
19 | 19 |
<requestFocus></requestFocus> |
... | ... | |
26 | 26 |
android:textStyle="bold" android:singleLine="false" |
27 | 27 |
android:layout_height="wrap_content" android:paddingLeft="5dip" |
28 | 28 |
android:layout_gravity="center_vertical" android:text="Protocol" |
29 |
android:layout_width="wrap_content" android:textColor="#333"></TextView>
|
|
29 |
android:layout_width="wrap_content"></TextView> |
|
30 | 30 |
<Spinner android:id="@+id/edit_protocol_spinner" |
31 | 31 |
android:layout_weight="1" android:layout_height="wrap_content" |
32 | 32 |
android:layout_marginRight="20dip" android:layout_width="wrap_content"></Spinner> |
... | ... | |
38 | 38 |
android:textStyle="bold" android:singleLine="false" |
39 | 39 |
android:layout_height="wrap_content" android:paddingLeft="5dip" |
40 | 40 |
android:layout_gravity="center_vertical" android:text="Port" |
41 |
android:layout_width="wrap_content" android:textColor="#333"></TextView>
|
|
41 |
android:layout_width="wrap_content"></TextView> |
|
42 | 42 |
<EditText android:inputType="number" android:layout_height="wrap_content" |
43 | 43 |
android:id="@+id/edit_port_text" android:layout_weight="1" |
44 | 44 |
android:layout_marginRight="20dip" android:layout_width="fill_parent"></EditText> |
... | ... | |
50 | 50 |
android:textStyle="bold" android:singleLine="false" |
51 | 51 |
android:layout_height="wrap_content" android:paddingLeft="5dip" |
52 | 52 |
android:layout_gravity="center_vertical" android:text="Algorithm" |
53 |
android:layout_width="wrap_content" android:textColor="#333"></TextView>
|
|
53 |
android:layout_width="wrap_content"></TextView> |
|
54 | 54 |
<Spinner android:layout_weight="1" android:layout_height="wrap_content" |
55 | 55 |
android:layout_marginRight="20dip" android:layout_width="wrap_content" android:id="@+id/edit_algorithm_spinner"></Spinner> |
56 | 56 |
</TableRow> |
b/res/layout/view_add_loadbalancer.xml | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
2 | 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | 3 |
android:id="@+id/view_loadbalncer_layout" android:orientation="vertical" |
4 |
android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="1"> |
|
4 |
android:layout_width="fill_parent" android:layout_height="fill_parent" |
|
5 |
android:weightSum="1"> |
|
5 | 6 |
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" |
6 | 7 |
android:layout_width="fill_parent" android:layout_height="fill_parent"> |
7 |
<LinearLayout android:layout_width="fill_parent" android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="vertical"> |
|
8 |
<TableLayout android:paddingLeft="5dip" android:layout_width="fill_parent" android:id="@+id/view_loadbalancer_layout" android:paddingBottom="30dip" android:layout_height="fill_parent"> |
|
9 |
<TextView android:layout_marginBottom="10dip" android:scrollHorizontally="true" android:textSize="20.0sp" android:layout_marginLeft="22dip" android:layout_height="wrap_content" android:gravity="fill_horizontal" android:layout_width="fill_parent" android:layout_marginTop="10dip" android:layout_marginRight="30dip" android:textColor="#fff" android:text="LoadBalancer"></TextView> |
|
10 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/edit_lb_name_layout" android:layout_width="fill_parent"> |
|
11 |
<TextView android:paddingLeft="5dip" android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textStyle="bold" android:singleLine="false" android:layout_marginLeft="22dip" android:textColor="#333" android:text="Name"></TextView> |
|
12 |
<EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:id="@+id/edit_lb_name_text" android:layout_marginRight="20dip"> |
|
8 |
<LinearLayout android:layout_width="fill_parent" |
|
9 |
android:id="@+id/linearLayout1" android:layout_height="wrap_content" |
|
10 |
android:orientation="vertical"> |
|
11 |
<TableLayout android:paddingLeft="5dip" |
|
12 |
android:layout_width="fill_parent" android:id="@+id/view_loadbalancer_layout" |
|
13 |
android:paddingBottom="30dip" android:layout_height="fill_parent"> |
|
14 |
<TextView android:layout_marginBottom="10dip" |
|
15 |
android:scrollHorizontally="true" android:textSize="20.0sp" |
|
16 |
android:layout_marginLeft="22dip" android:layout_height="wrap_content" |
|
17 |
android:gravity="fill_horizontal" android:layout_width="fill_parent" |
|
18 |
android:layout_marginTop="10dip" android:layout_marginRight="30dip" |
|
19 |
android:textColor="#fff" android:text="LoadBalancer"></TextView> |
|
20 |
<TableRow android:orientation="horizontal" |
|
21 |
android:layout_height="wrap_content" android:id="@+id/edit_lb_name_layout" |
|
22 |
android:layout_width="fill_parent"> |
|
23 |
<TextView android:paddingLeft="5dip" |
|
24 |
android:layout_gravity="center_vertical" android:layout_height="wrap_content" |
|
25 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
26 |
android:singleLine="false" android:layout_marginLeft="22dip" |
|
27 |
android:text="Name"></TextView> |
|
28 |
<EditText android:layout_height="wrap_content" |
|
29 |
android:layout_width="wrap_content" android:layout_weight="1" |
|
30 |
android:id="@+id/edit_lb_name_text" android:layout_marginRight="20dip"> |
|
13 | 31 |
<requestFocus></requestFocus> |
14 | 32 |
</EditText> |
15 | 33 |
</TableRow> |
16 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/edit_protocol_layout" android:layout_width="fill_parent"> |
|
17 |
<TextView android:paddingLeft="5dip" android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textStyle="bold" android:singleLine="false" android:layout_marginLeft="22dip" android:textColor="#333" android:text="Protocol"></TextView> |
|
18 |
<Spinner android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:layout_marginRight="20dip" android:id="@+id/edit_protocol_spinner"></Spinner> |
|
34 |
<TableRow android:orientation="horizontal" |
|
35 |
android:layout_height="wrap_content" android:id="@+id/edit_protocol_layout" |
|
36 |
android:layout_width="fill_parent"> |
|
37 |
<TextView android:paddingLeft="5dip" |
|
38 |
android:layout_gravity="center_vertical" android:layout_height="wrap_content" |
|
39 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
40 |
android:singleLine="false" android:layout_marginLeft="22dip" |
|
41 |
android:text="Protocol"></TextView> |
|
42 |
<Spinner android:layout_height="wrap_content" |
|
43 |
android:layout_width="wrap_content" android:layout_weight="1" |
|
44 |
android:layout_marginRight="20dip" android:id="@+id/edit_protocol_spinner"></Spinner> |
|
19 | 45 |
</TableRow> |
20 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/edit_port_layout" android:layout_width="fill_parent"> |
|
21 |
<TextView android:paddingLeft="5dip" android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textStyle="bold" android:singleLine="false" android:layout_marginLeft="22dip" android:textColor="#333" android:text="Port"></TextView> |
|
22 |
<EditText android:layout_height="wrap_content" android:layout_width="fill_parent" android:inputType="number" android:layout_weight="1" android:id="@+id/edit_port_text" android:layout_marginRight="20dip"></EditText> |
|
46 |
<TableRow android:orientation="horizontal" |
|
47 |
android:layout_height="wrap_content" android:id="@+id/edit_port_layout" |
|
48 |
android:layout_width="fill_parent"> |
|
49 |
<TextView android:paddingLeft="5dip" |
|
50 |
android:layout_gravity="center_vertical" android:layout_height="wrap_content" |
|
51 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
52 |
android:singleLine="false" android:layout_marginLeft="22dip" |
|
53 |
android:text="Port"></TextView> |
|
54 |
<EditText android:layout_height="wrap_content" |
|
55 |
android:layout_width="fill_parent" android:inputType="number" |
|
56 |
android:layout_weight="1" android:id="@+id/edit_port_text" |
|
57 |
android:layout_marginRight="20dip"></EditText> |
|
23 | 58 |
</TableRow> |
24 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/edit_vip_layout" android:layout_width="fill_parent"> |
|
25 |
<TextView android:paddingLeft="5dip" android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textStyle="bold" android:singleLine="false" android:layout_marginLeft="22dip" android:textColor="#333" android:text="@string/virtual_ip_type"></TextView> |
|
26 |
<Spinner android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:layout_marginRight="20dip" android:id="@+id/edit_vip_spinner"></Spinner> |
|
59 |
<TableRow android:orientation="horizontal" |
|
60 |
android:layout_height="wrap_content" android:id="@+id/edit_vip_layout" |
|
61 |
android:layout_width="fill_parent"> |
|
62 |
<TextView android:paddingLeft="5dip" |
|
63 |
android:layout_gravity="center_vertical" android:layout_height="wrap_content" |
|
64 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
65 |
android:singleLine="false" android:layout_marginLeft="22dip" |
|
66 |
android:text="@string/virtual_ip_type"></TextView> |
|
67 |
<Spinner android:layout_height="wrap_content" |
|
68 |
android:layout_width="wrap_content" android:layout_weight="1" |
|
69 |
android:layout_marginRight="20dip" android:id="@+id/edit_vip_spinner"></Spinner> |
|
27 | 70 |
</TableRow> |
28 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/edit_algorithm_layout" android:layout_width="fill_parent"> |
|
29 |
<TextView android:paddingLeft="5dip" android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textStyle="bold" android:singleLine="false" android:layout_marginLeft="22dip" android:textColor="#333" android:text="Algorithm"></TextView> |
|
30 |
<Spinner android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:layout_marginRight="20dip" android:id="@+id/edit_algorithm_spinner"></Spinner> |
|
71 |
<TableRow android:orientation="horizontal" |
|
72 |
android:layout_width="fill_parent" android:layout_height="wrap_content" |
|
73 |
android:id="@+id/select_vip_layout"> |
|
74 |
<TextView android:layout_marginLeft="22dip" |
|
75 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
76 |
android:textColor="#333" android:singleLine="false" |
|
77 |
android:paddingLeft="5dip" android:layout_gravity="center_vertical" |
|
78 |
android:layout_height="1dip"></TextView> |
|
79 |
<Button android:layout_height="wrap_content" |
|
80 |
android:layout_width="wrap_content" android:layout_marginRight="20dip" |
|
81 |
android:layout_weight="1" android:text="Selected Shared VIP" |
|
82 |
android:id="@+id/selected_shared_vip" android:clickable="true" android:paddingRight="20dip" android:drawablePadding="-8dip"></Button> |
|
31 | 83 |
</TableRow> |
32 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/edit_region_layout" android:layout_width="fill_parent"> |
|
33 |
<TextView android:paddingLeft="5dip" android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textStyle="bold" android:singleLine="false" android:layout_marginLeft="22dip" android:textColor="#333" android:text="Region"></TextView> |
|
34 |
<Spinner android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:layout_marginRight="20dip" android:id="@+id/edit_region_spinner"></Spinner> |
|
84 |
<TableRow android:orientation="horizontal" |
|
85 |
android:layout_height="wrap_content" android:id="@+id/edit_algorithm_layout" |
|
86 |
android:layout_width="fill_parent"> |
|
87 |
<TextView android:paddingLeft="5dip" |
|
88 |
android:layout_gravity="center_vertical" android:layout_height="wrap_content" |
|
89 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
90 |
android:singleLine="false" android:layout_marginLeft="22dip" |
|
91 |
android:text="Algorithm"></TextView> |
|
92 |
<Spinner android:layout_height="wrap_content" |
|
93 |
android:layout_width="wrap_content" android:layout_weight="1" |
|
94 |
android:layout_marginRight="20dip" android:id="@+id/edit_algorithm_spinner"></Spinner> |
|
35 | 95 |
</TableRow> |
36 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/edit_nodes_layout" android:layout_width="fill_parent"> |
|
37 |
<TextView android:paddingLeft="5dip" android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textStyle="bold" android:singleLine="false" android:layout_marginLeft="22dip" android:textColor="#333" android:text="Nodes"></TextView> |
|
38 |
<Button android:layout_height="wrap_content" android:text="Edit Nodes" android:layout_width="wrap_content" android:id="@+id/add_nodes_button" android:layout_weight="1" android:layout_marginRight="20dip"></Button> |
|
96 |
<TableRow android:orientation="horizontal" |
|
97 |
android:layout_height="wrap_content" android:id="@+id/edit_region_layout" |
|
98 |
android:layout_width="fill_parent"> |
|
99 |
<TextView android:paddingLeft="5dip" |
|
100 |
android:layout_gravity="center_vertical" android:layout_height="wrap_content" |
|
101 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
102 |
android:singleLine="false" android:layout_marginLeft="22dip" |
|
103 |
android:text="Region"></TextView> |
|
104 |
<Spinner android:layout_height="wrap_content" |
|
105 |
android:layout_width="wrap_content" android:layout_weight="1" |
|
106 |
android:layout_marginRight="20dip" android:id="@+id/edit_region_spinner"></Spinner> |
|
107 |
</TableRow> |
|
108 |
<TableRow android:orientation="horizontal" |
|
109 |
android:layout_height="wrap_content" android:id="@+id/edit_nodes_layout" |
|
110 |
android:layout_width="fill_parent"> |
|
111 |
<TextView android:paddingLeft="5dip" |
|
112 |
android:layout_gravity="center_vertical" android:layout_height="wrap_content" |
|
113 |
android:layout_width="wrap_content" android:textStyle="bold" |
|
114 |
android:singleLine="false" android:layout_marginLeft="22dip" |
|
115 |
android:text="Nodes"></TextView> |
|
116 |
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/add_nodes_button" |
|
117 |
android:layout_weight="1" android:layout_marginRight="20dip" android:text="Select Nodes" android:paddingRight="20dip" android:drawablePadding="-8dip"></Button> |
|
39 | 118 |
</TableRow> |
40 | 119 |
</TableLayout> |
41 |
<Button android:layout_gravity="center" android:text="Add Load Balancer" android:layout_width="wrap_content" android:id="@+id/add_lb_button" android:layout_height="wrap_content"></Button> |
|
120 |
<Button android:layout_gravity="center" android:text="Add Load Balancer" |
|
121 |
android:layout_width="wrap_content" android:id="@+id/add_lb_button" |
|
122 |
android:layout_height="wrap_content"></Button> |
|
42 | 123 |
</LinearLayout> |
43 | 124 |
</ScrollView> |
44 | 125 |
</LinearLayout> |
b/res/layout/view_loadbalancer.xml | ||
---|---|---|
18 | 18 |
<TextView android:layout_width="wrap_content" |
19 | 19 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
20 | 20 |
android:paddingLeft="5dip" android:text="ID: " android:singleLine="false" |
21 |
android:textStyle="bold" android:textColor="#333" android:id="@+id/id_label"/>
|
|
21 |
android:textStyle="bold" android:id="@+id/id_label"/> |
|
22 | 22 |
<TextView android:id="@+id/view_lb_id" |
23 | 23 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
24 | 24 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" |
... | ... | |
30 | 30 |
<TextView android:layout_width="wrap_content" |
31 | 31 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
32 | 32 |
android:paddingLeft="5dip" android:singleLine="false" |
33 |
android:textStyle="bold" android:textColor="#333" android:text="Name: "/>
|
|
33 |
android:textStyle="bold" android:text="Name: " android:typeface="normal"/>
|
|
34 | 34 |
<TextView android:id="@+id/view_name" |
35 | 35 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
36 | 36 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" |
... | ... | |
42 | 42 |
<TextView android:layout_width="wrap_content" |
43 | 43 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
44 | 44 |
android:paddingLeft="5dip" android:text="Protocol: " |
45 |
android:singleLine="false" android:textStyle="bold" |
|
46 |
android:textColor="#333" /> |
|
45 |
android:singleLine="false" android:textStyle="bold"/> |
|
47 | 46 |
<TextView android:id="@+id/view_protocol" |
48 | 47 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
49 | 48 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" |
... | ... | |
55 | 54 |
<TextView android:layout_width="wrap_content" |
56 | 55 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
57 | 56 |
android:paddingLeft="5dip" android:text="Port: " |
58 |
android:singleLine="false" android:textStyle="bold" |
|
59 |
android:textColor="#333" /> |
|
57 |
android:singleLine="false" android:textStyle="bold"/> |
|
60 | 58 |
<TextView android:id="@+id/view_port" |
61 | 59 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
62 | 60 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" |
... | ... | |
68 | 66 |
<TextView android:layout_width="wrap_content" |
69 | 67 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
70 | 68 |
android:paddingLeft="5dip" android:text="Algorithm: " |
71 |
android:singleLine="false" android:textStyle="bold" |
|
72 |
android:textColor="#333" /> |
|
69 |
android:singleLine="false" android:textStyle="bold"/> |
|
73 | 70 |
<TextView android:id="@+id/view_algorithm" |
74 | 71 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
75 | 72 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" |
... | ... | |
81 | 78 |
<TextView android:layout_width="wrap_content" |
82 | 79 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
83 | 80 |
android:paddingLeft="5dip" android:text="Status: " |
84 |
android:singleLine="false" android:textStyle="bold" |
|
85 |
android:textColor="#333" /> |
|
81 |
android:singleLine="false" android:textStyle="bold"/> |
|
86 | 82 |
<TextView android:id="@+id/view_status" |
87 | 83 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
88 | 84 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" |
... | ... | |
95 | 91 |
android:layout_height="wrap_content" android:layout_marginLeft="22dip" |
96 | 92 |
android:paddingLeft="5dip" android:text="Connection Logging: " |
97 | 93 |
android:singleLine="false" android:textStyle="bold" |
98 |
android:textColor="#333" android:id="@+id/connection_logging"/>
|
|
94 |
android:id="@+id/connection_logging"/> |
|
99 | 95 |
<TextView android:id="@+id/view_islogging" |
100 | 96 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
101 | 97 |
android:layout_marginRight="30dip" android:scrollHorizontally="true" android:gravity="fill_horizontal" |
... | ... | |
107 | 103 |
android:id="@+id/view_loadbalancer_layout" android:orientation="vertical" |
108 | 104 |
android:layout_width="fill_parent" android:layout_height="wrap_content" |
109 | 105 |
android:paddingLeft="5dip"> |
110 |
<TextView android:singleLine="false" android:textColor="#333" android:paddingLeft="5dip" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_marginLeft="22dip" android:layout_height="wrap_content" android:textStyle="bold" android:text="Virtual IPs"></TextView>
|
|
106 |
<TextView android:singleLine="false" android:paddingLeft="5dip" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_marginLeft="22dip" android:layout_height="wrap_content" android:textStyle="bold" android:text="Virtual IPs"></TextView> |
|
111 | 107 |
<!-- ID --> |
112 | 108 |
<!-- Ip Address --> |
113 | 109 |
<!-- IpVersion --> |
... | ... | |
121 | 117 |
android:id="@+id/view_loadbalancer_layout" android:orientation="vertical" |
122 | 118 |
android:layout_width="fill_parent" android:layout_height="wrap_content" |
123 | 119 |
android:paddingLeft="5dip"> |
124 |
<TextView android:singleLine="false" android:textColor="#333" android:paddingLeft="5dip" android:layout_width="wrap_content" android:layout_marginLeft="22dip" android:layout_height="wrap_content" android:textStyle="bold" android:text="Node IPs" android:id="@+id/TextView02"></TextView>
|
|
120 |
<TextView android:singleLine="false" android:paddingLeft="5dip" android:layout_width="wrap_content" android:layout_marginLeft="22dip" android:layout_height="wrap_content" android:textStyle="bold" android:text="Node IPs" android:id="@+id/TextView02"></TextView> |
|
125 | 121 |
<!-- ID --> |
126 | 122 |
<!-- Address --> |
127 | 123 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
b/src/com/rackspace/cloud/loadbalancer/api/client/AlgorithmManager.java | ||
---|---|---|
25 | 25 |
import com.rackspace.cloud.files.api.client.CustomHttpClient; |
26 | 26 |
import com.rackspace.cloud.loadbalancer.api.parsers.AlgorithmsXMLParser; |
27 | 27 |
import com.rackspace.cloud.servers.api.client.Account; |
28 |
import com.rackspacecloud.android.Preferences; |
|
28 | 29 |
|
29 | 30 |
public class AlgorithmManager extends EntityManager { |
30 | 31 |
|
31 | 32 |
public ArrayList<Algorithm> createList(Context context) { |
32 | 33 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
33 |
HttpGet get = new HttpGet(Account.getLoadBalancerDFWUrl() + Account.getAccount().getAccountId() + "/loadbalancers/algorithms.xml"); |
|
34 |
|
|
35 |
String url = ""; |
|
36 |
if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
37 |
url = Account.getLoadBalancerDFWUrl() + Account.getAccount().getAccountId() + "/loadbalancers/algorithms.xml"; |
|
38 |
} else if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
|
39 |
url = Account.getLoadBalancerLONUrl() + Account.getAccount().getAccountId() + "/loadbalancers/algorithms.xml"; |
|
40 |
} |
|
41 |
HttpGet get = new HttpGet(url); |
|
42 |
|
|
34 | 43 |
ArrayList<Algorithm> algorithms = new ArrayList<Algorithm>(); |
35 | 44 |
|
36 | 45 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
b/src/com/rackspace/cloud/loadbalancer/api/client/LoadBalancer.java | ||
---|---|---|
33 | 33 |
public static String getRegionUrl(String region){ |
34 | 34 |
if(region.equals("ORD")){ |
35 | 35 |
return Account.getLoadBalancerORDUrl(); |
36 |
} |
|
37 |
else if(region.equals("DFW")){ |
|
36 |
} else if(region.equals("DFW")){ |
|
38 | 37 |
return Account.getLoadBalancerDFWUrl(); |
39 |
} |
|
40 |
else{ |
|
38 |
} else if(region.equals("LON")){ |
|
39 |
return Account.getLoadBalancerLONUrl(); |
|
40 |
} else { |
|
41 | 41 |
return ""; |
42 | 42 |
} |
43 | 43 |
} |
... | ... | |
205 | 205 |
" port=\"" + getPort() + "\"" + |
206 | 206 |
" protocol=\"" + getProtocol() + "\"" + |
207 | 207 |
" algorithm=\"" + getAlgorithm() + "\"" + ">" + |
208 |
" <virtualIps>" + |
|
209 |
"<virtualIp type=\"" + getVirtualIpType() + "\"" + "/>" + |
|
210 |
" </virtualIps>" + |
|
208 |
" <virtualIps>"; |
|
209 |
if(getVirtualIpType().equals("SHARED")){ |
|
210 |
for(VirtualIp ip : getVirtualIps()){ |
|
211 |
xml += "<virtualIp id=\"" + ip.getId() + "\"" + "/>"; |
|
212 |
} |
|
213 |
} else { |
|
214 |
xml += "<virtualIp type=\"" + getVirtualIpType() + "\"" + "/>"; |
|
215 |
} |
|
216 |
xml += " </virtualIps>" + |
|
211 | 217 |
" <nodes>"; |
212 | 218 |
for(Node node : getNodes()){ |
213 | 219 |
xml += "<node address=\"" + node.getAddress() + "\"" + " port=\"" + node.getPort() + "\"" + |
b/src/com/rackspace/cloud/loadbalancer/api/client/LoadBalancerManager.java | ||
---|---|---|
36 | 36 |
import com.rackspace.cloud.servers.api.client.Account; |
37 | 37 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
38 | 38 |
import com.rackspace.cloud.servers.api.client.http.HttpBundle; |
39 |
import com.rackspacecloud.android.Preferences; |
|
39 | 40 |
|
40 | 41 |
public class LoadBalancerManager extends EntityManager { |
41 | 42 |
private Context context; |
... | ... | |
63 | 64 |
loadBalancer.setRegion("ORD"); |
64 | 65 |
} |
65 | 66 |
catch(LoadBalancersException lbe){ |
67 |
|
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
//Then try LON |
|
72 |
if(loadBalancer == null){ |
|
73 |
try{ |
|
74 |
loadBalancer = getLoadBalancerById(id, Account.getLoadBalancerLONUrl()); |
|
75 |
loadBalancer.setRegion("ORD"); |
|
76 |
} |
|
77 |
catch(LoadBalancersException lbe){ |
|
66 | 78 |
throw lbe; |
67 | 79 |
} |
68 | 80 |
} |
... | ... | |
81 | 93 |
HttpResponse resp = httpclient.execute(get); |
82 | 94 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
83 | 95 |
String body = responseHandler.handleResponse(resp); |
84 |
|
|
96 |
|
|
85 | 97 |
Log.d("info", "the xml body is " + body); |
86 |
|
|
98 |
|
|
87 | 99 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) { |
88 | 100 |
LoadBalancersXmlParser loadBalancersXMLParser = new LoadBalancersXmlParser(); |
89 | 101 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
... | ... | |
125 | 137 |
} |
126 | 138 |
|
127 | 139 |
public ArrayList<LoadBalancer> createList() throws LoadBalancersException{ |
128 |
ArrayList<LoadBalancer> loadBalancers = createSublist(Account.getLoadBalancerORDUrl()); |
|
129 |
for(LoadBalancer loadBalancer: loadBalancers){ |
|
130 |
loadBalancer.setRegion("ORD"); |
|
140 |
|
|
141 |
ArrayList<LoadBalancer> loadBalancers = new ArrayList<LoadBalancer>(); |
|
142 |
|
|
143 |
//if US account |
|
144 |
if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
145 |
loadBalancers.addAll(createSublist(Account.getLoadBalancerORDUrl())); |
|
146 |
for(LoadBalancer loadBalancer: loadBalancers){ |
|
147 |
loadBalancer.setRegion("ORD"); |
|
148 |
} |
|
149 |
ArrayList<LoadBalancer> DFWloadBalancers = createSublist(Account.getLoadBalancerDFWUrl()); |
|
150 |
for(LoadBalancer loadBalancer: DFWloadBalancers){ |
|
151 |
loadBalancer.setRegion("DFW"); |
|
152 |
} |
|
153 |
loadBalancers.addAll(DFWloadBalancers); |
|
131 | 154 |
} |
132 |
ArrayList<LoadBalancer> DFWloadBalancers = createSublist(Account.getLoadBalancerDFWUrl()); |
|
133 |
for(LoadBalancer loadBalancer: DFWloadBalancers){ |
|
134 |
loadBalancer.setRegion("DFW"); |
|
155 |
//if UK account |
|
156 |
else if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
|
157 |
loadBalancers.addAll(createSublist(Account.getLoadBalancerLONUrl())); |
|
158 |
for(LoadBalancer loadBalancer: loadBalancers){ |
|
159 |
loadBalancer.setRegion("LON"); |
|
160 |
} |
|
135 | 161 |
} |
136 |
loadBalancers.addAll(DFWloadBalancers); |
|
137 | 162 |
return loadBalancers; |
138 | 163 |
} |
139 | 164 |
|
140 | 165 |
public ArrayList<LoadBalancer> createSublist(String regionUrl) throws LoadBalancersException { |
141 |
//TODO:grab from ord and combine list |
|
142 | 166 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
143 |
//TODO:check for uk or us |
|
144 | 167 |
HttpGet get = new HttpGet(regionUrl + Account.getAccount().getAccountId() + "/loadbalancers"); |
145 | 168 |
ArrayList<LoadBalancer> loadBalancers = new ArrayList<LoadBalancer>(); |
146 | 169 |
|
... | ... | |
313 | 336 |
} |
314 | 337 |
return bundle; |
315 | 338 |
} |
316 |
|
|
317 |
|
|
339 |
|
|
340 |
|
|
318 | 341 |
} |
b/src/com/rackspace/cloud/loadbalancer/api/client/ProtocolManager.java | ||
---|---|---|
25 | 25 |
import com.rackspace.cloud.files.api.client.CustomHttpClient; |
26 | 26 |
import com.rackspace.cloud.loadbalancer.api.parsers.ProtocolsXMLParser; |
27 | 27 |
import com.rackspace.cloud.servers.api.client.Account; |
28 |
import com.rackspacecloud.android.Preferences; |
|
28 | 29 |
|
29 | 30 |
public class ProtocolManager extends EntityManager { |
30 | 31 |
|
31 | 32 |
public ArrayList<Protocol> createList(Context context) { |
32 | 33 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
33 |
HttpGet get = new HttpGet(Account.getLoadBalancerDFWUrl() + Account.getAccount().getAccountId() + "/loadbalancers/protocols.xml"); |
|
34 |
|
|
35 |
String url = ""; |
|
36 |
if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
37 |
url = Account.getLoadBalancerDFWUrl() + Account.getAccount().getAccountId() + "/loadbalancers/protocols.xml"; |
|
38 |
} else if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
|
39 |
url = Account.getLoadBalancerLONUrl() + Account.getAccount().getAccountId() + "/loadbalancers/protocols.xml"; |
|
40 |
} |
|
41 |
HttpGet get = new HttpGet(url); |
|
34 | 42 |
ArrayList<Protocol> protocols = new ArrayList<Protocol>(); |
35 | 43 |
|
36 | 44 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
b/src/com/rackspace/cloud/loadbalancer/api/client/VirtualIp.java | ||
---|---|---|
10 | 10 |
private String address; |
11 | 11 |
private String ipVersion; |
12 | 12 |
private String type; |
13 |
private LoadBalancer loadBalancer; |
|
13 | 14 |
public String getId() { |
14 | 15 |
return id; |
15 | 16 |
} |
... | ... | |
34 | 35 |
public void setType(String type) { |
35 | 36 |
this.type = type; |
36 | 37 |
} |
38 |
/** |
|
39 |
* @return the loadBalancer, the loadBalancer |
|
40 |
* that this vip is tied to |
|
41 |
*/ |
|
42 |
public LoadBalancer getLoadBalancer() { |
|
43 |
return loadBalancer; |
|
44 |
} |
|
45 |
/** |
|
46 |
* @return the loadBalancer |
|
47 |
*/ |
|
48 |
public void setLoadBalancer(LoadBalancer loadBalancer) { |
|
49 |
this.loadBalancer = loadBalancer; |
|
50 |
} |
|
37 | 51 |
} |
b/src/com/rackspace/cloud/loadbalancer/api/parsers/LoadBalancersXmlParser.java | ||
---|---|---|
69 | 69 |
virtualIp.setAddress(atts.getValue("address")); |
70 | 70 |
virtualIp.setIpVersion(atts.getValue("ipVersion")); |
71 | 71 |
virtualIp.setType(atts.getValue("type")); |
72 |
virtualIp.setLoadBalancer(loadBalancer); |
|
72 | 73 |
} else if ("nodes".equalsIgnoreCase(name)) { |
73 | 74 |
nodes = new ArrayList<Node>(); |
74 | 75 |
} else if ("node".equalsIgnoreCase(name)) { |
b/src/com/rackspace/cloud/servers/api/client/Account.java | ||
---|---|---|
4 | 4 |
package com.rackspace.cloud.servers.api.client; |
5 | 5 |
|
6 | 6 |
import com.rackspace.cloud.utils.StringUtils; |
7 |
import com.rackspacecloud.android.Preferences; |
|
7 | 8 |
|
8 | 9 |
|
9 | 10 |
|
... | ... | |
20 | 21 |
private String username; |
21 | 22 |
private String apiKey; |
22 | 23 |
private String accountId; |
23 |
private transient String authToken; |
|
24 | 24 |
private String authServer; |
25 |
private transient String serverUrl;
|
|
26 |
private transient String storageUrl;
|
|
25 |
private String loadBalancerUKUrl;
|
|
26 |
private String[] loadBalancerRegions;
|
|
27 | 27 |
private static String loadBalancerDFWUrl; |
28 | 28 |
private static String loadBalancerORDUrl; |
29 |
private String loadBalancerUKUrl; |
|
29 |
private static String loadBalancerLONUrl; |
|
30 |
private transient String authToken; |
|
31 |
private transient String serverUrl; |
|
32 |
private transient String storageUrl; |
|
30 | 33 |
private transient String storageToken; |
31 | 34 |
private transient String cdnManagementUrl; |
32 | 35 |
private transient static Account currentAccount; |
33 |
|
|
36 |
|
|
34 | 37 |
|
35 | 38 |
public static Account getAccount(){ |
36 | 39 |
return currentAccount; |
... | ... | |
113 | 116 |
*/ |
114 | 117 |
public void setAuthServer(String authServer) { |
115 | 118 |
this.authServer = authServer; |
119 |
|
|
120 |
/* |
|
121 |
* the auth server used determines which regions |
|
122 |
* can be used for load balancers, so set available |
|
123 |
* regions here. |
|
124 |
*/ |
|
125 |
if(authServer.equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
|
126 |
setLoadBalancerRegions(Preferences.UK_REGIONS); |
|
127 |
} else if (authServer.equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
128 |
setLoadBalancerRegions(Preferences.US_REGIONS); |
|
129 |
} else { |
|
130 |
setLoadBalancerRegions(new String[0]); |
|
131 |
} |
|
116 | 132 |
} |
117 | 133 |
|
118 | 134 |
//auth v1.1 should return loadbalancer endpoints and return account id .... |
... | ... | |
152 | 168 |
public static void setLoadBalancerORDUrl(String ordUrl) { |
153 | 169 |
loadBalancerORDUrl = ordUrl; |
154 | 170 |
} |
171 |
|
|
172 |
/** |
|
173 |
* @return the loadBalancerLONUrl |
|
174 |
*/ |
|
175 |
public static String getLoadBalancerLONUrl() { |
|
176 |
loadBalancerLONUrl = "https://lon.loadbalancers.api.rackspacecloud.com/v1.0/"; |
|
177 |
return loadBalancerLONUrl; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* @param loadBalancerLONUrl the loadBalancerORDUrl to set |
|
182 |
*/ |
|
183 |
public static void setLoadBalancerLONUrl(String lonUrl) { |
|
184 |
loadBalancerLONUrl = lonUrl; |
|
185 |
} |
|
155 | 186 |
|
156 | 187 |
/** |
157 | 188 |
* @return the loadBalancerUKUrl |
... | ... | |
199 | 230 |
*/ |
200 | 231 |
public void setStorageToken(String storageToken) { |
201 | 232 |
this.storageToken = storageToken; |
202 |
|
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* @return the load balancer regions |
|
237 |
*/ |
|
238 |
public String[] getLoadBalancerRegions() { |
|
239 |
return loadBalancerRegions; |
|
240 |
} |
|
241 |
|
|
242 |
/** |
|
243 |
* @param loadBalancerRegions the load |
|
244 |
* balancer regions to set |
|
245 |
*/ |
|
246 |
public void setLoadBalancerRegions(String[] loadBalancerRegions) { |
|
247 |
this.loadBalancerRegions = new String[loadBalancerRegions.length]; |
|
248 |
for(int i = 0 ; i < loadBalancerRegions.length; i++){ |
|
249 |
this.loadBalancerRegions[i] = loadBalancerRegions[i]; |
|
250 |
} |
|
203 | 251 |
} |
204 | 252 |
|
205 | 253 |
} |
b/src/com/rackspace/cloud/servers/api/client/http/Authentication.java | ||
---|---|---|
14 | 14 |
|
15 | 15 |
import com.rackspace.cloud.files.api.client.CustomHttpClient; |
16 | 16 |
import com.rackspace.cloud.servers.api.client.Account; |
17 |
import com.rackspacecloud.android.Preferences; |
|
17 | 18 |
|
18 | 19 |
/** |
19 | 20 |
* @author Mike Mayo - mike.mayo@rackspace.com - twitter.com/greenisus |
... | ... | |
35 | 36 |
Account.getAccount().setStorageUrl(resp.getFirstHeader("X-Storage-Url").getValue()); |
36 | 37 |
Account.getAccount().setStorageToken(resp.getFirstHeader("X-Storage-Token").getValue()); |
37 | 38 |
Account.getAccount().setCdnManagementUrl(resp.getFirstHeader("X-Cdn-Management-Url").getValue()); |
39 |
|
|
40 |
//Set the available regions for the account |
|
41 |
if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
|
42 |
Account.getAccount().setLoadBalancerRegions(Preferences.UK_REGIONS); |
|
43 |
} else if(Account.getAccount().getAuthServer().equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
44 |
Account.getAccount().setLoadBalancerRegions(Preferences.US_REGIONS); |
|
45 |
} |
|
46 |
|
|
38 | 47 |
return true; |
39 | 48 |
} else { |
40 | 49 |
Log.d("status code", Integer.toString(resp.getStatusLine().getStatusCode())); |
b/src/com/rackspacecloud/android/AddExternalNodeActivity.java | ||
---|---|---|
1 | 1 |
package com.rackspacecloud.android; |
2 | 2 |
|
3 |
import android.app.Activity; |
|
4 | 3 |
import android.content.Intent; |
5 | 4 |
import android.os.Bundle; |
6 |
import android.util.Log; |
|
7 | 5 |
import android.view.View; |
8 | 6 |
import android.view.Window; |
9 | 7 |
import android.view.View.OnClickListener; |
... | ... | |
18 | 16 |
public class AddExternalNodeActivity extends CloudActivity { |
19 | 17 |
|
20 | 18 |
private final String[] CONDITIONS = {"Enabled", "Disabled", "Draining"}; |
21 |
private String name; |
|
22 | 19 |
private String selectedPort; |
23 | 20 |
private String selectedIp; |
24 | 21 |
private String selectedWeight; |
b/src/com/rackspacecloud/android/AddLoadBalancerActivity.java | ||
---|---|---|
9 | 9 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancerManager; |
10 | 10 |
import com.rackspace.cloud.loadbalancer.api.client.Node; |
11 | 11 |
import com.rackspace.cloud.loadbalancer.api.client.Protocol; |
12 |
import com.rackspace.cloud.loadbalancer.api.client.VirtualIp; |
|
13 |
import com.rackspace.cloud.servers.api.client.Account; |
|
12 | 14 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
13 | 15 |
import com.rackspace.cloud.servers.api.client.http.HttpBundle; |
14 | 16 |
|
... | ... | |
16 | 18 |
import android.content.Intent; |
17 | 19 |
import android.os.AsyncTask; |
18 | 20 |
import android.os.Bundle; |
21 |
import android.text.Editable; |
|
22 |
import android.text.TextWatcher; |
|
23 |
import android.util.Log; |
|
19 | 24 |
import android.view.View; |
20 | 25 |
import android.view.View.OnClickListener; |
21 | 26 |
import android.widget.AdapterView; |
... | ... | |
24 | 29 |
import android.widget.Button; |
25 | 30 |
import android.widget.EditText; |
26 | 31 |
import android.widget.Spinner; |
32 |
import android.widget.TableRow;; |
|
27 | 33 |
|
28 | 34 |
public class AddLoadBalancerActivity extends CloudActivity implements OnItemSelectedListener { |
29 | 35 |
|
30 | 36 |
//TODO Shared Virtual IP (not in API though?) |
31 |
private static final String[] VIP_TYPES = {"Public", "ServiceNet"}; |
|
32 |
private static final String[] REGIONS = {"ORD", "DFW"}; |
|
37 |
private static final String[] VIP_TYPES = {"Public", "ServiceNet", "Shared"}; |
|
33 | 38 |
|
34 | 39 |
private static final int ADD_NODES_ACTIVITY_CODE = 165; |
40 |
private static final int SHARED_VIP_ACTIVITY_CODE = 235; |
|
35 | 41 |
|
36 | 42 |
private Protocol[] protocols; |
43 |
private Protocol selectedProtocol; |
|
37 | 44 |
private Algorithm[] algorithms; |
45 |
private Algorithm selectedAlgorithm; |
|
46 |
private VirtualIp selectedVip; |
|
38 | 47 |
private Spinner protocolSpinner; |
39 | 48 |
private Spinner algorithmSpinner; |
40 | 49 |
private Spinner vipSpinner; |
41 | 50 |
private Spinner regionSpinner; |
42 |
private Protocol selectedProtocol; |
|
43 |
private Algorithm selectedAlgorithm; |
|
51 |
private Button selectVipButton; |
|
52 |
private Button selectNodesButton; |
|
53 |
private EditText portEditText; |
|
44 | 54 |
private String selectedVipType; |
45 | 55 |
private String selectedRegion; |
46 | 56 |
private String selectedName; |
... | ... | |
65 | 75 |
else{ |
66 | 76 |
nodes = new ArrayList<Node>(); |
67 | 77 |
} |
68 |
|
|
78 |
setUpButtons(); |
|
79 |
setupText(); |
|
69 | 80 |
loadProtocolSpinner(); |
70 | 81 |
loadAlgorithmSpinner(); |
71 | 82 |
loadVipSpinner(); |
72 | 83 |
loadRegionSpinner(); |
73 |
setUpButtons(); |
|
74 | 84 |
} |
75 | 85 |
|
76 | 86 |
@Override |
... | ... | |
89 | 99 |
} |
90 | 100 |
else if (parent == vipSpinner){ |
91 | 101 |
selectedVipType = VIP_TYPES[position]; |
102 |
if(VIP_TYPES[position].equals("Shared")){ |
|
103 |
((TableRow) findViewById(R.id.select_vip_layout)).setVisibility(View.VISIBLE); |
|
104 |
} else { |
|
105 |
((TableRow) findViewById(R.id.select_vip_layout)).setVisibility(View.GONE); |
|
106 |
} |
|
92 | 107 |
} |
93 | 108 |
else if (parent == regionSpinner){ |
94 |
selectedRegion = REGIONS[position]; |
|
109 |
selectedRegion = Account.getAccount().getLoadBalancerRegions()[position]; |
|
110 |
updateVipIndicatorLight(); |
|
95 | 111 |
} |
96 | 112 |
} |
97 | 113 |
|
98 | 114 |
public void onNothingSelected(AdapterView<?> parent) { |
99 | 115 |
|
100 | 116 |
} |
101 |
|
|
117 |
|
|
102 | 118 |
private void setUpButtons(){ |
103 |
Button addNodes = (Button) findViewById(R.id.add_nodes_button); |
|
104 |
addNodes.setOnClickListener(new OnClickListener() { |
|
105 |
|
|
119 |
selectVipButton = (Button) findViewById(R.id.selected_shared_vip); |
|
120 |
updateVipIndicatorLight(); |
|
121 |
selectVipButton.setOnClickListener(new OnClickListener() { |
|
122 |
@Override |
|
123 |
public void onClick(View v) { |
|
124 |
Intent viewIntent = new Intent(getApplicationContext(), SharedVipActivity.class); |
|
125 |
viewIntent.putExtra("loadBalancerPort", ((EditText)findViewById(R.id.edit_port_text)).getText().toString()); |
|
126 |
viewIntent.putExtra("loadBalancerRegion", selectedRegion); |
|
127 |
startActivityForResult(viewIntent, SHARED_VIP_ACTIVITY_CODE); |
|
128 |
} |
|
129 |
}); |
|
130 |
((TableRow) findViewById(R.id.select_vip_layout)).setVisibility(View.GONE); |
|
131 |
|
|
132 |
selectNodesButton = (Button) findViewById(R.id.add_nodes_button); |
|
133 |
updateNodesIndicatorLight(); |
|
134 |
selectNodesButton.setOnClickListener(new OnClickListener() { |
|
106 | 135 |
@Override |
107 | 136 |
public void onClick(View v) { |
108 | 137 |
Intent viewIntent = new Intent(getApplicationContext(), AddNodesActivity.class); |
... | ... | |
117 | 146 |
@Override |
118 | 147 |
public void onClick(View v) { |
119 | 148 |
selectedName = ((EditText)findViewById(R.id.edit_lb_name_text)).getText().toString(); |
120 |
selectedPort = ((EditText)findViewById(R.id.edit_port_text)).getText().toString(); |
|
149 |
//selectedPort = ((EditText)findViewById(R.id.edit_port_text)).getText().toString();
|
|
121 | 150 |
if(!validName()){ |
122 | 151 |
showAlert("Error", "Load balancer name cannot be blank."); |
123 |
} |
|
124 |
else if(!validPort()){ |
|
152 |
} else if(!validPort()){ |
|
125 | 153 |
showAlert("Error", "Must have a protocol port number that is between 1 and 65535."); |
126 |
} |
|
127 |
else{ |
|
154 |
} else if(!validVip()){ |
|
155 |
showAlert("Error", "Please select a valid Virtual IP."); |
|
156 |
} else if(!validNodes()){ |
|
157 |
showAlert("Error", "You must select at least one enabled cloud server or add and enable at least one external node."); |
|
158 |
} else { |
|
128 | 159 |
loadBalancer = new LoadBalancer(); |
129 | 160 |
loadBalancer.setName(selectedName); |
130 | 161 |
loadBalancer.setProtocol(selectedProtocol.getName()); |
... | ... | |
132 | 163 |
loadBalancer.setVirtualIpType(selectedVipType); |
133 | 164 |
loadBalancer.setAlgorithm(selectedAlgorithm.getName()); |
134 | 165 |
loadBalancer.setNodes(nodes); |
166 |
if(selectedVip != null){ |
|
167 |
ArrayList<VirtualIp> vips = new ArrayList<VirtualIp>(); |
|
168 |
vips.add(selectedVip); |
|
169 |
loadBalancer.setVirtualIps(vips); |
|
170 |
} |
|
135 | 171 |
new AddLoadBalancerTask().execute(); |
136 | 172 |
} |
137 | 173 |
} |
138 | 174 |
}); |
139 | 175 |
} |
140 |
|
|
176 |
|
|
141 | 177 |
private boolean validName(){ |
142 | 178 |
return !selectedName.equals(""); |
143 | 179 |
} |
... | ... | |
145 | 181 |
private boolean validPort(){ |
146 | 182 |
return !selectedPort.equals("") && Integer.valueOf(selectedPort) > 0 && Integer.valueOf(selectedPort) < 65536; |
147 | 183 |
} |
184 |
|
|
185 |
private boolean validNodes(){ |
|
186 |
return nodes != null && nodes.size() > 0; |
|
187 |
} |
|
188 |
|
|
189 |
private void updateNodesIndicatorLight(){ |
|
190 |
if(validNodes()){ |
|
191 |
selectNodesButton.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0); |
|
192 |
} else { |
|
193 |
selectNodesButton.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_notification_overlay,0); |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
private boolean validVip(){ |
|
198 |
return selectedVip != null && !selectedVip.getLoadBalancer().getPort().equals(selectedPort) |
|
199 |
&& selectedVip.getLoadBalancer().getRegion().equals(selectedRegion); |
|
200 |
} |
|
201 |
|
|
202 |
private void updateVipIndicatorLight(){ |
|
203 |
if(validVip()){ |
|
204 |
selectVipButton.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0); |
|
205 |
} else { |
|
206 |
selectVipButton.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_notification_overlay,0); |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
210 |
private void setupText(){ |
|
211 |
portEditText = (EditText)findViewById(R.id.edit_port_text); |
|
212 |
portEditText.addTextChangedListener(new TextWatcher() { |
|
213 |
|
|
214 |
@Override |
|
215 |
public void onTextChanged(CharSequence s, int start, int before, int count) { |
|
216 |
selectedPort = s.toString(); |
|
217 |
updateVipIndicatorLight(); |
|
218 |
} |
|
219 |
@Override |
|
220 |
public void beforeTextChanged(CharSequence s, int start, int count, |
|
221 |
int after) { |
|
222 |
// do nothing |
|
223 |
} |
|
224 |
@Override |
|
225 |
public void afterTextChanged(Editable s) { |
|
226 |
// do nothing |
|
227 |
} |
|
228 |
}); |
|
229 |
} |
|
148 | 230 |
|
149 | 231 |
private void loadRegionSpinner() { |
150 | 232 |
regionSpinner = (Spinner) findViewById(R.id.edit_region_spinner); |
151 | 233 |
regionSpinner.setOnItemSelectedListener(this); |
152 | 234 |
|
153 |
ArrayAdapter<String> regionAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, REGIONS); |
|
235 |
ArrayAdapter<String> regionAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, |
|
236 |
Account.getAccount().getLoadBalancerRegions()); |
|
154 | 237 |
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
155 | 238 |
regionSpinner.setAdapter(regionAdapter); |
156 | 239 |
} |
... | ... | |
196 | 279 |
algorithmSpinner.setAdapter(algorithmAdapter); |
197 | 280 |
} |
198 | 281 |
|
199 |
@SuppressWarnings("unchecked") |
|
200 |
@Override |
|
201 |
protected void onActivityResult (int requestCode, int resultCode, Intent data){ |
|
202 |
if(requestCode == ADD_NODES_ACTIVITY_CODE && resultCode == RESULT_OK){ |
|
203 |
//set node list |
|
204 |
nodes = ((ArrayList<Node>)data.getSerializableExtra("nodes")); |
|
205 |
} |
|
206 |
else if(requestCode == ADD_NODES_ACTIVITY_CODE && resultCode == RESULT_CANCELED){ |
|
207 |
//don't change list |
|
208 |
|
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 | 282 |
private class AddLoadBalancerTask extends AsyncTask<Void, Void, HttpBundle> { |
213 | 283 |
private CloudServersException exception; |
214 | 284 |
|
215 | 285 |
protected void onPreExecute(){ |
216 | 286 |
showDialog(); |
217 | 287 |
} |
218 |
|
|
288 |
|
|
219 | 289 |
@Override |
220 | 290 |
protected HttpBundle doInBackground(Void... arg0) { |
221 | 291 |
HttpBundle bundle = null; |
... | ... | |
251 | 321 |
finish(); |
252 | 322 |
} |
253 | 323 |
} |
324 |
|
|
325 |
@SuppressWarnings("unchecked") |
|
326 |
@Override |
|
327 |
protected void onActivityResult (int requestCode, int resultCode, Intent data){ |
|
328 |
if(requestCode == ADD_NODES_ACTIVITY_CODE && resultCode == RESULT_OK){ |
|
329 |
//set node list |
|
330 |
nodes = ((ArrayList<Node>)data.getSerializableExtra("nodes")); |
|
331 |
updateNodesIndicatorLight(); |
|
332 |
} |
|
333 |
else if(requestCode == ADD_NODES_ACTIVITY_CODE && resultCode == RESULT_CANCELED){ |
|
334 |
//don't change list |
|
335 |
} |
|
336 |
else if(requestCode == SHARED_VIP_ACTIVITY_CODE && resultCode == RESULT_OK){ |
|
337 |
selectedVip = (VirtualIp)data.getSerializableExtra("selectedVip"); |
|
338 |
updateVipIndicatorLight(); |
|
339 |
} |
|
340 |
} |
|
254 | 341 |
} |
b/src/com/rackspacecloud/android/AddMoreNodesActivity.java | ||
---|---|---|
453 | 453 |
String[] ip = {data.getStringExtra("nodeIp")}; |
454 | 454 |
server.setPrivateIpAddresses(ip); |
455 | 455 |
servers.add(server); |
456 |
setServerList(servers); |
|
456 | 457 |
} else { |
457 | 458 |
showAlert("Error", "This IP belongs to a cloud server: \"" + getNameFromIp(node.getAddress()) |
458 | 459 |
+ "\", please select it from the list."); |
b/src/com/rackspacecloud/android/AddNodesActivity.java | ||
---|---|---|
355 | 355 |
String[] ip = {data.getStringExtra("nodeIp")}; |
356 | 356 |
server.setPrivateIpAddresses(ip); |
357 | 357 |
servers.add(server); |
358 |
setServerList(servers); |
|
358 | 359 |
} else { |
359 | 360 |
showAlert("Error", "This IP belongs to a cloud server: \"" + getNameFromIp(node.getAddress()) |
360 | 361 |
+ "\", please select it from the list."); |
b/src/com/rackspacecloud/android/CloudActivity.java | ||
---|---|---|
30 | 30 |
import android.view.WindowManager; |
31 | 31 |
import android.view.ViewGroup.LayoutParams; |
32 | 32 |
import android.widget.ProgressBar; |
33 |
import android.widget.Toast; |
|
33 | 34 |
|
34 | 35 |
/* |
35 | 36 |
* CloudActivity manages the display and hiding of |
... | ... | |
45 | 46 |
private ProgressDialog pDialog; |
46 | 47 |
|
47 | 48 |
@Override |
49 |
protected void onCreate(Bundle savedInstanceState){ |
|
50 |
super.onCreate(savedInstanceState); |
|
51 |
|
|
52 |
//So keyboard doesn't open till user clicks |
|
53 |
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
48 | 57 |
protected void onSaveInstanceState(Bundle outState) { |
49 | 58 |
super.onSaveInstanceState(outState); |
50 | 59 |
|
... | ... | |
95 | 104 |
viewIntent.putExtra("request", bundle.getCurlRequest()); |
96 | 105 |
startActivity(viewIntent); |
97 | 106 |
} |
107 |
|
|
108 |
protected void showToast(String message) { |
|
109 |
Context context = getApplicationContext(); |
|
110 |
int duration = Toast.LENGTH_SHORT; |
|
111 |
Toast toast = Toast.makeText(context, message, duration); |
|
112 |
toast.show(); |
|
113 |
} |
|
98 | 114 |
|
99 | 115 |
protected final CloudServersException parseCloudServersException(HttpResponse response) { |
100 | 116 |
CloudServersException cse = new CloudServersException(); |
b/src/com/rackspacecloud/android/CloudListActivity.java | ||
---|---|---|
30 | 30 |
import android.view.WindowManager; |
31 | 31 |
import android.view.ViewGroup.LayoutParams; |
32 | 32 |
import android.widget.ProgressBar; |
33 |
import android.widget.Toast; |
|
33 | 34 |
|
34 | 35 |
public class CloudListActivity extends ListActivity{ |
35 | 36 |
|
... | ... | |
38 | 39 |
private ProgressDialog pDialog; |
39 | 40 |
|
40 | 41 |
@Override |
42 |
protected void onCreate(Bundle savedInstanceState){ |
|
43 |
super.onCreate(savedInstanceState); |
|
44 |
|
|
45 |
//So keyboard doesn't open till user clicks |
|
46 |
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
41 | 50 |
protected void onSaveInstanceState(Bundle outState) { |
42 | 51 |
super.onSaveInstanceState(outState); |
43 | 52 |
|
... | ... | |
88 | 97 |
viewIntent.putExtra("request", bundle.getCurlRequest()); |
89 | 98 |
startActivity(viewIntent); |
90 | 99 |
} |
100 |
|
|
101 |
protected void showToast(String message) { |
|
102 |
Context context = getApplicationContext(); |
|
103 |
int duration = Toast.LENGTH_SHORT; |
|
104 |
Toast toast = Toast.makeText(context, message, duration); |
|
105 |
toast.show(); |
|
106 |
} |
|
91 | 107 |
|
92 | 108 |
protected final CloudServersException parseCloudServersException(HttpResponse response) { |
93 | 109 |
CloudServersException cse = new CloudServersException(); |
b/src/com/rackspacecloud/android/ListAccountsActivity.java | ||
---|---|---|
488 | 488 |
Protocol.setProtocols(result); |
489 | 489 |
new LoadAlgorithmsTask().execute((Void[]) null); |
490 | 490 |
} else { |
491 |
hideDialog(); |
|
491 | 492 |
showAlert("Login Failure", "There was a problem loading load balancer protocols. Please try again."); |
492 | 493 |
} |
493 | 494 |
} |
... | ... | |
506 | 507 |
Algorithm.setAlgorithms(result); |
507 | 508 |
new LoadFlavorsTask().execute((Void[]) null); |
508 | 509 |
} else { |
510 |
hideDialog(); |
|
509 | 511 |
showAlert("Login Failure", "There was a problem loading load balancer algorithms. Please try again."); |
510 | 512 |
} |
511 | 513 |
} |
b/src/com/rackspacecloud/android/Preferences.java | ||
---|---|---|
28 | 28 |
//Define auth server here |
29 | 29 |
public static final String COUNTRY_US_AUTH_SERVER = "https://auth.api.rackspacecloud.com/v1.0"; |
30 | 30 |
public static final String COUNTRY_UK_AUTH_SERVER = "https://lon.auth.api.rackspacecloud.com/v1.0"; |
31 |
|
|
32 |
//Regions |
|
33 |
public static final String[] US_REGIONS = {"ORD", "DFW"}; |
|
34 |
public static final String[] UK_REGIONS = {"LON"}; |
|
31 | 35 |
|
32 | 36 |
protected void onCreate(Bundle savedInstanceState) { |
33 | 37 |
super.onCreate(savedInstanceState); |
b/src/com/rackspacecloud/android/SharedVipActivity.java | ||
---|---|---|
1 |
package com.rackspacecloud.android; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import android.content.Context; |
|
6 |
import android.content.Intent; |
|
7 |
import android.os.AsyncTask; |
|
8 |
import android.os.Bundle; |
|
9 |
import android.util.Log; |
|
10 |
import android.view.LayoutInflater; |
|
11 |
import android.view.View; |
|
12 |
import android.view.ViewGroup; |
|
13 |
import android.widget.ArrayAdapter; |
|
14 |
import android.widget.ListView; |
|
15 |
import android.widget.TextView; |
|
16 |
|
|
17 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancer; |
|
18 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancerManager; |
|
19 |
import com.rackspace.cloud.loadbalancer.api.client.VirtualIp; |
|
20 |
import com.rackspace.cloud.loadbalancer.api.client.http.LoadBalancersException; |
|
21 |
|
|
22 |
public class SharedVipActivity extends CloudListActivity { |
|
23 |
|
|
24 |
private Context context; |
|
25 |
private LoadBalancer[] loadBalancers; |
|
26 |
private VirtualIp[] vips; |
|
27 |
private String loadBalancerPort; |
|
28 |
private String loadBalancerRegion; |
|
29 |
|
|
30 |
@Override |
|
31 |
public void onCreate(Bundle savedInstanceState) { |
|
32 |
super.onCreate(savedInstanceState); |
|
33 |
setContentView(R.layout.list_vips); |
|
34 |
context = getApplicationContext(); |
|
35 |
loadBalancerPort = (String) this.getIntent().getExtras().get("loadBalancerPort"); |
|
36 |
loadBalancerRegion = (String) this.getIntent().getExtras().get("loadBalancerRegion"); |
|
37 |
restoreState(savedInstanceState); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
protected void onSaveInstanceState(Bundle outState) { |
|
42 |
super.onSaveInstanceState(outState); |
|
43 |
outState.putSerializable("loadBalancers", loadBalancers); |
|
44 |
} |
|
45 |
|
|
46 |
protected void restoreState(Bundle state) { |
|
47 |
super.restoreState(state); |
|
48 |
|
|
49 |
if (state != null && state.containsKey("loadBalancers") && state.getSerializable("loadBalancers") != null) { |
|
50 |
loadBalancers = (LoadBalancer[]) state.getSerializable("loadBalancers"); |
|
51 |
if (loadBalancers.length == 0) { |
|
52 |
displayNoLoadBalancerCell(); |
|
53 |
} else { |
|
54 |
getListView().setDividerHeight(1); // restore divider lines |
|
55 |
setListAdapter(new VirtualIpAdapter()); |
|
56 |
} |
|
57 |
} else { |
|
58 |
loadLoadBalancers(); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
private void displayNoLoadBalancerCell() { |
|
63 |
String a[] = new String[1]; |
|
64 |
a[0] = "No Load Balancers"; |
|
65 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.noloadbalancerscell, R.id.no_loadbalancers_label, a)); |
|
66 |
getListView().setTextFilterEnabled(true); |
|
67 |
getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row |
|
68 |
getListView().setItemsCanFocus(false); |
|
69 |
} |
|
70 |
|
|
71 |
private void setLoadBalancersList(ArrayList<VirtualIp> vips) { |
|
72 |
if (vips == null) { |
|
73 |
vips = new ArrayList<VirtualIp>(); |
|
74 |
} |
|
75 |
|
|
76 |
this.vips = new VirtualIp[vips.size()]; |
|
77 |
|
|
78 |
if (vips != null) { |
|
79 |
for (int i = 0; i < vips.size(); i++) { |
|
80 |
VirtualIp virtualIp = vips.get(i); |
|
81 |
this.vips[i] = virtualIp; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
if (this.vips.length == 0) { |
|
86 |
displayNoLoadBalancerCell(); |
|
87 |
} else { |
|
88 |
getListView().setDividerHeight(1); // restore divider lines |
|
89 |
setListAdapter(new VirtualIpAdapter()); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
|
94 |
|
|
95 |
/* |
|
96 |
* only allow clicks on vips that do not have the same port |
|
97 |
* as the lb and are in same region |
|
98 |
*/ |
|
99 |
if (vips != null && vips.length > 0) { |
|
100 |
Log.d("info", "vip loc: " + vips[position].getLoadBalancer().getRegion() + " lb region: " + loadBalancerRegion); |
|
101 |
if(vips[position].getLoadBalancer().getPort().equals(loadBalancerPort)){ |
|
102 |
showToast("Cannot use this Virtual IP. The same port cannot be used on multiple load balancers for a Shared Virtual IP."); |
|
103 |
} else if(!vips[position].getLoadBalancer().getRegion().equals(loadBalancerRegion)){ |
|
104 |
showToast("Cannot use this Virtual IP. The Shared Virtual IP must come the same region as the new load balancer."); |
|
105 |
} else { |
|
106 |
Intent viewIntent = new Intent(); |
|
107 |
viewIntent.putExtra("selectedVip", vips[position]); |
|
108 |
setResult(RESULT_OK, viewIntent); |
|
109 |
finish(); |
|
110 |
} |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
// * Adapter/ |
|
115 |
class VirtualIpAdapter extends ArrayAdapter<VirtualIp> { |
|
116 |
|
|
117 |
VirtualIpAdapter() { |
|
118 |
super(SharedVipActivity.this, |
|
119 |
R.layout.sharedvipcell, vips); |
|
120 |
} |
|
121 |
|
|
122 |
public View getView(int position, View convertView, ViewGroup parent) { |
|
123 |
VirtualIp virtualIp = vips[position]; |
|
124 |
LayoutInflater inflater = getLayoutInflater(); |
|
125 |
View row = inflater.inflate(R.layout.sharedvipcell, |
|
126 |
parent, false); |
|
127 |
|
|
128 |
TextView vipAddress = (TextView) row.findViewById(R.id.vip_address); |
|
129 |
vipAddress.setText(virtualIp.getAddress()); |
|
130 |
|
|
131 |
TextView type = (TextView) row.findViewById(R.id.vip_type); |
|
132 |
type.setText(virtualIp.getType()); |
|
133 |
|
|
134 |
TextView name = (TextView) row.findViewById(R.id.load_balancer_name); |
|
135 |
name.setText(virtualIp.getLoadBalancer().getName()); |
|
136 |
|
|
137 |
TextView protocol = (TextView) row.findViewById(R.id.vip_protocol); |
|
138 |
protocol.setText(virtualIp.getLoadBalancer().getProtocol() |
|
139 |
+ "(" + virtualIp.getLoadBalancer().getPort() + ")"); |
|
140 |
|
|
141 |
return (row); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
private void loadLoadBalancers() { |
|
146 |
new LoadLoadBalancersTask().execute((Void[]) null); |
|
147 |
} |
|
148 |
|
|
149 |
private class LoadLoadBalancersTask extends AsyncTask<Void, Void, ArrayList<LoadBalancer>> { |
|
150 |
private LoadBalancersException exception; |
|
151 |
|
|
152 |
@Override |
|
153 |
protected void onPreExecute(){ |
|
154 |
showDialog(); |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
protected ArrayList<LoadBalancer> doInBackground(Void... arg0) { |
|
159 |
ArrayList<LoadBalancer> loadBalancers = null; |
|
160 |
try { |
|
161 |
loadBalancers = (new LoadBalancerManager(context)).createList(); |
|
162 |
} catch (LoadBalancersException e) { |
|
163 |
exception = e; |
|
164 |
} |
|
165 |
return loadBalancers; |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
protected void onPostExecute(ArrayList<LoadBalancer> result) { |
|
170 |
hideDialog(); |
|
171 |
if (exception != null) { |
|
172 |
showAlert("Error", exception.getMessage()); |
|
173 |
} |
|
174 |
ArrayList<VirtualIp> vipList = getVipList(result); |
|
175 |
setLoadBalancersList(vipList); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
private ArrayList<VirtualIp> getVipList(ArrayList<LoadBalancer> result){ |
|
180 |
ArrayList<VirtualIp> vips = new ArrayList<VirtualIp>(); |
|
181 |
for(LoadBalancer lb : result){ |
|
182 |
for(VirtualIp ip : lb.getVirtualIps()){ |
|
183 |
ip.setLoadBalancer(lb); |
|
184 |
vips.add(ip); |
|
185 |
} |
|
186 |
} |
|
187 |
return vips; |
|
188 |
} |
|
189 |
|
|
190 |
} |
Also available in: Unified diff