more changes to fix up the merge

This commit is contained in:
Alex Huang 2010-12-29 09:32:42 -08:00
parent 544fa7ff1b
commit 090bc1edb4
6 changed files with 48 additions and 54 deletions

View File

@ -101,7 +101,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
protected long saveStartedEvent(String eventType, String description, Long startEventId){
UserContext ctx = UserContext.current();
Long userId = ctx.getUserId();
Long userId = ctx.getCallerUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId;
if(startEvent == null){
@ -116,7 +116,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId){
UserContext ctx = UserContext.current();
Long userId = ctx.getUserId();
Long userId = ctx.getCallerUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId;
if(startEvent == null){

View File

@ -69,6 +69,7 @@ import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.domain.dao.DomainDao;
import com.cloud.event.EventTypes;
import com.cloud.event.EventUtils;
import com.cloud.event.EventVO;
import com.cloud.event.UsageEventVO;
import com.cloud.event.dao.EventDao;
@ -673,18 +674,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
<<<<<<< HEAD
EventUtils.saveEvent(userId, ip.getAllocatedToAccountId(), EventTypes.EVENT_NET_IP_RELEASE, "released a public ip: " + ipAddress);
=======
final EventVO event = new EventVO();
event.setUserId(userId);
event.setAccountId(ip.getAllocatedToAccountId());
event.setType(EventTypes.EVENT_NET_IP_RELEASE);
event.setParameters("address=" + addr + "\nsourceNat="+ip.isSourceNat());
event.setDescription("released a public ip: " + addr);
_eventDao.persist(event);
>>>>>>> remote access vpn, user ip address changes
EventUtils.saveEvent(userId, ip.getAllocatedToAccountId(), EventTypes.EVENT_NET_IP_RELEASE, "released a public ip: " + addr);
return success;
}
@ -1881,7 +1872,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override
<<<<<<< HEAD
public long getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(long zoneId, TrafficType trafficType, GuestIpType guestType) {
//find system public network offering
Long networkOfferingId = null;
@ -1904,7 +1894,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return networks.get(0).getId();
}
=======
@Override
public PublicIpAddress getPublicIpAddress(Ip ip) {
IPAddressVO addr = _ipAddressDao.findById(ip);
if (addr == null) {
@ -1913,5 +1903,4 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return new PublicIp(addr, _vlanDao.findById(addr.getVlanId()), NetUtils.createSequenceBasedMacAddress(addr.getMacAddress()));
}
>>>>>>> remote access vpn, user ip address changes
}

View File

@ -16,7 +16,6 @@ import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
@ -25,6 +24,7 @@ import com.cloud.offering.ServiceOffering;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
import com.cloud.utils.concurrency.NamedThreadFactory;
@ -152,10 +152,12 @@ public class VMStateListener extends AdapterBase implements StateListener<State,
if (!moveFromReserved) {
/*move resource from used*/
if (usedCpu >= vmCPU)
capacityCpu.setUsedCapacity(usedCpu - vmCPU);
if (usedMem >= vmMem)
capacityMemory.setUsedCapacity(usedMem - vmMem);
if (usedCpu >= vmCPU) {
capacityCpu.setUsedCapacity(usedCpu - vmCPU);
}
if (usedMem >= vmMem) {
capacityMemory.setUsedCapacity(usedMem - vmMem);
}
if (moveToReservered) {
if (reservedCpu + vmCPU <= totalCpu) {
@ -225,9 +227,9 @@ public class VMStateListener extends AdapterBase implements StateListener<State,
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
super.configure(name, params);
_hostCapacityCheckerDelay = Integer.parseInt(_configDao.getValue(Config.HostCapacityCheckerWait.key()));
_hostCapacityCheckerInterval = Integer.parseInt(_configDao.getValue(Config.HostCapacityCheckerInterval.key()));
_vmCapacityReleaseInterval = Integer.parseInt(_configDao.getValue(Config.VmHostCapacityReleaseInterval.key()));
_hostCapacityCheckerDelay = NumbersUtil.parseInt(_configDao.getValue(Config.HostCapacityCheckerWait.key()), 3600);
_hostCapacityCheckerInterval = NumbersUtil.parseInt(_configDao.getValue(Config.HostCapacityCheckerInterval.key()), 3600);
_vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.VmHostCapacityReleaseInterval.key()), 86400);
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HostCapacity-Checker"));
return true;
}

View File

@ -332,10 +332,10 @@ public class IPRangeConfig {
}
while (startIP <= endIP) {
if (!isPublicIPAllocated(NetUtils.long2Ip(startIP), vlanDbId, isAllocatedStmt)) {
if (!isPublicIPAllocated(startIP, vlanDbId, isAllocatedStmt)) {
try {
stmt.clearParameters();
stmt.setString(1, NetUtils.long2Ip(startIP));
stmt.setLong(1, startIP);
stmt.setLong(2, vlanDbId);
stmt.executeUpdate();
} catch (Exception ex) {
@ -386,10 +386,10 @@ public class IPRangeConfig {
return problemIPs;
}
private boolean isPublicIPAllocated(String ip, long vlanDbId, PreparedStatement stmt) {
private boolean isPublicIPAllocated(long ip, long vlanDbId, PreparedStatement stmt) {
try {
stmt.clearParameters();
stmt.setString(1, ip);
stmt.setLong(1, ip);
stmt.setLong(2, vlanDbId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
@ -463,7 +463,7 @@ public class IPRangeConfig {
while (startIP <= endIP) {
try {
stmt = conn.prepareStatement(insertSql);
stmt.setString(1, NetUtils.long2Ip(startIP));
stmt.setLong(1, startIP);
stmt.setLong(2, zoneId);
stmt.setLong(3, vlanDbId);
stmt.setLong(4, zoneId);

View File

@ -116,12 +116,12 @@ ALTER TABLE `cloud`.`service_offering` ADD CONSTRAINT `fk_service_offering__id`
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__domain_router_id` FOREIGN KEY `fk_user_vm__domain_router_id` (`domain_router_id`) REFERENCES `domain_router` (`id`);
ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__domain_router_id`(`domain_router_id`);
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__id` FOREIGN KEY `fk_user_vm__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__external_ip_address` FOREIGN KEY `fk_user_vm__external_ip_address` (`external_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`);
#ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__external_ip_address` FOREIGN KEY `fk_user_vm__external_ip_address` (`external_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`);
ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__external_ip_address`(`external_ip_address`);
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__external_vlan_db_id` FOREIGN KEY `fk_user_vm__external_vlan_db_id` (`external_vlan_db_id`) REFERENCES `vlan` (`id`);
ALTER TABLE `cloud`.`user_vm` ADD INDEX `i_user_vm__external_vlan_db_id`(`external_vlan_db_id`);
ALTER TABLE `cloud`.`domain_router` ADD CONSTRAINT `fk_domain_router__public_ip_address` FOREIGN KEY `fk_domain_router__public_ip_address` (`public_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`);
#ALTER TABLE `cloud`.`domain_router` ADD CONSTRAINT `fk_domain_router__public_ip_address` FOREIGN KEY `fk_domain_router__public_ip_address` (`public_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`);
ALTER TABLE `cloud`.`domain_router` ADD INDEX `i_domain_router__public_ip_address`(`public_ip_address`);
ALTER TABLE `cloud`.`domain_router` ADD CONSTRAINT `fk_domain_router__id` FOREIGN KEY `fk_domain_router__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE;
@ -164,10 +164,10 @@ ALTER TABLE `cloud`.`account_vlan_map` ADD INDEX `i_account_vlan_map__account_id
ALTER TABLE `cloud`.`account_vlan_map` ADD CONSTRAINT `fk_account_vlan_map__vlan_id` FOREIGN KEY `fk_account_vlan_map__vlan_id` (`vlan_db_id`) REFERENCES `vlan` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`account_vlan_map` ADD INDEX `i_account_vlan_map__vlan_id`(`vlan_db_id`);
ALTER TABLE `cloud`.`ip_forwarding` ADD INDEX `i_ip_forwarding__forwarding`(`forwarding`);
ALTER TABLE `cloud`.`ip_forwarding` ADD INDEX `i_ip_forwarding__public_ip_address__public_port`(`public_ip_address`, `public_port`);
ALTER TABLE `cloud`.`ip_forwarding` ADD CONSTRAINT `fk_ip_forwarding__public_ip_address` FOREIGN KEY `fk_ip_forwarding__public_ip_address` (`public_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`ip_forwarding` ADD INDEX `i_ip_forwarding__public_ip_address`(`public_ip_address`);
#ALTER TABLE `cloud`.`ip_forwarding` ADD INDEX `i_ip_forwarding__forwarding`(`forwarding`);
#ALTER TABLE `cloud`.`ip_forwarding` ADD INDEX `i_ip_forwarding__public_ip_address__public_port`(`public_ip_address`, `public_port`);
#ALTER TABLE `cloud`.`ip_forwarding` ADD CONSTRAINT `fk_ip_forwarding__public_ip_address` FOREIGN KEY `fk_ip_forwarding__public_ip_address` (`public_ip_address`) REFERENCES `user_ip_address` (`public_ip_address`) ON DELETE CASCADE;
#ALTER TABLE `cloud`.`ip_forwarding` ADD INDEX `i_ip_forwarding__public_ip_address`(`public_ip_address`);
ALTER TABLE `cloud`.`user_statistics` ADD CONSTRAINT `fk_user_statistics__account_id` FOREIGN KEY `fk_user_statistics__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`user_statistics` ADD INDEX `i_user_statistics__account_id`(`account_id`);
@ -246,4 +246,4 @@ ALTER TABLE `cloud`.`instance_group` ADD CONSTRAINT `fk_instance_group__account_
ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___group_id` FOREIGN KEY `fk_instance_group_vm_map___group_id` (`group_id`) REFERENCES `instance_group` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___instance_id` FOREIGN KEY `fk_instance_group_vm_map___instance_id` (`instance_id`) REFERENCES `user_vm` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`vlan` ADD CONSTRAINT `fk_vlan__network_id` FOREIGN KEY `fk_vlan__network_id` (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE;
#ALTER TABLE `cloud`.`vlan` ADD CONSTRAINT `fk_vlan__network_id` FOREIGN KEY `fk_vlan__network_id` (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE;

View File

@ -478,6 +478,7 @@ CREATE TABLE `cloud`.`firewall_rules` (
`xid` char(40) NOT NULL COMMENT 'external id',
`created` datetime COMMENT 'Date created',
PRIMARY KEY (`id`),
CONSTRAINT `fk_firewall_rules__ip_address` FOREIGN KEY(`ip_address`) REFERENCES `user_ip_address`(`public_ip_address`),
CONSTRAINT `fk_firewall_rules__network_id` FOREIGN KEY(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_firewall_rules__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_firewall_rules__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE
@ -517,19 +518,19 @@ CREATE TABLE `cloud`.`port_forwarding_rules` (
CREATE VIEW `cloud`.`port_forwarding_rules_view` AS SELECT fw.id, INET_NTOA(fw.ip_address) as src_ip_address, INET_NTOA(pf.dest_ip_address), fw.start_port as src_port_start, pf.dest_port_start, fw.end_port as src_end_port, pf.dest_port_end as dest_end_port, fw.state, fw.protocol, fw.purpose, fw.account_id from cloud.firewall_rules as fw inner join cloud.port_forwarding_rules as pf on fw.id=pf.id;
CREATE TABLE `cloud`.`ip_forwarding` (
`id` bigint unsigned NOT NULL auto_increment,
`group_id` bigint unsigned default NULL,
`public_ip_address` varchar(15) NOT NULL,
`public_port` varchar(10) default NULL,
`private_ip_address` varchar(15) NOT NULL,
`private_port` varchar(10) default NULL,
`enabled` tinyint(1) NOT NULL default '1',
`protocol` varchar(16) NOT NULL default 'TCP',
`forwarding` tinyint(1) NOT NULL default '1',
`algorithm` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
#CREATE TABLE `cloud`.`ip_forwarding` (
# `id` bigint unsigned NOT NULL auto_increment,
# `group_id` bigint unsigned default NULL,
# `public_ip_address` varchar(15) NOT NULL,
# `public_port` varchar(10) default NULL,
# `private_ip_address` varchar(15) NOT NULL,
# `private_port` varchar(10) default NULL,
# `enabled` tinyint(1) NOT NULL default '1',
# `protocol` varchar(16) NOT NULL default 'TCP',
# `forwarding` tinyint(1) NOT NULL default '1',
# `algorithm` varchar(255) default NULL,
# PRIMARY KEY (`id`)
#) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`host` (
@ -655,6 +656,8 @@ CREATE TABLE `cloud`.`user_ip_address` (
INDEX `i_user_ip_address__source_nat`(`source_nat`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE VIEW `cloud`.`user_ip_address_view` AS SELECT INET_NTOA(user_ip_address.public_ip_address) as public_ip_address, user_ip_address.data_center_id, user_ip_address.account_id, user_ip_address.domain_id, user_ip_address.source_nat, user_ip_address.allocated, user_ip_address.vlan_db_id, user_ip_address.one_to_one_nat, user_ip_address.state, user_ip_address.mac_address, user_ip_address.network_id as associated_network_id from user_ip_address;
CREATE TABLE `cloud`.`user_statistics` (
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT,
`data_center_id` bigint unsigned NOT NULL,
@ -1054,13 +1057,13 @@ CREATE TABLE `cloud`.`remote_access_vpn` (
`ipsec_psk` varchar(256) NOT NULL,
PRIMARY KEY (`vpn_server_addr`),
CONSTRAINT `fk_remote_access_vpn__account_id` FOREIGN KEY `fk_remote_access_vpn__account_id`(`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_remote_access_vpn__domain_id` FOREIGN KEY `fk_remote_access_vpn__domain_id`(
CONSTRAINT `fk_remote_access_vpn__network_id` FOREIGN KEY `fk_remote_access_vpn__network_id` (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE;
# CONSTRAINT `fk_remote_access_vpn__server_addr` FOREIGN KEY `fk_remote_access_vpn__server_addr` (`vpn_server_addr`) REFERENCES `user_ip_address` (`public_ip_address`) ON DELETE CASCADE,
CONSTRAINT `fk_remote_access_vpn__domain_id` FOREIGN KEY `fk_remote_access_vpn__domain_id`(`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_remote_access_vpn__network_id` FOREIGN KEY `fk_remote_access_vpn__network_id` (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_remote_access_vpn__server_addr` FOREIGN KEY `fk_remote_access_vpn__server_addr` (`vpn_server_addr`) REFERENCES `user_ip_address` (`public_ip_address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`vpn_users` (
`id` bigint unsigned NOT NULL auto_increment,
`id` bigint unsigned NOT NULL UNIQUE auto_increment,
`owner_id` bigint unsigned NOT NULL,
`domain_id` bigint unsigned NOT NULL,
`username` varchar(255) NOT NULL,
@ -1070,7 +1073,7 @@ CREATE TABLE `cloud`.`vpn_users` (
CONSTRAINT `fk_vpn_users__owner_id` FOREIGN KEY (`owner_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_vpn_users__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
INDEX `i_vpn_users_username`(`username`),
UNIQUE `i_vpn_users__account_id__username`(`account_id`, `username`)
UNIQUE `i_vpn_users__account_id__username`(`owner_id`, `username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`storage_pool` (