protected Guid getDataCenterId(Network network) { String networkName = network.getDataCenter().getName(); return getEntity( StoragePool.class, QueryType.GetStoragePoolByDatacenterName, new NameQueryParameters(networkName), "Datacenter: name=" + networkName ).getId(); } }
public static void validateAdd(DataCenter dataCenter) { if (dataCenter == null) { throw new ValidationException("Parameter 'data_center' is mandatory but was not provided."); } if (dataCenter.isLocal()==null) { throw new ValidationException("Parameter 'data_center.local' is mandatory but was not provided."); } if (dataCenter.getName()==null) { throw new ValidationException("Parameter 'data_center.name' is mandatory but was not provided."); } }
protected Guid getDataCenterId(Network network) { String networkName = network.getDataCenter().getName(); return getEntity(StoragePool.class, QueryType.GetStoragePoolByDatacenterName, new NameQueryParameters(networkName), "Datacenter: name=" + networkName).getId(); } }
private Guid getDataCenterId(Action action) { String dcIdFromAction = action.getDataCenter().getId(); if (dcIdFromAction != null) { return new Guid(dcIdFromAction); } return getDataCenterIdByName(action.getDataCenter().getName()); }
public StoragePool getStoragePool(DataCenter dataCenter) { StoragePool pool = null; if (dataCenter.isSetId()) { Guid id = asGuid(dataCenter.getId()); pool = getEntity(StoragePool.class, QueryType.GetStoragePoolById, new IdQueryParameters(id), "Datacenter: id=" + dataCenter.getId()); } else if (dataCenter.isSetName()) { pool = getEntity(StoragePool.class, QueryType.GetStoragePoolByDatacenterName, new NameQueryParameters(dataCenter.getName()), "Datacenter: name=" + dataCenter.getName()); } if (pool == null) { notFound(DataCenter.class); } return pool; }
public static void validateAdd(Cluster cluster) { if (cluster == null) { throw new ValidationException("Parameter 'cluster' is mandatory but was not provided."); } if (cluster.getName()==null) { throw new ValidationException("Parameter 'cluster.name' is mandatory but was not provided."); } if ( (cluster.getDataCenter()==null || cluster.getDataCenter().getId()==null) && (cluster.getDataCenter()==null || cluster.getDataCenter().getName()==null) ) { throw new ValidationException("Parameters 'cluster.data_center.id' or 'cluster.data_center.name' are mandatory but both were not provided."); } }
/** * Get the storage pool (i.e. datacenter entity) associated with the given * cluster. */ @SuppressWarnings("unchecked") public static StoragePool getStoragePool(DataCenter dataCenter, AbstractBackendResource parent) { StoragePool pool = null; if (dataCenter.isSetId()) { String id = dataCenter.getId(); Guid guid; try { guid = new Guid(id); // can't use asGuid() because the method is static. } catch (IllegalArgumentException e) { throw new MalformedIdException(e); } pool = parent.getEntity(StoragePool.class, QueryType.GetStoragePoolById, new IdQueryParameters(guid), "Datacenter: id=" + id); } else { String clusterName = dataCenter.getName(); pool = parent.getEntity(StoragePool.class, QueryType.GetStoragePoolByDatacenterName, new NameQueryParameters(clusterName), "Datacenter: name=" + clusterName); dataCenter.setId(pool.getId().toString()); } return pool; }
@Override protected void verify(DataCenter model, DataCenter transform) { assertNotNull(transform); assertEquals(model.getName(), transform.getName()); assertEquals(model.getId(), transform.getId()); assertEquals(model.getDescription(), transform.getDescription()); assertEquals(model.getComment(), transform.getComment()); assertEquals(model.isLocal(), transform.isLocal()); assertEquals(model.getStorageFormat(), transform.getStorageFormat()); assertEquals(model.getMacPool().getId(), transform.getMacPool().getId()); assertEquals(model.getQuotaMode(), transform.getQuotaMode()); }
to.setName(from.getName());
entity.setName(model.getName());