Example usage for javax.naming ConfigurationException ConfigurationException

List of usage examples for javax.naming ConfigurationException ConfigurationException

Introduction

In this page you can find the example usage for javax.naming ConfigurationException ConfigurationException.

Prototype

public ConfigurationException(String explanation) 

Source Link

Document

Constructs a new instance of ConfigurationException using an explanation.

Usage

From source file:com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.java

private Map<String, Object> getDeveloperProperties() throws ConfigurationException {

    final File file = PropertiesUtil.findConfigFile("developer.properties");
    if (file == null) {
        throw new ConfigurationException("Unable to find developer.properties.");
    }/*  ww  w.  jav a2s  .  c  o  m*/

    s_logger.info("developer.properties found at " + file.getAbsolutePath());
    try {
        final Properties properties = PropertiesUtil.loadFromFile(file);

        final String startMac = (String) properties.get("private.macaddr.start");
        if (startMac == null) {
            throw new ConfigurationException("Developers must specify start mac for private ip range");
        }

        final String startIp = (String) properties.get("private.ipaddr.start");
        if (startIp == null) {
            throw new ConfigurationException("Developers must specify start ip for private ip range");
        }
        final Map<String, Object> params = PropertiesUtil.toMap(properties);

        String endIp = (String) properties.get("private.ipaddr.end");
        if (endIp == null) {
            endIp = getEndIpFromStartIp(startIp, 16);
            params.put("private.ipaddr.end", endIp);
        }
        return params;
    } catch (final FileNotFoundException ex) {
        throw new CloudRuntimeException("Cannot find the file: " + file.getAbsolutePath(), ex);
    } catch (final IOException ex) {
        throw new CloudRuntimeException("IOException in reading " + file.getAbsolutePath(), ex);
    }
}

