Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Дмитрий Корытько
/
hware
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
db7d888b
...
db7d888b306c4982e4bb309e43f5b4c24e403075
authored
2015-08-04 00:50:42 +0300
by
root
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
save
1 parent
7d75e9a9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
294 additions
and
121 deletions
DevTools/src/main/java/org/emercit/devtools/app/UtilsController.java
DevTools/src/main/webapp/resources/js/app.js
DevTools/src/main/webapp/resources/js/app/controller/NetworkSetting.js
DevTools/src/main/webapp/resources/js/app/controller/Proxy.js
DevTools/src/main/webapp/resources/js/app/view/NetworkSetting.js
UtilsTools/src/main/java/org/emercit/ethmanager/service/EthLinux.java
UtilsTools/src/test/java/org/emercit/utilstools/TestEthLinux.java
UtilsTools/src/test/java/org/emercit/utilstools/TestProxyLinux.java
DevTools/src/main/java/org/emercit/devtools/app/UtilsController.java
View file @
db7d888
...
...
@@ -41,8 +41,6 @@ public class UtilsController {
@RequestMapping
(
value
=
"utils/ping"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
Vector
<
String
>
getResultPing
(
@RequestBody
String
host
)
{
return
UtilsService
.
INSTANCE
.
Ping
(
host
);
/*
Vector<String> results=new Vector<String>();
...
...
DevTools/src/main/webapp/resources/js/app.js
View file @
db7d888
...
...
@@ -245,10 +245,6 @@ Ext.application({
]
},
{
title
:
'ЖУРНАЛ'
,
items
:[
...
...
@@ -304,6 +300,9 @@ Ext.application({
});
Ext
.
getBody
().
unmask
();
}
});
...
...
DevTools/src/main/webapp/resources/js/app/controller/NetworkSetting.js
View file @
db7d888
...
...
@@ -11,95 +11,193 @@ Ext.define('App.controller.NetworkSetting', {
'toolbar button[action=showformping]'
:
{
click
:
this
.
OpenPingPanel
}
},
'toolbar button[action=loadEth]'
:
{
click
:
this
.
ReloadData
},
'toolbar button[action=rebootEth]'
:
{
click
:
this
.
RebootEth
}
});
Ext
.
Ajax
.
request
({
method
:
"GET"
,
url
:
'api/eth/byeth/eth0'
,
headers
:
{
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json'
},
success
:
function
(
response
,
opts
)
{
var
result
=
Ext
.
JSON
.
decode
(
response
.
responseText
);
Ext
.
getCmp
(
'cbxeth'
).
setValue
(
"eth0"
);
Ext
.
getCmp
(
"dhcp"
).
setValue
(
result
.
dhcp
);
Ext
.
getCmp
(
'mac'
).
setValue
(
result
.
mac
);
Ext
.
getCmp
(
'ip'
).
setValue
(
result
.
ip
);
Ext
.
getCmp
(
'gateway'
).
setValue
(
result
.
gateway
);
Ext
.
getCmp
(
'netmask'
).
setValue
(
result
.
netmask
);
var
str
=
""
;
for
(
var
i
in
result
.
info
){
str
=
str
+
result
.
info
[
i
]
+
"\n"
;
}
Ext
.
getCmp
(
'extinfo'
).
setValue
(
str
);
},
failure
:
function
(
response
,
opts
)
{
Ext
.
Msg
.
alert
(
'Ошибка'
,
'Сервер недоступен'
);
}
});
},
OpenPingPanel
:
function
()
{
var
panel
=
Ext
.
create
(
"App.view.PingUtil"
);
panel
.
show
();
panel
.
show
();
},
ReloadData
:
function
()
{
var
combo
=
Ext
.
getCmp
(
'cbxeth'
);
if
(
typeof
combo
.
getStore
().
lastOptions
!==
"undefined"
)
{
var
value
=
combo
.
getValue
();
var
valueField
=
combo
.
valueField
;
var
record
;
combo
.
getStore
().
each
(
function
(
r
){
if
(
r
.
data
[
valueField
]
==
value
){
record
=
r
;
return
false
;
}
});
var
eth
=
record
?
record
.
get
(
combo
.
displayField
)
:
null
;
RebootEth
:
function
(
btn
)
{
var
networksettingView
=
btn
.
up
(
'mvvm-NetworkSettingView'
);
//mask
networksettingView
.
mask
(
"Перезагрузка сетевого интерфейса..."
);
var
dhcp
=
Ext
.
getCmp
(
"dhcp"
).
getValue
();
var
ip
=
Ext
.
getCmp
(
'ip'
).
getValue
();
var
gateway
=
Ext
.
getCmp
(
'gateway'
).
getValue
();
var
netmask
=
Ext
.
getCmp
(
'netmask'
).
getValue
();
var
name
=
Ext
.
getCmp
(
'cbxeth'
).
getValue
();
var
record
=
{
id
:
0
,
name
:
name
,
info
:
null
,
mac
:
""
,
ip
:
ip
,
netmask
:
netmask
,
dhcp
:
dhcp
,
gateway
:
gateway
,
broadcast
:
""
};
if
(
record
)
{
var
data
=
Ext
.
util
.
JSON
.
encode
(
record
);
Ext
.
Ajax
.
request
({
method
:
"GET"
,
url
:
'api/net/byeth/'
+
eth
,
headers
:
{
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json'
},
success
:
function
(
response
,
opts
)
{
var
result
=
Ext
.
JSON
.
decode
(
response
.
responseText
);
Ext
.
getCmp
(
'fromnetwork'
).
viewModel
.
setData
(
result
);
Ext
.
getCmp
(
'mac'
).
setDisabled
(
true
);
},
failure
:
function
(
response
,
opts
)
{
}
});
//unmask
method
:
"POST"
,
url
:
'api/eth/reload'
,
timeout
:
60000
,
headers
:
{
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json'
},
params
:
data
,
success
:
function
(
response
,
opts
)
{
networksettingView
.
unmask
();
var
result
=
Ext
.
JSON
.
decode
(
response
.
responseText
);
Ext
.
Msg
.
alert
(
result
.
type
+
" "
+
"Код-"
+
result
.
code
,
result
.
message
);
}
},
failure
:
function
(
response
,
opts
)
{
networksettingView
.
unmask
();
Ext
.
Msg
.
alert
(
'Ошибка'
,
'Сервер недоступен'
);
}
});
}
},
ReloadData
:
function
(
btn
)
{
var
networksettingView
=
btn
.
up
(
'mvvm-NetworkSettingView'
);
//mask
networksettingView
.
mask
(
"Загрузка..."
);
Ext
.
Ajax
.
request
({
method
:
"GET"
,
url
:
'api/eth/byeth/eth0'
,
headers
:
{
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json'
},
success
:
function
(
response
,
opts
)
{
networksettingView
.
unmask
();
var
result
=
Ext
.
JSON
.
decode
(
response
.
responseText
);
Ext
.
getCmp
(
'cbxeth'
).
setValue
(
"eth0"
);
Ext
.
getCmp
(
"dhcp"
).
setValue
(
result
.
dhcp
);
Ext
.
getCmp
(
'mac'
).
setValue
(
result
.
mac
);
Ext
.
getCmp
(
'ip'
).
setValue
(
result
.
ip
);
Ext
.
getCmp
(
'gateway'
).
setValue
(
result
.
gateway
);
Ext
.
getCmp
(
'netmask'
).
setValue
(
result
.
netmask
);
var
str
=
""
;
for
(
var
i
in
result
.
info
){
str
=
str
+
result
.
info
[
i
]
+
"\n"
;
}
Ext
.
getCmp
(
'extinfo'
).
setValue
(
str
);
Ext
.
Msg
.
alert
(
'Успешно'
,
'Загрузка данных выполнена'
);
},
failure
:
function
(
response
,
opts
)
{
Ext
.
Msg
.
alert
(
'Ошибка'
,
'Сервер недоступен'
);
}
});
},
onSaveButtonClick
:
function
(
btn
)
{
var
networksettingView
=
btn
.
up
(
'mvvm-NetworkSettingView'
);
//mask
networksettingView
.
mask
(
"Сохранение..."
);
var
record
=
networksettingView
.
getViewModel
().
getData
();
var
dhcp
=
Ext
.
getCmp
(
"dhcp"
).
getValue
();
var
ip
=
Ext
.
getCmp
(
'ip'
).
getValue
();
var
gateway
=
Ext
.
getCmp
(
'gateway'
).
getValue
();
var
netmask
=
Ext
.
getCmp
(
'netmask'
).
getValue
();
var
name
=
Ext
.
getCmp
(
'cbxeth'
).
getValue
();
var
record
=
{
id
:
0
,
name
:
name
,
info
:
null
,
mac
:
""
,
ip
:
ip
,
netmask
:
netmask
,
dhcp
:
dhcp
,
gateway
:
gateway
,
broadcast
:
""
};
if
(
record
)
{
var
data
=
Ext
.
util
.
JSON
.
encode
(
record
);
var
data
=
Ext
.
util
.
JSON
.
encode
(
record
);
Ext
.
Ajax
.
request
({
method
:
"POST"
,
url
:
'api/eth/update'
,
...
...
@@ -109,26 +207,18 @@ Ext.define('App.controller.NetworkSetting', {
},
params
:
data
,
success
:
function
(
response
,
opts
)
{
networksettingView
.
unmask
();
var
result
=
Ext
.
JSON
.
decode
(
response
.
responseText
);
if
(
result
)
{
}
Ext
.
Msg
.
alert
(
result
.
type
+
" "
+
"Код-"
+
result
.
code
,
result
.
message
);
},
failure
:
function
(
response
,
opts
)
{
Ext
.
Msg
.
alert
(
'Failure'
,
'Обновление конфигурации не выполнено!
'
);
networksettingView
.
unmask
();
Ext
.
Msg
.
alert
(
'Ошибка'
,
'Сервер недоступен
'
);
}
});
}
networksettingView
.
unmask
();
}
}
});
...
...
DevTools/src/main/webapp/resources/js/app/controller/Proxy.js
View file @
db7d888
...
...
@@ -80,17 +80,13 @@ Ext.define('App.controller.Proxy', {
params
:
data
,
success
:
function
(
response
,
opts
)
{
var
Ok
=
Ext
.
JSON
.
decode
(
response
.
responseText
);
if
(
Ok
)
{
Ext
.
Msg
.
alert
(
'Success'
,
'Сохранение выполнено успешно'
);
}
else
{
Ext
.
Msg
.
alert
(
'Failure'
,
'Ошибка сохранения'
);
}
},
failure
:
function
(
response
,
opts
)
{
Ext
.
Msg
.
alert
(
'Failure'
,
'Ошибка сохранения'
);
}
var
result
=
Ext
.
JSON
.
decode
(
response
.
responseText
);
Ext
.
Msg
.
alert
(
result
.
type
+
" "
+
"Код-"
+
result
.
code
,
result
.
message
);
},
failure
:
function
(
response
,
opts
)
{
networksettingView
.
unmask
();
Ext
.
Msg
.
alert
(
'Ошибка'
,
'Сервер недоступен'
);
}
});
...
...
@@ -117,7 +113,11 @@ Ext.define('App.controller.Proxy', {
enabled
=
fsHttps
.
checkboxCmp
.
getValue
();
host
=
fsHttps
.
down
(
'#'
+
protocol
+
'Adress'
).
getValue
();
port
=
fsHttps
.
down
(
'#'
+
protocol
+
'Port'
).
getValue
();
port
=
parseInt
(
fsHttps
.
down
(
'#'
+
protocol
+
'Port'
).
getValue
());
if
(
port
==
null
)
{
port
=
0
;
}
var
fsHttpsAuth
=
fsHttps
.
down
(
'#fs'
+
protocol
+
'Auth'
);
...
...
@@ -133,7 +133,7 @@ Ext.define('App.controller.Proxy', {
id
:
id
,
protocol
:
protocol
,
host
:
host
,
port
:
parseInt
(
port
)
,
port
:
0
,
login
:
login
,
pass
:
pass
,
enabled
:
enabled
,
...
...
DevTools/src/main/webapp/resources/js/app/view/NetworkSetting.js
View file @
db7d888
...
...
@@ -49,8 +49,6 @@ Ext.define('App.view.NetworkSetting', {
xtype
:
'mvvm-EthView'
,
id
:
'cbxeth'
},
{
xtype
:
'checkboxfield'
,
...
...
@@ -80,8 +78,6 @@ Ext.define('App.view.NetworkSetting', {
fieldLabel
:
'IP'
,
id
:
'ip'
,
margin
:
'5 5 10 3'
},
{
xtype
:
'textfield'
,
...
...
@@ -89,8 +85,6 @@ Ext.define('App.view.NetworkSetting', {
fieldLabel
:
'GATEWAY'
,
id
:
'gateway'
,
margin
:
'5 5 10 3'
},
{
xtype
:
'textfield'
,
...
...
@@ -99,15 +93,13 @@ Ext.define('App.view.NetworkSetting', {
id
:
'netmask'
,
margin
:
'5 5 10 3'
},
{
xtype
:
'textarea'
,
{
xtype
:
'textarea'
,
bind
:
'{info}'
,
id
:
'
ttt
'
,
id
:
'
extinfo
'
,
fieldLabel
:
'СТАТУС'
,
margin
:
'5 5 10 3'
,
allowBlank
:
false
,
allowBlank
:
false
,
width
:
700
,
height
:
100
,
...
...
UtilsTools/src/main/java/org/emercit/ethmanager/service/EthLinux.java
View file @
db7d888
...
...
@@ -41,9 +41,9 @@ public class EthLinux implements IEth {
try
{
Vector
<
String
>
buff
=
cmdexec
.
Run
(
"ifdown "
+
name
);
Vector
<
String
>
buff
=
cmdexec
.
Run
(
"ifdown
"
+
"
"
+
name
);
Thread
.
sleep
(
5000
);
buff
=
cmdexec
.
Run
(
"ifup "
+
name
);
buff
=
cmdexec
.
Run
(
"ifup
"
+
"
"
+
name
);
Thread
.
sleep
(
5000
);
Msg
msg
=
Msg
.
RestartEthSucc
;
...
...
@@ -62,6 +62,7 @@ public class EthLinux implements IEth {
* Список интерфейсов Ethernet на данном устройстве
* @see org.emercit.ethmanager.service.IEth#getListEth()
*/
public
Vector
<
String
>
getListEth
()
{
Vector
<
String
>
result
=
new
Vector
<
String
>();
...
...
@@ -109,11 +110,12 @@ public class EthLinux implements IEth {
String
addr
=
cmdexec
.
Run
(
"ifconfig"
+
" "
+
eb
.
getName
()+
" "
+
"| grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"
).
firstElement
();
String
mask
=
cmdexec
.
Run
(
"ifconfig"
+
" "
+
eb
.
getName
()+
" "
+
"| grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'"
).
firstElement
();
//String gateway=cmdexec.Run("/sbin/route -n | grep 'UG' | awk '{print $2}'").firstElement();
eb
.
setIp
(
addr
);
eb
.
setNetmask
(
mask
);
eb
.
setGateway
(
""
);
eb
.
setIp
(
addr
);
eb
.
setNetmask
(
mask
);
eb
.
setGateway
(
""
);
}
return
eb
;
...
...
@@ -168,11 +170,9 @@ public class EthLinux implements IEth {
bw
.
write
(
"\n"
);
bw
.
write
(
"\n"
);
for
(
EthBean
eb:
ebs
)
{
if
(!
eb
.
getDhcp
())
{
if
(!
eb
.
getDhcp
())
{
bw
.
write
(
"auto "
+
eb
.
getName
());
bw
.
write
(
"\n"
);
...
...
@@ -194,8 +194,6 @@ public class EthLinux implements IEth {
bw
.
write
(
"\n"
);
bw
.
write
(
"\n"
);
}
bw
.
close
();
...
...
UtilsTools/src/test/java/org/emercit/utilstools/TestEthLinux.java
View file @
db7d888
...
...
@@ -6,14 +6,17 @@ import junit.framework.Test;
import
junit.framework.TestCase
;
import
junit.framework.TestSuite
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.Vector
;
import
org.emercit.utilstools.config.Msg
;
import
org.junit.Before
;
import
org.junit.After
;
import
org.junit.Ignore
;
import
org.emercit.ethmanager.model.EthBean
;
import
org.emercit.ethmanager.service.EthLinux
;
@Ignore
public
class
TestEthLinux
extends
TestCase
{
...
...
UtilsTools/src/test/java/org/emercit/utilstools/TestProxyLinux.java
0 → 100644
View file @
db7d888
package
org
.
emercit
.
utilstools
;
import
junit.framework.Test
;
import
junit.framework.TestCase
;
import
junit.framework.TestSuite
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.Vector
;
import
org.emercit.utilstools.config.Msg
;
import
org.junit.Before
;
import
org.junit.After
;
import
org.emercit.proxymanager.model.ProxyBean
;
import
org.emercit.proxymanager.service.ProxyLinux
;
import
org.emercit.utilstools.config.Msg
;
public
class
TestProxyLinux
extends
TestCase
{
private
Vector
<
ProxyBean
>
beans
;
private
ProxyLinux
proxylinux
;
public
TestProxyLinux
(
String
testName
)
{
super
(
testName
);
}
public
static
Test
suite
()
{
return
new
TestSuite
(
TestProxyLinux
.
class
);
}
@Before
public
void
upTestProxyLinux
()
{
}
@After
public
void
downTestProxyLinux
()
{
}
public
void
testProxyLinux
()
{
proxylinux
=
new
ProxyLinux
();
int
value
=
proxylinux
.
init
();
Msg
msg
=
Msg
.
getByCode
(
value
);
if
(
msg
.
getTypeVariable
().
getCode
()==
1
)
{
fail
(
"Инициализация настроек прокси не выполнена"
);
}
beans
=
proxylinux
.
getProxyBeans
();
assertNotNull
(
beans
);
for
(
ProxyBean
bean:
beans
)
{
bean
.
setHost
(
"127.127.127.127"
);
}
value
=
proxylinux
.
Config
(
beans
);
msg
=
Msg
.
getByCode
(
value
);
if
(
msg
.
getTypeVariable
().
getCode
()==
1
)
{
fail
(
"Изменение параметров прокси не выполнено"
);
}
assertTrue
(
true
);
}
}
//assertFalse(!stservice.IsRun("start.jar")); // Если true - то тест завален
// assertEquals(stservice.IsRun("start.jar")); // Если не равны - тест завален
// assertNotNull(stservice.IsRun("start.jar"))); // Если null - тест завален
//assertNull(stservice.IsRun("start.jar"))); // Если не null - тест завален
//assertNotSame(stservice.IsRun("start.jar")); // Если оба объекта являются одинаковыми(не одно и то же, что равны) - тест завален
//assertSame(stservice.IsRun("start.jar")); // Если оба объекта не являются одинаковыми - тест завален
Please
register
or
sign in
to post a comment