save
Showing
47 changed files
with
431 additions
and
137 deletions
| ... | @@ -123,7 +123,6 @@ | ... | @@ -123,7 +123,6 @@ |
| 123 | </dependency> | 123 | </dependency> |
| 124 | 124 | ||
| 125 | 125 | ||
| 126 | |||
| 127 | <!-- Test --> | 126 | <!-- Test --> |
| 128 | <dependency> | 127 | <dependency> |
| 129 | <groupId>junit</groupId> | 128 | <groupId>junit</groupId> |
| ... | @@ -136,7 +135,7 @@ | ... | @@ -136,7 +135,7 @@ |
| 136 | <dependency> | 135 | <dependency> |
| 137 | <groupId>org.emercit</groupId> | 136 | <groupId>org.emercit</groupId> |
| 138 | <artifactId>utilstools</artifactId> | 137 | <artifactId>utilstools</artifactId> |
| 139 | <version>1.16</version> | 138 | <version>1.19</version> |
| 140 | </dependency> | 139 | </dependency> |
| 141 | 140 | ||
| 142 | <dependency> | 141 | <dependency> |
| ... | @@ -175,17 +174,12 @@ | ... | @@ -175,17 +174,12 @@ |
| 175 | </repository> | 174 | </repository> |
| 176 | 175 | ||
| 177 | 176 | ||
| 178 | 177 | <repository> | |
| 179 | |||
| 180 | |||
| 181 | |||
| 182 | <repository> | ||
| 183 | <id>project.local</id> | 178 | <id>project.local</id> |
| 184 | <name>project</name> | 179 | <name>project</name> |
| 185 | <url>file:/root/git/hardwareconfig/DevTools/repo</url> | 180 | <url>file:/root/git/hardwareconfig/DevTools/repo</url> |
| 186 | </repository> | 181 | </repository> |
| 187 | 182 | ||
| 188 | |||
| 189 | <repository> | 183 | <repository> |
| 190 | <id>org.repo.jfrog.artifactory.libs-releases</id> | 184 | <id>org.repo.jfrog.artifactory.libs-releases</id> |
| 191 | <name>Repository1</name> | 185 | <name>Repository1</name> |
| ... | @@ -196,8 +190,6 @@ | ... | @@ -196,8 +190,6 @@ |
| 196 | 190 | ||
| 197 | </repository> | 191 | </repository> |
| 198 | 192 | ||
| 199 | |||
| 200 | |||
| 201 | <repository> | 193 | <repository> |
| 202 | <id>com.gradle.artifactoryonline.gradle.libs</id> | 194 | <id>com.gradle.artifactoryonline.gradle.libs</id> |
| 203 | <name>Repository2</name> | 195 | <name>Repository2</name> | ... | ... |
No preview for this file type
| 1 | 68bbcceb162642ef73ba7cbc1a566298 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | f25a2cb290554b0386fd490cfe37e70efd2fee19 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>utilstools</artifactId> | ||
| 7 | <version>1.17</version> | ||
| 8 | </project> |
| 1 | 58bd90bbafd0f760fd1b3431a441254a | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 12681302bf7ad714b51559323a7c329f8a144762 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | a5031e7fae238946730cb327db61a6dd | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 1a36b59b9e38024990e1d254a880565e6b58f89c | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>utilstools</artifactId> | ||
| 7 | <version>1.18</version> | ||
| 8 | </project> |
| 1 | 4fc7dbffb85bff4447fadeef1c278d3c | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | acca07e8810ca848c73079faa0391b90cd57a42c | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | f73db6aa09b61179237636fe50579b09 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 1fa268fb3c9205c4a7dae4b90c7a91764d7aeb71 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>utilstools</artifactId> | ||
| 7 | <version>1.19</version> | ||
| 8 | </project> |
| 1 | 27ce43deaf1b550eb735a663bdf8d213 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | a8dc0d60d637a828a75edc0d1e980098d9cedc69 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | <groupId>org.emercit</groupId> | 3 | <groupId>org.emercit</groupId> |
| 4 | <artifactId>utilstools</artifactId> | 4 | <artifactId>utilstools</artifactId> |
| 5 | <versioning> | 5 | <versioning> |
| 6 | <release>1.16</release> | 6 | <release>1.19</release> |
| 7 | <versions> | 7 | <versions> |
| 8 | <version>1.0</version> | 8 | <version>1.0</version> |
| 9 | <version>1.1</version> | 9 | <version>1.1</version> |
| ... | @@ -22,7 +22,10 @@ | ... | @@ -22,7 +22,10 @@ |
| 22 | <version>1.14</version> | 22 | <version>1.14</version> |
| 23 | <version>1.15</version> | 23 | <version>1.15</version> |
| 24 | <version>1.16</version> | 24 | <version>1.16</version> |
| 25 | <version>1.17</version> | ||
| 26 | <version>1.18</version> | ||
| 27 | <version>1.19</version> | ||
| 25 | </versions> | 28 | </versions> |
| 26 | <lastUpdated>20150803074609</lastUpdated> | 29 | <lastUpdated>20150803150448</lastUpdated> |
| 27 | </versioning> | 30 | </versioning> |
| 28 | </metadata> | 31 | </metadata> | ... | ... |
| ... | @@ -64,6 +64,15 @@ public class EthController { | ... | @@ -64,6 +64,15 @@ public class EthController { |
| 64 | public @ResponseBody MsgResult update(@RequestBody EthBean m) { | 64 | public @ResponseBody MsgResult update(@RequestBody EthBean m) { |
| 65 | return Msg.getMsgResultByCode(EthService.INSTANCE.Upd(m)); | 65 | return Msg.getMsgResultByCode(EthService.INSTANCE.Upd(m)); |
| 66 | } | 66 | } |
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | @RequestMapping(value="eth/reload" , method = RequestMethod.POST) | ||
| 71 | public @ResponseBody MsgResult reload(@RequestBody EthBean m) { | ||
| 72 | return Msg.getMsgResultByCode(EthService.INSTANCE.Reload(m)); | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 67 | 76 | ||
| 68 | } | 77 | } |
| 69 | 78 | ... | ... |
| 1 | package org.emercit.devtools.app; | 1 | package org.emercit.devtools.app; |
| 2 | 2 | ||
| 3 | |||
| 4 | import java.util.Locale; | ||
| 5 | |||
| 6 | import org.slf4j.Logger; | ||
| 7 | import org.slf4j.LoggerFactory; | ||
| 8 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 9 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 10 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | |||
| 12 | import javax.servlet.http.*; | ||
| 13 | import javax.servlet.ServletContext; | ||
| 14 | |||
| 15 | import java.io.*; | ||
| 16 | |||
| 17 | import org.springframework.stereotype.Controller; | ||
| 18 | import org.springframework.validation.BindingResult; | ||
| 19 | import org.springframework.web.bind.annotation.ModelAttribute; | ||
| 20 | import org.springframework.web.bind.annotation.PathVariable; | ||
| 21 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 22 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 23 | import org.springframework.web.bind.annotation.RequestParam; | ||
| 24 | import org.springframework.stereotype.Controller; | ||
| 25 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 26 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 27 | import org.springframework.web.bind.annotation.ResponseBody; | ||
| 28 | import org.springframework.web.bind.annotation.RequestBody; | ||
| 29 | |||
| 30 | import java.util.Vector; | ||
| 31 | |||
| 32 | import org.emercit.gsmmanager.model.GSMBean; | ||
| 33 | import org.emercit.utilstools.config.Msg; | ||
| 34 | import org.emercit.utilstools.config.MsgResult; | ||
| 35 | |||
| 36 | |||
| 37 | import org.emercit.devtools.service.GSMService; | ||
| 38 | |||
| 39 | |||
| 40 | @Controller | ||
| 41 | @RequestMapping("api") | ||
| 3 | public class GsmModemController { | 42 | public class GsmModemController { |
| 43 | |||
| 44 | |||
| 45 | @RequestMapping(value = "gsm", method = RequestMethod.GET) | ||
| 46 | public @ResponseBody GSMBean getGSM() { | ||
| 47 | |||
| 48 | return GSMService.INSTANCE.getGsm(); | ||
| 49 | } | ||
| 4 | 50 | ||
| 51 | @RequestMapping(value="gsm/update" , method = RequestMethod.POST) | ||
| 52 | public @ResponseBody MsgResult update(@RequestBody GSMBean m) { | ||
| 53 | |||
| 54 | return Msg.getMsgResultByCode(GSMService.INSTANCE.Update(m)); | ||
| 55 | |||
| 56 | } | ||
| 5 | } | 57 | } |
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | ... | ... |
| ... | @@ -31,7 +31,6 @@ public enum DevControlService { | ... | @@ -31,7 +31,6 @@ public enum DevControlService { |
| 31 | public DateInfo getDateInfo() { | 31 | public DateInfo getDateInfo() { |
| 32 | DateInfo dateinfo=new DateInfo(); | 32 | DateInfo dateinfo=new DateInfo(); |
| 33 | 33 | ||
| 34 | |||
| 35 | dateinfo.setNtp(ntplinux.getUseNtpServer()); | 34 | dateinfo.setNtp(ntplinux.getUseNtpServer()); |
| 36 | 35 | ||
| 37 | Calendar calendar = Calendar.getInstance(); | 36 | Calendar calendar = Calendar.getInstance(); |
| ... | @@ -40,7 +39,6 @@ public enum DevControlService { | ... | @@ -40,7 +39,6 @@ public enum DevControlService { |
| 40 | 39 | ||
| 41 | TimeZone timeZone = calendar.getTimeZone(); | 40 | TimeZone timeZone = calendar.getTimeZone(); |
| 42 | 41 | ||
| 43 | |||
| 44 | Date date=calendar.getTime(); | 42 | Date date=calendar.getTime(); |
| 45 | dateinfo.setDt(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date())); | 43 | dateinfo.setDt(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date())); |
| 46 | 44 | ... | ... |
| ... | @@ -38,6 +38,10 @@ public enum EthService { | ... | @@ -38,6 +38,10 @@ public enum EthService { |
| 38 | public int Upd(EthBean m) { | 38 | public int Upd(EthBean m) { |
| 39 | return ethlinux.Update(m); | 39 | return ethlinux.Update(m); |
| 40 | } | 40 | } |
| 41 | |||
| 42 | public int Reload(EthBean m) { | ||
| 43 | return ethlinux.reload(m.getName()); | ||
| 44 | } | ||
| 41 | 45 | ||
| 42 | 46 | ||
| 43 | } | 47 | } | ... | ... |
| ... | @@ -11,9 +11,11 @@ import org.emercit.svmanager.model.SvBean; | ... | @@ -11,9 +11,11 @@ import org.emercit.svmanager.model.SvBean; |
| 11 | import java.util.Vector; | 11 | import java.util.Vector; |
| 12 | 12 | ||
| 13 | import org.emercit.pckutils.checkservice.STService; | 13 | import org.emercit.pckutils.checkservice.STService; |
| 14 | import org.emercit.utilstools.config.Msg; | ||
| 14 | import org.emercit.utilstools.config.Paths; | 15 | import org.emercit.utilstools.config.Paths; |
| 15 | |||
| 16 | import org.apache.log4j.Logger; | 16 | import org.apache.log4j.Logger; |
| 17 | import org.emercit.pckutils.checkservice.STService; | ||
| 18 | |||
| 17 | 19 | ||
| 18 | public enum SvService { | 20 | public enum SvService { |
| 19 | 21 | ||
| ... | @@ -42,10 +44,8 @@ public enum SvService { | ... | @@ -42,10 +44,8 @@ public enum SvService { |
| 42 | public Vector<SvBean> getSvBeans() { | 44 | public Vector<SvBean> getSvBeans() { |
| 43 | 45 | ||
| 44 | svbeans=sv.get(); | 46 | svbeans=sv.get(); |
| 45 | 47 | ||
| 46 | for (SvBean s:svbeans) { // проверяем запущен или остановлен | 48 | for (SvBean s:svbeans) { // проверяем запущен или остановлен |
| 47 | |||
| 48 | |||
| 49 | try { | 49 | try { |
| 50 | boolean status=st.IsRun(s.getProcess()); | 50 | boolean status=st.IsRun(s.getProcess()); |
| 51 | 51 | ||
| ... | @@ -55,18 +55,12 @@ public enum SvService { | ... | @@ -55,18 +55,12 @@ public enum SvService { |
| 55 | 55 | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | try { s.setIsrun(st.IsRun(s.getProcess())); } catch (Exception e) {}; | 58 | try { s.setIsrun(st.IsRun(s.getProcess())); } catch (Exception e) {}; |
| 62 | } | 59 | } |
| 63 | 60 | ||
| 64 | return svbeans; | 61 | return svbeans; |
| 65 | } | 62 | } |
| 66 | 63 | ||
| 67 | /* | ||
| 68 | * | ||
| 69 | */ | ||
| 70 | public int Update(SvBean bean) { | 64 | public int Update(SvBean bean) { |
| 71 | 65 | ||
| 72 | svbeans=sv.get(); | 66 | svbeans=sv.get(); |
| ... | @@ -80,20 +74,31 @@ public enum SvService { | ... | @@ -80,20 +74,31 @@ public enum SvService { |
| 80 | return sv.set(svbeans); | 74 | return sv.set(svbeans); |
| 81 | } | 75 | } |
| 82 | 76 | ||
| 83 | public int Start(SvBean svbean) { | 77 | public int Start(SvBean svbean) { |
| 84 | svcontrol=new SvControl(svbean); | 78 | |
| 85 | return svcontrol.start(); | 79 | try { |
| 86 | } | ||
| 87 | 80 | ||
| 81 | if (!st.IsRun(svbean.getProcess())) { | ||
| 82 | svcontrol=new SvControl(svbean); | ||
| 83 | return svcontrol.start(); | ||
| 84 | }else { | ||
| 85 | return Msg.ProcessIsRunnig.getCode(); | ||
| 86 | } | ||
| 87 | |||
| 88 | } catch(Exception e) { | ||
| 89 | log.error(e.getMessage()); | ||
| 90 | return Msg.ProcessRestartError.getCode(); | ||
| 91 | } | ||
| 92 | |||
| 93 | } | ||
| 88 | public int Stop(SvBean svbean) { | 94 | public int Stop(SvBean svbean) { |
| 89 | svcontrol=new SvControl(svbean); | 95 | svcontrol=new SvControl(svbean); |
| 90 | return svcontrol.stop(); | 96 | return svcontrol.stop(); |
| 91 | } | 97 | } |
| 92 | 98 | ||
| 93 | public int Restart(SvBean svbean) { | 99 | public int Restart(SvBean svbean) { |
| 94 | svcontrol=new SvControl(svbean); | 100 | svcontrol=new SvControl(svbean); |
| 95 | return svcontrol.restart(); | 101 | return svcontrol.restart(); |
| 96 | } | 102 | } |
| 97 | 103 | ||
| 98 | |||
| 99 | } | 104 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -20,7 +20,6 @@ public enum UtilsService { | ... | @@ -20,7 +20,6 @@ public enum UtilsService { |
| 20 | Vector<String> result=cmdexec.Run("ping -c 7 "+host); | 20 | Vector<String> result=cmdexec.Run("ping -c 7 "+host); |
| 21 | 21 | ||
| 22 | return result; | 22 | return result; |
| 23 | |||
| 24 | }catch(Exception e) { | 23 | }catch(Exception e) { |
| 25 | 24 | ||
| 26 | return new Vector<String>(); | 25 | return new Vector<String>(); | ... | ... |
1.23 KB
1.13 KB
| ... | @@ -17,7 +17,7 @@ Ext.define('App.store.Sv', { | ... | @@ -17,7 +17,7 @@ Ext.define('App.store.Sv', { |
| 17 | api: { | 17 | api: { |
| 18 | read: 'api/sv/all', | 18 | read: 'api/sv/all', |
| 19 | create : 'null', | 19 | create : 'null', |
| 20 | update : 'null', | 20 | update : 'api/sv/update', |
| 21 | destroy : 'null' | 21 | destroy : 'null' |
| 22 | }, | 22 | }, |
| 23 | actionMethods : | 23 | actionMethods : | ... | ... |
| ... | @@ -8,9 +8,9 @@ function renderercell(value, metaData, record, row, col, store, gridView) { | ... | @@ -8,9 +8,9 @@ function renderercell(value, metaData, record, row, col, store, gridView) { |
| 8 | function rendererstatusimg(value, metaData, record, rowIndex, colIndex, store) { | 8 | function rendererstatusimg(value, metaData, record, rowIndex, colIndex, store) { |
| 9 | if(value) { | 9 | if(value) { |
| 10 | // return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+'Запущен'+'</div>'; | 10 | // return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+'Запущен'+'</div>'; |
| 11 | return '<span><img src="resources/img/button-green.png" height="18" width="18"/> </span>'; | 11 | return '<span><img src="resources/img/up.png" height="18" width="18"/> </span>'; |
| 12 | }else { | 12 | }else { |
| 13 | return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+'Остановлен'+'</div>'; | 13 | return '<span><img src="resources/img/down.png" height="18" width="18"/> </span>'; |
| 14 | } | 14 | } |
| 15 | } | 15 | } |
| 16 | 16 | ||
| ... | @@ -118,6 +118,9 @@ Ext.define('App.view.Sv', { | ... | @@ -118,6 +118,9 @@ Ext.define('App.view.Sv', { |
| 118 | 118 | ||
| 119 | grid.unmask(); | 119 | grid.unmask(); |
| 120 | 120 | ||
| 121 | grid.store.load(); | ||
| 122 | grid.getView().refresh(); | ||
| 123 | |||
| 121 | var result = Ext.JSON.decode(response.responseText); | 124 | var result = Ext.JSON.decode(response.responseText); |
| 122 | 125 | ||
| 123 | 126 | ||
| ... | @@ -134,20 +137,76 @@ Ext.define('App.view.Sv', { | ... | @@ -134,20 +137,76 @@ Ext.define('App.view.Sv', { |
| 134 | icon: 'resources/img/stop.png', | 137 | icon: 'resources/img/stop.png', |
| 135 | tooltip: 'Остановить', | 138 | tooltip: 'Остановить', |
| 136 | handler: function(grid, rowIndex, colIndex) { | 139 | handler: function(grid, rowIndex, colIndex) { |
| 137 | var rec = grid.getStore().getAt(rowIndex); | 140 | var rec = grid.getStore().getAt(rowIndex); |
| 138 | 141 | var data=Ext.util.JSON.encode(rec.data); | |
| 139 | console.log(rec); | 142 | |
| 140 | 143 | grid.mask("Остановка..."); | |
| 141 | //alert("Terminate " + rec.get('firstname')); | 144 | |
| 145 | Ext.Ajax.request({ | ||
| 146 | method: "POST", | ||
| 147 | url: 'api/sv/stop', | ||
| 148 | timeout: 60000, | ||
| 149 | headers: { | ||
| 150 | 'Accept': 'application/json', | ||
| 151 | 'Content-Type': 'application/json' | ||
| 152 | }, | ||
| 153 | params:data, | ||
| 154 | success: function(response, opts) { | ||
| 155 | |||
| 156 | grid.unmask(); | ||
| 157 | |||
| 158 | grid.store.load(); | ||
| 159 | grid.getView().refresh(); | ||
| 160 | |||
| 161 | var result = Ext.JSON.decode(response.responseText); | ||
| 162 | |||
| 163 | |||
| 164 | Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message); | ||
| 165 | |||
| 166 | }, failure: function(response, opts) { | ||
| 167 | grid.unmask(); | ||
| 168 | Ext.Msg.alert('Failure', 'Ошибка соединения'); | ||
| 169 | } | ||
| 170 | }); | ||
| 142 | } | 171 | } |
| 143 | }, | 172 | }, |
| 144 | { | 173 | { |
| 145 | icon: 'resources/img/replay.png', | 174 | icon: 'resources/img/replay.png', |
| 146 | tooltip: 'Перезапустить', | 175 | tooltip: 'Перезапустить', |
| 147 | handler: function(grid, rowIndex, colIndex) { | 176 | handler: function(grid, rowIndex, colIndex) { |
| 148 | var rec = grid.getStore().getAt(rowIndex); | 177 | var rec = grid.getStore().getAt(rowIndex); |
| 149 | 178 | var data=Ext.util.JSON.encode(rec.data); | |
| 150 | console.log(rec); | 179 | |
| 180 | grid.mask("Перезапуск..."); | ||
| 181 | |||
| 182 | Ext.Ajax.request({ | ||
| 183 | method: "POST", | ||
| 184 | url: 'api/sv/restart', | ||
| 185 | timeout: 60000, | ||
| 186 | headers: { | ||
| 187 | 'Accept': 'application/json', | ||
| 188 | 'Content-Type': 'application/json' | ||
| 189 | }, | ||
| 190 | params:data, | ||
| 191 | success: function(response, opts) { | ||
| 192 | |||
| 193 | |||
| 194 | |||
| 195 | grid.unmask(); | ||
| 196 | |||
| 197 | grid.store.load(); | ||
| 198 | grid.getView().refresh(); | ||
| 199 | |||
| 200 | var result = Ext.JSON.decode(response.responseText); | ||
| 201 | |||
| 202 | |||
| 203 | Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message); | ||
| 204 | |||
| 205 | }, failure: function(response, opts) { | ||
| 206 | grid.unmask(); | ||
| 207 | Ext.Msg.alert('Failure', 'Ошибка соединения'); | ||
| 208 | } | ||
| 209 | }); | ||
| 151 | } | 210 | } |
| 152 | } | 211 | } |
| 153 | 212 | ... | ... |
| ... | @@ -61,7 +61,7 @@ private static final long serialVersionUID = 1L; | ... | @@ -61,7 +61,7 @@ private static final long serialVersionUID = 1L; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | public boolean getDhcp() { | 63 | public boolean getDhcp() { |
| 64 | return this.dhcp; | 64 | return dhcp; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | public void setDhcp(boolean value) { | 67 | public void setDhcp(boolean value) { | ... | ... |
| ... | @@ -36,6 +36,28 @@ public class EthLinux implements IEth { | ... | @@ -36,6 +36,28 @@ public class EthLinux implements IEth { |
| 36 | return (Vector<EthBean>)db.select(); | 36 | return (Vector<EthBean>)db.select(); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | |||
| 40 | public int reload(String name) { | ||
| 41 | |||
| 42 | |||
| 43 | try { | ||
| 44 | Vector<String> buff=cmdexec.Run("ifdown "+name); | ||
| 45 | Thread.sleep(5000); | ||
| 46 | buff=cmdexec.Run("ifup "+name); | ||
| 47 | Thread.sleep(5000); | ||
| 48 | Msg msg=Msg.RestartEthSucc; | ||
| 49 | |||
| 50 | log.info(msg.getDescription()); | ||
| 51 | return msg.getCode(); | ||
| 52 | }catch(Exception e) { | ||
| 53 | |||
| 54 | log.error(e.getMessage()); | ||
| 55 | return Msg.RestartEthErr.getCode(); | ||
| 56 | } | ||
| 57 | |||
| 58 | } | ||
| 59 | |||
| 60 | |||
| 39 | /* | 61 | /* |
| 40 | * Список интерфейсов Ethernet на данном устройстве | 62 | * Список интерфейсов Ethernet на данном устройстве |
| 41 | * @see org.emercit.ethmanager.service.IEth#getListEth() | 63 | * @see org.emercit.ethmanager.service.IEth#getListEth() |
| ... | @@ -87,11 +109,11 @@ public class EthLinux implements IEth { | ... | @@ -87,11 +109,11 @@ public class EthLinux implements IEth { |
| 87 | 109 | ||
| 88 | String addr=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'").firstElement(); | 110 | String addr=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'").firstElement(); |
| 89 | String mask=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'").firstElement(); | 111 | String mask=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'").firstElement(); |
| 90 | String gateway=cmdexec.Run("/sbin/route -n | grep 'UG' | awk '{print $2}'").firstElement(); | 112 | //String gateway=cmdexec.Run("/sbin/route -n | grep 'UG' | awk '{print $2}'").firstElement(); |
| 91 | 113 | ||
| 92 | eb.setIp(addr); | 114 | eb.setIp(addr); |
| 93 | eb.setNetmask(mask); | 115 | eb.setNetmask(mask); |
| 94 | eb.setGateway(gateway); | 116 | eb.setGateway(""); |
| 95 | } | 117 | } |
| 96 | 118 | ||
| 97 | return eb; | 119 | return eb; |
| ... | @@ -146,12 +168,10 @@ public class EthLinux implements IEth { | ... | @@ -146,12 +168,10 @@ public class EthLinux implements IEth { |
| 146 | bw.write("\n"); | 168 | bw.write("\n"); |
| 147 | bw.write("\n"); | 169 | bw.write("\n"); |
| 148 | 170 | ||
| 149 | int id=0; | 171 | |
| 150 | |||
| 151 | for (EthBean eb:ebs) { | 172 | for (EthBean eb:ebs) { |
| 152 | 173 | ||
| 153 | eb.setId(id); | 174 | |
| 154 | |||
| 155 | if (!eb.getDhcp()) { | 175 | if (!eb.getDhcp()) { |
| 156 | 176 | ||
| 157 | bw.write("auto "+eb.getName()); | 177 | bw.write("auto "+eb.getName()); |
| ... | @@ -175,7 +195,7 @@ public class EthLinux implements IEth { | ... | @@ -175,7 +195,7 @@ public class EthLinux implements IEth { |
| 175 | bw.write("\n"); | 195 | bw.write("\n"); |
| 176 | bw.write("\n"); | 196 | bw.write("\n"); |
| 177 | 197 | ||
| 178 | id++; | 198 | |
| 179 | } | 199 | } |
| 180 | 200 | ||
| 181 | bw.close(); | 201 | bw.close(); |
| ... | @@ -191,7 +211,7 @@ public class EthLinux implements IEth { | ... | @@ -191,7 +211,7 @@ public class EthLinux implements IEth { |
| 191 | 211 | ||
| 192 | public int setDefaults() { | 212 | public int setDefaults() { |
| 193 | 213 | ||
| 194 | ebs=(Vector<EthBean>)db.select(); | 214 | ebs=new Vector<EthBean>(); |
| 195 | 215 | ||
| 196 | Vector<String> v=new Vector<String>(); | 216 | Vector<String> v=new Vector<String>(); |
| 197 | v.add(""); | 217 | v.add(""); |
| ... | @@ -202,7 +222,7 @@ public class EthLinux implements IEth { | ... | @@ -202,7 +222,7 @@ public class EthLinux implements IEth { |
| 202 | //Eth0 | 222 | //Eth0 |
| 203 | NewEb.setName(DefSettings.Eth0_name); | 223 | NewEb.setName(DefSettings.Eth0_name); |
| 204 | NewEb.setBroadcast(DefSettings.Eth0_broadcast); | 224 | NewEb.setBroadcast(DefSettings.Eth0_broadcast); |
| 205 | NewEb.setDhcp(DefSettings.Eth1_dhcp); | 225 | NewEb.setDhcp(DefSettings.Eth0_dhcp); |
| 206 | NewEb.setIp(DefSettings.Eth0_ip); | 226 | NewEb.setIp(DefSettings.Eth0_ip); |
| 207 | NewEb.setNetmask(DefSettings.Eth0_netmask); | 227 | NewEb.setNetmask(DefSettings.Eth0_netmask); |
| 208 | NewEb.setGateway(DefSettings.Eth0_gateway); | 228 | NewEb.setGateway(DefSettings.Eth0_gateway); |
| ... | @@ -212,19 +232,21 @@ public class EthLinux implements IEth { | ... | @@ -212,19 +232,21 @@ public class EthLinux implements IEth { |
| 212 | ebs.add(NewEb); | 232 | ebs.add(NewEb); |
| 213 | 233 | ||
| 214 | //Eth1 | 234 | //Eth1 |
| 215 | NewEb=new EthBean(); | 235 | /* |
| 236 | EthBean NewEb1=new EthBean(); | ||
| 216 | 237 | ||
| 217 | NewEb.setName(DefSettings.Eth1_name); | 238 | NewEb1.setName(DefSettings.Eth1_name); |
| 218 | NewEb.setDhcp(DefSettings.Eth1_dhcp); | 239 | NewEb1.setDhcp(DefSettings.Eth1_dhcp); |
| 219 | NewEb.setIp(DefSettings.Eth1_ip); | 240 | NewEb1.setIp(DefSettings.Eth1_ip); |
| 220 | NewEb.setNetmask(DefSettings.Eth1_netmask); | 241 | NewEb1.setNetmask(DefSettings.Eth1_netmask); |
| 221 | NewEb.setGateway(DefSettings.Eth1_gateway); | 242 | NewEb1.setGateway(DefSettings.Eth1_gateway); |
| 222 | NewEb.setBroadcast(DefSettings.Eth1_broadcast); | 243 | NewEb1.setBroadcast(DefSettings.Eth1_broadcast); |
| 223 | NewEb.setMac(DefSettings.Eth1_mac); | 244 | NewEb1.setMac(DefSettings.Eth1_mac); |
| 224 | NewEb.setId(DefSettings.Eth1_id); | 245 | NewEb1.setId(DefSettings.Eth1_id); |
| 225 | NewEb.setInfo(v); | 246 | NewEb1.setInfo(v); |
| 226 | 247 | ||
| 227 | ebs.add(NewEb); | 248 | ebs.add(NewEb1); |
| 249 | */ | ||
| 228 | 250 | ||
| 229 | } | 251 | } |
| 230 | return Config(ebs); | 252 | return Config(ebs); | ... | ... |
| ... | @@ -11,5 +11,7 @@ public interface IEth { | ... | @@ -11,5 +11,7 @@ public interface IEth { |
| 11 | public int Update(EthBean m); | 11 | public int Update(EthBean m); |
| 12 | public EthBean getEthByName(String name); | 12 | public EthBean getEthByName(String name); |
| 13 | public Vector<String> getListEth(); | 13 | public Vector<String> getListEth(); |
| 14 | public int reload(String name); | ||
| 15 | |||
| 14 | 16 | ||
| 15 | } | 17 | } | ... | ... |
| ... | @@ -34,7 +34,7 @@ public class Servers implements IServers { | ... | @@ -34,7 +34,7 @@ public class Servers implements IServers { |
| 34 | 34 | ||
| 35 | Vector<ServerBean> beans=new Vector<ServerBean>(); | 35 | Vector<ServerBean> beans=new Vector<ServerBean>(); |
| 36 | 36 | ||
| 37 | ServerBean rsb=new ServerBean(); | 37 | ServerBean rsb=new ServerBean(); |
| 38 | 38 | ||
| 39 | rsb.setId(DefSettings.Server_id); | 39 | rsb.setId(DefSettings.Server_id); |
| 40 | rsb.setIp(DefSettings.Server_ip); | 40 | rsb.setIp(DefSettings.Server_ip); | ... | ... |
| ... | @@ -49,7 +49,7 @@ public class Sv { | ... | @@ -49,7 +49,7 @@ public class Sv { |
| 49 | svbeans.add(svbean); | 49 | svbeans.add(svbean); |
| 50 | 50 | ||
| 51 | int res=set(svbeans); | 51 | int res=set(svbeans); |
| 52 | 52 | ||
| 53 | for (SvBean sv:svbeans ) { | 53 | for (SvBean sv:svbeans ) { |
| 54 | 54 | ||
| 55 | svcontrol=new SvControl(sv); | 55 | svcontrol=new SvControl(sv); | ... | ... |
| ... | @@ -27,18 +27,20 @@ public class SvControl implements ISvControl { | ... | @@ -27,18 +27,20 @@ public class SvControl implements ISvControl { |
| 27 | public SvControl(SvBean svbean) { | 27 | public SvControl(SvBean svbean) { |
| 28 | this.svbean=svbean; | 28 | this.svbean=svbean; |
| 29 | } | 29 | } |
| 30 | |||
| 31 | /* | 30 | /* |
| 32 | * Остановка процесса | 31 | * Остановка процесса |
| 33 | * @see org.emercit.svmanager.service.ISvControl#stop() | 32 | * @see org.emercit.svmanager.service.ISvControl#stop() |
| 34 | */ | 33 | */ |
| 35 | public int stop() { | 34 | public int stop() { |
| 36 | try { | 35 | try { |
| 37 | cmdLog.print(cmdexec.Run(Paths.dirInit_d+" "+this.svbean.getProcess()+" "+"stop")); | 36 | |
| 37 | |||
| 38 | cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"stop")); | ||
| 38 | 39 | ||
| 39 | Thread.sleep(this.svbean.getStoptime()); | 40 | Thread.sleep(this.svbean.getStoptime()); |
| 40 | 41 | ||
| 41 | if(st.IsRun(this.svbean.getProcess())) { //если еще запущен | 42 | if(st.IsRun(this.svbean.getProcess())) { //если еще запущен |
| 43 | |||
| 42 | log.error(Msg.ProcessStopError.getDescription()); | 44 | log.error(Msg.ProcessStopError.getDescription()); |
| 43 | return Msg.ProcessStopError.getCode(); | 45 | return Msg.ProcessStopError.getCode(); |
| 44 | } | 46 | } |
| ... | @@ -50,7 +52,6 @@ public class SvControl implements ISvControl { | ... | @@ -50,7 +52,6 @@ public class SvControl implements ISvControl { |
| 50 | return Msg.ProcessStopSucc.getCode(); | 52 | return Msg.ProcessStopSucc.getCode(); |
| 51 | } | 53 | } |
| 52 | 54 | ||
| 53 | |||
| 54 | /* | 55 | /* |
| 55 | * Запуск процесса | 56 | * Запуск процесса |
| 56 | * @see org.emercit.svmanager.service.ISvControl#start() | 57 | * @see org.emercit.svmanager.service.ISvControl#start() |
| ... | @@ -59,8 +60,6 @@ public class SvControl implements ISvControl { | ... | @@ -59,8 +60,6 @@ public class SvControl implements ISvControl { |
| 59 | 60 | ||
| 60 | try { | 61 | try { |
| 61 | 62 | ||
| 62 | System.out.println(Paths.dirInit_d+this.svbean.getProcess()+" "+"start"); | ||
| 63 | |||
| 64 | cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"start")); | 63 | cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"start")); |
| 65 | 64 | ||
| 66 | Thread.sleep(this.svbean.getStarttime()); | 65 | Thread.sleep(this.svbean.getStarttime()); |
| ... | @@ -86,14 +85,15 @@ public class SvControl implements ISvControl { | ... | @@ -86,14 +85,15 @@ public class SvControl implements ISvControl { |
| 86 | */ | 85 | */ |
| 87 | public int restart() { | 86 | public int restart() { |
| 88 | try { | 87 | try { |
| 89 | cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"restart")); | ||
| 90 | 88 | ||
| 91 | typeCode =Msg.getByCode(stop()).getTypeVariable().getCode(); | 89 | typeCode =Msg.getByCode(stop()).getTypeVariable().getCode(); |
| 92 | 90 | ||
| 91 | |||
| 93 | if (typeCode==0) { // Нет ошибки | 92 | if (typeCode==0) { // Нет ошибки |
| 94 | 93 | ||
| 95 | typeCode=Msg.getByCode(start()).getTypeVariable().getCode(); | 94 | typeCode=Msg.getByCode(start()).getTypeVariable().getCode(); |
| 96 | 95 | ||
| 96 | |||
| 97 | if (typeCode==0) { | 97 | if (typeCode==0) { |
| 98 | 98 | ||
| 99 | log.info(Msg.ProcessRestartSucc.getDescription()); | 99 | log.info(Msg.ProcessRestartSucc.getDescription()); |
| ... | @@ -109,7 +109,6 @@ public class SvControl implements ISvControl { | ... | @@ -109,7 +109,6 @@ public class SvControl implements ISvControl { |
| 109 | }catch(Exception e) { | 109 | }catch(Exception e) { |
| 110 | log.error(e.getMessage()); | 110 | log.error(e.getMessage()); |
| 111 | } | 111 | } |
| 112 | |||
| 113 | return Msg.ProcessRestartError.getCode(); | 112 | return Msg.ProcessRestartError.getCode(); |
| 114 | } | 113 | } |
| 115 | 114 | ||
| ... | @@ -119,7 +118,7 @@ public class SvControl implements ISvControl { | ... | @@ -119,7 +118,7 @@ public class SvControl implements ISvControl { |
| 119 | */ | 118 | */ |
| 120 | public int addAutoRun() { | 119 | public int addAutoRun() { |
| 121 | try { | 120 | try { |
| 122 | cmdLog.print(cmdexec.Run("update-rc.d "+this.svbean.getProcess()+" default")); | 121 | cmdLog.print(cmdexec.Run("update-rc.d "+this.svbean.getProcess()+" defaults")); |
| 123 | }catch(Exception e) { | 122 | }catch(Exception e) { |
| 124 | return Msg.ProcessAddAutoRunError.getCode(); | 123 | return Msg.ProcessAddAutoRunError.getCode(); |
| 125 | }; | 124 | }; | ... | ... |
| 1 | package org.emercit.utilstools; | 1 | package org.emercit.utilstools; |
| 2 | 2 | ||
| 3 | import org.emercit.devinfo.service.DevInfo; | 3 | |
| 4 | import org.emercit.svmanager.model.SvBean; | 4 | import org.emercit.ethmanager.model.EthBean; |
| 5 | import org.emercit.svmanager.service.SvControl; | 5 | import org.emercit.ethmanager.service.EthLinux; |
| 6 | import org.emercit.svmanager.service.Sv; | 6 | |
| 7 | import java.util.Vector; | ||
| 7 | 8 | ||
| 8 | import org.apache.log4j.Logger; | 9 | import org.apache.log4j.Logger; |
| 9 | 10 | ||
| 10 | public class App | 11 | public class App |
| 11 | { | 12 | { |
| 12 | private static final Logger log = Logger.getLogger(App.class); | 13 | private static final Logger log = Logger.getLogger(App.class); |
| 13 | 14 | ||
| 15 | |||
| 16 | |||
| 17 | private static EthLinux ethlinux=new EthLinux(); | ||
| 18 | |||
| 14 | public static void main( String[] args ) | 19 | public static void main( String[] args ) |
| 15 | { | 20 | { |
| 16 | System.out.println("");; | 21 | Vector<EthBean> neans=ethlinux.getEthBeans(); |
| 22 | |||
| 23 | |||
| 24 | EthBean bb=ethlinux.getEthByName("eth0"); | ||
| 25 | |||
| 26 | |||
| 27 | System.out.println(""); | ||
| 17 | } | 28 | } |
| 18 | } | 29 | } | ... | ... |
| ... | @@ -27,10 +27,10 @@ public class DefSettings { | ... | @@ -27,10 +27,10 @@ public class DefSettings { |
| 27 | public static final int Eth1_id=1; | 27 | public static final int Eth1_id=1; |
| 28 | public static final String Eth1_name="eth1"; | 28 | public static final String Eth1_name="eth1"; |
| 29 | public static final String Eth1_mac=""; | 29 | public static final String Eth1_mac=""; |
| 30 | public static final boolean Eth1_dhcp=true; | 30 | public static final boolean Eth1_dhcp=false; |
| 31 | public static final String Eth1_ip=""; | 31 | public static final String Eth1_ip="192.168.99.1"; |
| 32 | public static final String Eth1_netmask=""; | 32 | public static final String Eth1_netmask="255.255.255.0"; |
| 33 | public static final String Eth1_gateway=""; | 33 | public static final String Eth1_gateway="192.168.99.2"; |
| 34 | public static final String Eth1_broadcast=""; | 34 | public static final String Eth1_broadcast=""; |
| 35 | public static final String Eth1_extinfo=""; | 35 | public static final String Eth1_extinfo=""; |
| 36 | //GSM | 36 | //GSM |
| ... | @@ -83,5 +83,4 @@ public class DefSettings { | ... | @@ -83,5 +83,4 @@ public class DefSettings { |
| 83 | 83 | ||
| 84 | public static final String devtools_title="Web интерфейс для конфигурации"; | 84 | public static final String devtools_title="Web интерфейс для конфигурации"; |
| 85 | 85 | ||
| 86 | |||
| 87 | } | 86 | } | ... | ... |
| ... | @@ -28,15 +28,22 @@ public enum Msg { | ... | @@ -28,15 +28,22 @@ public enum Msg { |
| 28 | ProcessStartSucc(13,TypeMsg.INFO,"Процесс успешно запущен"), | 28 | ProcessStartSucc(13,TypeMsg.INFO,"Процесс успешно запущен"), |
| 29 | ProcessStartError(14,TypeMsg.ERROR,"Ошибка запуска процесса"), | 29 | ProcessStartError(14,TypeMsg.ERROR,"Ошибка запуска процесса"), |
| 30 | 30 | ||
| 31 | |||
| 32 | |||
| 31 | ProcessRestartSucc(15,TypeMsg.INFO,"Выполнена перезагрузка процесса"), | 33 | ProcessRestartSucc(15,TypeMsg.INFO,"Выполнена перезагрузка процесса"), |
| 32 | ProcessRestartError(16,TypeMsg.ERROR,"Ошибка при перезагрузки процесса"), | 34 | ProcessRestartError(16,TypeMsg.ERROR,"Ошибка при перезагрузки процесса"), |
| 33 | 35 | ||
| 34 | ProcessAddAutoRunSucc(17,TypeMsg.INFO,"Процесс успешно добалвен в автозагрузку"), | 36 | ProcessAddAutoRunSucc(17,TypeMsg.INFO,"Процесс успешно добалвен в автозагрузку"), |
| 35 | ProcessDelAutoRunSucc(18,TypeMsg.INFO,"Процесс удален из автозагрузки"), | 37 | ProcessDelAutoRunSucc(18,TypeMsg.INFO,"Процесс удален из автозагрузки"), |
| 36 | 38 | ||
| 37 | ProcessAddAutoRunError(19,TypeMsg.INFO,"Ошибка при добавлении процесса в автозагрузку"), | 39 | ProcessAddAutoRunError(19,TypeMsg.ERROR,"Ошибка при добавлении процесса в автозагрузку"), |
| 38 | ProcessDelAutoRunError(20,TypeMsg.INFO,"Ошибка при удалении процесса из автозагрузки"); | 40 | ProcessDelAutoRunError(20,TypeMsg.ERROR,"Ошибка при удалении процесса из автозагрузки"), |
| 41 | |||
| 42 | ProcessIsRunnig(21,TypeMsg.INFO,"Процесс выполняется"), | ||
| 39 | 43 | ||
| 44 | |||
| 45 | RestartEthSucc(22,TypeMsg.INFO,"Перезагрузка сетевого интерфейса успешно выполнена"), | ||
| 46 | RestartEthErr(23,TypeMsg.ERROR,"Перезагрузка сетевого интерфейса не выполнена"); | ||
| 40 | 47 | ||
| 41 | private int code; | 48 | private int code; |
| 42 | 49 | ... | ... |
| ... | @@ -20,7 +20,7 @@ public class Paths { | ... | @@ -20,7 +20,7 @@ public class Paths { |
| 20 | public static final String FINDPROCESS_SCRIPT=dirScripts+"findprocess.sh"; | 20 | public static final String FINDPROCESS_SCRIPT=dirScripts+"findprocess.sh"; |
| 21 | 21 | ||
| 22 | //PROCESS | 22 | //PROCESS |
| 23 | public static final String JETTY="strt"; | 23 | public static final String JETTY="jetty"; |
| 24 | public static final String CTRLPNL="ctrlpnl"; | 24 | public static final String CTRLPNL="ctrlpnl"; |
| 25 | 25 | ||
| 26 | public static final String UTILSTOOLS_LOGFILE="/var/log/devtools.log"; | 26 | public static final String UTILSTOOLS_LOGFILE="/var/log/devtools.log"; | ... | ... |
| 1 | package org.emercit.utilstools; | ||
| 2 | |||
| 3 | |||
| 4 | import junit.framework.Test; | ||
| 5 | import junit.framework.TestCase; | ||
| 6 | import junit.framework.TestSuite; | ||
| 7 | import static org.junit.Assert.*; | ||
| 8 | |||
| 9 | import org.junit.After; | ||
| 10 | import org.junit.AfterClass; | ||
| 11 | import org.junit.Before; | ||
| 12 | import org.junit.BeforeClass; | ||
| 13 | import org.junit.Ignore; | ||
| 14 | import org.emercit.pckutils.checkservice.STService; | ||
| 15 | |||
| 16 | public class TestCheckProccess extends TestCase { | ||
| 17 | |||
| 18 | private STService stservice=new STService(); | ||
| 19 | |||
| 20 | @Ignore | ||
| 21 | @Before | ||
| 22 | public void testCheck() { | ||
| 23 | try { | ||
| 24 | // assertTrue(stservice.IsRun("jetty")); | ||
| 25 | } | ||
| 26 | catch(Exception e) { | ||
| 27 | // fail("Тест завален"); | ||
| 28 | } | ||
| 29 | |||
| 30 | assertTrue( true ); | ||
| 31 | |||
| 32 | //assertFalse(!stservice.IsRun("start.jar")); // Если true - то тест завален | ||
| 33 | // assertEquals(stservice.IsRun("start.jar")); // Если не равны - тест завален | ||
| 34 | // assertNotNull(stservice.IsRun("start.jar"))); // Если null - тест завален | ||
| 35 | //assertNull(stservice.IsRun("start.jar"))); // Если не null - тест завален | ||
| 36 | //assertNotSame(stservice.IsRun("start.jar")); // Если оба объекта являются одинаковыми(не одно и то же, что равны) - тест завален | ||
| 37 | //assertSame(stservice.IsRun("start.jar")); // Если оба объекта не являются одинаковыми - тест завален | ||
| 38 | } | ||
| 39 | |||
| 40 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | |||
| 2 | package org.emercit.utilstools; | ||
| 3 | |||
| 4 | |||
| 5 | import junit.framework.Test; | ||
| 6 | import junit.framework.TestCase; | ||
| 7 | import junit.framework.TestSuite; | ||
| 8 | import static org.junit.Assert.*; | ||
| 9 | import java.util.Vector; | ||
| 10 | import org.emercit.utilstools.config.Msg; | ||
| 11 | import org.junit.Before; | ||
| 12 | import org.junit.After; | ||
| 13 | import org.emercit.ethmanager.model.EthBean; | ||
| 14 | import org.emercit.ethmanager.service.EthLinux; | ||
| 15 | |||
| 16 | |||
| 17 | public class TestEthLinux extends TestCase { | ||
| 18 | |||
| 19 | |||
| 20 | private EthBean bean; | ||
| 21 | |||
| 22 | private Vector<EthBean> beans; | ||
| 23 | |||
| 24 | private EthLinux ethlinux; | ||
| 25 | |||
| 26 | private int value; | ||
| 27 | |||
| 28 | private Msg msg; | ||
| 29 | |||
| 30 | public TestEthLinux( String testName ) | ||
| 31 | { | ||
| 32 | super( testName ); | ||
| 33 | } | ||
| 34 | |||
| 35 | public static Test suite() | ||
| 36 | { | ||
| 37 | return new TestSuite( TestEthLinux.class ); | ||
| 38 | } | ||
| 39 | |||
| 40 | @Before | ||
| 41 | public void upEthLinux() | ||
| 42 | { | ||
| 43 | |||
| 44 | } | ||
| 45 | |||
| 46 | @After | ||
| 47 | public void downEthLinux() | ||
| 48 | { | ||
| 49 | |||
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | /* | ||
| 54 | * Установка и сбро сетевых настроек | ||
| 55 | */ | ||
| 56 | public void testEthLinux() | ||
| 57 | { | ||
| 58 | ethlinux=new EthLinux(); | ||
| 59 | assertNotNull(ethlinux); | ||
| 60 | |||
| 61 | |||
| 62 | // INIT | ||
| 63 | int value=ethlinux.setDefaults(); | ||
| 64 | |||
| 65 | msg=Msg.getByCode(value); | ||
| 66 | if (msg.getTypeVariable().getCode()==1) { | ||
| 67 | fail("Тест завален"); | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | beans=ethlinux.getEthBeans(); | ||
| 72 | |||
| 73 | assertNotNull(beans); | ||
| 74 | |||
| 75 | bean=beans.firstElement(); | ||
| 76 | |||
| 77 | assertNotNull(bean); | ||
| 78 | |||
| 79 | value=ethlinux.reload(bean.getName()); | ||
| 80 | |||
| 81 | msg=Msg.getByCode(value); | ||
| 82 | if (msg.getTypeVariable().getCode()==1) { | ||
| 83 | fail("Тест завален"); | ||
| 84 | } | ||
| 85 | |||
| 86 | |||
| 87 | bean.setIp("192.168.99.1"); | ||
| 88 | |||
| 89 | value=ethlinux.Update(bean); | ||
| 90 | msg=Msg.getByCode(value); | ||
| 91 | if (msg.getTypeVariable().getCode()==1) { | ||
| 92 | fail("Тест завален"); | ||
| 93 | } | ||
| 94 | |||
| 95 | assertTrue( true ); | ||
| 96 | } | ||
| 97 | |||
| 98 | |||
| 99 | |||
| 100 | |||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 104 | |||
| 105 | |||
| 106 | //assertFalse(!stservice.IsRun("start.jar")); // Если true - то тест завален | ||
| 107 | // assertEquals(stservice.IsRun("start.jar")); // Если не равны - тест завален | ||
| 108 | // assertNotNull(stservice.IsRun("start.jar"))); // Если null - тест завален | ||
| 109 | //assertNull(stservice.IsRun("start.jar"))); // Если не null - тест завален | ||
| 110 | //assertNotSame(stservice.IsRun("start.jar")); // Если оба объекта являются одинаковыми(не одно и то же, что равны) - тест завален | ||
| 111 | //assertSame(stservice.IsRun("start.jar")); // Если оба объекта не являются одинаковыми - тест завален |
| 1 | 1 | ||
| 2 | package org.emercit.utilstools; | 2 | package org.emercit.utilstools; |
| 3 | 3 | ||
| 4 | |||
| 5 | import junit.framework.Test; | 4 | import junit.framework.Test; |
| 6 | import junit.framework.TestCase; | 5 | import junit.framework.TestCase; |
| 7 | import junit.framework.TestSuite; | 6 | import junit.framework.TestSuite; |
| ... | @@ -11,6 +10,7 @@ import org.junit.After; | ... | @@ -11,6 +10,7 @@ import org.junit.After; |
| 11 | import org.junit.AfterClass; | 10 | import org.junit.AfterClass; |
| 12 | import org.junit.Before; | 11 | import org.junit.Before; |
| 13 | import org.junit.BeforeClass; | 12 | import org.junit.BeforeClass; |
| 13 | import org.junit.Ignore; | ||
| 14 | import org.emercit.svmanager.service.SvControl; | 14 | import org.emercit.svmanager.service.SvControl; |
| 15 | import org.emercit.svmanager.service.Sv; | 15 | import org.emercit.svmanager.service.Sv; |
| 16 | import org.emercit.svmanager.model.SvBean; | 16 | import org.emercit.svmanager.model.SvBean; |
| ... | @@ -19,6 +19,7 @@ import java.util.Vector; | ... | @@ -19,6 +19,7 @@ import java.util.Vector; |
| 19 | 19 | ||
| 20 | import org.emercit.utilstools.config.Msg; | 20 | import org.emercit.utilstools.config.Msg; |
| 21 | 21 | ||
| 22 | @Ignore | ||
| 22 | public class TestSvControl extends TestCase { | 23 | public class TestSvControl extends TestCase { |
| 23 | 24 | ||
| 24 | private Sv sv; | 25 | private Sv sv; |
| ... | @@ -36,6 +37,7 @@ public class TestSvControl extends TestCase { | ... | @@ -36,6 +37,7 @@ public class TestSvControl extends TestCase { |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | 39 | ||
| 40 | |||
| 39 | public static Test suite() | 41 | public static Test suite() |
| 40 | { | 42 | { |
| 41 | return new TestSuite( TestSvControl.class ); | 43 | return new TestSuite( TestSvControl.class ); |
| ... | @@ -44,8 +46,10 @@ public class TestSvControl extends TestCase { | ... | @@ -44,8 +46,10 @@ public class TestSvControl extends TestCase { |
| 44 | /* | 46 | /* |
| 45 | * Тестирование управления процессами | 47 | * Тестирование управления процессами |
| 46 | */ | 48 | */ |
| 49 | @Ignore | ||
| 47 | public void testSvControl() | 50 | public void testSvControl() |
| 48 | { | 51 | { |
| 52 | |||
| 49 | 53 | ||
| 50 | sv=new Sv(); | 54 | sv=new Sv(); |
| 51 | svbeans=sv.get(); | 55 | svbeans=sv.get(); |
| ... | @@ -54,22 +58,39 @@ public class TestSvControl extends TestCase { | ... | @@ -54,22 +58,39 @@ public class TestSvControl extends TestCase { |
| 54 | 58 | ||
| 55 | for (SvBean svbean:svbeans) { | 59 | for (SvBean svbean:svbeans) { |
| 56 | svcontrol=new SvControl(svbean); | 60 | svcontrol=new SvControl(svbean); |
| 57 | //START | 61 | |
| 62 | |||
| 58 | Msg msg=Msg.getByCode(svcontrol.start()); | 63 | Msg msg=Msg.getByCode(svcontrol.start()); |
| 59 | 64 | ||
| 60 | if(msg.getTypeVariable().getCode()==1) { | 65 | if(msg.getTypeVariable().getCode()==1) { |
| 61 | fail("Тест завален"); | 66 | fail("Тест завален"); |
| 62 | } | 67 | } |
| 63 | //RESTART | 68 | |
| 69 | |||
| 64 | msg=Msg.getByCode(svcontrol.restart()); | 70 | msg=Msg.getByCode(svcontrol.restart()); |
| 65 | if(msg.getTypeVariable().getCode()==1) { | 71 | if(msg.getTypeVariable().getCode()==1) { |
| 66 | fail("Тест завален"); | 72 | fail("Тест завален"); |
| 67 | } | 73 | } |
| 68 | //STOP | 74 | |
| 69 | msg=Msg.getByCode(svcontrol.stop()); | 75 | msg=Msg.getByCode(svcontrol.stop()); |
| 70 | if(msg.getTypeVariable().getCode()==1) { | 76 | if(msg.getTypeVariable().getCode()==1) { |
| 71 | fail("Тест завален"); | 77 | fail("Тест завален"); |
| 72 | } | 78 | } |
| 79 | |||
| 80 | msg=Msg.getByCode(svcontrol.addAutoRun()); | ||
| 81 | if(msg.getTypeVariable().getCode()==1) { | ||
| 82 | fail("Тест завален"); | ||
| 83 | } | ||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | msg=Msg.getByCode(svcontrol.delAutoRun()); | ||
| 88 | if(msg.getTypeVariable().getCode()==1) { | ||
| 89 | fail("Тест завален"); | ||
| 90 | } | ||
| 91 | |||
| 92 | |||
| 93 | |||
| 73 | } | 94 | } |
| 74 | assertTrue( true ); | 95 | assertTrue( true ); |
| 75 | } | 96 | } | ... | ... |
-
Please register or sign in to post a comment