使用yavijava创建兼容低版本的虚拟机

痛点

在使用 https://github.com/yavijava/yavijava 创建虚拟机的过程中,默认会将虚拟机的兼容性自动设置为ESXI的版本,如在ESXI 6.5上创建的虚拟机,其兼容性则为 ESXi 6.5 及更高版本 (虚拟机版本 13), 这样导致迁移的时候不能将这个虚拟机迁移到小于ESXI 6.5版本的主机上。

解决

在查询很多资料之后,确认可以通过 https://www.altaro.com/vmware/4-ways-to-downgrade-the-vm-hardware-version/ 文中的方法,将虚拟机先从清单中删掉,更改虚拟机的vmx文件,将virtualHW.version改为需要的版本,重新注册虚拟机即可。

在已知了这些方法之后,进行尝试, 发现在初始化虚拟机之后是无法再进行更改的,只有创建的时候设置好才行,如下即可。

1
2
3
4
5
6
7
8
9
10
11
vmSpec.setVersion("vmx-10"); # 10 表示 esxi 5.5
// call the createVM_Task method on the vm folder
Task task = vmFolder.createVM_Task(vmSpec, rp, null);
String result = task.waitForTask();

if(result == Task.SUCCESS){
System.out.println("VM Created Sucessfully");
}else{
System.out.println("VM could not be created. ");
return;
}
n/yunparse/index.php?url=//美剧/周一/GOT权游/S07/Online/02按时发达的十分.mp4~bdyun";
URL repoUrl = new URL(OriginUrl);
URI uri;
try {
uri = new URI(repoUrl.getProtocol(), repoUrl.getUserInfo(), repoUrl.getHost(), repoUrl.getPort(), repoUrl.getPath(), repoUrl.getQuery(), repoUrl.getRef());
System.out.println(uri.toASCIIString());
} catch (URISyntaxException e) {
}

Python

python3:

1
2
3
4
5
6
import string
import urllib.parse

url = "https://meijumao.cn/yunparse/index.php?url=//美剧/周一/GOT权游/S07/Online/02按时发达的十分.mp4~bdyun"
print(urllib.parse.quote(url,safe=string.printable))

python2:

1
2
3
4
5
6
import string
from urllib import quote

url = "https://meijumao.cn/yunparse/index.php?url=//美剧/周一/GOT权游/S07/Online/02按时发达的十分.mp4~bdyun"
print urllib.parse.quote(url,safe=string.printable)

结果 'https://meijumao.cn/yunparse/index.php?url=//%E7%BE%8E%E5%89%A7/%E5%91%A8%E4%B8%80/GOT%E6%9D%83%E6%B8%B8/S07/Online/02%E6%8C%89%E6%97%B6%E5%8F%91%E8%BE%BE%E7%9A%84%E5%8D%81%E5%88%86.mp4~bdyun

Java 解析json数组字符串为Java对象

套用罗锤子的话:这可能是最方便快捷的方式了

json字符串:

1
2
3
4
5
6
[{ "number" : "3",
"title" : "hello_world"
},
{ "number" : "2",
"title" : "hello_world"
}]

Java代码:

1
2
3
4
5
6
7
class Wrapper{
int number;
String title;
}

Gson gson = new Gson();
Wrapper[] data = gson.fromJson(idcstring, Wrapper[].class);