Search in sources :

Example 6 with PropertyInfo

use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.

the class ExecutionContext method getResourceLimit.

public long getResourceLimit(String name) {
    PropertyInfo sysprops = coordinatorClient.getPropertyInfo();
    String value = sysprops.getProperty(name);
    return NumberUtils.toLong(value);
}
Also used : PropertyInfo(com.emc.storageos.model.property.PropertyInfo)

Example 7 with PropertyInfo

use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.

the class EndPointLocator method queryCachedNetworkVip.

/**
 * Consults the cached value of network_vip. If set, returns it. If not set, gets it
 * from coordinator and update cache.
 *
 * @return
 */
private String queryCachedNetworkVip() {
    String networkVipToReturn = null;
    if (_cachedNetworkVip == null) {
        _log.debug("No cached value found for network_vip property");
        PropertyInfo props = null;
        try {
            props = _coordinator.getPropertyInfo();
        } catch (Exception e) {
            _log.error("Could not query for network_vip property", e);
            return null;
        }
        if (props == null) {
            _log.error("Query for network_vip property returned null");
            return null;
        }
        networkVipToReturn = props.getProperty(OVF_NETWORK_VIP);
        synchronized (this) {
            _cachedNetworkVip = networkVipToReturn;
        }
        if (networkVipToReturn == null || networkVipToReturn.equals("")) {
            _log.debug("Cluster endpoint value is not supplied");
            return null;
        }
    } else {
        _log.debug("Cached value found for network_vip.  Reusing {}", _cachedNetworkVip);
        networkVipToReturn = _cachedNetworkVip;
    }
    return networkVipToReturn;
}
Also used : PropertyInfo(com.emc.storageos.model.property.PropertyInfo) SecurityException(com.emc.storageos.security.exceptions.SecurityException)

Example 8 with PropertyInfo

use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.

the class KeyCertificateAlgorithmValuesHolder method loadIPsAndNames.

/**
 * loads all the cluster's IPs and the DNS names
 */
public void loadIPsAndNames() {
    PropertyInfo props = coordinator.getPropertyInfo();
    if (props == null) {
        throw SecurityException.retryables.keystoreUnavailable();
    }
    addresses = new HashSet<InetAddress>();
    String ipAddress = props.getProperty(NETWORK_STANDALONE_IP_ADDRESS_PROPERTY_NAME);
    InetAddress inet;
    if (StringUtils.isNotBlank(ipAddress) && !ipAddress.equals(UNDEFINED_IPV4_ADDRESS)) {
        ipAddress = ipAddress.trim();
        inet = getInetAddress(ipAddress);
        addresses.add(inet);
        log.debug("Standalone ip address is:" + ipAddress + ". Canonical host name is " + inet.getCanonicalHostName());
    }
    for (int index = 1; index <= MAX_NUMBER_OF_NODES; index++) {
        ipAddress = props.getProperty(String.format(NETWORK_NODE_IP_ADDRESS_PROPERTY_NAME_FORMAT, index));
        if (StringUtils.isNotBlank(ipAddress) && !ipAddress.equals(UNDEFINED_IPV4_ADDRESS)) {
            ipAddress = ipAddress.trim();
            inet = getInetAddress(ipAddress);
            addresses.add(inet);
            log.debug("Node #" + index + " IPv4 address is:" + ipAddress + ". Canonical host name is " + inet.getCanonicalHostName());
        }
        ipAddress = props.getProperty(String.format(NETWORK_NODE_IP_ADDRESS6_PROPERTY_NAME_FORMAT, index));
        if (StringUtils.isNotBlank(ipAddress) && !ipAddress.equals(UNDEFINED_IPV6_ADDRESS)) {
            ipAddress = ipAddress.trim();
            inet = getInetAddress(ipAddress);
            addresses.add(inet);
            log.debug("Node #" + index + " IPv6 address is:" + ipAddress + ". Canonical host name is " + inet.getCanonicalHostName());
        }
    }
    InetAddress ipv6VipAddress = null;
    InetAddress ipv4VipAddress = null;
    ipAddress = props.getProperty(NETWORK_VIP6_PROPERTY_NAME);
    if (StringUtils.isNotBlank(ipAddress) && !ipAddress.trim().equals(UNDEFINED_IPV6_ADDRESS)) {
        ipAddress = ipAddress.trim();
        ipv6VipAddress = getInetAddress(ipAddress);
        log.debug("VIP IPv6 address is:" + ipAddress + ". Canonical host name is " + ipv6VipAddress.getCanonicalHostName());
        addresses.add(ipv6VipAddress);
    }
    ipAddress = props.getProperty(NETWORK_VIP_PROPERTY_NAME);
    if (StringUtils.isNotBlank(ipAddress) && !ipAddress.trim().equals(UNDEFINED_IPV4_ADDRESS)) {
        ipAddress = ipAddress.trim();
        ipv4VipAddress = getInetAddress(ipAddress);
        log.debug("VIP IPv4 address is:" + ipAddress + ". Canonical host name is " + ipv4VipAddress.getCanonicalHostName());
        addresses.add(ipv4VipAddress);
    } else if (ipv6VipAddress == null) {
        ipv4VipAddress = addresses.iterator().next();
    }
    certificateCommonName = decideCommonName(ipv4VipAddress, ipv6VipAddress);
}
Also used : PropertyInfo(com.emc.storageos.model.property.PropertyInfo) InetAddress(java.net.InetAddress)

