Skip to content

Commit 45065c7

Browse files
sbalineniSheng Yang
authored andcommitted
Contrail plugin fixes - removed wrappers for db updates
Signed-off-by: Sheng Yang <sheng.yang@citrix.com>
1 parent dcfc76f commit 45065c7

3 files changed

Lines changed: 50 additions & 14 deletions

File tree

‎plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailElementImpl.java‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class ContrailElementImpl extends AdapterBase
7878
private static final Map<Service, Map<Capability, String>> _capabilities = InitCapabilities();
7979

8080
@Inject ResourceManager _resourceMgr;
81+
@Inject ConfigurationServer _configServer;
8182
@Inject NetworkDao _networksDao;
8283
@Inject ContrailManager _manager;
8384
@Inject NicDao _nicDao;
@@ -284,6 +285,32 @@ public boolean destroy(Network network, ReservationContext context)
284285

285286
@Override
286287
public boolean isReady(PhysicalNetworkServiceProvider provider) {
288+
Map<String, String> serviceMap = ((ConfigurationServerImpl)_configServer).getServicesAndProvidersForNetwork( _manager.getRouterOffering().getId());
289+
List<TrafficType> types = new ArrayList<TrafficType>();
290+
types.add(TrafficType.Control);
291+
types.add(TrafficType.Management);
292+
types.add(TrafficType.Storage);
293+
List<NetworkVO> systemNets = _manager.findSystemNetworks(types);
294+
if (systemNets != null && !systemNets.isEmpty()) {
295+
for (NetworkVO net: systemNets) {
296+
s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
297+
_networksDao.update(net.getId(), net, serviceMap);
298+
}
299+
} else {
300+
s_logger.debug("no system networks created yet");
301+
}
302+
serviceMap = ((ConfigurationServerImpl)_configServer).getServicesAndProvidersForNetwork( _manager.getPublicRouterOffering().getId());
303+
types = new ArrayList<TrafficType>();
304+
types.add(TrafficType.Public);
305+
systemNets = _manager.findSystemNetworks(types);
306+
if (systemNets != null && !systemNets.isEmpty()) {
307+
for (NetworkVO net: systemNets) {
308+
s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
309+
_networksDao.update(net.getId(), net, serviceMap);
310+
}
311+
} else {
312+
s_logger.debug("no system networks created yet");
313+
}
287314
return true;
288315
}
289316

‎plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java‎

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import javax.inject.Inject;
3232
import javax.naming.ConfigurationException;
33+
import javax.ejb.Local;
3334

3435
import net.juniper.contrail.api.ApiConnector;
3536
import net.juniper.contrail.api.ApiConnectorFactory;
@@ -99,7 +100,7 @@
99100
import java.io.File;
100101
import java.io.FileInputStream;
101102

102-
@Component
103+
@Local(value = { ContrailManager.class})
103104
public class ContrailManagerImpl extends ManagerBase implements ContrailManager {
104105
@Inject public ConfigurationService _configService;
105106
@Inject ConfigurationServer _configServer;
@@ -135,7 +136,6 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
135136
private ModelController _controller;
136137

137138
ContrailManagerImpl() {
138-
setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT);
139139
_database = new ModelDatabase();
140140
}
141141

@@ -242,24 +242,33 @@ private NetworkOffering EnableNetworkOffering(long id) {
242242
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
243243

244244
File configFile = PropertiesUtil.findConfigFile(configuration);
245-
final Properties configProps = new Properties();
246245
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;
255247
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+
}
258263
}
259264
_api = ApiConnectorFactory.build(hostname, port);
260265
} catch (IOException ex) {
261266
s_logger.warn("Unable to read " + configuration, ex);
262267
throw new ConfigurationException();
268+
} catch (Exception ex) {
269+
s_logger.debug("Exception in configure: " + ex);
270+
ex.printStackTrace();
271+
throw new ConfigurationException();
263272
}
264273

265274
_controller = new ModelController(this, _api, _vmDao, _networksDao, _nicDao, _vlanDao, _ipAddressDao);

‎plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/NetworkPolicyModel.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void build(ModelController controller, List<? extends NetworkACLItem> rul
120120
}
121121

122122
Integer portStart = rule.getSourcePortStart();
123-
Integer portEnd = rule.getSourcePortStart();
123+
Integer portEnd = rule.getSourcePortEnd();
124124
if (portStart == null) {
125125
portStart = 0;
126126
}

0 commit comments

Comments
 (0)