From source file:com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.java

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    boolean success = super.configure(name, params);
    if (!success) {
        return false;
    }/*  w  w w.j  av  a2 s  .co  m*/

    _storage = new JavaStorageLayer();
    _storage.configure("StorageLayer", params);

    String domrScriptsDir = (String) params.get("domr.scripts.dir");
    if (domrScriptsDir == null) {
        domrScriptsDir = getDefaultDomrScriptsDir();
    }

    String hypervisorScriptsDir = (String) params.get("hypervisor.scripts.dir");
    if (hypervisorScriptsDir == null) {
        hypervisorScriptsDir = getDefaultHypervisorScriptsDir();
    }

    String kvmScriptsDir = (String) params.get("kvm.scripts.dir");
    if (kvmScriptsDir == null) {
        kvmScriptsDir = getDefaultKvmScriptsDir();
    }

    String networkScriptsDir = (String) params.get("network.scripts.dir");
    if (networkScriptsDir == null) {
        networkScriptsDir = getDefaultNetworkScriptsDir();
    }

    String storageScriptsDir = (String) params.get("storage.scripts.dir");
    if (storageScriptsDir == null) {
        storageScriptsDir = getDefaultStorageScriptsDir();
    }

    final String bridgeType = (String) params.get("network.bridge.type");
    if (bridgeType == null) {
        _bridgeType = BridgeType.NATIVE;
    } else {
        _bridgeType = BridgeType.valueOf(bridgeType.toUpperCase());
    }

    params.put("domr.scripts.dir", domrScriptsDir);

    _virtRouterResource = new VirtualRoutingResource(this);
    success = _virtRouterResource.configure(name, params);

    if (!success) {
        return false;
    }

    _host = (String) params.get("host");
    if (_host == null) {
        _host = "localhost";
    }

    _dcId = (String) params.get("zone");
    if (_dcId == null) {
        _dcId = "default";
    }

    _pod = (String) params.get("pod");
    if (_pod == null) {
        _pod = "default";
    }

    _clusterId = (String) params.get("cluster");

    _updateHostPasswdPath = Script.findScript(hypervisorScriptsDir, VRScripts.UPDATE_HOST_PASSWD);
    if (_updateHostPasswdPath == null) {
        throw new ConfigurationException("Unable to find update_host_passwd.sh");
    }

    _modifyVlanPath = Script.findScript(networkScriptsDir, "modifyvlan.sh");
    if (_modifyVlanPath == null) {
        throw new ConfigurationException("Unable to find modifyvlan.sh");
    }

    _versionstringpath = Script.findScript(kvmScriptsDir, "versions.sh");
    if (_versionstringpath == null) {
        throw new ConfigurationException("Unable to find versions.sh");
    }

    _patchViaSocketPath = Script.findScript(kvmScriptsDir + "/patch/", "patchviasocket.py");
    if (_patchViaSocketPath == null) {
        throw new ConfigurationException("Unable to find patchviasocket.py");
    }

    _heartBeatPath = Script.findScript(kvmScriptsDir, "kvmheartbeat.sh");
    if (_heartBeatPath == null) {
        throw new ConfigurationException("Unable to find kvmheartbeat.sh");
    }

    _createvmPath = Script.findScript(storageScriptsDir, "createvm.sh");
    if (_createvmPath == null) {
        throw new ConfigurationException("Unable to find the createvm.sh");
    }

    _manageSnapshotPath = Script.findScript(storageScriptsDir, "managesnapshot.sh");
    if (_manageSnapshotPath == null) {
        throw new ConfigurationException("Unable to find the managesnapshot.sh");
    }

    _resizeVolumePath = Script.findScript(storageScriptsDir, "resizevolume.sh");
    if (_resizeVolumePath == null) {
        throw new ConfigurationException("Unable to find the resizevolume.sh");
    }

    _createTmplPath = Script.findScript(storageScriptsDir, "createtmplt.sh");
    if (_createTmplPath == null) {
        throw new ConfigurationException("Unable to find the createtmplt.sh");
    }

    _securityGroupPath = Script.findScript(networkScriptsDir, "security_group.py");
    if (_securityGroupPath == null) {
        throw new ConfigurationException("Unable to find the security_group.py");
    }

    _ovsTunnelPath = Script.findScript(networkScriptsDir, "ovstunnel.py");
    if (_ovsTunnelPath == null) {
        throw new ConfigurationException("Unable to find the ovstunnel.py");
    }

    _routerProxyPath = Script.findScript("scripts/network/domr/", "router_proxy.sh");
    if (_routerProxyPath == null) {
        throw new ConfigurationException("Unable to find the router_proxy.sh");
    }

    _ovsPvlanDhcpHostPath = Script.findScript(networkScriptsDir, "ovs-pvlan-dhcp-host.sh");
    if (_ovsPvlanDhcpHostPath == null) {
        throw new ConfigurationException("Unable to find the ovs-pvlan-dhcp-host.sh");
    }

    _ovsPvlanVmPath = Script.findScript(networkScriptsDir, "ovs-pvlan-vm.sh");
    if (_ovsPvlanVmPath == null) {
        throw new ConfigurationException("Unable to find the ovs-pvlan-vm.sh");
    }

    String value = (String) params.get("developer");
    final boolean isDeveloper = Boolean.parseBoolean(value);

    if (isDeveloper) {
        params.putAll(getDeveloperProperties());
    }

    _pool = (String) params.get("pool");
    if (_pool == null) {
        _pool = "/root";
    }

    final String instance = (String) params.get("instance");

    _hypervisorType = HypervisorType.getType((String) params.get("hypervisor.type"));
    if (_hypervisorType == HypervisorType.None) {
        _hypervisorType = HypervisorType.KVM;
    }

    _hypervisorURI = (String) params.get("hypervisor.uri");
    if (_hypervisorURI == null) {
        _hypervisorURI = LibvirtConnection.getHypervisorURI(_hypervisorType.toString());
    }

    _networkDirectSourceMode = (String) params.get("network.direct.source.mode");
    _networkDirectDevice = (String) params.get("network.direct.device");

    String startMac = (String) params.get("private.macaddr.start");
    if (startMac == null) {
        startMac = "00:16:3e:77:e2:a0";
    }

    String startIp = (String) params.get("private.ipaddr.start");
    if (startIp == null) {
        startIp = "192.168.166.128";
    }

    _pingTestPath = Script.findScript(kvmScriptsDir, "pingtest.sh");
    if (_pingTestPath == null) {
        throw new ConfigurationException("Unable to find the pingtest.sh");
    }

    _linkLocalBridgeName = (String) params.get("private.bridge.name");
    if (_linkLocalBridgeName == null) {
        if (isDeveloper) {
            _linkLocalBridgeName = "cloud-" + instance + "-0";
        } else {
            _linkLocalBridgeName = "cloud0";
        }
    }

    _publicBridgeName = (String) params.get("public.network.device");
    if (_publicBridgeName == null) {
        _publicBridgeName = "cloudbr0";
    }

    _privBridgeName = (String) params.get("private.network.device");
    if (_privBridgeName == null) {
        _privBridgeName = "cloudbr1";
    }

    _guestBridgeName = (String) params.get("guest.network.device");
    if (_guestBridgeName == null) {
        _guestBridgeName = _privBridgeName;
    }

    _privNwName = (String) params.get("private.network.name");
    if (_privNwName == null) {
        if (isDeveloper) {
            _privNwName = "cloud-" + instance + "-private";
        } else {
            _privNwName = "cloud-private";
        }
    }

    _localStoragePath = (String) params.get("local.storage.path");
    if (_localStoragePath == null) {
        _localStoragePath = "/var/lib/libvirt/images/";
    }

    final File storagePath = new File(_localStoragePath);
    _localStoragePath = storagePath.getAbsolutePath();

    _localStorageUUID = (String) params.get("local.storage.uuid");
    if (_localStorageUUID == null) {
        _localStorageUUID = UUID.randomUUID().toString();
    }

    value = (String) params.get("scripts.timeout");
    _timeout = NumbersUtil.parseInt(value, 30 * 60) * 1000;

    value = (String) params.get("stop.script.timeout");
    _stopTimeout = NumbersUtil.parseInt(value, 120) * 1000;

    value = (String) params.get("cmds.timeout");
    _cmdsTimeout = NumbersUtil.parseInt(value, 7200) * 1000;

    value = (String) params.get("vm.memballoon.disable");
    if (Boolean.parseBoolean(value)) {
        _noMemBalloon = true;
    }

    _videoHw = (String) params.get("vm.video.hardware");
    value = (String) params.get("vm.video.ram");
    _videoRam = NumbersUtil.parseInt(value, 0);

    value = (String) params.get("host.reserved.mem.mb");
    // Reserve 1GB unless admin overrides
    _dom0MinMem = NumbersUtil.parseInt(value, 1024) * 1024 * 1024L;

    value = (String) params.get("kvmclock.disable");
    if (Boolean.parseBoolean(value)) {
        _noKvmClock = true;
    }

    LibvirtConnection.initialize(_hypervisorURI);
    Connect conn = null;
    try {
        conn = LibvirtConnection.getConnection();

        if (_bridgeType == BridgeType.OPENVSWITCH) {
            if (conn.getLibVirVersion() < 10 * 1000 + 0) {
                throw new ConfigurationException(
                        "Libvirt version 0.10.0 required for openvswitch support, but version "
                                + conn.getLibVirVersion() + " detected");
            }
        }
    } catch (final LibvirtException e) {
        throw new CloudRuntimeException(e.getMessage());
    }

    if (HypervisorType.KVM == _hypervisorType) {
        /* Does node support HVM guest? If not, exit */
        if (!IsHVMEnabled(conn)) {
            throw new ConfigurationException("NO HVM support on this machine, please make sure: "
                    + "1. VT/SVM is supported by your CPU, or is enabled in BIOS. "
                    + "2. kvm modules are loaded (kvm, kvm_amd|kvm_intel)");
        }
    }

    _hypervisorPath = getHypervisorPath(conn);
    try {
        _hvVersion = conn.getVersion();
        _hvVersion = _hvVersion % 1000000 / 1000;
        _hypervisorLibvirtVersion = conn.getLibVirVersion();
        _hypervisorQemuVersion = conn.getVersion();
    } catch (final LibvirtException e) {
        s_logger.trace("Ignoring libvirt error.", e);
    }

    _guestCpuMode = (String) params.get("guest.cpu.mode");
    if (_guestCpuMode != null) {
        _guestCpuModel = (String) params.get("guest.cpu.model");

        if (_hypervisorLibvirtVersion < 9 * 1000 + 10) {
            s_logger.warn("Libvirt version 0.9.10 required for guest cpu mode, but version "
                    + prettyVersion(_hypervisorLibvirtVersion) + " detected, so it will be disabled");
            _guestCpuMode = "";
            _guestCpuModel = "";
        }
        params.put("guest.cpu.mode", _guestCpuMode);
        params.put("guest.cpu.model", _guestCpuModel);
    }

    final String cpuFeatures = (String) params.get("guest.cpu.features");
    if (cpuFeatures != null) {
        _cpuFeatures = new ArrayList<String>();
        for (final String feature : cpuFeatures.split(" ")) {
            if (!feature.isEmpty()) {
                _cpuFeatures.add(feature);
            }
        }
    }

    final String[] info = NetUtils.getNetworkParams(_privateNic);

    _monitor = new KVMHAMonitor(null, info[0], _heartBeatPath);
    final Thread ha = new Thread(_monitor);
    ha.start();

    _storagePoolMgr = new KVMStoragePoolManager(_storage, _monitor);

    _sysvmISOPath = (String) params.get("systemvm.iso.path");
    if (_sysvmISOPath == null) {
        final String[] isoPaths = { "/usr/share/cloudstack-common/vms/systemvm.iso" };
        for (final String isoPath : isoPaths) {
            if (_storage.exists(isoPath)) {
                _sysvmISOPath = isoPath;
                break;
            }
        }
        if (_sysvmISOPath == null) {
            s_logger.debug("Can't find system vm ISO");
        }
    }

    switch (_bridgeType) {
    case OPENVSWITCH:
        getOvsPifs();
        break;
    case NATIVE:
    default:
        getPifs();
        break;
    }

    if (_pifs.get("private") == null) {
        s_logger.debug("Failed to get private nic name");
        throw new ConfigurationException("Failed to get private nic name");
    }

    if (_pifs.get("public") == null) {
        s_logger.debug("Failed to get public nic name");
        throw new ConfigurationException("Failed to get public nic name");
    }
    s_logger.debug("Found pif: " + _pifs.get("private") + " on " + _privBridgeName + ", pif: "
            + _pifs.get("public") + " on " + _publicBridgeName);

    _canBridgeFirewall = canBridgeFirewall(_pifs.get("public"));

    _localGateway = Script.runSimpleBashScript("ip route |grep default|awk '{print $3}'");
    if (_localGateway == null) {
        s_logger.debug("Failed to found the local gateway");
    }

    _mountPoint = (String) params.get("mount.path");
    if (_mountPoint == null) {
        _mountPoint = "/mnt";
    }

    value = (String) params.get("vm.migrate.downtime");
    _migrateDowntime = NumbersUtil.parseInt(value, -1);

    value = (String) params.get("vm.migrate.pauseafter");
    _migratePauseAfter = NumbersUtil.parseInt(value, -1);

    value = (String) params.get("vm.migrate.speed");
    _migrateSpeed = NumbersUtil.parseInt(value, -1);
    if (_migrateSpeed == -1) {
        //get guest network device speed
        _migrateSpeed = 0;
        final String speed = Script
                .runSimpleBashScript("ethtool " + _pifs.get("public") + " |grep Speed | cut -d \\  -f 2");
        if (speed != null) {
            final String[] tokens = speed.split("M");
            if (tokens.length == 2) {
                try {
                    _migrateSpeed = Integer.parseInt(tokens[0]);
                } catch (final NumberFormatException e) {
                    s_logger.trace("Ignoring migrateSpeed extraction error.", e);
                }
                s_logger.debug(
                        "device " + _pifs.get("public") + " has speed: " + String.valueOf(_migrateSpeed));
            }
        }
        params.put("vm.migrate.speed", String.valueOf(_migrateSpeed));
    }

    final Map<String, String> bridges = new HashMap<String, String>();
    bridges.put("linklocal", _linkLocalBridgeName);
    bridges.put("public", _publicBridgeName);
    bridges.put("private", _privBridgeName);
    bridges.put("guest", _guestBridgeName);

    params.put("libvirt.host.bridges", bridges);
    params.put("libvirt.host.pifs", _pifs);

    params.put("libvirt.computing.resource", this);
    params.put("libvirtVersion", _hypervisorLibvirtVersion);

    configureVifDrivers(params);
    configureDiskActivityChecks(params);

    final KVMStorageProcessor storageProcessor = new KVMStorageProcessor(_storagePoolMgr, this);
    storageProcessor.configure(name, params);
    storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor);

    return true;
}

