The WsDevClient class in the sample code does not contain an
example showing how to create a repository. The sample code
expects that a repository has already been created within your
environment and that its details have been provided in the
WsDevClient.properties
file.
Creating a storage repository is not complicated and the process can be extrapolated from the other examples or from the API documentation included with the SDK. In this example, we use the information that we have already learned to create a storage repository.
A storage repository is a child object of a FileSystem object. Therefore, it is necessary to obtain the ID of the FileSystem object where the storage repository must be created. The following loop can be used to populate the testfileSystemId with the ID of a file system named "nfs:/mnt/vol1/repo01":
...
fileserver = api.fileServerGetById(fsid);
final List<Id<FileSystem>> fileSystemIds = fileserver.getFileSystemIds();
for (final Id<FileSystem> fileSystemId : fileSystemIds)
{
if (fileSystemId.getName().equals("nfs:/mnt/vol1/repo01
")){
testfileSystemId = fileSystemId;
}
}
Use the fileSystemCreateRepository method provided by the OvmWsSoapClient class to create the repository for the file system identified by its file system ID:
// Create a repository Repository myrepo = new Repository(); myrepo.setName("MyRepository"); final Job repositoryCreateJob = api.fileSystemCreateRepository(testfileSystemId, myrepo); System.out.println("create repository job id: " + repositoryCreateJob.getId()); myrepoId = waitForJobComplete(api, repositoryCreateJob, Repository.class);