@Override
protected void handle(final InstantiateVolumeOnPrimaryStorageMsg msg) {
if (msg.getDestHost() == null) {
String hostUuid = getAvailableHostUuidForOperation();
if (hostUuid == null) {
throw new OperationFailureException(operr("the shared mount point primary storage[uuid:%s, name:%s] cannot find any " +
"available host in attached clusters for instantiating the volume", self.getUuid(), self.getName()));
}
msg.setDestHost(HostInventory.valueOf(dbf.findByUuid(hostUuid, HostVO.class)));
}
HypervisorFactory f = getHypervisorFactoryByHostUuid(msg.getDestHost().getUuid());
HypervisorBackend bkd = f.getHypervisorBackend(self);
bkd.handle(msg, new ReturnValueCompletion<InstantiateVolumeOnPrimaryStorageReply>(msg) {
@Override
public void success(InstantiateVolumeOnPrimaryStorageReply reply) {
bus.reply(msg, reply);
}
@Override
public void fail(ErrorCode errorCode) {
InstantiateVolumeOnPrimaryStorageReply reply = new InstantiateVolumeOnPrimaryStorageReply();
reply.setError(errorCode);
bus.reply(msg, reply);
}
});
}