From source file:org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.java

protected Answer copySnapshotToTemplateFromNfsToNfs(CopyCommand cmd, SnapshotObjectTO srcData,
        NfsTO srcDataStore, TemplateObjectTO destData, NfsTO destDataStore) {

    if (srcData.getHypervisorType() == HypervisorType.XenServer) {
        return copySnapshotToTemplateFromNfsToNfsXenserver(cmd, srcData, srcDataStore, destData, destDataStore);
    } else if (srcData.getHypervisorType() == HypervisorType.KVM) {
        File srcFile = getFile(srcData.getPath(), srcDataStore.getUrl(), _nfsVersion);
        File destFile = getFile(destData.getPath(), destDataStore.getUrl(), _nfsVersion);

        VolumeObjectTO volumeObjectTO = srcData.getVolume();
        ImageFormat srcFormat = null;//from  www .j ava 2 s  . c om
        //TODO: the image format should be stored in snapshot table, instead of getting from volume
        if (volumeObjectTO != null) {
            srcFormat = volumeObjectTO.getFormat();
        } else {
            srcFormat = ImageFormat.QCOW2;
        }

        // get snapshot file name
        String templateName = srcFile.getName();
        // add kvm file extension for copied template name
        String fileName = templateName + "." + srcFormat.getFileExtension();
        String destFileFullPath = destFile.getAbsolutePath() + File.separator + fileName;
        s_logger.debug("copy snapshot " + srcFile.getAbsolutePath() + " to template " + destFileFullPath);
        Script.runSimpleBashScript("cp " + srcFile.getAbsolutePath() + " " + destFileFullPath);
        String metaFileName = destFile.getAbsolutePath() + File.separator + _tmpltpp;
        File metaFile = new File(metaFileName);
        try {
            _storage.create(destFile.getAbsolutePath(), _tmpltpp);
            try ( // generate template.properties file
                    FileWriter writer = new FileWriter(metaFile);
                    BufferedWriter bufferWriter = new BufferedWriter(writer);) {
                // KVM didn't change template unique name, just used the template name passed from orchestration layer, so no need
                // to send template name back.
                bufferWriter.write("uniquename=" + destData.getName());
                bufferWriter.write("\n");
                bufferWriter.write("filename=" + fileName);
                bufferWriter.write("\n");
                long size = _storage.getSize(destFileFullPath);
                bufferWriter.write("size=" + size);

                /**
                 * Snapshots might be in either QCOW2 or RAW image format
                 *
                 * For example RBD snapshots are in RAW format
                 */
                Processor processor = null;
                if (srcFormat == ImageFormat.QCOW2) {
                    processor = new QCOW2Processor();
                } else if (srcFormat == ImageFormat.RAW) {
                    processor = new RawImageProcessor();
                } else {
                    throw new ConfigurationException("Unknown image format " + srcFormat.toString());
                }

                Map<String, Object> params = new HashMap<String, Object>();
                params.put(StorageLayer.InstanceConfigKey, _storage);

                processor.configure("template processor", params);
                String destPath = destFile.getAbsolutePath();

                FormatInfo info = processor.process(destPath, null, templateName);
                TemplateLocation loc = new TemplateLocation(_storage, destPath);
                loc.create(1, true, destData.getName());
                loc.addFormat(info);
                loc.save();

                TemplateProp prop = loc.getTemplateInfo();
                TemplateObjectTO newTemplate = new TemplateObjectTO();
                newTemplate.setPath(destData.getPath() + File.separator + fileName);
                newTemplate.setFormat(srcFormat);
                newTemplate.setSize(prop.getSize());
                newTemplate.setPhysicalSize(prop.getPhysicalSize());
                return new CopyCmdAnswer(newTemplate);
            } catch (ConfigurationException e) {
                s_logger.debug("Failed to create template:" + e.toString());
                return new CopyCmdAnswer(e.toString());
            } catch (InternalErrorException e) {
                s_logger.debug("Failed to create template:" + e.toString());
                return new CopyCmdAnswer(e.toString());
            }
        } catch (IOException e) {
            s_logger.debug("Failed to create template:" + e.toString());
            return new CopyCmdAnswer(e.toString());
        }
    }

    return new CopyCmdAnswer("");
}