Example 9 with PropertyInfo

use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.

the class StubCoordinatorClientImpl method getPropertyInfo.

@Override
public PropertyInfo getPropertyInfo() throws CoordinatorException {
    PropertyInfo info = new PropertyInfo();
    info.setProperties((Map) defaultProperties);
    return info;
}
Also used : PropertyInfo(com.emc.storageos.model.property.PropertyInfo)

Example 10 with PropertyInfo

use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.

the class ComputeImageServerMigration method process.

@Override
public void process() throws MigrationCallbackException {
    try {
        // Retrieve data from zk db using coordinator client
        Configuration config1 = coordinatorClient.queryConfiguration(PropertyInfoExt.TARGET_PROPERTY, PropertyInfoExt.TARGET_PROPERTY_ID);
        log.info("imageServerIP:" + config1.getConfig(IMAGE_SERVER_ADDRESS));
        PropertyInfo p = coordinatorClient.getPropertyInfo();
        EncryptionProviderImpl encryptionProvider1 = new EncryptionProviderImpl();
        encryptionProvider1.setCoordinator(coordinatorClient);
        encryptionProvider1.start();
        this.encryptionProvider = encryptionProvider1;
        if (!StringUtils.isBlank(p.getProperty("image_server_address"))) {
            ComputeImageServer imageServer = new ComputeImageServer();
            imageServer.setId(URIUtil.createId(ComputeImageServer.class));
            imageServer.setImageServerIp(p.getProperty(IMAGE_SERVER_ADDRESS));
            imageServer.setLabel(p.getProperty(IMAGE_SERVER_ADDRESS));
            imageServer.setImageServerUser(p.getProperty(IMAGE_SERVER_USERNAME));
            imageServer.setTftpBootDir(p.getProperty(IMAGE_SERVER_TFTPBOOT_DIR));
            imageServer.setImageServerSecondIp(p.getProperty(IMAGE_SERVER_OS_NETWORK_IP));
            imageServer.setImageServerHttpPort(p.getProperty(IMAGE_SERVER_HTTP_PORT));
            imageServer.setImageDir(p.getProperty(IMAGE_SERVER_IMAGEDIR));
            String encryptedPassword = p.getProperty(IMAGE_SERVER_ENC_PWD);
            try {
                imageServer.setImageServerPassword(encryptionProvider.decrypt(Base64.decodeBase64(encryptedPassword)));
            } catch (Exception e) {
                log.error("Can't decrypt image server password :" + e.getLocalizedMessage());
                log.error("Failed to save image server details into database during migration", e);
                throw e;
            }
            associateComputeImages(imageServer);
            dbClient.createObject(imageServer);
            log.info("Saved imageServer info into cassandra db");
            // Associate all existing Compute Systems to this image server
            List<URI> computeSystemURIs = dbClient.queryByType(ComputeSystem.class, true);
            Iterator<ComputeSystem> computeSystemListIterator = dbClient.queryIterativeObjects(ComputeSystem.class, computeSystemURIs);
            while (computeSystemListIterator.hasNext()) {
                ComputeSystem computeSystem = computeSystemListIterator.next();
                computeSystem.setComputeImageServer(imageServer.getId());
                dbClient.persistObject(computeSystem);
            }
            // Delete imageserverConf data from ZK db.
            Configuration config = coordinatorClient.queryConfiguration(PropertyInfoExt.TARGET_PROPERTY, PropertyInfoExt.TARGET_PROPERTY_ID);
            config.removeConfig(IMAGE_SERVER_ADDRESS);
            config.removeConfig(IMAGE_SERVER_USERNAME);
            config.removeConfig(IMAGE_SERVER_ENC_PWD);
            config.removeConfig(IMAGE_SERVER_TFTPBOOT_DIR);
            config.removeConfig(IMAGE_SERVER_HTTP_PORT);
            config.removeConfig(IMAGE_SERVER_OS_NETWORK_IP);
            config.removeConfig(IMAGE_SERVER_IMAGEDIR);
            coordinatorClient.persistServiceConfiguration(config);
        } else {
            log.info("No image server configuration found in Zookeeper db");
        }
    } catch (Exception e) {
        log.error("Exception occured while migrating compute image server information");
        log.error(e.getMessage(), e);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ComputeImageServer(com.emc.storageos.db.client.model.ComputeImageServer) PropertyInfo(com.emc.storageos.model.property.PropertyInfo) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Aggregations

PropertyInfo (com.emc.storageos.model.property.PropertyInfo)19 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)5 Configuration (com.emc.storageos.coordinator.common.Configuration)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)2 HashMap (java.util.HashMap)2 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)1 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)1 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)1 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)1 EncryptionProviderImpl (com.emc.storageos.db.client.impl.EncryptionProviderImpl)1 AuditLog (com.emc.storageos.db.client.model.AuditLog)1 ComputeImageServer (com.emc.storageos.db.client.model.ComputeImageServer)1 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 SecurityException (com.emc.storageos.security.exceptions.SecurityException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)1