cp1.php969.net,19.EVE-NG优化非官方支持镜像的接口显示名称

目前已优化的设备包含:

H3C

vSR

H3C

vFW

H3C

vLB

HuaweiUSG

HillStone

以 H3C vSR 举例

原接口名称

a4c26d1e5885305701be709a3d33442f.png

终端执行命令

root@eve-ng:~#cp/opt/unetlab/html/includes/__node.php{,.`date

+%s`}&&sed -i “/case’a10′:/i\\\t\t\t\t\tcase

‘vsr’:\n\t\t\t\t\t\tfor (\$i = 0; \$i < \$this-> ethernet;

\$i++) {\n\t\t\t\t\t\t\t\$n =

‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))

{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old

one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =

\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttry

{\n\t\t\t\t\t\t\t\t\t\$this -> ethernets[\$i] =

newInterfc(Array(‘name’ => \$n, ‘type’ =>

‘ethernet’),\$i);\n\t\t\t\t\t\t\t\t} catch (Exception

\$e){\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s

‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M

d H:i:s’).(string)

\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//

Setting CMD flags(virtual device and map to TAP

device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device

%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this

->tenant).’:’.sprintf(‘x’, \$this -> id /

\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,

\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev

tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this

->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php

root@eve-ng:~#

更改后的接口名称与 OS 中显示的名称吻合

a4c26d1e5885305701be709a3d33442f.png

注意:

老用户直接执行命令即可!

新用户在导入设备时,接口名称就已优化,无需额外执行命令!

所有设备相应的执行命令:(每个命令都有细微差别)

1、H3C vSR:

cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed

-i “/case’a10′:/i\\\t\t\t\t\tcase ‘vsr’:\n\t\t\t\t\t\tfor (\$i = 0;

\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\t\$n =

‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))

{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old

one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =

\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else

{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->

ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>

‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)

{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s

‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M

d H:i:s’).(string)

\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//

Setting CMD flags(virtual device and map to TAP

device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device

%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this

->tenant).’:’.sprintf(‘x’, \$this -> id /

\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,

\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev

tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this

->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php

2、H3C vFW:

cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed

-i “/case’a10′:/i\\\t\t\t\t\tcase ‘vfw’:\n\t\t\t\t\t\tfor (\$i = 0;

\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\t\$n =

‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))

{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old

one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =

\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else

{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->

ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>

‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)

{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s

‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M

d H:i:s’).(string)

\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//

Setting CMD flags(virtual device and map to TAP

device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device

%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this

->tenant).’:’.sprintf(‘x’, \$this -> id /

\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,

\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev

tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this

->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php

3、H3C vLB:

cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed

-i “/case’a10′:/i\\\t\t\t\t\tcase ‘vlb’:\n\t\t\t\t\t\tfor (\$i = 0;

\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\t\$n =

‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))

{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old

one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =

\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else

{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->

ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>

‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)

{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s

‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M

d H:i:s’).(string)

\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//

Setting CMD flags(virtual device and map to TAP

device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device

%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this

->tenant).’:’.sprintf(‘x’, \$this -> id /

\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,

\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev

tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this

->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php

4、Huawei USG:

cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed

-i “/case’a10′:/i\\\t\t\t\t\tcase ‘usg’:\n\t\t\t\t\t\tfor (\$i = 0;

\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\tif (\$i==0)

{\n\t\t\t\t\t\t\t\t\$n

=’Gi0/’.\$i.’/0′; //Interface name\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\$n

=’Gi1/0/’.(\$i-1); //Interface name\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif

(isset(\$old_ethernets[\$i])){\n\t\t\t\t\t\t\t\t// Previous

interface found, copy from oldone\n\t\t\t\t\t\t\t\t\$this ->

ethernets[\$i] =\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else

{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->

ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>

‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)

{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s

‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M

d H:i:s’).(string)

\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//

Setting CMD flags(virtual device and map to TAP

device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device

%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this

->tenant).’:’.sprintf(‘x’, \$this -> id /

512).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,

\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev

tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this ->

id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php

5、HillStone:

cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed

-i “/case’a10′:/i\\\t\t\t\t\tcase ‘hillstone’:\n\t\t\t\t\t\tfor

(\$i = 0; \$i ethernet; \$i++)

{\n\t\t\t\t\t\t\t\$n =

‘ethernet0/’.\$i; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))

{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old

one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =

\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttry

{\n\t\t\t\t\t\t\t\t\t\$this -> ethernets[\$i] =

newInterfc(Array(‘name’ => \$n, ‘type’ =>

‘ethernet’),\$i);\n\t\t\t\t\t\t\t\t} catch (Exception

\$e){\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s

‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M

d H:i:s’).(string)

\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//

Setting CMD flags(virtual device and map to TAP

device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device

%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this

->tenant).’:’.sprintf(‘x’, \$this -> id /

512).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,

\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev

tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this

->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php

http://www.emulatedlab.com/archives/578

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值