From source file:com.cloud.hypervisor.xenserver.resource.CitrixResourceBase.java

private void CheckXenHostInfo() throws ConfigurationException {
    final Connection conn = ConnPool.getConnect(_host.getIp(), _username, _password);
    if (conn == null) {
        throw new ConfigurationException("Can not create connection to " + _host.getIp());
    }/* www  .ja v  a 2s  .  c o m*/
    try {
        Host.Record hostRec = null;
        try {
            final Host host = Host.getByUuid(conn, _host.getUuid());
            hostRec = host.getRecord(conn);
            final Pool.Record poolRec = Pool.getAllRecords(conn).values().iterator().next();
            _host.setPool(poolRec.uuid);

        } catch (final Exception e) {
            throw new ConfigurationException("Can not get host information from " + _host.getIp());
        }
        if (!hostRec.address.equals(_host.getIp())) {
            final String msg = "Host " + _host.getIp()
                    + " seems be reinstalled, please remove this host and readd";
            s_logger.error(msg);
            throw new ConfigurationException(msg);
        }
    } finally {
        try {
            Session.logout(conn);
        } catch (final Exception e) {
        }
    }
}

From source file:com.wso2telco.proxy.entity.Endpoints.java

private String constructRedirectUrl(RedirectUrlInfo redirectUrlInfo, UserStatus userStatus)
        throws ConfigurationException {
    String redirectURL = null;//  w  w  w  .j  av  a2 s .  c  o  m
    String authorizeUrl = redirectUrlInfo.getAuthorizeUrl();
    String queryString = redirectUrlInfo.getQueryString();
    String msisdnHeader = redirectUrlInfo.getMsisdnHeader();
    String loginHintMsisdn = redirectUrlInfo.getLoginhintMsisdn();
    String operatorName = redirectUrlInfo.getOperatorName();
    String telcoScope = redirectUrlInfo.getTelcoScope();
    String ipAddress = redirectUrlInfo.getIpAddress();
    String prompt = redirectUrlInfo.getPrompt();
    String validationRegex = configurationService.getDataHolder().getMobileConnectConfig().getMsisdn()
            .getValidationRegex();
    boolean isShowTnc = redirectUrlInfo.isShowTnc();
    ScopeParam.msisdnMismatchResultTypes headerMismatchResult = redirectUrlInfo.getHeaderMismatchResult();
    ScopeParam.heFailureResults heFailureResult = redirectUrlInfo.getHeFailureResult();

    String transactionId = redirectUrlInfo.getTransactionId();
    if (authorizeUrl != null) {
        redirectURL = authorizeUrl + queryString + "&" + AuthProxyConstants.OPERATOR + "=" + operatorName + "&"
                + AuthProxyConstants.TELCO_SCOPE + "=" + telcoScope + "&" + AuthProxyConstants.SHOW_TNC + "="
                + isShowTnc + "&" + AuthProxyConstants.HEADER_MISMATCH_RESULT + "=" + headerMismatchResult + "&"
                + AuthProxyConstants.HE_FAILURE_RESULT + "=" + heFailureResult;

        if (msisdnHeader != null && StringUtils.isNotEmpty(msisdnHeader)) {
            redirectURL = redirectURL + "&" + AuthProxyConstants.MSISDN_HEADER + "=" + msisdnHeader;
        }

        if (loginHintMsisdn != null && !StringUtils.isEmpty(loginHintMsisdn)) {
            redirectURL = redirectURL + "&" + AuthProxyConstants.LOGIN_HINT_MSISDN + "=" + loginHintMsisdn;
        }

        // Reconstruct Authorize url with ip address.
        if (ipAddress != null) {
            redirectURL += "&" + AuthProxyConstants.IP_ADDRESS + "=" + ipAddress;
        }

        if (StringUtils.isNotEmpty(transactionId)) {
            redirectURL = redirectURL + "&" + AuthProxyConstants.TRANSACTION_ID + "=" + transactionId;
        }

        if (StringUtils.isNotEmpty(prompt)) {
            redirectURL = redirectURL + "&" + AuthProxyConstants.TELCO_PROMPT + "=" + prompt;
        }

        if (StringUtils.isNotEmpty(validationRegex)) {
            redirectURL = redirectURL + "&" + AuthProxyConstants.MSISDN_VALIDATION_REGEX + "="
                    + validationRegex;
        }
    } else {
        String errMsg = "AuthorizeURL could not be found in mobile-connect.xml";
        DataPublisherUtil.updateAndPublishUserStatus(userStatus,
                DataPublisherUtil.UserState.CONFIGURATION_ERROR, errMsg);

        throw new ConfigurationException(errMsg);
    }
    return redirectURL;
}

