Merge branch '3.0.x' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 3.0.x

This commit is contained in:
Vijayendra Bhamidipati 2012-07-06 15:58:55 -07:00
commit b5cb3ef70e
15 changed files with 182 additions and 116 deletions

View File

@ -28,7 +28,7 @@ import com.cloud.network.Site2SiteVpnConnection;
@Implementation(description="Lists site to site vpn connection gateways", responseObject=Site2SiteVpnConnectionResponse.class)
public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd {
public static final Logger s_logger = Logger.getLogger (ListVpnCustomerGatewaysCmd.class.getName());
public static final Logger s_logger = Logger.getLogger (ListVpnConnectionsCmd.class.getName());
private static final String s_name = "listvpnconnectionsresponse";

View File

@ -57,7 +57,7 @@ public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.ESP_POLICY, type=CommandType.STRING, required=true, description="ESP policy of the customer gateway")
private String espPolicy;
@Parameter(name=ApiConstants.LIFETIME, type=CommandType.STRING, required=false, description="Lifetime of vpn connection to the customer gateway, in seconds")
@Parameter(name=ApiConstants.LIFETIME, type=CommandType.LONG, required=false, description="Lifetime of vpn connection to the customer gateway, in seconds")
private Long lifetime;
/////////////////////////////////////////////////////

View File

@ -42,3 +42,6 @@ create_privatetemplate_from_snapshot.sh=..,0755,/opt/xensource/bin
upgrade_snapshot.sh=..,0755,/opt/xensource/bin
cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin

View File

@ -2085,12 +2085,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
List<Provider> providersToImplement = getNetworkProviders(network.getId());
for (NetworkElement element : _networkElements) {
if (providersToImplement.contains(element.getProvider())) {
if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), "VirtualRouter")) {
if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), element.getProvider().getName())) {
// The physicalNetworkId will not get translated into a uuid by the reponse serializer,
// because the serializer would look up the NetworkVO class's table and retrieve the
// network id instead of the physical network id.
// So just throw this exception as is. We may need to TBD by changing the serializer.
throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + "either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Asking " + element.getName() + " to implemenet " + network);

View File

