diff --git a/api/src/com/cloud/api/commands/CreateNetworkCmd.java b/api/src/com/cloud/api/commands/CreateNetworkCmd.java index e83bc31878b..cb957694d76 100644 --- a/api/src/com/cloud/api/commands/CreateNetworkCmd.java +++ b/api/src/com/cloud/api/commands/CreateNetworkCmd.java @@ -135,8 +135,8 @@ public class CreateNetworkCmd extends BaseCmd { return displayText; } - public Boolean getIsShared() { - return false; + public boolean getIsShared() { + return isShared == null ? false : isShared; } ///////////////////////////////////////////////////// diff --git a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java index 6de4878c7f4..2560eb36d99 100644 --- a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java +++ b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java @@ -36,6 +36,7 @@ import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.GenericSearchBuilder; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.SearchCriteria.Func; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; @@ -63,16 +64,16 @@ public class IPAddressDaoImpl extends GenericDaoBase implem VlanDbIdSearchUnallocated = createSearchBuilder(); VlanDbIdSearchUnallocated.and("allocated", VlanDbIdSearchUnallocated.entity().getAllocatedTime(), SearchCriteria.Op.NULL); VlanDbIdSearchUnallocated.and("vlanDbId", VlanDbIdSearchUnallocated.entity().getVlanId(), SearchCriteria.Op.EQ); - // VlanDbIdSearchUnallocated.addRetrieve("ipAddress", - // VlanDbIdSearchUnallocated.entity().getAddress()); VlanDbIdSearchUnallocated.done(); AllIpCount = createSearchBuilder(Integer.class); + AllIpCount.select(null, Func.COUNT, AllIpCount.entity().getAddress()); AllIpCount.and("dc", AllIpCount.entity().getDataCenterId(), Op.EQ); AllIpCount.and("vlan", AllIpCount.entity().getVlanId(), Op.EQ); AllIpCount.done(); AllocatedIpCount = createSearchBuilder(Integer.class); + AllocatedIpCount.select(null, Func.COUNT, AllocatedIpCount.entity().getAddress()); AllocatedIpCount.and("dc", AllocatedIpCount.entity().getDataCenterId(), Op.EQ); AllocatedIpCount.and("vlan", AllocatedIpCount.entity().getVlanId(), Op.EQ); AllocatedIpCount.and("allocated", AllocatedIpCount.entity().getAllocatedTime(), Op.NNULL); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 7ed490daaac..5e6cb7b0c3f 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1,4 +1,6 @@ SET foreign_key_checks = 0; +use cloud; + DROP VIEW IF EXISTS `cloud`.`port_forwarding_rules_view`; DROP TABLE IF EXISTS `cloud`.`configuration`; DROP TABLE IF EXISTS `cloud`.`ip_forwarding`; @@ -610,6 +612,7 @@ CREATE TABLE `cloud`.`user_ip_address` ( `allocated` datetime NULL COMMENT 'Date this ip was allocated to someone', `vlan_db_id` bigint unsigned NOT NULL, `one_to_one_nat` int(1) unsigned NOT NULL default '0', + `state` char(32) NOT NULL default 'Free' COMMENT 'state of the ip address', PRIMARY KEY (`public_ip_address`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;