From a5caa102a847ef3da8f457b64510ee516a1b831b Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 17:19:10 +0100 Subject: [PATCH 01/11] Get rid of several warnings and errors in the agent sources --- agent/pom.xml | 33 +++++++++++++ .../agent/dao/impl/PropertiesStorage.java | 49 +++++++++---------- .../com/cloud/agent/dhcp/FakeDhcpSnooper.java | 5 -- agent/src/com/cloud/agent/mockvm/MockVm.java | 7 --- .../consoleproxy/ConsoleProxyResource.java | 20 ++------ 5 files changed, 62 insertions(+), 52 deletions(-) diff --git a/agent/pom.xml b/agent/pom.xml index 14133226053..c3ac308882a 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -115,5 +115,38 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-antrun-plugin + + [1.7,) + + run + + + + + + + + + + + + diff --git a/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java b/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java index 411d946a294..0c100b37be6 100755 --- a/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java +++ b/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java @@ -119,34 +119,33 @@ public class PropertiesStorage implements StorageComponent { return true; } - @Override - public void setName(String name) { - // TODO Auto-generated method stub - - } + @Override + public void setName(String name) { + // TODO Auto-generated method stub - @Override - public void setConfigParams(Map params) { - // TODO Auto-generated method stub - - } + } - @Override - public Map getConfigParams() { - // TODO Auto-generated method stub - return null; - } + @Override + public void setConfigParams(Map params) { + // TODO Auto-generated method stub - @Override - public int getRunLevel() { - // TODO Auto-generated method stub - return 0; - } + } - @Override - public void setRunLevel(int level) { - // TODO Auto-generated method stub - - } + @Override + public Map getConfigParams() { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getRunLevel() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void setRunLevel(int level) { + // TODO Auto-generated method stub + } } diff --git a/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java b/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java index 73a994e8bd9..432caa63c32 100644 --- a/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java +++ b/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java @@ -18,9 +18,6 @@ package com.cloud.agent.dhcp; import java.net.InetAddress; import java.net.UnknownHostException; - -import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Queue; @@ -32,8 +29,6 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; import com.cloud.utils.Pair; import com.cloud.utils.net.NetUtils; diff --git a/agent/src/com/cloud/agent/mockvm/MockVm.java b/agent/src/com/cloud/agent/mockvm/MockVm.java index 306a6c40786..8a806eea354 100644 --- a/agent/src/com/cloud/agent/mockvm/MockVm.java +++ b/agent/src/com/cloud/agent/mockvm/MockVm.java @@ -71,11 +71,4 @@ public class MockVm { return vncPort; } - public static void main(String[] args) { - long i = 10; - Long l = null; - if (i == l) { - System.out.print("fdfd"); - } - } } diff --git a/agent/src/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java b/agent/src/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java index 6f49f47a1ed..054acd1caeb 100644 --- a/agent/src/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java +++ b/agent/src/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java @@ -32,9 +32,12 @@ import java.util.Properties; import javax.naming.ConfigurationException; -import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.log4j.Logger; +import com.google.gson.Gson; + +import org.apache.cloudstack.managed.context.ManagedContextRunnable; + import com.cloud.agent.Agent.ExitStatus; import com.cloud.agent.api.AgentControlAnswer; import com.cloud.agent.api.Answer; @@ -61,7 +64,6 @@ import com.cloud.resource.ServerResourceBase; import com.cloud.utils.NumbersUtil; import com.cloud.utils.net.NetUtils; import com.cloud.utils.script.Script; -import com.google.gson.Gson; /** * @@ -130,19 +132,6 @@ public class ConsoleProxyResource extends ServerResourceBase implements } } - private boolean copyCertToDirectory(String certificate, String filePath) - throws IOException { - boolean success; - // copy cert to the dir - FileWriter fstream = new FileWriter(filePath); - BufferedWriter out = new BufferedWriter(fstream); - out.write(certificate); - // Close the output stream - out.close(); - success = true; - return success; - } - protected Answer execute(final CheckConsoleProxyLoadCommand cmd) { return executeProxyLoadScan(cmd, cmd.getProxyVmId(), cmd.getProxyVmName(), cmd.getProxyManagementIp(), @@ -204,6 +193,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements return null; } + @Override public Type getType() { return Host.Type.ConsoleProxy; } From 54a3d8048b887796ac470c2a2238f5503ccabb6e Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 17:19:47 +0100 Subject: [PATCH 02/11] Get rid of a few errors and warnings in the engine storage integration-test sources --- engine/storage/integration-test/pom.xml | 33 +++++++++++++++++++ .../test/resources/storageContext.xml | 3 -- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml index dc4065e5988..4e5fdeb7eb9 100644 --- a/engine/storage/integration-test/pom.xml +++ b/engine/storage/integration-test/pom.xml @@ -185,5 +185,38 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-antrun-plugin + + [1.7,) + + run + + + + + + + + + + + + diff --git a/engine/storage/integration-test/test/resources/storageContext.xml b/engine/storage/integration-test/test/resources/storageContext.xml index 0dcd6a83407..c9845157afd 100644 --- a/engine/storage/integration-test/test/resources/storageContext.xml +++ b/engine/storage/integration-test/test/resources/storageContext.xml @@ -85,10 +85,7 @@ -<<<<<<< HEAD -======= ->>>>>>> pluggable_vm_snapshot From a3fae88c2725f0d5166af28ff7f4e15a16c2be67 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 17:20:44 +0100 Subject: [PATCH 03/11] Set cloudstack as the parent for our checkstyle config --- parents/checkstyle/pom.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/parents/checkstyle/pom.xml b/parents/checkstyle/pom.xml index 245631bc2ba..746cb3fe312 100644 --- a/parents/checkstyle/pom.xml +++ b/parents/checkstyle/pom.xml @@ -1,7 +1,11 @@ 4.0.0 Apache CloudStack Checkstyle Configuration - org.apache.cloudstack checkstyle 0.0.1-SNAPSHOT + + org.apache.cloudstack + cloudstack + 4.3.0-SNAPSHOT + From d17a8f8b1181fa83fcd232905e623dad8e37cfda Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 17:21:10 +0100 Subject: [PATCH 04/11] Get rid of some errors and warnings in the plugins user-authenticators ldap sources --- plugins/user-authenticators/ldap/pom.xml | 37 ++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/plugins/user-authenticators/ldap/pom.xml b/plugins/user-authenticators/ldap/pom.xml index 1f9dea06631..34121e4db31 100644 --- a/plugins/user-authenticators/ldap/pom.xml +++ b/plugins/user-authenticators/ldap/pom.xml @@ -90,6 +90,40 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.codehaus.gmaven + + + gmaven-plugin + + [1.3,) + + compile + testCompile + + + + + + + + + + + + @@ -104,7 +138,6 @@ cglib cglib-nodep - 2.2 - + From 29aa4ae8da647bcc2558c625d14f6db2dde76a38 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 17:21:55 +0100 Subject: [PATCH 05/11] Get rid of some errors and warnings in the server and usage sources --- server/pom.xml | 33 +++++++++++++++++++++++++++++++++ usage/pom.xml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/server/pom.xml b/server/pom.xml index c7978e2dd38..527bd97165c 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -228,5 +228,38 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-antrun-plugin + + [1.7,) + + run + + + + + + + + + + + + diff --git a/usage/pom.xml b/usage/pom.xml index 04d16307601..e71a1d07de5 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -119,6 +119,39 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-antrun-plugin + + [1.7,) + + run + + + + + + + + + + + + From 9e5e9fdc670f36040ab24d985039a511945d5831 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 18:57:03 +0100 Subject: [PATCH 06/11] Fix version and build paths for the checkstyle code --- parents/checkstyle/pom.xml | 3 +-- plugins/network-elements/nicira-nvp/pom.xml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/parents/checkstyle/pom.xml b/parents/checkstyle/pom.xml index 746cb3fe312..de60100c873 100644 --- a/parents/checkstyle/pom.xml +++ b/parents/checkstyle/pom.xml @@ -2,10 +2,9 @@ 4.0.0 Apache CloudStack Checkstyle Configuration checkstyle - 0.0.1-SNAPSHOT org.apache.cloudstack - cloudstack + cloud-maven-standard 4.3.0-SNAPSHOT diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml index 5c65e6a8180..9341c93c381 100644 --- a/plugins/network-elements/nicira-nvp/pom.xml +++ b/plugins/network-elements/nicira-nvp/pom.xml @@ -37,7 +37,7 @@ org.apache.cloudstack checkstyle - 0.0.1-SNAPSHOT + ${project.version} From 479f404aeafb4874cd660f113c0281e10db02114 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 20:14:46 +0100 Subject: [PATCH 07/11] Fix several rat issues introduced by recent commits --- parents/checkstyle/pom.xml | 10 +++++++ .../src/main/resources/tooling/checkstyle.xml | 18 +++++++++++++ .../debian/config/etc/logrotate.d/cloud | 11 -------- .../management/ProviderTestConfiguration.java | 26 +++++++++++++++--- .../PublicNetworkTestConfiguration.java | 26 +++++++++++++++--- .../test/resources/providerContext.xml | 18 +++++++++++++ .../test/resources/publicNetworkContext.xml | 10 +++++++ pom.xml | 1 + .../debian/config/etc/logrotate.d/cloud | 27 +++++++++++++++++++ 9 files changed, 128 insertions(+), 19 deletions(-) delete mode 100644 patches/systemvm/debian/config/etc/logrotate.d/cloud create mode 100644 systemvm/patches/debian/config/etc/logrotate.d/cloud diff --git a/parents/checkstyle/pom.xml b/parents/checkstyle/pom.xml index de60100c873..b1b7b21b11a 100644 --- a/parents/checkstyle/pom.xml +++ b/parents/checkstyle/pom.xml @@ -1,3 +1,13 @@ + 4.0.0 Apache CloudStack Checkstyle Configuration diff --git a/parents/checkstyle/src/main/resources/tooling/checkstyle.xml b/parents/checkstyle/src/main/resources/tooling/checkstyle.xml index 84653839754..83493d677ba 100644 --- a/parents/checkstyle/src/main/resources/tooling/checkstyle.xml +++ b/parents/checkstyle/src/main/resources/tooling/checkstyle.xml @@ -1,4 +1,22 @@ + diff --git a/patches/systemvm/debian/config/etc/logrotate.d/cloud b/patches/systemvm/debian/config/etc/logrotate.d/cloud deleted file mode 100644 index 40c42032e79..00000000000 --- a/patches/systemvm/debian/config/etc/logrotate.d/cloud +++ /dev/null @@ -1,11 +0,0 @@ -/var/log/cloud.log { - rotate 4 - daily - missingok - notifempty - compress - delaycompress - postrotate - pkill socat > /dev/null - endscript -} diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ProviderTestConfiguration.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ProviderTestConfiguration.java index 818d6a07b1f..3c215901533 100644 --- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ProviderTestConfiguration.java +++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ProviderTestConfiguration.java @@ -1,3 +1,21 @@ +/* + * 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.network.contrail.management; import org.springframework.context.annotation.Bean; @@ -5,8 +23,8 @@ import org.springframework.context.annotation.Configuration; @Configuration public class ProviderTestConfiguration { - @Bean - ServerDBSync getServerDBSync() { - return new ServerDBSyncImpl(); - } + @Bean + ServerDBSync getServerDBSync() { + return new ServerDBSyncImpl(); + } } diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java index a184b14fe71..b41e282d934 100644 --- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java +++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTestConfiguration.java @@ -1,3 +1,21 @@ +/* + * 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.network.contrail.management; import org.mockito.Mockito; @@ -6,8 +24,8 @@ import org.springframework.context.annotation.Configuration; @Configuration public class PublicNetworkTestConfiguration { - @Bean - ServerDBSync getServerDBSync() { - return Mockito.mock(ServerDBSync.class); - } + @Bean + ServerDBSync getServerDBSync() { + return Mockito.mock(ServerDBSync.class); + } } diff --git a/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml b/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml index f412bc00c6e..62a9f6286f0 100644 --- a/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml +++ b/plugins/network-elements/juniper-contrail/test/resources/providerContext.xml @@ -1,4 +1,22 @@ + + tools/marvin/marvin/sandbox/advanced/sandbox.cfg tools/ngui/static/bootstrap/* tools/ngui/static/js/lib/* + **/.checkstyle diff --git a/systemvm/patches/debian/config/etc/logrotate.d/cloud b/systemvm/patches/debian/config/etc/logrotate.d/cloud new file mode 100644 index 00000000000..37440ace69f --- /dev/null +++ b/systemvm/patches/debian/config/etc/logrotate.d/cloud @@ -0,0 +1,27 @@ +# 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. +/var/log/cloud.log { + rotate 4 + daily + missingok + notifempty + compress + delaycompress + postrotate + pkill socat > /dev/null + endscript +} From 84b5bfff74440076a2666272fde63b84b61cb0dd Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Mon, 4 Nov 2013 20:24:26 +0100 Subject: [PATCH 08/11] Fix formal pom parsing done by Jenkins --- parents/checkstyle/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/parents/checkstyle/pom.xml b/parents/checkstyle/pom.xml index b1b7b21b11a..48d58bb51d3 100644 --- a/parents/checkstyle/pom.xml +++ b/parents/checkstyle/pom.xml @@ -16,5 +16,6 @@ org.apache.cloudstack cloud-maven-standard 4.3.0-SNAPSHOT + ../../maven-standard/pom.xml From 9a62239a92c5eafca6fafee1fbccd413bdfb91af Mon Sep 17 00:00:00 2001 From: Min Chen Date: Mon, 4 Nov 2013 12:31:31 -0800 Subject: [PATCH 09/11] CLOUDSTACK-5017: Throw CloudRuntimeException in case of template/volume download when ssvm is not ready so that caller can remove some leftover entries in template_store_ref and volume_store_ref. --- .../storage/image/TemplateServiceImpl.java | 46 ++++++++++++++---- .../storage/volume/VolumeServiceImpl.java | 48 ++++++++++++++----- .../storage/download/DownloadMonitorImpl.java | 6 ++- 3 files changed, 76 insertions(+), 24 deletions(-) diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java index 3e3c6d84b5c..308347d8a38 100644 --- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java +++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java @@ -172,12 +172,26 @@ public class TemplateServiceImpl implements TemplateService { return; } - TemplateOpContext context = new TemplateOpContext(callback, - templateOnStore, null); + try { + TemplateOpContext context = new TemplateOpContext(callback, + templateOnStore, null); - AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); - caller.setCallback(caller.getTarget().createTemplateCallback(null, null)).setContext(context); - store.getDriver().createAsync(store, templateOnStore, caller); + AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); + caller.setCallback(caller.getTarget().createTemplateCallback(null, null)).setContext(context); + store.getDriver().createAsync(store, templateOnStore, caller); + } catch (CloudRuntimeException ex) { + // clean up already persisted template_store_ref entry in case of createTemplateCallback is never called + TemplateDataStoreVO templateStoreVO = _vmTemplateStoreDao.findByStoreTemplate(store.getId(), template.getId()); + if (templateStoreVO != null) { + TemplateInfo tmplObj = _templateFactory.getTemplate(template, store); + tmplObj.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed); + } + TemplateApiResult result = new TemplateApiResult(template); + result.setResult(ex.getMessage()); + if (callback != null) { + callback.complete(result); + } + } } @Override @@ -732,11 +746,23 @@ public class TemplateServiceImpl implements TemplateService { if (s_logger.isDebugEnabled()) { s_logger.debug("Invoke datastore driver createAsync to create template on destination store"); } - TemplateOpContext context = new TemplateOpContext(null, - (TemplateObject) templateOnStore, future); - AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); - caller.setCallback(caller.getTarget().copyTemplateCrossZoneCallBack(null, null)).setContext(context); - destStore.getDriver().createAsync(destStore, templateOnStore, caller); + try { + TemplateOpContext context = new TemplateOpContext(null, + (TemplateObject)templateOnStore, future); + AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); + caller.setCallback(caller.getTarget().copyTemplateCrossZoneCallBack(null, null)).setContext(context); + destStore.getDriver().createAsync(destStore, templateOnStore, caller); + } catch (CloudRuntimeException ex) { + // clean up already persisted template_store_ref entry in case of createTemplateCallback is never called + TemplateDataStoreVO templateStoreVO = _vmTemplateStoreDao.findByStoreTemplate(destStore.getId(), srcTemplate.getId()); + if (templateStoreVO != null) { + TemplateInfo tmplObj = _templateFactory.getTemplate(srcTemplate, destStore); + tmplObj.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed); + } + TemplateApiResult res = new TemplateApiResult((TemplateObject)templateOnStore); + res.setResult(ex.getMessage()); + future.complete(res); + } return future; } diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 79e8cc87ca6..86e49f97a77 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -40,6 +40,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event; +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.Scope; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; @@ -55,7 +56,6 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.storage.command.CommandResult; import org.apache.cloudstack.storage.command.CopyCmdAnswer; import org.apache.cloudstack.storage.command.DeleteCommand; -import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; @@ -165,12 +165,24 @@ public class VolumeServiceImpl implements VolumeService { DataObject volumeOnStore = dataStore.create(volume); volumeOnStore.processEvent(Event.CreateOnlyRequested); - CreateVolumeContext context = new CreateVolumeContext(null, volumeOnStore, - future); - AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); - caller.setCallback(caller.getTarget().createVolumeCallback(null, null)).setContext(context); + try { + CreateVolumeContext context = new CreateVolumeContext(null, volumeOnStore, + future); + AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); + caller.setCallback(caller.getTarget().createVolumeCallback(null, null)).setContext(context); - dataStore.getDriver().createAsync(dataStore, volumeOnStore, caller); + dataStore.getDriver().createAsync(dataStore, volumeOnStore, caller); + } catch (CloudRuntimeException ex) { + // clean up already persisted volume_store_ref entry in case of createVolumeCallback is never called + VolumeDataStoreVO volStoreVO = _volumeStoreDao.findByStoreVolume(dataStore.getId(), volume.getId()); + if (volStoreVO != null) { + VolumeInfo volObj = volFactory.getVolume(volume, dataStore); + volObj.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed); + } + VolumeApiResult volResult = new VolumeApiResult((VolumeObject)volumeOnStore); + volResult.setResult(ex.getMessage()); + future.complete(volResult); + } return future; } @@ -1022,13 +1034,25 @@ public class VolumeServiceImpl implements VolumeService { volumeOnStore.processEvent(Event.CreateOnlyRequested); - CreateVolumeContext context = new CreateVolumeContext(null, volumeOnStore, - future); - AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); - caller.setCallback(caller.getTarget().registerVolumeCallback(null, null)); - caller.setContext(context); + try { + CreateVolumeContext context = new CreateVolumeContext(null, volumeOnStore, + future); + AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); + caller.setCallback(caller.getTarget().registerVolumeCallback(null, null)); + caller.setContext(context); - store.getDriver().createAsync(store, volumeOnStore, caller); + store.getDriver().createAsync(store, volumeOnStore, caller); + } catch (CloudRuntimeException ex) { + // clean up already persisted volume_store_ref entry in case of createVolumeCallback is never called + VolumeDataStoreVO volStoreVO = _volumeStoreDao.findByStoreVolume(store.getId(), volume.getId()); + if (volStoreVO != null) { + VolumeInfo volObj = volFactory.getVolume(volume, store); + volObj.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed); + } + VolumeApiResult res = new VolumeApiResult((VolumeObject)volumeOnStore); + res.setResult(ex.getMessage()); + future.complete(res); + } return future; } diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java index d455f1e673c..89b3407b60f 100755 --- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java +++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java @@ -67,6 +67,7 @@ import com.cloud.storage.upload.UploadListener; import com.cloud.template.VirtualMachineTemplate; import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ManagerBase; +import com.cloud.utils.exception.CloudRuntimeException; @Component @Local(value = { DownloadMonitor.class }) @@ -169,8 +170,9 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor } EndPoint ep = _epSelector.select(template); if (ep == null) { - s_logger.warn("There is no secondary storage VM for downloading template to image store " + store.getName()); - return; + String errMsg = "There is no secondary storage VM for downloading template to image store " + store.getName(); + s_logger.warn(errMsg); + throw new CloudRuntimeException(errMsg); } DownloadListener dl = new DownloadListener(ep, store, template, _timer, this, dcmd, callback); From 5ccf3a90abb79eace839a8e61cf950248aa913c8 Mon Sep 17 00:00:00 2001 From: chriscameronv Date: Wed, 30 Oct 2013 14:44:56 -0600 Subject: [PATCH 10/11] switch label for VLAN to VLAN/VNI --- .../classes/resources/messages.properties | 8 +++++--- ui/dictionary.jsp | 2 ++ ui/scripts/network.js | 2 +- ui/scripts/system.js | 16 ++++++++-------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 12d2a11a294..d548527267b 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -1176,9 +1176,11 @@ label.virtual.machines=Virtual machines label.virtual.network=Virtual Network label.virtual.router=Virtual Router label.virtual.routers=Virtual Routers -label.vlan.id=VLAN ID -label.vlan.range=VLAN Range -label.vlan=VLAN +label.vlan.id=VLAN/VNI ID +label.vlan.range=VLAN/VNI Range +label.vlan=VLAN/VNI +label.vnet=VLAN/VNI +label.vnet.id=VLAN/VNI ID label.vxlan.id=VXLAN ID label.vxlan.range=VXLAN Range label.vxlan=VXLAN diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index 1bf0eab4648..ed269c8a3a0 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -1133,6 +1133,8 @@ dictionary = { 'label.use.vm.ip': '', 'label.value': '', 'label.vcdcname': '', +'label.vnet': '', +'label.vnet.id': '', 'label.vcenter.cluster': '', 'label.vcenter.datacenter': '', 'label.vcenter.datastore': '', diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 708b2f10ef1..4196b108cf3 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1151,7 +1151,7 @@ } }, vlan: { - label: 'label.vlan.id' + label: 'label.vnet.id' }, broadcasturi: { diff --git a/ui/scripts/system.js b/ui/scripts/system.js index c07f5f756cd..15959483367 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -1152,7 +1152,7 @@ label: 'label.state' }, vlan: { - label: 'VLAN Range(s)', + label: 'VLAN/VNI Range(s)', isEditable: true }, tags: { @@ -1384,7 +1384,7 @@ label: 'label.type' }, vlan: { - label: 'label.vlan.id' + label: 'label.vnet.id' }, broadcasturi: { label: 'broadcast URI' @@ -1820,13 +1820,13 @@ }, dedicatedGuestVlanRanges: { - title: 'Dedicated VLAN Ranges', + title: 'Dedicated VLAN/VNI Ranges', listView: { section: 'dedicatedGuestVlanRanges', id: 'dedicatedGuestVlanRanges', fields: { guestvlanrange: { - label: 'VLAN Range(s)' + label: 'VLAN/VNI Range(s)' }, domain: { label: 'label.domain' @@ -1851,17 +1851,17 @@ }, actions: { add: { - label: 'Dedicate VLAN Range', + label: 'Dedicate VLAN/VNI Range', messages: { notification: function(args) { - return 'Dedicate VLAN Range'; + return 'Dedicate VLAN/VNI Range'; } }, createForm: { - title: 'Dedicate VLAN Range', + title: 'Dedicate VLAN/VNI Range', fields: { vlanrange: { - label: 'VLAN Range', + label: 'VLAN/VNI Range', /* select: function(args) { var items = []; if(args.context.physicalNetworks[0].vlan != null && args.context.physicalNetworks[0].vlan.length > 0) { From eb9cfffd246267bbb5fe4befeb9afeaaf366874a Mon Sep 17 00:00:00 2001 From: Min Chen Date: Mon, 4 Nov 2013 14:26:42 -0800 Subject: [PATCH 11/11] Fix NPE due to race condition during system vm launch. --- .../org/apache/cloudstack/storage/volume/VolumeServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 86e49f97a77..5818aa8d924 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -453,6 +453,7 @@ public class VolumeServiceImpl implements VolumeService { } catch (Throwable e) { s_logger.debug("failed to create template on storage", e); templateOnPrimaryStoreObj.processEvent(Event.OperationFailed); + dataStore.create(template); // make sure that template_spool_ref entry is still present so that the second thread can acquire the lock VolumeApiResult result = new VolumeApiResult(volume); result.setResult(e.toString()); future.complete(result);