@ -69,7 +69,7 @@ public class BareMetalElement extends AdapterBase implements NetworkElement {
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest,
ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
Host host = dest.getHost();
if (host.getHypervisorType() != HypervisorType.BareMetal) {
if (host == null || host.getHypervisorType() != HypervisorType.BareMetal) {
return true;
}

View File

@ -85,7 +85,6 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
@Override
protected boolean canHandle(Network network, Service service) {
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(network);
@ -441,21 +440,24 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
Site2SiteVpnGateway vpnGw = _vpnGatewayDao.findById(conn.getVpnGatewayId());
IpAddress ip = _ipAddressDao.findById(vpnGw.getAddrId());
/*
if (!canHandle(network, Service.Vpn)) {
return false;
}
*/
Map<Capability, String> vpnCapabilities = capabilities.get(Service.Vpn);
if (!vpnCapabilities.get(Capability.VpnTypes).contains("s2svpn")) {
s_logger.error("try to start site 2 site vpn on unsupported network element?");
return false;
}
Long vpcId = ip.getVpcId();
Vpc vpc = _vpcMgr.getVpc(vpcId);
if (!_vpcMgr.vpcProviderEnabledInZone(vpc.getZoneId())) {
throw new ResourceUnavailableException("VPC provider is not enabled in zone " + vpc.getZoneId(),
DataCenter.class, vpc.getZoneId());
}
List<DomainRouterVO> routers = _vpcMgr.getVpcRouters(ip.getVpcId());
if (routers == null || routers.size() != 1) {
s_logger.debug("Cannot enable site-to-site VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId());
return true;
throw new ResourceUnavailableException("Cannot enable site-to-site VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(),
DataCenter.class, vpc.getZoneId());
}
return _vpcRouterMgr.startSite2SiteVpn(conn, routers.get(0));
@ -466,21 +468,24 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
Site2SiteVpnGateway vpnGw = _vpnGatewayDao.findById(conn.getVpnGatewayId());
IpAddress ip = _ipAddressDao.findById(vpnGw.getAddrId());
/*
if (!canHandle(network, Service.Vpn)) {
return false;
}
*/
Map<Capability, String> vpnCapabilities = capabilities.get(Service.Vpn);
if (!vpnCapabilities.get(Capability.VpnTypes).contains("s2svpn")) {
s_logger.error("try to stop site 2 site vpn on unsupported network element?");
return false;
}
Long vpcId = ip.getVpcId();
Vpc vpc = _vpcMgr.getVpc(vpcId);
if (!_vpcMgr.vpcProviderEnabledInZone(vpc.getZoneId())) {
throw new ResourceUnavailableException("VPC provider is not enabled in zone " + vpc.getZoneId(),
DataCenter.class, vpc.getZoneId());
}
List<DomainRouterVO> routers = _vpcMgr.getVpcRouters(ip.getVpcId());
if (routers == null || routers.size() != 1) {
s_logger.debug("Cannot disable site-to-site VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId());
return true;
throw new ResourceUnavailableException("Cannot enable site-to-site VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(),
DataCenter.class, vpc.getZoneId());
}
return _vpcRouterMgr.stopSite2SiteVpn(conn, routers.get(0));

View File

@ -420,22 +420,33 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
InsufficientCapacityException {
boolean result = true;
try {
PlugNicCommand plugNicCmd = new PlugNicCommand(vm, nic);
Commands cmds = new Commands(OnError.Stop);
cmds.addCommand("plugnic", plugNicCmd);
_agentMgr.send(dest.getHost().getId(), cmds);
PlugNicAnswer plugNicAnswer = cmds.getAnswer(PlugNicAnswer.class);
if (!(plugNicAnswer != null && plugNicAnswer.getResult())) {
s_logger.warn("Unable to plug nic for vm " + vm.getHostName());
result = false;
}
DomainRouterVO router = _routerDao.findById(vm.getId());
if (router.getState() == State.Running) {
try {
PlugNicCommand plugNicCmd = new PlugNicCommand(vm, nic);
Commands cmds = new Commands(OnError.Stop);
cmds.addCommand("plugnic", plugNicCmd);
_agentMgr.send(dest.getHost().getId(), cmds);
PlugNicAnswer plugNicAnswer = cmds.getAnswer(PlugNicAnswer.class);
if (!(plugNicAnswer != null && plugNicAnswer.getResult())) {
s_logger.warn("Unable to plug nic for vm " + vm.getHostName());
result = false;
}
} catch (OperationTimedoutException e) {
throw new AgentUnavailableException("Unable to plug nic for router " + vm.getHostName() + " in network " + network,
dest.getHost().getId(), e);
} catch (OperationTimedoutException e) {
throw new AgentUnavailableException("Unable to plug nic for router " + vm.getHostName() + " in network " + network,
dest.getHost().getId(), e);
}
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
", so not sending PlugNic command to the backend");
} else {
s_logger.warn("Unable to apply PlugNic, vm " + router + " is not in the right state " + router.getState());
throw new ResourceUnavailableException("Unable to apply PlugNic on the backend," +
" vm " + vm + " is not in the right state", DataCenter.class, router.getDataCenterIdToDeployIn());
}
return result;
@ -447,23 +458,34 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
boolean result = true;
DomainRouterVO router = _routerDao.findById(vm.getId());
try {
UnPlugNicCommand unplugNicCmd = new UnPlugNicCommand(vm, nic);
Commands cmds = new Commands(OnError.Stop);
cmds.addCommand("unplugnic", unplugNicCmd);
_agentMgr.send(dest.getHost().getId(), cmds);
UnPlugNicAnswer unplugNicAnswer = cmds.getAnswer(UnPlugNicAnswer.class);
if (!(unplugNicAnswer != null && unplugNicAnswer.getResult())) {
s_logger.warn("Unable to unplug nic from router " + router);
result = false;
}
} catch (OperationTimedoutException e) {
throw new AgentUnavailableException("Unable to unplug nic from rotuer " + router + " from network " + network,
dest.getHost().getId(), e);
}
if (router.getState() == State.Running) {
try {
UnPlugNicCommand unplugNicCmd = new UnPlugNicCommand(vm, nic);
Commands cmds = new Commands(OnError.Stop);
cmds.addCommand("unplugnic", unplugNicCmd);
_agentMgr.send(dest.getHost().getId(), cmds);
UnPlugNicAnswer unplugNicAnswer = cmds.getAnswer(UnPlugNicAnswer.class);
if (!(unplugNicAnswer != null && unplugNicAnswer.getResult())) {
s_logger.warn("Unable to unplug nic from router " + router);
result = false;
}
} catch (OperationTimedoutException e) {
throw new AgentUnavailableException("Unable to unplug nic from rotuer " + router + " from network " + network,
dest.getHost().getId(), e);
}
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
s_logger.debug("Vm " + router.getInstanceName() + " is in " + router.getState() +
", so not sending unplug nic command to the backend");
} else {
s_logger.warn("Unable to apply unplug nic, Vm " + router + " is not in the right state " + router.getState());
throw new ResourceUnavailableException("Unable to apply unplug nic on the backend," +
" vm " + router +" is not in the right state", DataCenter.class, router.getDataCenterIdToDeployIn());
}
return result;
}
@ -956,29 +978,43 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
* @param add
* @param privateNic
* @return
* @throws AgentUnavailableException
* @throws ResourceUnavailableException TODO
*/
protected boolean setupVpcPrivateNetwork(VirtualRouter router, boolean add, NicProfile privateNic)
throws AgentUnavailableException {
throws ResourceUnavailableException {
PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(), privateNic.getIp4Address());
Network network = _networkDao.findById(privateNic.getNetworkId());
String vlanTag = network.getBroadcastUri().getHost();
String netmask = NetUtils.getCidrNetmask(network.getCidr());
PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask, ipVO.getMacAddress());
List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
privateIps.add(ip);
Commands cmds = new Commands(OnError.Stop);
createVpcAssociatePrivateIPCommands(router, privateIps, cmds, add);
if (sendCommandsToRouter(router, cmds)) {
s_logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network);
return true;
if (router.getState() == State.Running) {
PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(), privateNic.getIp4Address());
Network network = _networkDao.findById(privateNic.getNetworkId());
String vlanTag = network.getBroadcastUri().getHost();
String netmask = NetUtils.getCidrNetmask(network.getCidr());
PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask, ipVO.getMacAddress());
List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
privateIps.add(ip);
Commands cmds = new Commands(OnError.Stop);
createVpcAssociatePrivateIPCommands(router, privateIps, cmds, add);
if (sendCommandsToRouter(router, cmds)) {
s_logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network);
return true;
} else {
s_logger.warn("Failed to associate ip address " + ip + " in vpc network " + network);
return false;
}
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
", so not sending setup private network command to the backend");
} else {
s_logger.warn("Failed to associate ip address " + ip + " in vpc network " + network);
return false;
s_logger.warn("Unable to setup private gateway, virtual router " + router + " is not in the right state " + router.getState());
throw new ResourceUnavailableException("Unable to setup Private gateway on the backend," +
" virtual router " + router + " is not in the right state", DataCenter.class, router.getDataCenterIdToDeployIn());
}
return true;
}
@Override
@ -1031,7 +1067,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
for (VirtualRouter router : routers) {
if (router.getState() == State.Running) {
result = result && sendStaticRoutes(staticRoutes, routers.get(0));
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
", so not sending StaticRoute command to the backend");

View File

@ -96,4 +96,10 @@ public interface VpcManager extends VpcService{
* @return
*/
List<DomainRouterVO> getVpcRouters(long vpcId);
/**
* @param zoneId
* @return
*/
boolean vpcProviderEnabledInZone(long zoneId);
}

View File

@ -516,19 +516,23 @@ public class VpcManagerImpl implements VpcManager, Manager{
}
@Override
public Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr,
String networkDomain) {
public boolean vpcProviderEnabledInZone(long zoneId)
{
//the provider has to be enabled at least in one network in the zone
boolean providerEnabled = false;
for (PhysicalNetwork pNtwk : _pNtwkDao.listByZone(zoneId)) {
if (_ntwkMgr.isProviderEnabledInPhysicalNetwork(pNtwk.getId(), Provider.VPCVirtualRouter.getName())) {
providerEnabled = true;
break;
return true;
}
}
if (!providerEnabled) {
return false;
}
@Override
public Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr,
String networkDomain) {
if (!vpcProviderEnabledInZone(zoneId)) {
throw new InvalidParameterValueException("Provider " + Provider.VPCVirtualRouter.getName() +
" should be enabled in at least one physical network of the zone specified");
}

View File

@ -19,9 +19,11 @@ import javax.ejb.Local;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDaoImpl;
import com.cloud.network.Network;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.RouterNetworkDaoImpl;
import com.cloud.network.RouterNetworkVO;
import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.UserStatisticsVO;
import com.cloud.user.dao.UserStatisticsDaoImpl;
import com.cloud.utils.component.ComponentLocator;
@ -265,7 +267,10 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
// 2) add router to the network
for (Network guestNetwork : guestNetworks) {
if (!isRouterPartOfGuestNetwork(router.getId(), guestNetwork.getId())) {
addRouterToGuestNetwork(router, guestNetwork);
//add only when network is not private network
if (!(guestNetwork.getName() != NetworkOffering.SystemPrivateGatewayNetworkOffering)) {
addRouterToGuestNetwork(router, guestNetwork);
}
}
}
}

View File

@ -2137,7 +2137,7 @@ CREATE TABLE `cloud`.`port_profile` (
CREATE TABLE `cloud`.`s2s_vpn_gateway` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`uuid` varchar(40),
`addr_id` bigint unsigned UNIQUE NOT NULL,
`addr_id` bigint unsigned NOT NULL,
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
CONSTRAINT `fk_s2s_vpn_gateway__addr_id` FOREIGN KEY (`addr_id`) REFERENCES `user_ip_address` (`id`) ON DELETE CASCADE,
@ -2147,7 +2147,7 @@ CREATE TABLE `cloud`.`s2s_vpn_gateway` (
CREATE TABLE `cloud`.`s2s_customer_gateway` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`uuid` varchar(40),
`gateway_ip` char(40) UNIQUE NOT NULL,
`gateway_ip` char(40) NOT NULL,
`guest_cidr_list` varchar(200) NOT NULL,
`ipsec_psk` varchar(256),
`ike_policy` varchar(30) NOT NULL,

View File

@ -7484,7 +7484,7 @@ div.panel.ui-dialog div.list-view div.fixed-header {
color: #FFFFFF;
background: url(../images/buttons.png) no-repeat -457px -503px;
font-size: 11px;
padding: 6px 24px 6px 9px;
padding: 6px 17px 6px 9px;
/*+text-shadow:0px 1px 1px #395065;*/
-moz-text-shadow: 0px 1px 1px #395065;
-webkit-text-shadow: 0px 1px 1px #395065;

View File

@ -161,7 +161,7 @@
$title.html(name);
$cidr.html(cidr);
$vmCount.append(
$('<span>').addClass('total').html(virtualMachines.length),
$('<span>').addClass('total').html(virtualMachines != null? virtualMachines.length: 0),
' VMs'
);
$tier.append($actions);
@ -221,7 +221,7 @@
return $tier;
},
chart: function(args) {
chart: function(args) {
var $browser = args.$browser;
var siteToSiteVPN = args.siteToSiteVPN;
var tiers = args.tiers;
@ -260,7 +260,7 @@
return true;
};
if (tiers.length) {
if (tiers != null && tiers.length > 0) {
$(tiers).map(function(index, tier) {
var $tier = elems.tier({
name: tier.name,
@ -538,7 +538,7 @@
context: context,
response: {
success: function(args) {
var tiers = args.data.tiers;
var tiers = args.tiers;
var $chart = elems.chart({
$browser: $browser,
siteToSiteVPN: siteToSiteVPN,

View File

@ -254,6 +254,12 @@
$elem.appendTo($container);
});
var checkTitle = function(str) {
if ($('#header.nologo').size() == 0) {
return str.replace(/CloudStack/ig,'CloudPlatform');
} else { return str; }
};
// User options
var $options = $('<div>').attr({ id: 'user-options' })
.appendTo($('#header'));
@ -274,13 +280,13 @@
}
if (this == 'About') {
$link.click(function() {
var $logo = $('<div>').addClass('logo').html('CloudStack'),
var $logo = $('<div>').addClass('logo').html(checkTitle('CloudStack')),
$version = $('<div>').addClass('version').html(g_cloudstackversion),
$about = $('<div>').addClass('about').append($logo).append($version);
$about.dialog({
modal: true,
width: 300,
title: 'About CloudStack',
title: checkTitle('About CloudStack'),
closeOnEscape: false,
dialogClass: 'dialog-about',
buttons: {

View File

@ -509,34 +509,36 @@
},
// Get tiers
dataProvider: function(args) {
var tiers = [ // Dummy content
{
id: 1,
name: 'web',
cidr: '192.168.0.0/24',
state: 'Running',
virtualMachines: [
{ name: 'i-2-VM' },
{ name: 'i-3-VM' }
]
},
{
id: 2,
name: 'app',
state: 'Stopped',
cidr: '10.0.0.0/24',
virtualMachines: []
}
];
setTimeout(function() {
args.response.success({
data: {
tiers: tiers
}
});
}, 1000);
dataProvider: function(args) {
$.ajax({
url: createURL("listNetworks"),
dataType: "json",
data: {
vpcid: args.context.vpc[0].id,
listAll: true
},
async: true,
success: function(json) {
var networks = json.listnetworksresponse.network;
if(networks != null && networks.length > 0) {
for(var i = 0; i < networks.length; i++) {
$.ajax({
url: createURL("listVirtualMachines"),
dataType: "json",
data: {
networkid: networks[i].id,
listAll: true
},
async: false,
success: function(json) {
networks[i].virtualMachines = json.listvirtualmachinesresponse.virtualmachine;
}
});
}
}
args.response.success({ tiers: networks });
}
});
}
}
};