Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//

package com.cloud.agent.api;

import com.cloud.agent.api.to.VirtualMachineTO;

public class CleanForMigrationStorageCommand extends Command {
private VirtualMachineTO vmSpec;

protected CleanForMigrationStorageCommand() {
}

public CleanForMigrationStorageCommand(VirtualMachineTO vmSpec) {
this.vmSpec = vmSpec;
}

public VirtualMachineTO getVmSpec() {
return vmSpec;
}

@Override
public boolean executeInSequence() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//

package com.cloud.agent.api;

public class CleanForMigrationStorageCommandAnswer extends Answer {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class CleanForMigrationStorageCommandAnswer extends Answer {
public class CleanForMigrationStorageAnswer extends Answer {


protected CleanForMigrationStorageCommandAnswer() {
}

public CleanForMigrationStorageCommandAnswer(CleanForMigrationStorageCommand cmd) {
super(cmd);
}


public CleanForMigrationStorageCommandAnswer(CleanForMigrationStorageCommand cmd, Exception ex) {
super(cmd, ex);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//

package com.cloud.agent.api;

import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.agent.api.to.VolumeTO;

public class PrepareForMigrationStorageAnswer extends Answer {
VirtualMachineTO vmSpec;
VolumeTO[] volumes;

protected PrepareForMigrationStorageAnswer() {
}

public PrepareForMigrationStorageAnswer(PrepareForMigrationStorageCommand cmd, VirtualMachineTO vmSpec, VolumeTO[] volumes) {
super(cmd, false, null);
this.vmSpec = vmSpec;
this.volumes = volumes;
}

public PrepareForMigrationStorageAnswer(PrepareForMigrationStorageCommand cmd, Exception ex) {
super(cmd, ex);
}

public VirtualMachineTO getVmSpec() {
return vmSpec;
}

public VolumeTO[] getVolumes() {
return volumes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//

package com.cloud.agent.api;

import org.apache.cloudstack.storage.to.VolumeObjectTO;

public class PrepareForMigrationStorageCommand extends Command {
private VolumeObjectTO volumeTO;

protected PrepareForMigrationStorageCommand() {
}

public PrepareForMigrationStorageCommand(VolumeObjectTO volumeTO) {
this.volumeTO = volumeTO;
}

public VolumeObjectTO getVolumeTO() {
return volumeTO;
}

public void setVolumeTO(VolumeObjectTO volumeTO) {
this.volumeTO = volumeTO;
}

@Override
public boolean executeInSequence() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import com.xensource.xenapi.Network;
import com.xensource.xenapi.SR;

@ResourceWrapper(handles = MigrateWithStorageReceiveCommand.class)
@ResourceWrapper(handles = MigrateWithStorageReceiveCommand.class)
public final class XenServer610MigrateWithStorageReceiveCommandWrapper extends CommandWrapper<MigrateWithStorageReceiveCommand, Answer, XenServer610Resource> {

private static final Logger s_logger = Logger.getLogger(XenServer610MigrateWithStorageReceiveCommandWrapper.class);
Expand Down Expand Up @@ -87,6 +87,11 @@ public Answer execute(final MigrateWithStorageReceiveCommand command, final XenS
final String uuid = xsHost.getUuid();

final Map<String, String> other = new HashMap<String, String>();

if (vmSpec.getDetails().containsKey("forcemigrate")) {
other.put("force", vmSpec.getDetails().get("forcemigrate"));
}

other.put("live", "true");

final Host host = Host.getByUuid(connection, uuid);
Expand All @@ -101,4 +106,4 @@ public Answer execute(final MigrateWithStorageReceiveCommand command, final XenS
return new MigrateWithStorageReceiveAnswer(command, e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import com.xensource.xenapi.VIF;
import com.xensource.xenapi.VM;

@ResourceWrapper(handles = MigrateWithStorageSendCommand.class)
@ResourceWrapper(handles = MigrateWithStorageSendCommand.class)
public final class XenServer610MigrateWithStorageSendCommandWrapper extends CommandWrapper<MigrateWithStorageSendCommand, Answer, XenServer610Resource> {

private static final Logger s_logger = Logger.getLogger(XenServer610MigrateWithStorageSendCommandWrapper.class);
Expand All @@ -73,14 +73,17 @@ public Answer execute(final MigrateWithStorageSendCommand command, final XenServ
// the answer object. It'll be deserialzed and object created in migrate with
// storage send command execution.
final Map<String, String> other = new HashMap<String, String>();
if (vmSpec.getDetails().containsKey("forcemigrate")) {
other.put("force", vmSpec.getDetails().get("forcemigrate"));
}
other.put("live", "true");

// Create the vdi map which tells what volumes of the vm need to go
// on which sr on the destination.
final Map<VDI, SR> vdiMap = new HashMap<VDI, SR>();
for (final Pair<VolumeTO, Object> entry : volumeToSr) {
if (entry.second() instanceof SR) {
final SR sr = (SR)entry.second();
final SR sr = (SR) entry.second();
final VDI vdi = xenServer610Resource.getVDIbyUuid(connection, entry.first().getPath());
vdiMap.put(vdi, sr);
} else {
Expand All @@ -98,7 +101,7 @@ public Answer execute(final MigrateWithStorageSendCommand command, final XenServ
final Map<VIF, Network> vifMap = new HashMap<VIF, Network>();
for (final Pair<NicTO, Object> entry : nicToNetwork) {
if (entry.second() instanceof Network) {
final Network network = (Network)entry.second();
final Network network = (Network) entry.second();
final VIF vif = xenServer610Resource.getVifByMac(connection, vmToMigrate, entry.first().getMac());
vifMap.put(vif, network);
} else {
Expand Down Expand Up @@ -148,4 +151,4 @@ public Answer execute(final MigrateWithStorageSendCommand command, final XenServ
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//

package com.cloud.hypervisor.xenserver.resource.wrapper.xenbase;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.CleanForMigrationStorageCommand;
import com.cloud.agent.api.CleanForMigrationStorageCommandAnswer;
import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
import com.cloud.resource.CommandWrapper;
import com.cloud.resource.ResourceWrapper;
import com.xensource.xenapi.Connection;
import com.xensource.xenapi.Types;
import com.xensource.xenapi.VM;
import org.apache.log4j.Logger;
import org.apache.xmlrpc.XmlRpcException;

@ResourceWrapper(handles = CleanForMigrationStorageCommand.class)
public final class CitrixCleanForMigrationStorageCommandWrapper extends CommandWrapper<CleanForMigrationStorageCommand, Answer, CitrixResourceBase> {

private static final Logger s_logger = Logger.getLogger(CitrixCleanForMigrationStorageCommandWrapper.class);

@Override
public Answer execute(final CleanForMigrationStorageCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
try {
VM vm = citrixResourceBase.getVM(conn, command.getVmSpec().getName());
vm.destroy(conn);
} catch (Types.XenAPIException e) {
s_logger.warn("Catch Exception " + e.getClass().getName() + " clean for migration storage failed due to " + e.toString(), e);
return new CleanForMigrationStorageCommandAnswer(command, e);
} catch (XmlRpcException e) {
s_logger.warn("Catch Exception " + e.getClass().getName() + " clean for migration storage failed due to " + e.toString(), e);
return new CleanForMigrationStorageCommandAnswer(command, e);
}

return new CleanForMigrationStorageCommandAnswer(command);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpassante , the lint check fails because of this; no eol before eof

Loading