From source file:com.cloud.hypervisor.xenserver.resource.CitrixResourceBase.java

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    _name = name;//  www .ja va2s.com

    try {
        _dcId = Long.parseLong((String) params.get("zone"));
    } catch (final NumberFormatException e) {
        throw new ConfigurationException("Unable to get the zone " + params.get("zone"));
    }

    _host.setUuid((String) params.get("guid"));

    _name = _host.getUuid();
    _host.setIp((String) params.get("ipaddress"));

    _username = (String) params.get("username");
    _password.add((String) params.get("password"));
    _pod = (String) params.get("pod");
    _cluster = (String) params.get("cluster");
    _privateNetworkName = (String) params.get("private.network.device");
    _publicNetworkName = (String) params.get("public.network.device");
    _guestNetworkName = (String) params.get("guest.network.device");
    _instance = (String) params.get("instance.name");
    _securityGroupEnabled = Boolean.parseBoolean((String) params.get("securitygroupenabled"));

    _linkLocalPrivateNetworkName = (String) params.get("private.linkLocal.device");
    if (_linkLocalPrivateNetworkName == null) {
        _linkLocalPrivateNetworkName = "cloud_link_local_network";
    }

    _storageNetworkName1 = (String) params.get("storage.network.device1");
    _storageNetworkName2 = (String) params.get("storage.network.device2");

    _heartbeatTimeout = NumbersUtil.parseInt((String) params.get("xenserver.heartbeat.timeout"), 120);
    _heartbeatInterval = NumbersUtil.parseInt((String) params.get("xenserver.heartbeat.interval"), 60);

    String value = (String) params.get("wait");
    _wait = NumbersUtil.parseInt(value, 600);

    value = (String) params.get("migratewait");
    _migratewait = NumbersUtil.parseInt(value, 3600);

    _maxNics = NumbersUtil.parseInt((String) params.get("xenserver.nics.max"), 7);

    if (_pod == null) {
        throw new ConfigurationException("Unable to get the pod");
    }

    if (_host.getIp() == null) {
        throw new ConfigurationException("Unable to get the host address");
    }

    if (_username == null) {
        throw new ConfigurationException("Unable to get the username");
    }

    if (_password.peek() == null) {
        throw new ConfigurationException("Unable to get the password");
    }

    if (_host.getUuid() == null) {
        throw new ConfigurationException("Unable to get the uuid");
    }

    CheckXenHostInfo();

    storageHandler = buildStorageHandler();

    _vrResource = new VirtualRoutingResource(this);
    if (!_vrResource.configure(name, params)) {
        throw new ConfigurationException("Unable to configure VirtualRoutingResource");
    }
    return true;
}

