Skip to content

Commit 462ad5c

Browse files
author
Abhinandan Prateek
committed
bug 8962: network related improvements
1 parent a2ed3fa commit 462ad5c

4 files changed

Lines changed: 156 additions & 65 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
package com.cloud.api.commands;
1919

2020

21+
import java.util.ArrayList;
22+
import java.util.List;
23+
2124
import org.apache.log4j.Logger;
2225

2326
import com.cloud.api.ApiConstants;
@@ -32,6 +35,7 @@
3235
import com.cloud.api.response.ZoneResponse;
3336
import com.cloud.async.AsyncJob;
3437
import com.cloud.event.EventTypes;
38+
import com.cloud.exception.InvalidParameterValueException;
3539
import com.cloud.user.Account;
3640
import com.cloud.uservm.UserVm;
3741

@@ -54,7 +58,12 @@ public class AssignVMCmd extends BaseCmd {
5458
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
5559
private Long domainId;
5660

61+
//Network information
62+
@IdentityMapper(entityTableName="networks")
63+
@Parameter(name=ApiConstants.NETWORK_IDS, type=CommandType.LIST, collectionType=CommandType.LONG, description="list of network ids that will be part of VM network after move")
64+
private List<Long> networkIds;
5765

66+
5867
/////////////////////////////////////////////////////
5968
/////////////////// Accessors ///////////////////////
6069
/////////////////////////////////////////////////////
@@ -70,6 +79,10 @@ public String getAccountName() {
7079
public Long getDomainId() {
7180
return domainId;
7281
}
82+
83+
public List<Long> getNetworkIds() {
84+
return networkIds;
85+
}
7386

7487
/////////////////////////////////////////////////////
7588
/////////////// API Implementation///////////////////

‎core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
253253
protected long _dcId;
254254
protected String _pod;
255255
protected String _cluster;
256-
protected static final XenServerPoolVms s_vms = new XenServerPoolVms();
256+
private static final XenServerPoolVms s_vms = new XenServerPoolVms();
257257
protected String _privateNetworkName;
258258
protected String _linkLocalPrivateNetworkName;
259259
protected String _publicNetworkName;
@@ -1081,7 +1081,7 @@ public StartAnswer execute(StartCommand cmd) {
10811081
}
10821082
}
10831083
}
1084-
s_logger.debug("The VM " + vmName + " is in Starting state.");
1084+
s_logger.debug("1. The VM " + vmName + " is in Starting state.");
10851085
s_vms.put(_cluster, _name, vmName, State.Starting);
10861086

