|
30 | 30 |
|
31 | 31 | import javax.inject.Inject; |
32 | 32 | import javax.naming.ConfigurationException; |
| 33 | +import javax.ejb.Local; |
33 | 34 |
|
34 | 35 | import net.juniper.contrail.api.ApiConnector; |
35 | 36 | import net.juniper.contrail.api.ApiConnectorFactory; |
|
99 | 100 | import java.io.File; |
100 | 101 | import java.io.FileInputStream; |
101 | 102 |
|
102 | | -@Component |
| 103 | +@Local(value = { ContrailManager.class}) |
103 | 104 | public class ContrailManagerImpl extends ManagerBase implements ContrailManager { |
104 | 105 | @Inject public ConfigurationService _configService; |
105 | 106 | @Inject ConfigurationServer _configServer; |
@@ -135,7 +136,6 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager |
135 | 136 | private ModelController _controller; |
136 | 137 |
|
137 | 138 | ContrailManagerImpl() { |
138 | | - setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT); |
139 | 139 | _database = new ModelDatabase(); |
140 | 140 | } |
141 | 141 |
|
@@ -242,24 +242,33 @@ private NetworkOffering EnableNetworkOffering(long id) { |
242 | 242 | public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { |
243 | 243 |
|
244 | 244 | File configFile = PropertiesUtil.findConfigFile(configuration); |
245 | | - final Properties configProps = new Properties(); |
246 | 245 | try { |
247 | | - configProps.load(new FileInputStream(configFile)); |
248 | | - String value = configProps.getProperty("management.db_sync_interval"); |
249 | | - if (value != null) { |
250 | | - _dbSyncInterval = Integer.valueOf(value); |
251 | | - } |
252 | | - |
253 | | - String hostname = configProps.getProperty("api.hostname"); |
254 | | - String portStr = configProps.getProperty("api.port"); |
| 246 | + String hostname = null; |
255 | 247 | int port = 0; |
256 | | - if (portStr != null && portStr.length() > 0) { |
257 | | - port = Integer.parseInt(portStr); |
| 248 | + if (configFile == null) { |
| 249 | + hostname = "localhost"; |
| 250 | + port = 8082; |
| 251 | + } else { |
| 252 | + final Properties configProps = new Properties(); |
| 253 | + configProps.load(new FileInputStream(configFile)); |
| 254 | + String value = configProps.getProperty("management.db_sync_interval"); |
| 255 | + if (value != null) { |
| 256 | + _dbSyncInterval = Integer.valueOf(value); |
| 257 | + } |
| 258 | + hostname = configProps.getProperty("api.hostname"); |
| 259 | + String portStr = configProps.getProperty("api.port"); |
| 260 | + if (portStr != null && portStr.length() > 0) { |
| 261 | + port = Integer.parseInt(portStr); |
| 262 | + } |
258 | 263 | } |
259 | 264 | _api = ApiConnectorFactory.build(hostname, port); |
260 | 265 | } catch (IOException ex) { |
261 | 266 | s_logger.warn("Unable to read " + configuration, ex); |
262 | 267 | throw new ConfigurationException(); |
| 268 | + } catch (Exception ex) { |
| 269 | + s_logger.debug("Exception in configure: " + ex); |
| 270 | + ex.printStackTrace(); |
| 271 | + throw new ConfigurationException(); |
263 | 272 | } |
264 | 273 |
|
265 | 274 | _controller = new ModelController(this, _api, _vmDao, _networksDao, _nicDao, _vlanDao, _ipAddressDao); |
|
0 commit comments