OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / WebContent / sync.jsp
1 <%@ page import="org.ultramonkey.l7.model.*,
2                                  org.ultramonkey.l7.controller.*,
3                                  org.ultramonkey.l7.view.*, java.util.*"
4         language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
5 %>
6 <%
7
8         /*
9          * check session
10          */
11         L7guiServletBase base = new L7guiServletBase();
12         if (session.isNew() || base.checkSession(session) == false) {
13                 MessageView error = new MessageView(41387, LogCategorySet.GUI_USER_AUTHENTICATION,
14                                 Message.INVALID_SESSSION);
15                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
16                 response.sendRedirect(RedirectPages.LOGIN);
17                 return;
18         }
19
20         /*
21          * get result message
22          */
23         MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
24         String errorMessage = "";
25         int errorNumber = 0;
26         String category = "";
27         if (message != null) {
28                 errorMessage = message.getMessage();
29                 errorNumber = message.getErrno();
30                 category = message.getCategory();
31                 session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
32         }
33         
34         /*
35          * get command message
36          */
37         MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
38         String commandMessage = "";
39         int commandNumber = 0;
40         String commandCategory = "";
41         if (commandmessage != null) {
42                 commandMessage = commandmessage.getMessage();
43                 commandNumber = commandmessage.getErrno();
44                 commandCategory = commandmessage.getCategory();
45                 session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
46         }
47         
48         /*
49          * get cluster status
50          */
51         L7guiFramework framework = new L7guiFramework(); 
52         ClusterData cd = framework.getClusterData();
53         if (cd == null) {
54                 MessageView error = new MessageView(41388, LogCategorySet.GUI_USER_AUTHENTICATION,
55                                 Message.CLUSTER_DATA_ERROR);
56                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
57                 response.sendRedirect(RedirectPages.LOGIN);
58                 return;
59         }
60         session.setAttribute("cd",cd);
61         
62         /*
63          * get sync status and get self/other IP
64          */
65         String syncLogStatus = null;
66         String syncMonitorStatus = null;
67         String syncServiceStatus = null;
68         String syncRepStatus = null;
69         String syncSnmpStatus = null;
70         String syncGuiStatus = null;
71         String selfIp = null;
72         String otherIp = null;
73         
74         
75         if ( (cd.self_status == ClusterStatus.ACTIVE ) || (cd.self_status == ClusterStatus.STANDBY) ){
76                 // get sync Status
77                 syncLogStatus = (String)session.getAttribute(SessionKeys.LOG_SYNC_STATE);
78                 syncMonitorStatus = (String)session.getAttribute(SessionKeys.MONITOR_SYNC_STATE);
79                 syncServiceStatus = (String)session.getAttribute(SessionKeys.VS_SYNC_STATE);
80                 syncRepStatus = (String)session.getAttribute(SessionKeys.REP_SYNC_STATE);
81                 syncSnmpStatus = (String)session.getAttribute(SessionKeys.SNMP_SYNC_STATE);
82                 syncGuiStatus = (String)session.getAttribute(SessionKeys.GUI_SYNC_STATE);
83                 if ( (syncLogStatus == null) || (syncMonitorStatus == null) || (syncServiceStatus == null) 
84                                 || (syncRepStatus == null) || (syncSnmpStatus == null) || (syncGuiStatus == null) ){
85
86                         MessageView error = new MessageView(41389, LogCategorySet.GUI_USER_AUTHENTICATION,
87                                         Message.CLUSTER_DATA_ERROR);
88                         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
89                         response.sendRedirect(RedirectPages.LOGIN);
90                         return;
91                 }
92         
93                 // get Self/Other IP
94                 selfIp = cd.self_ip;
95                 otherIp = cd.other_ip;
96                 if ( (selfIp == null) || (otherIp == null) ){
97                         MessageView error = new MessageView(41390, LogCategorySet.GUI_IO_COMMAND,
98                                         Message.CLUSTER_DATA_ERROR);
99                         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
100                         response.sendRedirect(RedirectPages.LOGIN);
101                         return;
102                 }
103         }
104         
105         
106         /*
107          * fix style seat
108          */
109         String cssSeat = "l7gui_single_style.css";
110         if ( cd.self_status == ClusterStatus.ACTIVE ){
111                 cssSeat = "l7gui_act_style.css";
112         }
113         else if ( cd.self_status == ClusterStatus.STANDBY ){
114                 cssSeat = "l7gui_sby_style.css";
115         }
116
117         
118 %>
119
120         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
121         <html>
122                 <head>
123                         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
124                         <meta http-equiv="Pragma" content="no-cache">
125                         <meta http-equiv="Cache-Control" content="no-cache">
126                         <meta http-equiv="Expires" content="0"> 
127                         <meta http-equiv="Content-Script-Type" content="text/javascript" />
128                         <meta http-equiv="Content-Style-Type" content="text/css" />
129                         <script src="l7gui.js" type="text/javascript"></script>
130                         <noscript> 
131                 <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
132                         </noscript> 
133                         <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
134                         <link rel="shortcut icon" href="images/favicon.ico" />
135
136                         <title>Sync Resources</title>
137                 </head>
138
139                 <body class="normal">
140                 <jsp:include page="menu.jsp" flush="false"/>
141
142                 <div id="content">
143
144                 <h1>Sync Resources</h1>
145         <% if ( (cd.self_status != ClusterStatus.ACTIVE ) && (cd.self_status != ClusterStatus.STANDBY) ){
146         %>
147                         <p class="error">"Sync Resources" function is effective only when cluster is applied. </p>
148         <% 
149                 }
150                 else {
151         
152                         if (message != null) {
153                 %>
154                 
155                 <p class="error">[<%=category %>-<%=errorNumber %>]</p>
156                 <p class="error"><%=errorMessage %></p>
157                 
158                 <%
159                         }
160                         else if (commandmessage != null ){
161                 %>
162                 <p class="success">[<%=commandCategory %>-<%=commandNumber %>]</p>
163                 <p class="success"><%=commandMessage %></p>
164                 <%              
165                         }
166                 %>      
167                 
168
169                 <form method="post" action="SyncStateServlet" name="sync">
170                 <fieldset class="">
171                 <legend>Sync Info</legend>
172                 <h3> <%= selfIp %> <img class="arrow2" src="images/arrowlogo2.gif" alt="arrowlogo" /> <%=otherIp %> </h3>
173                 
174
175                 <table  class="infotable" cellspacing="0">
176                         <thead>
177                         <tr>
178                                 <th>Sync<br />CHECK</th><th>Category</th><th>Description</th>
179                         </tr>
180                         </thead>
181                         <tbody>
182                         <tr>
183                                 <td class="center"><input type="checkbox" name="sync_category" value="log_all"></td>
184                                 <td class="left">Log</td>
185                                 <td class="left"> Log settings</td>
186                         </tr>
187                         <tr>
188                                 <td class="center"><input type="checkbox" name="sync_category" value="monitor"></td>
189                                 <td class="left">Monitor</td>
190                                 <td class="left">Monitor settings</td>
191                         </tr>
192                         <tr>
193                                 <td class="center"><input type="checkbox" name="sync_category" value="service"></td>
194                                 <td class="left">Service</td>
195                                 <td class="left">VirtualService settings</td>
196                         </tr>
197                         <tr>
198                                 <td class="center"><input type="checkbox" name="sync_category" value="replication_info"></td>
199                                 <td class="left">Replication</td>
200                                 <td class="left">Replication settings</td>
201                         </tr>
202                         <tr>
203                                 <td class="center"><input type="checkbox" name="sync_category" value="snmp_info"></td>
204                                 <td class="left">SNMP Agent</td>
205                                 <td class="left">SNMP Agent settings</td>
206                         </tr>
207                         <tr>
208                                 <td class="center"><input type="checkbox" name="sync_category" value="userdata"></td>
209                                 <td class="left">GUI</td>
210                                 <td class="left">GUI User Management (Users &amp; Password)</td>
211                         </tr>
212                         </tbody>
213                 </table>
214                 </fieldset>
215
216         <input type="submit" name="button" value="<%=ButtonMode.SAVESYNC%>" onClick="return confirm(savesync)" />
217
218 </form>
219         <%
220         }
221         %>
222         </div>
223         </body>
224 </html>