From source file:com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource.java

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    _name = name;//from  ww  w. ja  v a2s .c om

    _scriptsDir = (String) params.get("domr.scripts.dir");
    if (_scriptsDir == null) {
        if (s_logger.isInfoEnabled()) {
            s_logger.info(
                    "VirtualRoutingResource _scriptDir can't be initialized from domr.scripts.dir param, use default");
        }
        _scriptsDir = getDefaultScriptsDir();
    }

    if (s_logger.isInfoEnabled()) {
        s_logger.info("VirtualRoutingResource _scriptDir to use: " + _scriptsDir);
    }

    String value = (String) params.get("scripts.timeout");
    _timeout = NumbersUtil.parseInt(value, 120) * 1000;

    value = (String) params.get("start.script.timeout");
    _startTimeout = NumbersUtil.parseInt(value, 360) * 1000;

    value = (String) params.get("ssh.sleep");
    _sleep = NumbersUtil.parseInt(value, 10) * 1000;

    value = (String) params.get("ssh.retry");
    _retry = NumbersUtil.parseInt(value, 36);

    value = (String) params.get("ssh.port");
    _port = NumbersUtil.parseInt(value, 3922);

    _publicIpAddress = (String) params.get("public.ip.address");
    if (_publicIpAddress != null) {
        s_logger.warn("Incoming public ip address is overriden.  Will always be using the same ip address: "
                + _publicIpAddress);
    }

    _firewallPath = findScript("call_firewall.sh");
    if (_firewallPath == null) {
        throw new ConfigurationException("Unable to find the call_firewall.sh");
    }

    _loadbPath = findScript("call_loadbalancer.sh");
    if (_loadbPath == null) {
        throw new ConfigurationException("Unable to find the call_loadbalancer.sh");
    }

    _savepasswordPath = findScript("save_password_to_domr.sh");
    if (_savepasswordPath == null) {
        throw new ConfigurationException("Unable to find save_password_to_domr.sh");
    }

    _dhcpEntryPath = findScript("dhcp_entry.sh");
    if (_dhcpEntryPath == null) {
        throw new ConfigurationException("Unable to find dhcp_entry.sh");
    }

    _vmDataPath = findScript("vm_data.sh");
    if (_vmDataPath == null) {
        throw new ConfigurationException("Unable to find user_data.sh");
    }

    _publicEthIf = (String) params.get("public.network.device");
    if (_publicEthIf == null) {
        _publicEthIf = "xenbr1";
    }
    _publicEthIf = _publicEthIf.toLowerCase();

    _privateEthIf = (String) params.get("private.network.device");
    if (_privateEthIf == null) {
        _privateEthIf = "xenbr0";
    }
    _privateEthIf = _privateEthIf.toLowerCase();

    _bumpUpPriorityPath = findScript("bumpUpPriority.sh");
    if (_bumpUpPriorityPath == null) {
        throw new ConfigurationException("Unable to find bumpUpPriority.sh");
    }

    _routerProxyPath = findScript("router_proxy.sh");
    if (_routerProxyPath == null) {
        throw new ConfigurationException("Unable to find router_proxy.sh");
    }

    return true;
}

