bug 8533: all IP Address fields in DB have char(40) type

status 8533: resolved fixed
This commit is contained in:
alena 2011-03-22 13:36:11 -07:00
parent 89fbaada2a
commit f84c81a47d
3 changed files with 144 additions and 20 deletions

View File

@ -0,0 +1,102 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.NetworkResponse;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network;
import com.cloud.user.UserContext;
@Implementation(description="Updates a network", responseObject=NetworkResponse.class)
public class UpdateNetworkCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(UpdateNetworkCmd.class.getName());
private static final String s_name = "updatenetworkresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network")
private Long id;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the new name for the network")
private String name;
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the new display text for the network")
private String displayText;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public String getNetworkName() {
return name;
}
public String getDisplayText() {
return displayText;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
Network network = _networkService.getNetwork(id);
if (network == null) {
throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist");
} else {
return _networkService.getNetwork(id).getAccountId();
}
}
@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException{
Network result = _networkService.updateNetwork(getId(), getNetworkName(), getDisplayText(), UserContext.current().getCaller());
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update network");
}
}
}

View File

@ -216,7 +216,7 @@ CREATE TABLE `cloud`.`nics` (
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
`instance_id` bigint unsigned COMMENT 'vm instance id',
`mac_address` varchar(17) COMMENT 'mac address',
`ip4_address` varchar(15) COMMENT 'ip4 address',
`ip4_address` char(40) COMMENT 'ip4 address',
`netmask` varchar(15) COMMENT 'netmask for ip4 address',
`gateway` varchar(15) COMMENT 'gateway',
`ip_type` varchar(32) COMMENT 'type of ip',
@ -300,7 +300,7 @@ CREATE TABLE `cloud`.`op_host_upgrade` (
CREATE TABLE `cloud`.`op_lock` (
`key` varchar(128) NOT NULL UNIQUE COMMENT 'primary key of the table',
`mac` varchar(17) NOT NULL COMMENT 'mac address of who acquired this lock',
`ip` varchar(15) NOT NULL COMMENT 'ip address of who acquired this lock',
`ip` char(40) NOT NULL COMMENT 'ip address of who acquired this lock',
`thread` varchar(255) NOT NULL COMMENT 'Thread that acquired this lock',
`acquired_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Time acquired',
`waiters` int NOT NULL DEFAULT 0 COMMENT 'How many have waited for this',
@ -371,7 +371,7 @@ CREATE TABLE `cloud`.`volumes` (
`pod_id` bigint unsigned COMMENT 'pod this volume belongs to',
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center this volume belongs to',
`iscsi_name` varchar(255) COMMENT 'iscsi target name',
`host_ip` varchar(15) COMMENT 'host ip address for convenience',
`host_ip` char(40) COMMENT 'host ip address for convenience',
`volume_type` varchar(64) NOT NULL COMMENT 'root, swap or data',
`resource_type` varchar(64) COMMENT 'pool-based or host-based',
`pool_type` varchar(64) COMMENT 'type of the pool',
@ -490,7 +490,7 @@ CREATE TABLE `cloud`.`data_center` (
CREATE TABLE `cloud`.`op_dc_ip_address_alloc` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`ip_address` varchar(15) NOT NULL COMMENT 'ip address',
`ip_address` char(40) NOT NULL COMMENT 'ip address',
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center it belongs to',
`pod_id` bigint unsigned NOT NULL COMMENT 'pod it belongs to',
`instance_id` bigint unsigned NULL COMMENT 'instance id',
@ -507,7 +507,7 @@ CREATE TABLE `cloud`.`op_dc_ip_address_alloc` (
CREATE TABLE `cloud`.`op_dc_link_local_ip_address_alloc` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`ip_address` varchar(15) NOT NULL COMMENT 'ip address',
`ip_address` char(40) NOT NULL COMMENT 'ip address',
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center it belongs to',
`pod_id` bigint unsigned NOT NULL COMMENT 'pod it belongs to',
`instance_id` bigint unsigned NULL COMMENT 'instance id',
@ -600,17 +600,17 @@ CREATE TABLE `cloud`.`host` (
`name` varchar(255) NOT NULL,
`status` varchar(32) NOT NULL,
`type` varchar(32) NOT NULL,
`private_ip_address` varchar(15) NOT NULL,
`private_ip_address` char(40) NOT NULL,
`private_netmask` varchar(15),
`private_mac_address` varchar(17),
`storage_ip_address` varchar(15) NOT NULL,
`storage_ip_address` char(40) NOT NULL,
`storage_netmask` varchar(15),
`storage_mac_address` varchar(17),
`storage_ip_address_2` varchar(15),
`storage_ip_address_2` char(40),
`storage_mac_address_2` varchar(17),
`storage_netmask_2` varchar(15),
`cluster_id` bigint unsigned COMMENT 'foreign key to cluster',
`public_ip_address` varchar(15),
`public_ip_address` char(40),
`public_netmask` varchar(15),
`public_mac_address` varchar(17),
`proxy_port` int(10) unsigned,
@ -667,7 +667,7 @@ CREATE TABLE `cloud`.`mshost` (
`msid` bigint unsigned NOT NULL UNIQUE COMMENT 'management server id derived from MAC address',
`name` varchar(255),
`version` varchar(255),
`service_ip` varchar(15) NOT NULL,
`service_ip` char(40) NOT NULL,
`service_port` integer NOT NULL,
`last_update` DATETIME NULL COMMENT 'Last record update time',
`removed` datetime COMMENT 'date removed if not null',
@ -746,7 +746,7 @@ CREATE TABLE `cloud`.`user_statistics` (
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT,
`data_center_id` bigint unsigned NOT NULL,
`account_id` bigint unsigned NOT NULL,
`public_ip_address` varchar(15),
`public_ip_address` char(40),
`device_id` bigint unsigned NOT NULL,
`device_type` varchar(32) NOT NULL,
`network_id` bigint unsigned,
@ -792,7 +792,7 @@ CREATE TABLE `cloud`.`vm_instance` (
`vm_template_id` bigint unsigned,
`guest_os_id` bigint unsigned NOT NULL,
`private_mac_address` varchar(17),
`private_ip_address` varchar(15),
`private_ip_address` char(40),
`private_netmask` varchar(15),
`pod_id` bigint unsigned,
`data_center_id` bigint unsigned NOT NULL COMMENT 'Data Center the instance belongs to',
@ -834,7 +834,7 @@ CREATE TABLE `cloud`.`user_vm` (
`id` bigint unsigned UNIQUE NOT NULL,
`iso_id` bigint unsigned,
`display_name` varchar(255),
`guest_ip_address` varchar(15) COMMENT 'ip address within the guest network',
`guest_ip_address` char(40) COMMENT 'ip address within the guest network',
`guest_mac_address` varchar(17) COMMENT 'mac address within the guest network',
`guest_netmask` varchar(15) COMMENT 'netmask within the guest network',
`user_data` varchar(2048),
@ -855,10 +855,10 @@ CREATE TABLE `cloud`.`user_vm_details` (
CREATE TABLE `cloud`.`domain_router` (
`id` bigint unsigned UNIQUE NOT NULL COMMENT 'Primary Key',
`public_mac_address` varchar(17) COMMENT 'mac address of the public facing network card',
`public_ip_address` varchar(15) COMMENT 'public ip address used for source net',
`public_ip_address` char(40) COMMENT 'public ip address used for source net',
`public_netmask` varchar(15) COMMENT 'netmask used for the domR',
`guest_netmask` varchar(15) COMMENT 'netmask used for the guest network',
`guest_ip_address` varchar(15) COMMENT ' ip address in the guest network',
`guest_ip_address` char(40) COMMENT ' ip address in the guest network',
`network_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'network configuration that this domain router belongs to',
`role` varchar(64) NOT NULL COMMENT 'type of role played by this router',
PRIMARY KEY (`id`),
@ -924,7 +924,7 @@ CREATE TABLE `cloud`.`template_zone_ref` (
CREATE TABLE `cloud`.`console_proxy` (
`id` bigint unsigned NOT NULL auto_increment,
`public_mac_address` varchar(17) unique COMMENT 'mac address of the public facing network card',
`public_ip_address` varchar(15) UNIQUE COMMENT 'public ip address for the console proxy',
`public_ip_address` char(40) UNIQUE COMMENT 'public ip address for the console proxy',
`public_netmask` varchar(15) COMMENT 'public netmask used for the console proxy',
`active_session` int(10) NOT NULL DEFAULT 0 COMMENT 'active session number',
`last_update` DATETIME NULL COMMENT 'Last session update time',
@ -936,7 +936,7 @@ CREATE TABLE `cloud`.`console_proxy` (
CREATE TABLE `cloud`.`secondary_storage_vm` (
`id` bigint unsigned NOT NULL auto_increment,
`public_mac_address` varchar(17) unique COMMENT 'mac address of the public facing network card',
`public_ip_address` varchar(15) UNIQUE COMMENT 'public ip address for the sec storage vm',
`public_ip_address` char(40) UNIQUE COMMENT 'public ip address for the sec storage vm',
`public_netmask` varchar(15) COMMENT 'public netmask used for the sec storage vm',
`guid` varchar(255) COMMENT 'copied from guid of secondary storage host',
`nfs_share` varchar(255) COMMENT 'server and path exported by the nfs server ',
@ -1128,7 +1128,7 @@ CREATE TABLE `cloud`.`load_balancer` (
`name` varchar(255) NOT NULL,
`description` varchar(4096) NULL,
`account_id` bigint unsigned NOT NULL,
`ip_address` varchar(15) NOT NULL,
`ip_address` char(40) NOT NULL,
`public_port` varchar(10) NOT NULL,
`private_port` varchar(10) NOT NULL,
`algorithm` varchar(255) NOT NULL,
@ -1140,7 +1140,7 @@ CREATE TABLE `cloud`.`remote_access_vpn` (
`account_id` bigint unsigned NOT NULL,
`network_id` bigint unsigned NOT NULL,
`domain_id` bigint unsigned NOT NULL,
`local_ip` varchar(15) NOT NULL,
`local_ip` char(40) NOT NULL,
`ip_range` varchar(32) NOT NULL,
`ipsec_psk` varchar(256) NOT NULL,
`state` char(32) NOT NULL,
@ -1176,7 +1176,7 @@ CREATE TABLE `cloud`.`storage_pool` (
`cluster_id` bigint unsigned COMMENT 'foreign key to cluster',
`available_bytes` bigint unsigned,
`capacity_bytes` bigint unsigned,
`host_address` varchar(255) NOT NULL COMMENT 'FQDN or IP of storage server',
`host_address` char(40) NOT NULL COMMENT 'FQDN or IP of storage server',
`path` varchar(255) NOT NULL COMMENT 'Filesystem path that is shared',
`created` datetime COMMENT 'date the pool created',
`removed` datetime COMMENT 'date removed if not null',

View File

@ -14,3 +14,25 @@ CREATE TABLE `cloud`.`domain_network_ref` (
CONSTRAINT `fk_domain_network_ref__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_domain_network_ref__networks_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`nics` MODIFY `ip4_address` char(40);
ALTER TABLE `cloud`.`op_lock` MODIFY `ip` char(40) NOT NULL;
ALTER TABLE `cloud`.`volumes` MODIFY `host_ip` char(40);
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` MODIFY `ip_address` char(40) NOT NULL;
ALTER TABLE `cloud`.`op_dc_link_local_ip_address_alloc` MODIFY `ip_address` char(40) NOT NULL;
ALTER TABLE `cloud`.`host` MODIFY `private_ip_address` char(40) NOT NULL;
ALTER TABLE `cloud`.`host` MODIFY `storage_ip_address` char(40) NOT NULL;
ALTER TABLE `cloud`.`host` MODIFY `storage_ip_address_2` char(40);
ALTER TABLE `cloud`.`host` MODIFY `public_ip_address` char(40);
ALTER TABLE `cloud`.`mshost` MODIFY `service_ip` char(40) NOT NULL;
ALTER TABLE `cloud`.`user_statistics` MODIFY `public_ip_address` char(40);
ALTER TABLE `cloud`.`vm_instance` MODIFY `private_ip_address` char(40);
ALTER TABLE `cloud`.`user_vm` MODIFY `guest_ip_address` char(40);
ALTER TABLE `cloud`.`domain_router` MODIFY `public_ip_address` char(40);
ALTER TABLE `cloud`.`domain_router` MODIFY `guest_ip_address` char(40);
ALTER TABLE `cloud`.`console_proxy` MODIFY `public_ip_address` char(40) UNIQUE;
ALTER TABLE `cloud`.`secondary_storage_vm` MODIFY `public_ip_address` char(40) UNIQUE;
ALTER TABLE `cloud`.`load_balancer` MODIFY `ip_address` char(40) NOT NULL;
ALTER TABLE `cloud`.`remote_access_vpn` MODIFY `local_ip` char(40) NOT NULL;
ALTER TABLE `cloud`.`storage_pool` MODIFY `host_address` char(40) NOT NULL;