diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java index 8efaebe1c84..1957f823f43 100644 --- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java +++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java @@ -196,10 +196,16 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { } private boolean isVolumeOnManagedStorage(VolumeInfo volumeInfo) { - long storagePooldId = volumeInfo.getDataStore().getId(); - StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePooldId); + DataStore dataStore = volumeInfo.getDataStore(); - return storagePoolVO.isManaged(); + if (dataStore.getRole() == DataStoreRole.Primary) { + long storagePooldId = dataStore.getId(); + StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePooldId); + + return storagePoolVO.isManaged(); + } + + return false; } // canHandle returns true if the storage driver for the DataObject that's passed in can support certain features (what features we diff --git a/engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategyTest.java b/engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategyTest.java new file mode 100644 index 00000000000..ec85f7d32fc --- /dev/null +++ b/engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategyTest.java @@ -0,0 +1,84 @@ +/* + * 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 org.apache.cloudstack.storage.motion; + +import com.cloud.storage.DataStoreRole; +import com.cloud.storage.ImageStore; +import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy; +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; +import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority; +import org.apache.cloudstack.storage.datastore.PrimaryDataStoreImpl; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; +import org.apache.cloudstack.storage.image.store.ImageStoreImpl; +import org.apache.cloudstack.storage.volume.VolumeObject; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.MockitoAnnotations.initMocks; + +@RunWith(MockitoJUnitRunner.class) +public class StorageSystemDataMotionStrategyTest { + + @Mock + VolumeObject source; + @Mock + DataObject destination; + @Mock + PrimaryDataStore sourceStore; + @Mock + ImageStore destinationStore; + + @InjectMocks + DataMotionStrategy strategy = new StorageSystemDataMotionStrategy(); + @Mock + PrimaryDataStoreDao _storagePoolDao; + + @Before public void setUp() throws Exception { + sourceStore = mock(PrimaryDataStoreImpl.class); + destinationStore = mock(ImageStoreImpl.class); + source = mock(VolumeObject.class); + destination = mock(VolumeObject.class); + + initMocks(strategy); + } + + @Test + public void cantHandleSecondary() { + doReturn(sourceStore).when(source).getDataStore(); + doReturn(DataStoreRole.Primary).when(sourceStore).getRole(); + doReturn(destinationStore).when(destination).getDataStore(); + doReturn(DataStoreRole.Image).when((DataStore)destinationStore).getRole(); + doReturn(sourceStore).when(source).getDataStore(); + doReturn(destinationStore).when(destination).getDataStore(); + StoragePoolVO storeVO = new StoragePoolVO(); + doReturn(storeVO).when(_storagePoolDao).findById(0l); + + assertTrue(strategy.canHandle(source,destination) == StrategyPriority.CANT_HANDLE); + } +} \ No newline at end of file diff --git a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index e6c0a8da6ec..e9cf926ac5a 100644 --- a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -401,9 +401,9 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy return null; } - if (vm != null && vm.getState() != State.Running) { + if (vm != null && vm.getState() != State.Starting && vm.getState() != State.Running) { if (s_logger.isInfoEnabled()) { - s_logger.info("Detected that vm : " + vmId + " is not currently at running state, we will fail the proxy assignment for it"); + s_logger.info("Detected that vm : " + vmId + " is not currently in starting or running state, we will fail the proxy assignment for it"); } return null; } diff --git a/systemvm/debian/opt/cloud/bin/setup/router.sh b/systemvm/debian/opt/cloud/bin/setup/router.sh index f41e57e6375..2a8a4ad5d56 100755 --- a/systemvm/debian/opt/cloud/bin/setup/router.sh +++ b/systemvm/debian/opt/cloud/bin/setup/router.sh @@ -61,6 +61,10 @@ setup_router() { then log_it "Reloading udev for new udev NIC assignment" udevadm control --reload-rules && udevadm trigger + if [ "$HYPERVISOR" == "vmware" ]; then + sync + reboot + fi fi fi diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index f0d70bac77e..6dc45c067cc 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -3285,6 +3285,9 @@ allowedActions.push("resetSSHKeyForVirtualMachine"); } else if (jsonObj.state == 'Starting') { // allowedActions.push("stop"); + if (isAdmin()) { + allowedActions.push("viewConsole"); + } } else if (jsonObj.state == 'Error') { allowedActions.push("destroy"); } else if (jsonObj.state == 'Expunging') { diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 22145ae5d69..962c38e772b 100755 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -22096,6 +22096,10 @@ if (isAdmin()) allowedActions.push("migrate"); + } else if (jsonObj.state == 'Starting') { + if (isAdmin()) { + allowedActions.push("viewConsole"); + } } else if (jsonObj.state == 'Stopped') { allowedActions.push("start"); @@ -22113,10 +22117,13 @@ if (jsonObj.state == 'Running') { allowedActions.push("stop"); - allowedActions.push("viewConsole"); if (isAdmin()) allowedActions.push("migrate"); + } else if (jsonObj.state == 'Starting') { + if (isAdmin()) { + allowedActions.push("viewConsole"); + } } else if (jsonObj.state == 'Stopped') { allowedActions.push("start"); } @@ -22140,6 +22147,10 @@ allowedActions.push("viewConsole"); if (isAdmin()) allowedActions.push("migrate"); + } else if (jsonObj.state == 'Starting') { + if (isAdmin()) { + allowedActions.push("viewConsole"); + } } else if (jsonObj.state == 'Stopped') { allowedActions.push("start");