From source file:com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.java

protected VifDriver getVifDriverClass(final String vifDriverClassName, final Map<String, Object> params)
        throws ConfigurationException {
    VifDriver vifDriver;/*from w  w  w.  j a  v a  2  s .  c  om*/

    try {
        final Class<?> clazz = Class.forName(vifDriverClassName);
        vifDriver = (VifDriver) clazz.newInstance();
        vifDriver.configure(params);
    } catch (final ClassNotFoundException e) {
        throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e);
    } catch (final InstantiationException e) {
        throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
    } catch (final IllegalAccessException e) {
        throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
    }
    return vifDriver;
}

From source file:com.cloud.vm.UserVmManagerImpl.java

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    _name = name;//  ww w .  ja v a 2s.  c om

    ComponentLocator locator = ComponentLocator.getCurrentLocator();
    _configDao = locator.getDao(ConfigurationDao.class);
    if (_configDao == null) {
        throw new ConfigurationException("Unable to get the configuration dao.");
    }

    Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);

    _instance = configs.get("instance.name");
    if (_instance == null) {
        _instance = "DEFAULT";
    }

    String value = _configDao.getValue(Config.CreatePrivateTemplateFromVolumeWait.toString());
    _createprivatetemplatefromvolumewait = NumbersUtil.parseInt(value,
            Integer.parseInt(Config.CreatePrivateTemplateFromVolumeWait.getDefaultValue()));

    value = _configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString());
    _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value,
            Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));

    String workers = configs.get("expunge.workers");
    int wrks = NumbersUtil.parseInt(workers, 10);

    String time = configs.get("expunge.interval");
    _expungeInterval = NumbersUtil.parseInt(time, 86400);
    if (_expungeInterval < 600) {
        _expungeInterval = 600;
    }
    time = configs.get("expunge.delay");
    _expungeDelay = NumbersUtil.parseInt(time, _expungeInterval);
    if (_expungeDelay < 600) {
        _expungeDelay = 600;
    }
    _executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("UserVm-Scavenger"));

    _itMgr.registerGuru(VirtualMachine.Type.User, this);

    VirtualMachine.State.getStateMachine()
            .registerListener(new UserVmStateListener(_usageEventDao, _networkDao, _nicDao));

    s_logger.info("User VM Manager is configured.");

    return true;
}

