mirror of https://github.com/apache/cloudstack.git
Contrail plugin fixes - removed wrappers for db updates
Signed-off-by: Sheng Yang <sheng.yang@citrix.com>
This commit is contained in:
parent
dcfc76f92b
commit
45065c712d
|
|
@ -78,6 +78,7 @@ public class ContrailElementImpl extends AdapterBase
|
|||
private static final Map<Service, Map<Capability, String>> _capabilities = InitCapabilities();
|
||||
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject ConfigurationServer _configServer;
|
||||
@Inject NetworkDao _networksDao;
|
||||
@Inject ContrailManager _manager;
|
||||
@Inject NicDao _nicDao;
|
||||
|
|
@ -284,6 +285,32 @@ public class ContrailElementImpl extends AdapterBase
|
|||
|
||||
@Override
|
||||
public boolean isReady(PhysicalNetworkServiceProvider provider) {
|
||||
Map<String, String> serviceMap = ((ConfigurationServerImpl)_configServer).getServicesAndProvidersForNetwork( _manager.getRouterOffering().getId());
|
||||
List<TrafficType> types = new ArrayList<TrafficType>();
|
||||
types.add(TrafficType.Control);
|
||||
types.add(TrafficType.Management);
|
||||
types.add(TrafficType.Storage);
|
||||
List<NetworkVO> systemNets = _manager.findSystemNetworks(types);
|
||||
if (systemNets != null && !systemNets.isEmpty()) {
|
||||
for (NetworkVO net: systemNets) {
|
||||
s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
|
||||
_networksDao.update(net.getId(), net, serviceMap);
|
||||
}
|
||||
} else {
|
||||
s_logger.debug("no system networks created yet");
|
||||
}
|
||||
serviceMap = ((ConfigurationServerImpl)_configServer).getServicesAndProvidersForNetwork( _manager.getPublicRouterOffering().getId());
|
||||
types = new ArrayList<TrafficType>();
|
||||
types.add(TrafficType.Public);
|
||||
systemNets = _manager.findSystemNetworks(types);
|
||||
if (systemNets != null && !systemNets.isEmpty()) {
|
||||
for (NetworkVO net: systemNets) {
|
||||
s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
|
||||
_networksDao.update(net.getId(), net, serviceMap);
|
||||
}
|
||||
} else {
|
||||
s_logger.debug("no system networks created yet");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import java.util.TimerTask;
|
|||
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.ejb.Local;
|
||||
|
||||
import net.juniper.contrail.api.ApiConnector;
|
||||
import net.juniper.contrail.api.ApiConnectorFactory;
|
||||
|
|
@ -99,7 +100,7 @@ import com.cloud.vm.dao.VMInstanceDao;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
@Component
|
||||
@Local(value = { ContrailManager.class})
|
||||
public class ContrailManagerImpl extends ManagerBase implements ContrailManager {
|
||||
@Inject public ConfigurationService _configService;
|
||||
@Inject ConfigurationServer _configServer;
|
||||
|
|
@ -135,7 +136,6 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
private ModelController _controller;
|
||||
|
||||
ContrailManagerImpl() {
|
||||
setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT);
|
||||
_database = new ModelDatabase();
|
||||
}
|
||||
|
||||
|
|
@ -242,24 +242,33 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
|
||||
File configFile = PropertiesUtil.findConfigFile(configuration);
|
||||
final Properties configProps = new Properties();
|
||||
try {
|
||||
configProps.load(new FileInputStream(configFile));
|
||||
String value = configProps.getProperty("management.db_sync_interval");
|
||||
if (value != null) {
|
||||
_dbSyncInterval = Integer.valueOf(value);
|
||||
}
|
||||
|
||||
String hostname = configProps.getProperty("api.hostname");
|
||||
String portStr = configProps.getProperty("api.port");
|
||||
String hostname = null;
|
||||
int port = 0;
|
||||
if (portStr != null && portStr.length() > 0) {
|
||||
port = Integer.parseInt(portStr);
|
||||
if (configFile == null) {
|
||||
hostname = "localhost";
|
||||
port = 8082;
|
||||
} else {
|
||||
final Properties configProps = new Properties();
|
||||
configProps.load(new FileInputStream(configFile));
|
||||
String value = configProps.getProperty("management.db_sync_interval");
|
||||
if (value != null) {
|
||||
_dbSyncInterval = Integer.valueOf(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();
|
||||
}
|
||||
|
||||
_controller = new ModelController(this, _api, _vmDao, _networksDao, _nicDao, _vlanDao, _ipAddressDao);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class NetworkPolicyModel extends ModelObjectBase {
|
|||
}
|
||||
|
||||
Integer portStart = rule.getSourcePortStart();
|
||||
Integer portEnd = rule.getSourcePortStart();
|
||||
Integer portEnd = rule.getSourcePortEnd();
|
||||
if (portStart == null) {
|
||||
portStart = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue