Search in sources :

Example 16 with VirtualDataCenterRestRep

use of com.emc.storageos.model.vdc.VirtualDataCenterRestRep in project coprhd-controller by CoprHD.

the class VirtualDataCenters method itemDetails.

public static void itemDetails(String id) {
    VirtualDataCenterRestRep vdc = VirtualDataCenterUtils.get(id);
    if (vdc == null) {
        error(MessagesUtils.get(UNKNOWN, id));
    }
    Tasks<VirtualDataCenterRestRep> vdcTasks = VirtualDataCenterUtils.getTasks(uri(id));
    Task<VirtualDataCenterRestRep> latestTask = null;
    if (vdcTasks != null) {
        latestTask = vdcTasks.latestFinishedTask();
    }
    render(vdc, latestTask);
}
Also used : VirtualDataCenterRestRep(com.emc.storageos.model.vdc.VirtualDataCenterRestRep)

Example 17 with VirtualDataCenterRestRep

use of com.emc.storageos.model.vdc.VirtualDataCenterRestRep in project coprhd-controller by CoprHD.

the class VirtualDataCenters method save.

@FlashException(keep = true, referrer = { "create", "edit" })
@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void save(VirtualDataCenterForm vdc) {
    vdc.validate("vdc");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    if (vdc.isNew()) {
        VirtualDataCenterAddParam vdcToAdd = new VirtualDataCenterAddParam();
        vdcToAdd.setName(vdc.name);
        vdcToAdd.setApiEndpoint(vdc.apiEndpoint);
        vdcToAdd.setDescription(vdc.description);
        vdcToAdd.setSecretKey(vdc.secretKey);
        try {
            vdcToAdd.setCertificateChain(FileUtils.readFileToString(vdc.certChain));
        } catch (Exception e) {
            flash.error(MessagesUtils.get("vdc.certChain.invalid.error"));
            Common.handleError();
        }
        Task<VirtualDataCenterRestRep> task = VirtualDataCenterUtils.create(vdcToAdd);
        flash.put("inProgressTask", task.getTaskResource().getId());
    } else {
        VirtualDataCenterRestRep currentVDC = VirtualDataCenterUtils.get(vdc.id);
        if (currentVDC != null) {
            VirtualDataCenterModifyParam vdcToUpdate = new VirtualDataCenterModifyParam();
            vdcToUpdate.setName(vdc.name);
            vdcToUpdate.setDescription(vdc.description);
            Task<VirtualDataCenterRestRep> task = VirtualDataCenterUtils.update(uri(vdc.id), vdcToUpdate);
            flash.put("inProgressTask", task.getTaskResource().getId());
        }
    }
    Cache.delete(Common.VDCS);
    if (StringUtils.isNotBlank(vdc.referrerUrl)) {
        redirect(vdc.referrerUrl);
    } else {
        list();
    }
}
Also used : VirtualDataCenterRestRep(com.emc.storageos.model.vdc.VirtualDataCenterRestRep) VirtualDataCenterAddParam(com.emc.storageos.model.vdc.VirtualDataCenterAddParam) FlashException(controllers.util.FlashException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) VirtualDataCenterModifyParam(com.emc.storageos.model.vdc.VirtualDataCenterModifyParam) FlashException(controllers.util.FlashException) Restrictions(controllers.deadbolt.Restrictions)

Example 18 with VirtualDataCenterRestRep

use of com.emc.storageos.model.vdc.VirtualDataCenterRestRep in project coprhd-controller by CoprHD.

the class VirtualDataCenterMapper method map.

public static VirtualDataCenterRestRep map(VirtualDataCenter from) {
    if (from == null) {
        return null;
    }
    VirtualDataCenterRestRep to = new VirtualDataCenterRestRep();
    mapDataObjectFields(from, to);
    to.setDescription(from.getDescription());
    to.setApiEndpoint(from.getApiEndpoint());
    to.setStatus(from.getConnectionStatus().name());
    to.setLocal(from.getLocal());
    to.setShortId(from.getShortId());
    to.setGeoCommandEndpoint(from.getGeoCommandEndpoint());
    to.setGeoDataEndpoint(from.getGeoDataEndpoint());
    to.setLastSeenTimeInMillis(from.getLastSeenTimeInMillis());
    return to;
}
Also used : VirtualDataCenterRestRep(com.emc.storageos.model.vdc.VirtualDataCenterRestRep)

Aggregations

VirtualDataCenterRestRep (com.emc.storageos.model.vdc.VirtualDataCenterRestRep)18 Test (org.junit.Test)6 URI (java.net.URI)4 FlashException (controllers.util.FlashException)3 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 VirtualDataCenterAddParam (com.emc.storageos.model.vdc.VirtualDataCenterAddParam)2 VirtualDataCenterList (com.emc.storageos.model.vdc.VirtualDataCenterList)2 Restrictions (controllers.deadbolt.Restrictions)2 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1 RoleAssignmentChanges (com.emc.storageos.model.auth.RoleAssignmentChanges)1 RoleAssignmentEntry (com.emc.storageos.model.auth.RoleAssignmentEntry)1 VirtualDataCenterModifyParam (com.emc.storageos.model.vdc.VirtualDataCenterModifyParam)1 ViPRClientHelper (com.emc.storageos.usermanagement.util.ViPRClientHelper)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1 VirtualDataCenters (com.emc.vipr.client.core.VirtualDataCenters)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 WebResource (com.sun.jersey.api.client.WebResource)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 GET (javax.ws.rs.GET)1