diff --git a/api/src/com/cloud/agent/api/to/FirewallRuleTO.java b/api/src/com/cloud/agent/api/to/FirewallRuleTO.java index d66c91c803f..ae6bfb5c538 100644 --- a/api/src/com/cloud/agent/api/to/FirewallRuleTO.java +++ b/api/src/com/cloud/agent/api/to/FirewallRuleTO.java @@ -17,7 +17,6 @@ */ package com.cloud.agent.api.to; -import com.cloud.network.IpAddress; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.FirewallRule.State; import com.cloud.utils.net.NetUtils; diff --git a/api/src/com/cloud/api/commands/DisableStaticNat.java b/api/src/com/cloud/api/commands/DisableStaticNatCmd.java similarity index 98% rename from api/src/com/cloud/api/commands/DisableStaticNat.java rename to api/src/com/cloud/api/commands/DisableStaticNatCmd.java index 5e8cb9707ee..afdcce1d8bc 100644 --- a/api/src/com/cloud/api/commands/DisableStaticNat.java +++ b/api/src/com/cloud/api/commands/DisableStaticNatCmd.java @@ -31,7 +31,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; @Implementation(description="Disables static rule for given ip address", responseObject=SuccessResponse.class) -public class DisableStaticNat extends BaseAsyncCmd { +public class DisableStaticNatCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeletePortForwardingRuleCmd.class.getName()); private static final String s_name = "disablestaticnatresponse"; diff --git a/api/src/com/cloud/api/commands/EnableStaticNat.java b/api/src/com/cloud/api/commands/EnableStaticNatCmd.java similarity index 98% rename from api/src/com/cloud/api/commands/EnableStaticNat.java rename to api/src/com/cloud/api/commands/EnableStaticNatCmd.java index 5c18e4d3ba4..81dbc4a251f 100644 --- a/api/src/com/cloud/api/commands/EnableStaticNat.java +++ b/api/src/com/cloud/api/commands/EnableStaticNatCmd.java @@ -29,7 +29,7 @@ import com.cloud.api.response.SuccessResponse; import com.cloud.exception.NetworkRuleConflictException; @Implementation(description="Enables static nat for given ip address", responseObject=SuccessResponse.class) -public class EnableStaticNat extends BaseCmd{ +public class EnableStaticNatCmd extends BaseCmd{ public static final Logger s_logger = Logger.getLogger(CreateIpForwardingRuleCmd.class.getName()); private static final String s_name = "enablestaticnatresponse"; diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index c90283f42c5..9b12f467c82 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -111,11 +111,11 @@ deletePortForwardingRule=com.cloud.api.commands.DeletePortForwardingRuleCmd;15 #### updatePortForwardingRule=com.cloud.api.commands.UpdatePortForwardingRuleCmd;15 #### NAT commands -enableStaticNat=com.cloud.api.commands.EnableStaticNat;15 +enableStaticNat=com.cloud.api.commands.EnableStaticNatCmd;15 createIpForwardingRule=com.cloud.api.commands.CreateIpForwardingRuleCmd;15 deleteIpForwardingRule=com.cloud.api.commands.DeleteIpForwardingRuleCmd;15 listIpForwardingRules=com.cloud.api.commands.ListIpForwardingRulesCmd;15 -disableStaticNat=com.cloud.api.commands.DisableStaticNat;15 +disableStaticNat=com.cloud.api.commands.DisableStaticNatCmd;15 #### load balancer commands createLoadBalancerRule=com.cloud.api.commands.CreateLoadBalancerRuleCmd;15 diff --git a/server/src/com/cloud/network/IPAddressVO.java b/server/src/com/cloud/network/IPAddressVO.java index ee69371e6d5..aa50c1dd938 100644 --- a/server/src/com/cloud/network/IPAddressVO.java +++ b/server/src/com/cloud/network/IPAddressVO.java @@ -53,7 +53,7 @@ public class IPAddressVO implements IpAddress { @Id @Column(name="public_ip_address") - @Enumerated(value=EnumType.ORDINAL) + @Enumerated(value=EnumType.STRING) private Ip address = null; @Column(name="data_center_id", updatable=false) diff --git a/server/src/com/cloud/network/rules/PortForwardingRuleVO.java b/server/src/com/cloud/network/rules/PortForwardingRuleVO.java index 305c8d95938..04db1def417 100644 --- a/server/src/com/cloud/network/rules/PortForwardingRuleVO.java +++ b/server/src/com/cloud/network/rules/PortForwardingRuleVO.java @@ -34,7 +34,7 @@ import com.cloud.utils.net.Ip; @PrimaryKeyJoinColumn(name="id") public class PortForwardingRuleVO extends FirewallRuleVO implements PortForwardingRule { - @Enumerated(value=EnumType.ORDINAL) + @Enumerated(value=EnumType.STRING) @Column(name="dest_ip_address") private Ip destinationIpAddress = null; diff --git a/server/src/com/cloud/test/IPRangeConfig.java b/server/src/com/cloud/test/IPRangeConfig.java index 52aec125ca5..dd10d9ac525 100644 --- a/server/src/com/cloud/test/IPRangeConfig.java +++ b/server/src/com/cloud/test/IPRangeConfig.java @@ -465,7 +465,7 @@ public class IPRangeConfig { while (startIP <= endIP) { try { stmt = conn.prepareStatement(insertSql); - stmt.setLong(1, startIP); + stmt.setString(1, NetUtils.long2Ip(startIP)); stmt.setLong(2, zoneId); stmt.setLong(3, vlanDbId); stmt.setLong(4, zoneId); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 8eac6733044..7f4752c94d6 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -103,7 +103,10 @@ CREATE TABLE `cloud`.`op_it_work` ( `instance_id` bigint unsigned NOT NULL COMMENT 'vm instance', `resource_type` char(32) COMMENT 'type of resource being worked on', `resource_id` bigint unsigned COMMENT 'resource id being worked on', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + CONSTRAINT `fk_op_it_work__mgmt_server_id` FOREIGN KEY (`mgmt_server_id`) REFERENCES `mshost`(`msid`), + CONSTRAINT `fk_op_it_work__instance_id` FOREIGN KEY (`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE, + INDEX `i_op_it_work__step`(`step`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`hypervsior_properties` ( @@ -519,29 +522,13 @@ CREATE TABLE `cloud`.`load_balancer_vm_map` ( CREATE TABLE `cloud`.`port_forwarding_rules` ( `id` bigint unsigned NOT NULL COMMENT 'id', `instance_id` bigint unsigned NOT NULL COMMENT 'vm instance id', - `dest_ip_address` bigint unsigned NOT NULL COMMENT 'id_address', + `dest_ip_address` char(40) NOT NULL COMMENT 'id_address', `dest_port_start` int(10) NOT NULL COMMENT 'starting port of the port range to map to', `dest_port_end` int(10) NOT NULL COMMENT 'end port of the the port range to map to', PRIMARY KEY (`id`), CONSTRAINT `fk_port_forwarding_rules__id` FOREIGN KEY(`id`) REFERENCES `firewall_rules`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE VIEW `cloud`.`port_forwarding_rules_view` AS SELECT fw.id, INET_NTOA(fw.ip_address_id) as src_ip_address_id, 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`.`host` ( `id` bigint unsigned NOT NULL auto_increment, @@ -656,7 +643,7 @@ CREATE TABLE `cloud`.`user_ip_address` ( `id` bigint unsigned NOT NULL UNIQUE auto_increment, `account_id` bigint unsigned NULL, `domain_id` bigint unsigned NULL, - `public_ip_address` bigint unsigned NOT NULL, + `public_ip_address` char(40) NOT NULL, `data_center_id` bigint unsigned NOT NULL COMMENT 'zone that it belongs to', `source_nat` int(1) unsigned NOT NULL default '0', `allocated` datetime NULL COMMENT 'Date this ip was allocated to someone', @@ -678,7 +665,6 @@ 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 user_ip_address.id, INET_NTOA(user_ip_address.public_ip_address) as 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.vm_id, user_ip_address.state, user_ip_address.mac_address, user_ip_address.source_network_id as network_id, 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, diff --git a/utils/src/com/cloud/utils/db/GenericDaoBase.java b/utils/src/com/cloud/utils/db/GenericDaoBase.java index a673ccaf555..79a8e0979da 100755 --- a/utils/src/com/cloud/utils/db/GenericDaoBase.java +++ b/utils/src/com/cloud/utils/db/GenericDaoBase.java @@ -1293,7 +1293,7 @@ public abstract class GenericDaoBase implements Gene pstmt.setString(j, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cal.getTime())); } } else if (attr.field.getType().isEnum()) { - final Enumerated enumerated = attr.field.getType().getAnnotation(Enumerated.class); + final Enumerated enumerated = attr.field.getAnnotation(Enumerated.class); final EnumType type = (enumerated == null) ? EnumType.STRING : enumerated.value(); if (type == EnumType.STRING) { pstmt.setString(j, value == null ? null : value.toString()); @@ -1307,7 +1307,7 @@ public abstract class GenericDaoBase implements Gene } else if (attr.field.getType() == byte[].class) { pstmt.setBytes(j, (byte[])value); } else if (attr.field.getType() == Ip.class) { - final Enumerated enumerated = attr.field.getType().getAnnotation(Enumerated.class); + final Enumerated enumerated = attr.field.getAnnotation(Enumerated.class); final EnumType type = (enumerated == null) ? EnumType.ORDINAL : enumerated.value(); if (type == EnumType.STRING) { pstmt.setString(j, value == null ? null : value.toString());