From source file:com.cloud.consoleproxy.ConsoleProxyManagerImpl.java

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Start configuring console proxy manager : " + name);
    }//from  w w w . j  a va 2s  .c o m

    Map<String, String> configs = _configDao.getConfiguration("management-server", params);

    String value = configs.get(Config.ConsoleProxyCmdPort.key());
    value = configs.get("consoleproxy.sslEnabled");
    if (value != null && value.equalsIgnoreCase("true")) {
        _sslEnabled = true;
    }

    _consoleProxyUrlDomain = configs.get(Config.ConsoleProxyUrlDomain.key());
    if (_sslEnabled && (_consoleProxyUrlDomain == null || _consoleProxyUrlDomain.isEmpty())) {
        s_logger.warn("Empty console proxy domain, explicitly disabling SSL");
        _sslEnabled = false;
    }

    value = configs.get(Config.ConsoleProxyCapacityScanInterval.key());
    _capacityScanInterval = NumbersUtil.parseLong(value, DEFAULT_CAPACITY_SCAN_INTERVAL);

    _capacityPerProxy = NumbersUtil.parseInt(configs.get("consoleproxy.session.max"), DEFAULT_PROXY_CAPACITY);
    _standbyCapacity = NumbersUtil.parseInt(configs.get("consoleproxy.capacity.standby"),
            DEFAULT_STANDBY_CAPACITY);
    _proxySessionTimeoutValue = NumbersUtil.parseInt(configs.get("consoleproxy.session.timeout"),
            DEFAULT_PROXY_SESSION_TIMEOUT);

    value = configs.get("consoleproxy.port");
    if (value != null) {
        _consoleProxyPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT);
    }

    value = configs.get(Config.ConsoleProxyDisableRpFilter.key());
    if (value != null && value.equalsIgnoreCase("true")) {
        _disableRpFilter = true;
    }

    value = configs.get("secondary.storage.vm");
    if (value != null && value.equalsIgnoreCase("true")) {
        _useStorageVm = true;
    }

    if (s_logger.isInfoEnabled()) {
        s_logger.info("Console proxy max session soft limit : " + _capacityPerProxy);
        s_logger.info("Console proxy standby capacity : " + _standbyCapacity);
    }

    _instance = configs.get("instance.name");
    if (_instance == null) {
        _instance = "DEFAULT";
    }

    Map<String, String> agentMgrConfigs = _configDao.getConfiguration("AgentManager", params);

    value = agentMgrConfigs.get("port");
    _mgmtPort = NumbersUtil.parseInt(value, 8250);

    _listener = new ConsoleProxyListener(
            new VmBasedAgentHook(_instanceDao, _hostDao, _configDao, _ksMgr, _agentMgr, _keysMgr));
    _agentMgr.registerForHostEvents(_listener, true, true, false);

    _itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this);

    //check if there is a default service offering configured
    String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key());
    if (cpvmSrvcOffIdStr != null) {
        _serviceOffering = _offeringDao.findByUuid(cpvmSrvcOffIdStr);
        if (_serviceOffering == null) {
            try {
                _serviceOffering = _offeringDao.findById(Long.parseLong(cpvmSrvcOffIdStr));
            } catch (NumberFormatException ex) {
                s_logger.debug("The system service offering specified by global config is not id, but uuid="
                        + cpvmSrvcOffIdStr + " for console proxy vm");
            }
        }
        if (_serviceOffering == null) {
            s_logger.warn("Can't find system service offering specified by global config, uuid="
                    + cpvmSrvcOffIdStr + " for console proxy vm");
        }
    }

    if (_serviceOffering == null || !_serviceOffering.getSystemUse()) {
        int ramSize = NumbersUtil.parseInt(_configDao.getValue("console.ram.size"), DEFAULT_PROXY_VM_RAMSIZE);
        int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("console.cpu.mhz"), DEFAULT_PROXY_VM_CPUMHZ);
        List<ServiceOfferingVO> offerings = _offeringDao.createSystemServiceOfferings(
                "System Offering For Console Proxy", ServiceOffering.consoleProxyDefaultOffUniqueName, 1,
                ramSize, cpuFreq, 0, 0, false, null, Storage.ProvisioningType.THIN, true, null, true,
                VirtualMachine.Type.ConsoleProxy, true);
        // this can sometimes happen, if DB is manually or programmatically manipulated
        if (offerings == null || offerings.size() < 2) {
            String msg = "Data integrity problem : System Offering For Console Proxy has been removed?";
            s_logger.error(msg);
            throw new ConfigurationException(msg);
        }
    }

    _loadScanner = new SystemVmLoadScanner<Long>(this);
    _loadScanner.initScan(STARTUP_DELAY, _capacityScanInterval);
    _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);

    _staticPublicIp = _configDao.getValue("consoleproxy.static.publicIp");
    if (_staticPublicIp != null) {
        _staticPort = NumbersUtil.parseInt(_configDao.getValue("consoleproxy.static.port"), 8443);
    }

    if (s_logger.isInfoEnabled()) {
        s_logger.info("Console Proxy Manager is configured.");
    }
    return true;
}