Skip to content

Commit fa2dd8e

Browse files
author
Kelven Yang
committed
bug 6745: Using UUID instead of integers - for VM instances
1 parent fab2d1f commit fa2dd8e

29 files changed

Lines changed: 935 additions & 673 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.api;
19+
20+
public interface Identity {
21+
String getUuid();
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.api;
19+
20+
import static java.lang.annotation.ElementType.FIELD;
21+
22+
import java.lang.annotation.Retention;
23+
import java.lang.annotation.RetentionPolicy;
24+
import java.lang.annotation.Target;
25+
26+
@Retention(RetentionPolicy.RUNTIME)
27+
@Target({FIELD})
28+
public @interface IdentityMapper {
29+
String entityTableName();
30+
}

‎api/src/com/cloud/api/commands/DestroyVMCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.cloud.api.ApiConstants;
2323
import com.cloud.api.BaseAsyncCmd;
2424
import com.cloud.api.BaseCmd;
25+
import com.cloud.api.IdentityMapper;
2526
import com.cloud.api.Implementation;
2627
import com.cloud.api.Parameter;
2728
import com.cloud.api.ServerApiException;
@@ -45,6 +46,7 @@ public class DestroyVMCmd extends BaseAsyncCmd {
4546
//////////////// API parameters /////////////////////
4647
/////////////////////////////////////////////////////
4748

49+
@IdentityMapper(entityTableName="vm_instance")
4850
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
4951
private Long id;
5052

‎api/src/com/cloud/api/commands/GetVMPasswordCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import com.cloud.api.ApiConstants;
2626
import com.cloud.api.BaseCmd;
27+
import com.cloud.api.IdentityMapper;
2728
import com.cloud.api.Implementation;
2829
import com.cloud.api.Parameter;
2930
import com.cloud.api.response.GetVMPasswordResponse;
@@ -40,6 +41,7 @@ public class GetVMPasswordCmd extends BaseCmd {
4041
//////////////// API parameters /////////////////////
4142
/////////////////////////////////////////////////////
4243

44+
@IdentityMapper(entityTableName="vm_instance")
4345
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
4446
private Long id;
4547

‎api/src/com/cloud/api/commands/ListVMsCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.cloud.api.ApiConstants;
2525
import com.cloud.api.BaseListCmd;
26+
import com.cloud.api.IdentityMapper;
2627
import com.cloud.api.Implementation;
2728
import com.cloud.api.Parameter;
2829
import com.cloud.api.response.ListResponse;
@@ -55,6 +56,7 @@ public class ListVMsCmd extends BaseListCmd {
5556
@Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="the host ID")
5657
private Long hostId;
5758

59+
@IdentityMapper(entityTableName="vm_instance")
5860
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the virtual machine")
5961
private Long id;
6062

‎api/src/com/cloud/api/commands/MigrateVMCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.cloud.api.ApiConstants;
2323
import com.cloud.api.BaseAsyncCmd;
2424
import com.cloud.api.BaseCmd;
25+
import com.cloud.api.IdentityMapper;
2526
import com.cloud.api.Implementation;
2627
import com.cloud.api.Parameter;
2728
import com.cloud.api.ServerApiException;
@@ -52,6 +53,7 @@ public class MigrateVMCmd extends BaseAsyncCmd {
5253
@Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, required=false, description="destination Host ID to migrate VM to")
5354
private Long hostId;
5455

56+
@IdentityMapper(entityTableName="vm_instance")
5557
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=true, description="the ID of the virtual machine")
5658
private Long virtualMachineId;
5759

‎api/src/com/cloud/api/commands/RebootVMCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.cloud.api.ApiConstants;
2323
import com.cloud.api.BaseAsyncCmd;
2424
import com.cloud.api.BaseCmd;
25+
import com.cloud.api.IdentityMapper;
2526
import com.cloud.api.Implementation;
2627
import com.cloud.api.Parameter;
2728
import com.cloud.api.ServerApiException;
@@ -44,6 +45,7 @@ public class RebootVMCmd extends BaseAsyncCmd {
4445
//////////////// API parameters /////////////////////
4546
/////////////////////////////////////////////////////
4647

48+
@IdentityMapper(entityTableName="vm_instance")
4749
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
4850
private Long id;
4951

‎api/src/com/cloud/api/commands/RecoverVMCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.cloud.api.ApiConstants;
2424
import com.cloud.api.BaseCmd;
25+
import com.cloud.api.IdentityMapper;
2526
import com.cloud.api.Implementation;
2627
import com.cloud.api.Parameter;
2728
import com.cloud.api.ServerApiException;
@@ -40,6 +41,7 @@ public class RecoverVMCmd extends BaseCmd {
4041
//////////////// API parameters /////////////////////
4142
/////////////////////////////////////////////////////
4243

44+
@IdentityMapper(entityTableName="vm_instance")
4345
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
4446
private Long id;
4547

‎api/src/com/cloud/api/commands/ResetVMPasswordCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.cloud.api.ApiConstants;
2323
import com.cloud.api.BaseAsyncCmd;
2424
import com.cloud.api.BaseCmd;
25+
import com.cloud.api.IdentityMapper;
2526
import com.cloud.api.Implementation;
2627
import com.cloud.api.Parameter;
2728
import com.cloud.api.ServerApiException;
@@ -46,6 +47,7 @@ public class ResetVMPasswordCmd extends BaseAsyncCmd {
4647
//////////////// API parameters /////////////////////
4748
/////////////////////////////////////////////////////
4849

50+
@IdentityMapper(entityTableName="vm_instance")
4951
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
5052
private Long id;
5153

‎api/src/com/cloud/api/commands/RestoreVMCmd.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.cloud.api.ApiConstants;
66
import com.cloud.api.BaseAsyncCmd;
77
import com.cloud.api.BaseCmd;
8+
import com.cloud.api.IdentityMapper;
89
import com.cloud.api.Implementation;
910
import com.cloud.api.Parameter;
1011
import com.cloud.api.ServerApiException;
@@ -25,6 +26,7 @@ public class RestoreVMCmd extends BaseAsyncCmd {
2526
public static final Logger s_logger = Logger.getLogger(RestoreVMCmd.class);
2627
private static final String s_name = "restorevmresponse";
2728

29+
@IdentityMapper(entityTableName="vm_instance")
2830
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=true, description="Virtual Machine ID")
2931
private Long vmId;
3032

0 commit comments

Comments
 (0)