Show Table of Contents
2.10. 为资源添加子资源
以下示例展示了如何为资源添加子资源。在这个示例中,为名为 'test' 的虚拟机添加了一个大小为 ‘1073741824L'、接口是 'virtio'、格式是 'cow' 的新磁盘。
过程 2.6. 为资源添加子资源
- 声明一个需要添加子资源的资源实例。
VM vm = api.getVMs().get("test"); - 创建参数来定义资源的属性:
Disk diskParam = new Disk(); diskParam.setProvisionedSize(1073741824L); diskParam.setInterface("virtio"); diskParam.setFormat("cow"); - 添加子资源:
Disk disk = vm.getDisks().add(diskParam);

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.