Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
83b2f5e9
T
tp-qemu
项目概览
openeuler
/
tp-qemu
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tp-qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
83b2f5e9
编写于
7月 25, 2013
作者:
Y
Yang Feng
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #658 from humanux/mac_change_v1
tests.mac_change : change mac when the interface is active
上级
6e53599f
4dd80b2e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
18 deletion
+21
-18
tests/cfg/mac_change.cfg
tests/cfg/mac_change.cfg
+10
-0
tests/mac_change.py
tests/mac_change.py
+11
-18
未找到文件。
tests/cfg/mac_change.cfg
浏览文件 @
83b2f5e9
...
@@ -2,3 +2,13 @@
...
@@ -2,3 +2,13 @@
virt_test_type = qemu libvirt
virt_test_type = qemu libvirt
type = mac_change
type = mac_change
kill_vm = yes
kill_vm = yes
variants:
- down_change:
only Linux
shutdown_int = yes
int_shutdown_cmd = ifconfig %s down
int_activate_cmd = ifconfig %s up
- @up_change:
virtio_net:
no RHEL.5, RHEL.6.0, RHEL.6.1, RHEL.6.2, RHEL.6.3
shutdown_int = no
tests/mac_change.py
浏览文件 @
83b2f5e9
...
@@ -15,18 +15,6 @@ def run_mac_change(test, params, env):
...
@@ -15,18 +15,6 @@ def run_mac_change(test, params, env):
@param params: Dictionary with the test parameters.
@param params: Dictionary with the test parameters.
@param env: Dictionary with test environment.
@param env: Dictionary with test environment.
"""
"""
def
get_drive_num
(
session
,
path
):
"""
return file path drive
"""
cmd
=
"wmic datafile where
\"
path='%s'
\"
get drive"
%
path
info
=
session
.
cmd_output
(
cmd
,
timeout
=
360
).
strip
()
drive_num
=
re
.
search
(
r
'(\w):'
,
info
,
re
.
M
)
if
not
drive_num
:
raise
error
.
TestError
(
"No path %s in your guest"
%
path
)
return
drive_num
.
group
()
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
...
@@ -47,6 +35,10 @@ def run_mac_change(test, params, env):
...
@@ -47,6 +35,10 @@ def run_mac_change(test, params, env):
logging
.
info
(
"The initial MAC address is %s"
,
old_mac
)
logging
.
info
(
"The initial MAC address is %s"
,
old_mac
)
if
os_type
==
"linux"
:
if
os_type
==
"linux"
:
interface
=
utils_net
.
get_linux_ifname
(
session_serial
,
old_mac
)
interface
=
utils_net
.
get_linux_ifname
(
session_serial
,
old_mac
)
if
params
.
get
(
"shutdown_int"
,
"yes"
)
==
"yes"
:
int_shutdown_cmd
=
params
.
get
(
"int_shutdown_cmd"
,
"ifconfig %s down"
)
session_serial
.
cmd
(
int_shutdown_cmd
%
interface
)
else
:
else
:
connection_id
=
utils_net
.
get_windows_nic_attribute
(
session
,
connection_id
=
utils_net
.
get_windows_nic_attribute
(
session
,
...
@@ -62,17 +54,14 @@ def run_mac_change(test, params, env):
...
@@ -62,17 +54,14 @@ def run_mac_change(test, params, env):
"netconnectionid"
,
"netconnectionid"
,
connection_id
,
connection_id
,
"pnpdeviceid"
)
"pnpdeviceid"
)
devcon_path
=
r
"\\devcon\\wxp_x86\\"
cd_drive
=
utils_misc
.
get_winutils_vol
(
session
)
cd_drive
=
get_drive_num
(
session
,
devcon_path
)
copy_cmd
=
r
"xcopy %s:\devcon\wxp_x86\devcon.exe c:\ "
%
cd_drive
copy_cmd
=
r
"xcopy %s\devcon\wxp_x86\devcon.exe c:\ "
%
cd_drive
session
.
cmd
(
copy_cmd
)
session
.
cmd
(
copy_cmd
)
# Start change MAC address
# Start change MAC address
error
.
context
(
"Changing MAC address to %s"
%
new_mac
,
logging
.
info
)
error
.
context
(
"Changing MAC address to %s"
%
new_mac
,
logging
.
info
)
if
os_type
==
"linux"
:
if
os_type
==
"linux"
:
change_cmd
=
change_cmd_pattern
%
(
interface
,
change_cmd
=
change_cmd_pattern
%
(
interface
,
new_mac
)
interface
,
new_mac
,
interface
)
else
:
else
:
change_cmd
=
change_cmd_pattern
%
(
int
(
nic_index
),
change_cmd
=
change_cmd_pattern
%
(
int
(
nic_index
),
""
.
join
(
new_mac
.
split
(
":"
)))
""
.
join
(
new_mac
.
split
(
":"
)))
...
@@ -83,6 +72,10 @@ def run_mac_change(test, params, env):
...
@@ -83,6 +72,10 @@ def run_mac_change(test, params, env):
error
.
context
(
"Verify the new mac address, and restart the network"
,
error
.
context
(
"Verify the new mac address, and restart the network"
,
logging
.
info
)
logging
.
info
)
if
os_type
==
"linux"
:
if
os_type
==
"linux"
:
if
params
.
get
(
"shutdown_int"
,
"yes"
)
==
"yes"
:
int_activate_cmd
=
params
.
get
(
"int_activate_cmd"
,
"ifconfig %s up"
)
session_serial
.
cmd
(
int_activate_cmd
%
interface
)
session_serial
.
cmd
(
"ifconfig | grep -i %s"
%
new_mac
)
session_serial
.
cmd
(
"ifconfig | grep -i %s"
%
new_mac
)
logging
.
info
(
"Mac address change successfully, net restart..."
)
logging
.
info
(
"Mac address change successfully, net restart..."
)
dhclient_cmd
=
"dhclient -r && dhclient %s"
%
interface
dhclient_cmd
=
"dhclient -r && dhclient %s"
%
interface
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录