Search in sources :

Example 21 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class KeyCertificateAlgorithmValuesHolder method getV1Cert.

public String getV1Cert() {
    log.info("trying to get v1 ovf properties");
    final String[] cmd = { "/etc/systool", "--getoverrides" };
    // 2 min
    final long _SYSTOOL_TIMEOUT = 120000;
    final Exec.Result result = Exec.sudo(_SYSTOOL_TIMEOUT, cmd);
    if (!result.exitedNormally() || result.getExitValue() != 0) {
        log.error("Systool command failed. Result exit value: " + result.getExitValue());
        return null;
    }
    String[] propsStrings = result.getStdOutput().split(LINE_DELIMITER);
    PropertyInfoExt props = new PropertyInfoExt(propsStrings);
    String keyAndCertPem = props.getProperty(V1_SSL_CERT_PROPERTY_NAME);
    if (keyAndCertPem == null) {
        log.info("Deprecated property " + V1_SSL_CERT_PROPERTY_NAME + " not configured in previous version.");
    }
    return keyAndCertPem;
}
Also used : Exec(com.emc.storageos.services.util.Exec) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt)

Example 22 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class SendEvent method generateConfigFile.

/**
 * Generates configuration file with name taken from variable CONFIG_FILE_NAME
 * Returns the created file name.
 */
protected String generateConfigFile() throws JAXBException, LocalRepositoryException, IOException {
    ZipOutputStream zos = null;
    try {
        PropertyInfoExt properties = new PropertyInfoExt(coordinator.getPropertyInfo().getProperties());
        zos = new ZipOutputStream(new FileOutputStream(CONFIG_FILE_PATH));
        ZipEntry ze = new ZipEntry(CONFIG_FILE_NAME + getFileExtension());
        zos.putNextEntry(ze);
        if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
            // gson should not be used any more
            (new ObjectMapper()).writeValue(zos, properties);
        } else {
            JAXBContext jaxbContext = JAXBContext.newInstance(PropertyInfo.class);
            Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.marshal(properties, zos);
        }
        zos.flush();
    } finally {
        if (zos != null) {
            zos.close();
        }
    }
    return CONFIG_FILE_PATH;
}
Also used : Marshaller(javax.xml.bind.Marshaller) ZipOutputStream(java.util.zip.ZipOutputStream) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ZipEntry(java.util.zip.ZipEntry) JAXBContext(javax.xml.bind.JAXBContext) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 23 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method getTargetProperties.

/**
 * Get all target properties - include global(shared by active/standby), or site specific properties
 *
 * @return
 * @throws Exception
 */
public PropertyInfoExt getTargetProperties() throws Exception {
    PropertyInfoExt targetPropInfo = _coordinator.getTargetInfo(PropertyInfoExt.class);
    PropertyInfoExt siteScopePropInfo = _coordinator.getTargetInfo(_coordinator.getSiteId(), PropertyInfoExt.class);
    if (targetPropInfo != null && siteScopePropInfo != null) {
        PropertyInfoExt combinedProps = new PropertyInfoExt();
        for (Entry<String, String> entry : targetPropInfo.getAllProperties().entrySet()) {
            combinedProps.addProperty(entry.getKey(), entry.getValue());
        }
        for (Entry<String, String> entry : siteScopePropInfo.getAllProperties().entrySet()) {
            combinedProps.addProperty(entry.getKey(), entry.getValue());
        }
        return combinedProps;
    } else if (targetPropInfo != null) {
        return targetPropInfo;
    } else if (siteScopePropInfo != null) {
        return siteScopePropInfo;
    } else {
        return null;
    }
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt)

Example 24 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method setSiteSpecificProperties.

/**
 * Set site specific properties
 *
 * @param props
 * @param siteId
 */
public void setSiteSpecificProperties(Map<String, String> props, String siteId) {
    PropertyInfoExt siteScopeInfo = new PropertyInfoExt(props);
    ConfigurationImpl siteCfg = new ConfigurationImpl();
    siteCfg.setId(PropertyInfoExt.TARGET_PROPERTY_ID);
    siteCfg.setKind(PropertyInfoExt.TARGET_PROPERTY);
    siteCfg.setConfig(TARGET_INFO, siteScopeInfo.encodeAsString());
    _coordinator.persistServiceConfiguration(siteId, siteCfg);
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 25 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class IPSecMonitor method isSameVdcAsLocalNode.

/**
 * check if specified node is in the same VDC as the local node
 *
 * @param node
 * @return
 */
private boolean isSameVdcAsLocalNode(String node) {
    PropertyInfoExt vdcProps = LocalRepository.getInstance().getVdcPropertyInfo();
    String myVdcId = vdcProps.getProperty("vdc_myid");
    String vdcShortId = getVdcShortIdByIp(node);
    if (vdcShortId != null && vdcShortId.equals(myVdcId)) {
        log.info(node + " is in the same vdc as localhost");
        return true;
    }
    log.info(node + " is NOT in the same vdc as localhost");
    return false;
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt)

Aggregations

PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)33 HashMap (java.util.HashMap)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)4 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)4 Test (org.junit.Test)4 Site (com.emc.storageos.coordinator.client.model.Site)3 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)3 IOException (java.io.IOException)3 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)2 SiteParam (com.emc.storageos.model.dr.SiteParam)2 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)2 PropertyMetadata (com.emc.storageos.model.property.PropertyMetadata)2 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)1