Search in sources :

Example 1 with ModelController

use of org.apache.cloudstack.network.contrail.model.ModelController in project cloudstack by apache.

the class ContrailManagerImpl method configure.

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    File configFile = PropertiesUtil.findConfigFile(configuration);
    FileInputStream fileStream = null;
    try {
        String hostname = null;
        int port = 0;
        if (configFile == null) {
            return false;
        } else {
            final Properties configProps = new Properties();
            fileStream = new FileInputStream(configFile);
            configProps.load(fileStream);
            String value = configProps.getProperty("management.db_sync_interval");
            if (value != null) {
                _dbSyncInterval = Integer.parseInt(value);
            }
            hostname = configProps.getProperty("api.hostname");
            String portStr = configProps.getProperty("api.port");
            if (portStr != null && portStr.length() > 0) {
                port = Integer.parseInt(portStr);
            }
        }
        _api = ApiConnectorFactory.build(hostname, port);
    } catch (IOException ex) {
        s_logger.warn("Unable to read " + configuration, ex);
        throw new ConfigurationException();
    } catch (Exception ex) {
        s_logger.debug("Exception in configure: " + ex);
        ex.printStackTrace();
        throw new ConfigurationException();
    } finally {
        IOUtils.closeQuietly(fileStream);
    }
    _controller = new ModelController(this, _api, _vmDao, _networksDao, _nicDao, _vlanDao, _ipAddressDao);
    try {
        _routerOffering = locateNetworkOffering(routerOfferingName, routerOfferingDisplayText, Provider.JuniperContrailRouter);
        _routerPublicOffering = locatePublicNetworkOffering(routerPublicOfferingName, routerPublicOfferingDisplayText, Provider.JuniperContrailRouter);
        _vpcRouterOffering = locateNetworkOffering(vpcRouterOfferingName, vpcRouterOfferingDisplayText, Provider.JuniperContrailVpcRouter);
        _vpcOffering = locateVpcOffering();
    } catch (Exception ex) {
        s_logger.debug("Exception in locating network offerings: " + ex);
        ex.printStackTrace();
        throw new ConfigurationException();
    }
    _eventHandler.subscribe();
    initializeDefaultVirtualNetworkModels();
    return true;
}
Also used : ConfigurationException(javax.naming.ConfigurationException) IOException(java.io.IOException) Properties(java.util.Properties) ModelController(org.apache.cloudstack.network.contrail.model.ModelController) File(java.io.File) FileInputStream(java.io.FileInputStream) ConfigurationException(javax.naming.ConfigurationException) IOException(java.io.IOException)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 ConfigurationException (javax.naming.ConfigurationException)1 ModelController (org.apache.cloudstack.network.contrail.model.ModelController)1