use of org.apache.cloudstack.backup.veeam.api.EntityReferences in project cloudstack by apache.
the class VeeamClient method listJobs.
public List<BackupOffering> listJobs() {
LOG.debug("Trying to list backup policies that are Veeam jobs");
try {
final HttpResponse response = get("/jobs");
checkResponseOK(response);
final ObjectMapper objectMapper = new XmlMapper();
final EntityReferences entityReferences = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
final List<BackupOffering> policies = new ArrayList<>();
if (entityReferences == null || entityReferences.getRefs() == null) {
return policies;
}
for (final Ref ref : entityReferences.getRefs()) {
policies.add(new VeeamBackupOffering(ref.getName(), ref.getUid()));
}
return policies;
} catch (final IOException e) {
LOG.error("Failed to list Veeam jobs due to:", e);
checkResponseTimeOut(e);
}
return new ArrayList<>();
}
use of org.apache.cloudstack.backup.veeam.api.EntityReferences in project cloudstack by apache.
the class VeeamClient method listAllBackups.
public void listAllBackups() {
LOG.debug("Trying to list Veeam backups");
try {
final HttpResponse response = get("/backups");
checkResponseOK(response);
final ObjectMapper objectMapper = new XmlMapper();
final EntityReferences entityReferences = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
for (final Ref ref : entityReferences.getRefs()) {
LOG.debug("Veeam Backup found, name: " + ref.getName() + ", uid: " + ref.getUid() + ", type: " + ref.getType());
}
} catch (final IOException e) {
LOG.error("Failed to list Veeam backups due to:", e);
checkResponseTimeOut(e);
}
}
use of org.apache.cloudstack.backup.veeam.api.EntityReferences in project cloudstack by apache.
the class VeeamClient method listBackupRepository.
// //////////////////////////////////////////////////////
// ////////////// Public Veeam APIs /////////////////////
// //////////////////////////////////////////////////////
public Ref listBackupRepository(final String backupServerId, final String backupName) {
LOG.debug(String.format("Trying to list backup repository for backup job [name: %s] in server [id: %s].", backupName, backupServerId));
try {
String repositoryName = getRepositoryNameFromJob(backupName);
final HttpResponse response = get(String.format("/backupServers/%s/repositories", backupServerId));
checkResponseOK(response);
final ObjectMapper objectMapper = new XmlMapper();
final EntityReferences references = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
for (final Ref ref : references.getRefs()) {
if (ref.getType().equals("RepositoryReference") && ref.getName().equals(repositoryName)) {
return ref;
}
}
} catch (final IOException e) {
LOG.error(String.format("Failed to list Veeam backup repository used by backup job [name: %s] due to: [%s].", backupName, e.getMessage()), e);
checkResponseTimeOut(e);
}
return null;
}
use of org.apache.cloudstack.backup.veeam.api.EntityReferences in project cloudstack by apache.
the class VeeamClient method findDCHierarchy.
// /////////////////////////////////////////////////////////////////
// ////////////// Private Veeam Helper Methods /////////////////////
// /////////////////////////////////////////////////////////////////
private String findDCHierarchy(final String vmwareDcName) {
LOG.debug("Trying to find hierarchy ID for vmware datacenter: " + vmwareDcName);
try {
final HttpResponse response = get("/hierarchyRoots");
checkResponseOK(response);
final ObjectMapper objectMapper = new XmlMapper();
final EntityReferences references = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
for (final Ref ref : references.getRefs()) {
if (ref.getName().equals(vmwareDcName) && ref.getType().equals("HierarchyRootReference")) {
return ref.getUid();
}
}
} catch (final IOException e) {
LOG.error("Failed to list Veeam jobs due to:", e);
checkResponseTimeOut(e);
}
throw new CloudRuntimeException("Failed to find hierarchy reference for VMware datacenter " + vmwareDcName + " in Veeam, please ask administrator to check Veeam B&R manager configuration");
}
Aggregations