所以我从命令行运行这个,打开putty并连接。没有脚本也能很好地工作。
putty.exe -ssh admin@xxx.xxx.xxx.xxx -pw ****** -m "C:\newVM.sh"
脚本:
acli;
#创建Server2016的克隆
# vm。clone aTest clone_from_vm="Server2016RefImage"内存=8G num_cores_per_vcpu=2 num_vcpus=2;
#创建D驱动器
# vm。disk_create aTest bus=scsi create_size=200G index=1 container=" container -1";
#添加一个网卡
# vm。nic_create aTest connected=true network="Vlan6";
如果我在putty中运行它,每一行都会运行得很好,但我不确定我是否正确地将命令串在一起。如果我尝试执行脚本,它会打开putty会话,然后冻结。
我是不是搞错对象了?有什么地方可以让我学到一些这方面的基本知识吗?youtube上的视频还是Pluralsight上的?nutanix的文档只能提供给我这么多,除此之外,在这里我找不到任何其他资源。很抱歉这个新手的问题,但是我被难住了。
最佳答案galad2003
\nacli vm.clone aTest clone_from_vm=\"Server2016RefImage\" memory=8G num_cores_per_vcpu=2 num_vcpus=2;\n
\nI can get them to run now using putty or plink, there seems to be no difference but what I can't do now is run multiple commands one after another. It will now clone my existing VM but I can't get it to add the hard drive or NIC from a script.
\n
\nDo I need to add in a time delay between commands? Maybe this is something that would work better with a product like Ansible?
\n
\nIdeally I would like to just have the script prompt me for a VM name and IP when I run it.
\n
\nIf there is a better way to do this please let me know. Again, I am used to running PS scripts from my laptop to a server and they execute the script. I am just trying to do the equivalent shell commands and I am just not that well versed in shell scripting.
\n
\nI see Nutanix has PS commandlets but I have not gotten that to work in our environment yet and the ACLI are so elegant I hate to not use them.","className":"post__content__best_answer"}">