10871087
Host host = Host.getByUuid(conn, _host.uuid);
@@ -1164,7 +1164,7 @@ public StartAnswer execute(StartCommand cmd) {
11641164
} finally {
11651165
synchronized (s_vms) {
11661166
if (state != State.Stopped) {
1167-
s_logger.debug("The VM " + vmName + " is in " + state + " state.");
1167+
s_logger.debug("2. The VM " + vmName + " is in " + state + " state.");
11681168
s_vms.put(_cluster, _name, vmName, state);
11691169
} else {
11701170
s_logger.debug("The VM is in stopped state, detected problem during startup : " + vmName);
@@ -2168,7 +2168,7 @@ protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd
21682168
Integer vncPort = null;
21692169
if (state == State.Running) {
21702170
synchronized (s_vms) {
2171-
s_logger.debug("The VM " + vmName + " is in " + State.Running + " state");
2171+
s_logger.debug("3. The VM " + vmName + " is in " + State.Running + " state");
21722172
s_vms.put(_cluster, _name, vmName, State.Running);
21732173
}
21742174
}
@@ -2191,7 +2191,7 @@ protected PrepareForMigrationAnswer execute(PrepareForMigrationCommand cmd) {
21912191
for (NicTO nic : nics) {
21922192
getNetwork(conn, nic);
21932193
}
2194-
s_logger.debug("The VM " + vm.getName() + " is in " + State.Migrating + " state");
2194+
s_logger.debug("4. The VM " + vm.getName() + " is in " + State.Migrating + " state");
21952195
s_vms.put(_cluster, _name, vm.getName(), State.Migrating);
21962196

21972197
return new PrepareForMigrationAnswer(cmd);
@@ -2428,7 +2428,7 @@ protected MigrateAnswer execute(final MigrateCommand cmd) {
24282428

24292429
state = s_vms.getState(_cluster, vmName);
24302430

2431-
s_logger.debug("The VM " + vmName + " is in " + State.Stopping + " state");
2431+
s_logger.debug("5. The VM " + vmName + " is in " + State.Stopping + " state");
24322432
s_vms.put(_cluster, _name, vmName, State.Stopping);
24332433
try {
24342434
Set<VM> vms = VM.getByNameLabel(conn, vmName);
@@ -2495,7 +2495,7 @@ protected MigrateAnswer execute(final MigrateCommand cmd) {
24952495
s_logger.warn(msg, e);
24962496
return new MigrateAnswer(cmd, false, msg, null);
24972497
} finally {
2498-
s_logger.debug("The VM " + vmName + " is in " + state + " state");
2498+
s_logger.debug("6. The VM " + vmName + " is in " + state + " state");
24992499
s_vms.put(_cluster, _name, vmName, state);
25002500
}
25012501

@@ -2618,7 +2618,7 @@ record = vm.getRecord(conn);
26182618
@Override
26192619
public RebootAnswer execute(RebootCommand cmd) {
26202620
Connection conn = getConnection();
2621-
s_logger.debug("The VM " + cmd.getVmName() + " is in " + State.Starting + " state");
2621+
s_logger.debug("7. The VM " + cmd.getVmName() + " is in " + State.Starting + " state");
26222622
s_vms.put(_cluster, _name, cmd.getVmName(), State.Starting);
26232623
try {
26242624
Set<VM> vms = null;
@@ -2642,7 +2642,7 @@ public RebootAnswer execute(RebootCommand cmd) {
26422642
}
26432643
return new RebootAnswer(cmd, "reboot succeeded", null, null);
26442644
} finally {
2645-
s_logger.debug("The VM " + cmd.getVmName() + " is in " + State.Running + " state");
2645+
s_logger.debug("8. The VM " + cmd.getVmName() + " is in " + State.Running + " state");
26462646
s_vms.put(_cluster, _name, cmd.getVmName(), State.Running);
26472647
}
26482648
}
@@ -3136,7 +3136,7 @@ public StopAnswer execute(StopCommand cmd) {
31363136

31373137
State state = s_vms.getState(_cluster, vmName);
31383138

3139-
s_logger.debug("The VM " + vmName + " is in " + State.Stopping + " state");
3139+
s_logger.debug("9. The VM " + vmName + " is in " + State.Stopping + " state");
31403140
s_vms.put(_cluster, _name, vmName, State.Stopping);
31413141

31423142
try {
@@ -3198,7 +3198,7 @@ public StopAnswer execute(StopCommand cmd) {
31983198
String msg = "VM destroy failed in Stop " + vmName + " Command due to " + e.getMessage();
31993199
s_logger.warn(msg, e);
32003200
} finally {
3201-
s_logger.debug("The VM " + vmName + " is in " + state + " state");
3201+
s_logger.debug("10. The VM " + vmName + " is in " + state + " state");
32023202
s_vms.put(_cluster, _name, vmName, state);
32033203
}
32043204
}
@@ -6637,7 +6637,7 @@ protected HashMap<String, Pair<String, State>> deltaClusterSync(Connection conn)
66376637
s_logger.warn("Detecting a change in host for " + vm);
66386638
changes.put(vm, new Pair<String, State>(host_uuid, newState));
66396639

6640-
s_logger.debug("The VM " + vm + " is in " + newState + " state");
6640+
s_logger.debug("11. The VM " + vm + " is in " + newState + " state");
66416641
s_vms.put(_cluster, host_uuid, vm, newState);
66426642
continue;
66436643
}
@@ -6661,7 +6661,7 @@ protected HashMap<String, Pair<String, State>> deltaClusterSync(Connection conn)
66616661
changes.put(vm, new Pair<String, State>(host_uuid, newState));
66626662
} else if (oldState.second() == State.Starting) {
66636663
if (newState == State.Running) {
6664-
s_logger.debug("The VM " + vm + " is in " + State.Running + " state");
6664+
s_logger.debug("12. The VM " + vm + " is in " + State.Running + " state");
66656665
s_vms.put(_cluster, host_uuid, vm, newState);
66666666
} else if (newState == State.Stopped) {
66676667
s_logger.warn("Ignoring vm " + vm + " because of a lag in starting the vm.");
@@ -6673,13 +6673,13 @@ protected HashMap<String, Pair<String, State>> deltaClusterSync(Connection conn)
66736673
}
66746674
} else if (oldState.second() == State.Stopping) {
66756675
if (newState == State.Stopped) {
6676-
s_logger.debug("The VM " + vm + " is in " + State.Stopped + " state");
6676+
s_logger.debug("13. The VM " + vm + " is in " + State.Stopped + " state");
66776677
s_vms.put(_cluster, host_uuid, vm, newState);
66786678
} else if (newState == State.Running) {
66796679
s_logger.warn("Ignoring vm " + vm + " because of a lag in stopping the vm. ");
66806680
}
66816681
} else if (oldState.second() != newState) {
6682-
s_logger.debug("The VM " + vm + " is in " + newState + " state was " + oldState.second());
6682+
s_logger.debug("14. The VM " + vm + " is in " + newState + " state was " + oldState.second());
66836683
s_vms.put(_cluster, host_uuid, vm, newState);
66846684
if (newState == State.Stopped) {
66856685
/*

‎core/src/com/cloud/vm/UserVmVO.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,8 @@ public String getDetail(String name) {
126126
public void setAccountId(long accountId){
127127
this.accountId = accountId;
128128
}
129+
130+
public void setDomainId(long domainId){
131+
this.domainId = domainId;
132+
}
129133
}

0 commit comments

Comments
 (0)