002 - demo试运行
2019-05-07 本文已影响0人
xwlan
1、获取所有vm的信息 - getallvms.py
[root@centos samples]# python getallvms.py -s ipaddr -o 443 -u username -p password -S
('Name : ', 'test_002')
('Template : ', False)
('Path : ', '[datastore1] test_002/test_002.vmx')
('Guest : ', 'CentOS 7 (64-bit)')
('Instance UUID : ', '525af8ba-a833-1f32-3c81-54fff458314d')
('Bios UUID : ', '564db0c8-422c-4d53-e8ac-895d79304f28')
('State : ', 'poweredOff')
('VMware-tools: ', 'toolsNotInstalled')
IP : None
('Name : ', 'test_001')
('Template : ', False)
('Path : ', '[datastore1] test_001/test_001.vmx')
('Guest : ', 'CentOS 7 (64-bit)')
('Instance UUID : ', '520daeff-39f3-80d1-e20b-d119bac916e6')
('Bios UUID : ', '564d4252-bab9-bc06-a966-d6606f2257c4')
('State : ', 'poweredOff')
('VMware-tools: ', 'toolsNotInstalled')
IP : None
2、获取所有vm的名字 - get_vm_names.py
[root@centos samples]# python get_vm_names.py -s ipaddr -o 443 -u username -p password -S
test_002
test_001
3、重启vm - reboot_vm.py
[root@centos samples]# python reboot_vm.py -s ipaddr -o 443 -u username -p password -S -j uuid
Found: test_002
The current powerState is: poweredOn
its done.
4、增加端口组到虚拟交换机 - add_portgroup_to_vswitch.py
[root@centos samples]# python add_portgroup_to_vswitch.py -s ipaddr -o 443 -u username-p password -v 虚拟交换机名字 -g 端口组名字 -i vlan_id -c -r esxi名字
Matched ESXi hosts: ['MiWiFi-R3D-srv']
image.png