From e91dd3e653a23a357c9d1932eba94b11879b717e Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Tue, 10 Jul 2012 04:43:01 +0530 Subject: [PATCH 01/79] CS-12739:DeployvM wizard when choosing to Add a new network if user does not provide the network name then clicking on Next does nothing --- ui/index.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/index.jsp b/ui/index.jsp index fb3327f5466..af05f4a652d 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -257,7 +257,7 @@
-
+
*
From 9eebdd808d6b48e9b8d573cd4c337a3c55f17d8c Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Tue, 10 Jul 2012 15:40:14 +0530 Subject: [PATCH 02/79] CS-15475:Not showing Add GuestNetwork Tab in Network in multi zone setup of advanced and basic zones together --- ui/scripts/network.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 150ade27846..baeb9722b5a 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -197,7 +197,7 @@ label: 'label.add.guest.network', preFilter: function(args) { - var basicZoneExists = false; + var basicZoneExists = true; //Modifying the logic behind displaying the tabs depending on the networktype $.ajax({ url: createURL("listZones"), dataType: "json", @@ -206,8 +206,8 @@ if(json.listzonesresponse.zone != null && json.listzonesresponse.zone.length > 0) { zoneObjs = json.listzonesresponse.zone; $(zoneObjs).each(function() { - if(this.networktype == "Basic") { - basicZoneExists = true; + if(this.networktype == "Advanced") { + basicZoneExists = false; // For any occurence of an Advanced zone with any combination of basic zone , the add guest network tab will be displayed return false; //break each loop } }); From 374be31b63f6ea0f835495933730358380745a56 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Fri, 13 Jul 2012 12:32:38 +0530 Subject: [PATCH 03/79] CS-15572 : StartIndex handled incorrectly when switching between the various Filter by options while listing ISOs in the UI --- ui/scripts/ui/widgets/listView.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js index b01d01e18b0..60f701bcec9 100644 --- a/ui/scripts/ui/widgets/listView.js +++ b/ui/scripts/ui/widgets/listView.js @@ -1261,6 +1261,10 @@ return true; }); + $listView.find('#filterBy').bind('click',function(event) { + page = 1; //Handling the case to display more than 20 entities on a page while switching between panels + return page; + }); var search = function() { loadBody( $table, From f2bbf62d9d5d87149b5db729b902e6ba6364718a Mon Sep 17 00:00:00 2001 From: kishan Date: Wed, 18 Jul 2012 14:20:04 -0700 Subject: [PATCH 04/79] Added getUser API to get user details using API key. Services like S3 can user this API to authenticate. API is admin only. --- .../com/cloud/api/commands/GetUserCmd.java | 76 +++++++++++++++++++ api/src/com/cloud/user/AccountService.java | 2 + client/tomcatconf/commands.properties.in | 1 + .../com/cloud/user/AccountManagerImpl.java | 5 ++ .../com/cloud/user/dao/UserAccountDao.java | 1 + .../cloud/user/dao/UserAccountDaoImpl.java | 17 +++++ 6 files changed, 102 insertions(+) create mode 100644 api/src/com/cloud/api/commands/GetUserCmd.java diff --git a/api/src/com/cloud/api/commands/GetUserCmd.java b/api/src/com/cloud/api/commands/GetUserCmd.java new file mode 100644 index 00000000000..465e440a0f3 --- /dev/null +++ b/api/src/com/cloud/api/commands/GetUserCmd.java @@ -0,0 +1,76 @@ +// 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.api.commands; + +import org.apache.log4j.Logger; + +import com.cloud.api.ApiConstants; +import com.cloud.api.BaseCmd; +import com.cloud.api.Implementation; +import com.cloud.api.Parameter; +import com.cloud.api.response.UserResponse; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.user.UserAccount; + +@Implementation(description="Find user account by API key", responseObject=UserResponse.class) +public class GetUserCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(GetUserCmd.class.getName()); + + private static final String s_name = "getuserresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name=ApiConstants.API_KEY, type=CommandType.STRING, required=true, description="API key of the user") + private String apiKey; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public String getApiKey() { + return apiKey; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return 0; + } + + @Override + public void execute(){ + UserAccount result = _accountService.getUserByApiKey(getApiKey()); + if(result != null){ + UserResponse response = _responseGenerator.createUserResponse(result); + response.setResponseName(getCommandName()); + response.setResponseName(getCommandName()); + this.setResponseObject(response); + } else { + throw new InvalidParameterValueException("User with specified API key does not exist"); + } + } +} diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java index 02e9b27f0f5..53383d3c7c3 100755 --- a/api/src/com/cloud/user/AccountService.java +++ b/api/src/com/cloud/user/AccountService.java @@ -196,6 +196,8 @@ public interface AccountService { List searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException; + UserAccount getUserByApiKey(String apiKey); + void checkAccess(Account account, Domain domain) throws PermissionDeniedException; void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException; diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 08c175bbc52..28beadeef85 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -19,6 +19,7 @@ listUsers=com.cloud.api.commands.ListUsersCmd;7 ####lockUser=com.cloud.api.commands.LockUserCmd;7 disableUser=com.cloud.api.commands.DisableUserCmd;7 enableUser=com.cloud.api.commands.EnableUserCmd;7 +getUser=com.cloud.api.commands.GetUserCmd;1 #### Domain commands createDomain=com.cloud.api.commands.CreateDomainCmd;1 diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index e66b886839d..0a11dc4d884 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -2225,4 +2225,9 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag } } + + @Override + public UserAccount getUserByApiKey(String apiKey) { + return _userAccountDao.getUserByApiKey(apiKey); + } } diff --git a/server/src/com/cloud/user/dao/UserAccountDao.java b/server/src/com/cloud/user/dao/UserAccountDao.java index f0907192c46..eb4e0cdf517 100644 --- a/server/src/com/cloud/user/dao/UserAccountDao.java +++ b/server/src/com/cloud/user/dao/UserAccountDao.java @@ -23,4 +23,5 @@ import com.cloud.utils.db.GenericDao; public interface UserAccountDao extends GenericDao { UserAccount getUserAccount(String username, Long domainId); boolean validateUsernameInDomain(String username, Long domainId); + UserAccount getUserByApiKey(String apiKey); } diff --git a/server/src/com/cloud/user/dao/UserAccountDaoImpl.java b/server/src/com/cloud/user/dao/UserAccountDaoImpl.java index 5cc7434c886..663e58fba4f 100644 --- a/server/src/com/cloud/user/dao/UserAccountDaoImpl.java +++ b/server/src/com/cloud/user/dao/UserAccountDaoImpl.java @@ -21,10 +21,20 @@ import javax.ejb.Local; import com.cloud.user.UserAccount; import com.cloud.user.UserAccountVO; import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; @Local(value={UserAccountDao.class}) public class UserAccountDaoImpl extends GenericDaoBase implements UserAccountDao { + + protected final SearchBuilder userAccountSearch; + + protected UserAccountDaoImpl() { + userAccountSearch = createSearchBuilder(); + userAccountSearch.and("apiKey", userAccountSearch.entity().getApiKey(), SearchCriteria.Op.EQ); + userAccountSearch.done(); + } + @Override public UserAccount getUserAccount(String username, Long domainId) { if ((username == null) || (domainId == null)) { @@ -45,4 +55,11 @@ public class UserAccountDaoImpl extends GenericDaoBase impl } return false; } + + @Override + public UserAccount getUserByApiKey(String apiKey) { + SearchCriteria sc = userAccountSearch.create(); + sc.setParameters("apiKey",apiKey); + return findOneBy(sc); + } } From 8e648e4a98d8eaa3d8475220e53fb83c07968cc8 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Wed, 18 Jul 2012 15:45:16 -0700 Subject: [PATCH 05/79] Fixed update endpointe.url global config var --- server/src/com/cloud/configuration/Config.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index df2fc9ec741..6c0af1b0528 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -215,7 +215,7 @@ public enum Config { ApplyAllocationAlgorithmToPods("Advanced", ManagementServer.class, Boolean.class, "apply.allocation.algorithm.to.pods", "false", "If true, deployment planner applies the allocation heuristics at pods first in the given datacenter during VM resource allocation", "true,false"), VmUserDispersionWeight("Advanced", ManagementServer.class, Float.class, "vm.user.dispersion.weight", "1", "Weight for user dispersion heuristic (as a value between 0 and 1) applied to resource allocation during vm deployment. Weight for capacity heuristic will be (1 - weight of user dispersion)", null), VmAllocationAlgorithm("Advanced", ManagementServer.class, String.class, "vm.allocation.algorithm", "random", "'random', 'firstfit', 'userdispersing', 'userconcentratedpod_random', 'userconcentratedpod_firstfit' : Order in which hosts within a cluster will be considered for VM/volume allocation.", null), - EndpointeUrl("Advanced", ManagementServer.class, String.class, "endpointe.url", "http://localhost:8080/client/api", "Endpointe Url", "The endpoint callback URL"), + EndpointeUrl("Advanced", ManagementServer.class, String.class, "endpointe.url", "http://localhost:8080/client/api", "Endpointe Url", null), ElasticLoadBalancerEnabled("Advanced", ManagementServer.class, String.class, "network.loadbalancer.basiczone.elb.enabled", "false", "Whether the load balancing service is enabled for basic zones", "true,false"), ElasticLoadBalancerNetwork("Advanced", ManagementServer.class, String.class, "network.loadbalancer.basiczone.elb.network", "guest", "Whether the elastic load balancing service public ips are taken from the public or guest network", "guest,public"), ElasticLoadBalancerVmMemory("Advanced", ManagementServer.class, Integer.class, "network.loadbalancer.basiczone.elb.vm.ram.size", "128", "Memory in MB for the elastic load balancer vm", null), From 44f289e0a6e156fca459c693ab80d13acc4b339c Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Thu, 19 Jul 2012 13:35:27 +0200 Subject: [PATCH 06/79] debian: Do not depend on the cloud-daemonize package We are in the process of removing this from all packages and files --- debian/control | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index 1ffb93728e4..db717a48114 100644 --- a/debian/control +++ b/debian/control @@ -123,7 +123,7 @@ Provides: vmops-agent Conflicts: vmops-agent Replaces: vmops-agent Architecture: any -Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-agent-deps (= ${source:Version}), python, cloud-python (= ${source:Version}), cloud-agent-libs (= ${source:Version}), cloud-agent-scripts (= ${source:Version}), libcommons-httpclient-java, libcommons-collections-java, libcommons-dbcp-java, libcommons-pool-java, libcommons-logging-java, libvirt0, cloud-daemonize, sysvinit-utils, chkconfig, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, ebtables, vlan, libcglib-java, libcommons-httpclient-java, libservlet2.5-java, liblog4j1.2-java, libjna-java, wget +Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-agent-deps (= ${source:Version}), python, cloud-python (= ${source:Version}), cloud-agent-libs (= ${source:Version}), cloud-agent-scripts (= ${source:Version}), libcommons-httpclient-java, libcommons-collections-java, libcommons-dbcp-java, libcommons-pool-java, libcommons-logging-java, libvirt0, sysvinit-utils, chkconfig, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, ebtables, vlan, libcglib-java, libcommons-httpclient-java, libservlet2.5-java, liblog4j1.2-java, libjna-java, wget Description: CloudStack agent The CloudStack agent is in charge of managing shared computing resources in a CloudStack Cloud Stack-powered cloud. Install this package if this computer @@ -141,7 +141,7 @@ Provides: vmops-usage Conflicts: vmops-usage Replaces: vmops-usage Architecture: any -Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-deps (= ${source:Version}), cloud-server (= ${source:Version}), cloud-daemonize (= ${source:Version}), cloud-setup (= ${source:Version}), cloud-client (= ${source:Version}) +Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-deps (= ${source:Version}), cloud-server (= ${source:Version}), cloud-setup (= ${source:Version}), cloud-client (= ${source:Version}) Description: CloudStack usage monitor The CloudStack usage monitor provides usage accounting across the entire cloud for cloud operators to charge based on usage parameters. @@ -149,6 +149,6 @@ Description: CloudStack usage monitor Package: cloud-cli Provides: cloud-cli Architecture: any -Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-deps (= ${source:Version}), cloud-server (= ${source:Version}), cloud-daemonize (= ${source:Version}), cloud-setup (= ${source:Version}), cloud-client (= ${source:Version}) +Depends: openjdk-6-jre, cloud-utils (= ${source:Version}), cloud-core (= ${source:Version}), cloud-deps (= ${source:Version}), cloud-server (= ${source:Version}), cloud-setup (= ${source:Version}), cloud-client (= ${source:Version}) Description: CloudStack commandline tool The CloudStack commandline tool for invoking APi From 308cb36066b155eb720381cbaedeb051235938a6 Mon Sep 17 00:00:00 2001 From: Chiradeep Vittal Date: Thu, 19 Jul 2012 16:35:45 -0700 Subject: [PATCH 07/79] Unnecessary INFO log cluttering up the logs. Also make logs more informative --- .../storage/upload/UploadMonitorImpl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java index 25ada43f49d..891d44f8912 100755 --- a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java +++ b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java @@ -437,8 +437,6 @@ public class UploadMonitorImpl implements UploadMonitor { @Override public void run() { try { - s_logger.info("Extract Monitor Garbage Collection Thread is running."); - GlobalLock scanLock = GlobalLock.getInternLock("uploadmonitor.storageGC"); try { if (scanLock.lock(3)) { @@ -476,24 +474,26 @@ public class UploadMonitorImpl implements UploadMonitor { if( getTimeDiff(extractJob.getLastUpdated()) > EXTRACT_URL_LIFE_LIMIT_IN_SECONDS ){ String path = extractJob.getInstallPath(); HostVO secStorage = ApiDBUtils.findHostById(extractJob.getHostId()); - s_logger.debug("Sending deletion of extract URL "+extractJob.getUploadUrl()); + // Would delete the symlink for the Type and if Type == VOLUME then also the volume DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(path, extractJob.getType(),extractJob.getUploadUrl(), secStorage.getParent()); HostVO ssvm = _ssvmMgr.pickSsvmHost(secStorage); if( ssvm == null ) { - s_logger.warn("There is no secondary storage VM for secondary storage host " + extractJob.getHostId()); - continue; + s_logger.warn("UploadMonitor cleanup: There is no secondary storage VM for secondary storage host " + extractJob.getHostId()); + continue; //TODO: why continue? why not break? + } + if (s_logger.isDebugEnabled()) { + s_logger.debug("UploadMonitor cleanup: Sending deletion of extract URL "+ extractJob.getUploadUrl() + " to ssvm " + ssvm.getId()); } - try { - send(ssvm.getId(), cmd, null); + send(ssvm.getId(), cmd, null); //TODO: how do you know if it was successful? _uploadDao.remove(extractJob.getId()); } catch (AgentUnavailableException e) { - s_logger.warn("Unable to delete the link for " +extractJob.getType()+ " id=" +extractJob.getTypeId()+ " url="+extractJob.getUploadUrl(), e); + s_logger.warn("UploadMonitor cleanup: Unable to delete the link for " + extractJob.getType()+ " id=" + extractJob.getTypeId()+ " url="+ extractJob.getUploadUrl() + " on ssvm " + ssvm.getId(), e); } } } } - + } From 3631e7a1d2858d37023cc719432a93c756a0b0b6 Mon Sep 17 00:00:00 2001 From: David Nalley Date: Fri, 20 Jul 2012 13:49:56 -0400 Subject: [PATCH 08/79] cleaning up some last license header files in agent-simulator --- .../db/create-schema-simulator.sql | 28 +++++++++++-------- .../zucchini/zucchini.configuration.sql | 28 +++++++++++-------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/agent-simulator/db/create-schema-simulator.sql b/agent-simulator/db/create-schema-simulator.sql index bae65ee1c34..0b3a820b92d 100644 --- a/agent-simulator/db/create-schema-simulator.sql +++ b/agent-simulator/db/create-schema-simulator.sql @@ -1,15 +1,19 @@ -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by 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. -# -# Automatically generated by addcopyright.py at 04/03/2012 +# 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. DROP TABLE IF EXISTS `cloud`.`mockhost`; DROP TABLE IF EXISTS `cloud`.`mocksecstorage`; DROP TABLE IF EXISTS `cloud`.`mockstoragepool`; diff --git a/agent-simulator/scripts/zucchini/zucchini.configuration.sql b/agent-simulator/scripts/zucchini/zucchini.configuration.sql index 6a267be52ab..f2c492ea189 100644 --- a/agent-simulator/scripts/zucchini/zucchini.configuration.sql +++ b/agent-simulator/scripts/zucchini/zucchini.configuration.sql @@ -1,15 +1,19 @@ -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by 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. -# -# Automatically generated by addcopyright.py at 04/03/2012 +# 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. update configuration set value='pod' where name='network.dns.basiczone.updates'; update configuration set value='false' where name='use.user.concentrated.pod.allocation'; From 50da77c63fafb3478d47720869d861e07b26a45a Mon Sep 17 00:00:00 2001 From: David Nalley Date: Fri, 20 Jul 2012 13:51:56 -0400 Subject: [PATCH 09/79] cleaning up one remaining license header issue in api --- .../cloud/api/BaseListTaggedResourcesCmd.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/api/src/com/cloud/api/BaseListTaggedResourcesCmd.java b/api/src/com/cloud/api/BaseListTaggedResourcesCmd.java index 9a70b107089..1894fba8bb4 100644 --- a/api/src/com/cloud/api/BaseListTaggedResourcesCmd.java +++ b/api/src/com/cloud/api/BaseListTaggedResourcesCmd.java @@ -1,15 +1,19 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. +// 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 // -// Automatically generated by addcopyright.py at 04/03/2012 +// 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.api; import java.util.Collection; From bacb50d1bac59929aabc569cc71bdc22bae31577 Mon Sep 17 00:00:00 2001 From: David Nalley Date: Fri, 20 Jul 2012 13:58:48 -0400 Subject: [PATCH 10/79] cleaning up last license headers in build --- build/deploy/production/db/templates-dev.sql | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/build/deploy/production/db/templates-dev.sql b/build/deploy/production/db/templates-dev.sql index b673e44443e..2a96750e707 100644 --- a/build/deploy/production/db/templates-dev.sql +++ b/build/deploy/production/db/templates-dev.sql @@ -1,15 +1,19 @@ -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by 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. -# -# Automatically generated by addcopyright.py at 04/03/2012 +# 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. INSERT INTO `vmops`.`vm_template` (id, unique_name, name, public, path, created, type, hvm, bits, created_by, url, checksum, ready, display_text, enable_password) VALUES (1, 'routing', 'DomR Template', 0, 'tank/volumes/demo/template/private/u000000/os/routing', now(), 'ext3', 0, 64, 1, 'http://vmopsserver.lab.vmops.com/images/routing/vmi-root-fc8-x86_64-domR.img.bz2', 'd00927f863a23b98cc6df6e377c9d0c6', 0, 'DomR Template', 0); INSERT INTO `vmops`.`vm_template` (id, unique_name, name, public, path, created, type, hvm, bits, created_by, url, checksum, ready, display_text, enable_password) From 385f2e7923c13fc207444d2eaeac9d8fcb4d9894 Mon Sep 17 00:00:00 2001 From: David Nalley Date: Fri, 20 Jul 2012 14:02:24 -0400 Subject: [PATCH 11/79] cleaning up a few last license headers in client --- .../SYSCONFDIR/init.d/cloud-management.in | 27 +++++++++++-------- .../SYSCONFDIR/init.d/cloud-management.in | 27 +++++++++++-------- .../SYSCONFDIR/init.d/cloud-management.in | 27 +++++++++++-------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/client/distro/opensuse/SYSCONFDIR/init.d/cloud-management.in b/client/distro/opensuse/SYSCONFDIR/init.d/cloud-management.in index 52eb3aa4746..d071b39d2e7 100755 --- a/client/distro/opensuse/SYSCONFDIR/init.d/cloud-management.in +++ b/client/distro/opensuse/SYSCONFDIR/init.d/cloud-management.in @@ -2,17 +2,22 @@ # # /etc/init.d/tomcat6 -- startup script for the Tomcat 6 servlet engine -#Copyright 2012 Citrix Systems, Inc. Licensed under the -#Apache License, Version 2.0 (the "License"); you may not use this -#file except in compliance with the License. Citrix Systems, Inc. -#reserves all rights not expressly granted by 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. - +# 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. ### BEGIN INIT INFO # Provides: tomcat-vmops # Required-Start: $local_fs $remote_fs $network diff --git a/client/distro/sles/SYSCONFDIR/init.d/cloud-management.in b/client/distro/sles/SYSCONFDIR/init.d/cloud-management.in index 52eb3aa4746..d071b39d2e7 100755 --- a/client/distro/sles/SYSCONFDIR/init.d/cloud-management.in +++ b/client/distro/sles/SYSCONFDIR/init.d/cloud-management.in @@ -2,17 +2,22 @@ # # /etc/init.d/tomcat6 -- startup script for the Tomcat 6 servlet engine -#Copyright 2012 Citrix Systems, Inc. Licensed under the -#Apache License, Version 2.0 (the "License"); you may not use this -#file except in compliance with the License. Citrix Systems, Inc. -#reserves all rights not expressly granted by 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. - +# 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. ### BEGIN INIT INFO # Provides: tomcat-vmops # Required-Start: $local_fs $remote_fs $network diff --git a/client/distro/ubuntu/SYSCONFDIR/init.d/cloud-management.in b/client/distro/ubuntu/SYSCONFDIR/init.d/cloud-management.in index 2711ffc6db9..b4f2d3e0312 100755 --- a/client/distro/ubuntu/SYSCONFDIR/init.d/cloud-management.in +++ b/client/distro/ubuntu/SYSCONFDIR/init.d/cloud-management.in @@ -2,17 +2,22 @@ # # /etc/init.d/tomcat6 -- startup script for the Tomcat 6 servlet engine -#Copyright 2012 Citrix Systems, Inc. Licensed under the -#Apache License, Version 2.0 (the "License"); you may not use this -#file except in compliance with the License. Citrix Systems, Inc. -#reserves all rights not expressly granted by 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. - +# 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. ### BEGIN INIT INFO # Provides: tomcat-vmops # Required-Start: $local_fs $remote_fs $network From 7c62865090ea1bff317e5e63f1c495b86eab7046 Mon Sep 17 00:00:00 2001 From: David Nalley Date: Fri, 20 Jul 2012 14:07:32 -0400 Subject: [PATCH 12/79] additional copy of license not needed --- daemonize/COPYING | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 daemonize/COPYING diff --git a/daemonize/COPYING b/daemonize/COPYING deleted file mode 100644 index db2569eea6d..00000000000 --- a/daemonize/COPYING +++ /dev/null @@ -1,16 +0,0 @@ -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. From 2f6cef64022b6d45ba745d2e7b5c6ab612bb7ec8 Mon Sep 17 00:00:00 2001 From: David Nalley Date: Fri, 20 Jul 2012 14:09:16 -0400 Subject: [PATCH 13/79] fixing license statement in debian --- debian/copyright | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/debian/copyright b/debian/copyright index cee717125ad..13a83393a91 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,10 +1,16 @@ -Copyright 2012 Citrix Systems, Inc. Licensed under the -Apache License, Version 2.0 (the "License"); you may not use this -file except in compliance with the License. Citrix Systems, Inc. -reserves all rights not expressly granted by 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. +# 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. From 67bc9c819ada18ffdba1081377bcb6e2afdf56f6 Mon Sep 17 00:00:00 2001 From: David Nalley Date: Fri, 20 Jul 2012 15:59:31 -0400 Subject: [PATCH 14/79] fixing some more license headers --- .../debian/config/root/savepassword.sh | 29 ++++++++++--------- .../commands/AddNetscalerLoadBalancerCmd.java | 17 ++++++----- .../ConfigureNetscalerLoadBalancerCmd.java | 16 +++++----- .../DeleteNetscalerLoadBalancerCmd.java | 17 ++++++----- .../ListNetscalerLoadBalancerNetworksCmd.java | 16 +++++----- .../ListNetscalerLoadBalancersCmd.java | 16 +++++----- .../allocator/RandomStoragePoolAllocator.java | 17 ++++++----- .../server/auth/LDAPUserAuthenticator.java | 17 ++++++----- .../server/auth/MD5UserAuthenticator.java | 27 +++++++++-------- .../auth/PlainTextUserAuthenticator.java | 17 ++++++----- 10 files changed, 108 insertions(+), 81 deletions(-) diff --git a/patches/systemvm/debian/config/root/savepassword.sh b/patches/systemvm/debian/config/root/savepassword.sh index c2c89e2b318..80a6928df0e 100755 --- a/patches/systemvm/debian/config/root/savepassword.sh +++ b/patches/systemvm/debian/config/root/savepassword.sh @@ -1,17 +1,20 @@ #!/bin/bash -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by 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. -# -# Automatically generated by addcopyright.py at 04/03/2012 - +# 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. diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java index 283293f4db5..1a88de2cb6c 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java +++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java @@ -1,15 +1,18 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 + package com.cloud.api.commands; import org.apache.log4j.Logger; diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java index f5633a34c5d..de1a7c84ef5 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java +++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java @@ -1,15 +1,17 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 package com.cloud.api.commands; import java.util.List; diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java index a2cb54058e0..b063fdf6396 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java +++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java @@ -1,15 +1,18 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 + package com.cloud.api.commands; import org.apache.log4j.Logger; diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java index 909956048d3..c0c5950d57e 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java +++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java @@ -1,15 +1,17 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 package com.cloud.api.commands; import java.util.ArrayList; diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancersCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancersCmd.java index daca1112de0..98fe6e95df7 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancersCmd.java +++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancersCmd.java @@ -1,15 +1,17 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 package com.cloud.api.commands; import java.util.ArrayList; diff --git a/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java b/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java index def048e792f..919270349a9 100644 --- a/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java +++ b/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java @@ -1,15 +1,18 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 + package com.cloud.storage.allocator; import java.util.ArrayList; diff --git a/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java b/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java index 8a056cc4545..7c6e52f6659 100644 --- a/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java +++ b/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java @@ -1,15 +1,18 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// package com.cloud.server.auth; import java.util.HashMap; diff --git a/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java b/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java index 2aec4a7937f..5c5d21fe08f 100644 --- a/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java +++ b/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java @@ -1,15 +1,18 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 +// 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.server.auth; import java.util.Map; diff --git a/plugins/user-authenticators/plain-text/src/com/cloud/server/auth/PlainTextUserAuthenticator.java b/plugins/user-authenticators/plain-text/src/com/cloud/server/auth/PlainTextUserAuthenticator.java index f05a8cd815f..006daf98e9b 100644 --- a/plugins/user-authenticators/plain-text/src/com/cloud/server/auth/PlainTextUserAuthenticator.java +++ b/plugins/user-authenticators/plain-text/src/com/cloud/server/auth/PlainTextUserAuthenticator.java @@ -1,15 +1,18 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by the License. -// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 + package com.cloud.server.auth; import java.math.BigInteger; From 152b17b7f399acc0667845a137f3a4610292f774 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Fri, 20 Jul 2012 14:05:44 -0700 Subject: [PATCH 15/79] Remove dummy VPC UI from networks section --- ui/scripts/network.js | 87 +------------------------------------------ 1 file changed, 1 insertion(+), 86 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 6699d163d97..ed621d07092 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -177,7 +177,7 @@ } }); - var sectionsToShow = ['networks', 'vpc']; + var sectionsToShow = ['networks']; if(havingSecurityGroupNetwork == true) sectionsToShow.push('securityGroups'); @@ -3179,91 +3179,6 @@ } } } - }, - vpc: { - type: 'select', - title: 'VPC', - id: 'vpc', - listView: { - id: 'vpc', - label: 'VPC', - fields: { - name: { label: 'Name' }, - zone: { label: 'Zone' }, - cidr: { label: 'CIDR' } - }, - dataProvider: function(args) { - args.response.success({ - data: [ - { - name: 'VPC 1', - zone: 'San Jose', - cidr: '0.0.0.0/0', - networkdomain: 'testdomain', - accountdomain: 'testdomain' - }, - { - name: 'VPC 2', - zone: 'San Jose', - cidr: '0.0.0.0/0', - networkdomain: 'testdomain', - accountdomain: 'testdomain' - }, - { - name: 'VPC 3', - zone: 'Cupertino', - cidr: '0.0.0.0/0', - networkdomain: 'testdomain', - accountdomain: 'testdomain' - }, - { - name: 'VPC 4', - zone: 'San Jose', - cidr: '0.0.0.0/0', - networkdomain: 'testdomain', - accountdomain: 'testdomain' - } - ] - }); - }, - actions: { - add: { - label: 'Add VPC', - createForm: { - title: 'Add new VPC', - fields: { - name: { label: 'Name', validation: { required: true } }, - zone: { - label: 'Zone', - validation: { required: true }, - select: function(args) { - args.response.success({ - data: [ - { id: 'zone1', description: 'Zone 1' }, - { id: 'zone2', description: 'Zone 2' }, - { id: 'zone3', description: 'Zone 3' } - ] - }); - } - } - } - }, - messages: { - notification: function(args) { return 'Add new VPC'; } - }, - action: function(args) { - args.response.success(); - }, - notification: { poll: function(args) { args.complete(); } } - }, - editVpc: { - label: 'Edit VPC', - action: { - custom: cloudStack.uiCustom.vpc(cloudStack.vpc) - } - } - } - } } } }; From 9b4c578e0d10afb600c7aa1e63bddb93a7a02de8 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Wed, 18 Jul 2012 10:59:07 -0700 Subject: [PATCH 16/79] More logging on nic release --- .../src/com/cloud/network/guru/ControlNetworkGuru.java | 9 +++++++++ .../src/com/cloud/network/guru/PodBasedNetworkGuru.java | 4 ++++ server/src/com/cloud/network/guru/PublicNetworkGuru.java | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/server/src/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/com/cloud/network/guru/ControlNetworkGuru.java index 6cbed8dffc2..ec8887f340c 100755 --- a/server/src/com/cloud/network/guru/ControlNetworkGuru.java +++ b/server/src/com/cloud/network/guru/ControlNetworkGuru.java @@ -173,9 +173,15 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu DataCenterVO dcVo = _dcDao.findById(dcId); if(dcVo.getNetworkType() != NetworkType.Basic) { super.release(nic, vm, reservationId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Released nic: " + nic); + } return true; } else { nic.deallocate(); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Released nic: " + nic); + } return true; } } @@ -183,6 +189,9 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu _dcDao.releaseLinkLocalIpAddress(nic.getId(), reservationId); nic.deallocate(); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Released nic: " + nic); + } return true; } diff --git a/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java b/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java index 12f23cca99b..b513325d5ee 100755 --- a/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java +++ b/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java @@ -149,6 +149,10 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru { nic.deallocate(); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Released nic: " + nic); + } + return true; } diff --git a/server/src/com/cloud/network/guru/PublicNetworkGuru.java b/server/src/com/cloud/network/guru/PublicNetworkGuru.java index 46477f375d4..f23ff9af950 100755 --- a/server/src/com/cloud/network/guru/PublicNetworkGuru.java +++ b/server/src/com/cloud/network/guru/PublicNetworkGuru.java @@ -198,6 +198,10 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { txn.commit(); } nic.deallocate(); + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Deallocated nic: " + nic); + } } @Override From 4c6e547e701790e8f0330fb872f6d18ec76ba7b3 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Fri, 20 Jul 2012 18:20:14 -0700 Subject: [PATCH 17/79] create devcloud base image from veewee --- tools/devcloud/veewee/README | 5 ++ tools/devcloud/veewee/definition.rb | 56 +++++++++++++ tools/devcloud/veewee/preseed.cfg | 122 ++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 tools/devcloud/veewee/README create mode 100644 tools/devcloud/veewee/definition.rb create mode 100644 tools/devcloud/veewee/preseed.cfg diff --git a/tools/devcloud/veewee/README b/tools/devcloud/veewee/README new file mode 100644 index 00000000000..c9299e504b4 --- /dev/null +++ b/tools/devcloud/veewee/README @@ -0,0 +1,5 @@ +Install DevCloud Base system: +1. get code from https://github.com/jedi4ever/veewee, and install +2. veewee vbox define devcloud ubuntu-12.04-server-i386 +3. put these two files(definition.rb and preseed.cfg) under ./definition/devcloud/ +3. veewee vbox build devcloud diff --git a/tools/devcloud/veewee/definition.rb b/tools/devcloud/veewee/definition.rb new file mode 100644 index 00000000000..d025ce9a4ea --- /dev/null +++ b/tools/devcloud/veewee/definition.rb @@ -0,0 +1,56 @@ +# 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. + + +Veewee::Session.declare({ + :cpu_count => '1', + :memory_size=> '2048', + :disk_size => '20000', + :disk_format => 'VMDK', + :hostiocache => 'off', + :os_type_id => 'Ubuntu', + :iso_file => "ubuntu-12.04-server-i386.iso", + :iso_src => "http://releases.ubuntu.com/12.04/ubuntu-12.04-server-i386.iso", + :iso_md5 => '32184a83c8b5e6031e1264e5c499bc03', + :iso_download_timeout => "1000", + :boot_wait => "4", + :ioapic => "on", + :nestedpaging => "on", + :hwvirtex => "on", + :boot_cmd_sequence => [ + '', + '/install/vmlinuz noapic preseed/url=http://%IP%:%PORT%/preseed.cfg ', + 'debian-installer=en_US auto locale=en_US kbd-chooser/method=us ', + 'hostname=%NAME% ', + 'fb=false debconf/frontend=noninteractive ', + 'keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false ', + 'initrd=/install/initrd.gz -- ' +], + :kickstart_port => "7122", + :kickstart_timeout => "10000", + :kickstart_file => "preseed.cfg", + :ssh_login_timeout => "10000", + :ssh_user => "devcloud", + :ssh_password => "devcloud", + :ssh_key => "", + :ssh_host_port => "2222", + :ssh_guest_port => "22", + :sudo_cmd => "echo '%p'|sudo -S sh '%f'", + :shutdown_cmd => "shutdown -P now", + :postinstall_files => [ "postinstall.sh"], + :postinstall_timeout => "10000" +}) diff --git a/tools/devcloud/veewee/preseed.cfg b/tools/devcloud/veewee/preseed.cfg new file mode 100644 index 00000000000..4a97171e76f --- /dev/null +++ b/tools/devcloud/veewee/preseed.cfg @@ -0,0 +1,122 @@ +# 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. + +## Options to set on the command line +d-i debian-installer/locale string en_US.utf8 +d-i console-setup/ask_detect boolean false +d-i console-setup/layout string USA + +#d-i netcfg/get_hostname string dummy +d-i netcfg/get_hostname string devcloud +d-i netcfg/get_domain string cloudstack.org + +# Continue without a default route +# Not working , specify a dummy in the DHCP +#d-i netcfg/no_default_route boolean + +d-i time/zone string UTC +d-i clock-setup/utc-auto boolean true +d-i clock-setup/utc boolean true + +d-i kbd-chooser/method select American English + +d-i netcfg/wireless_wep string + +d-i base-installer/kernel/override-image string linux-server +#d-i base-installer/kernel/override-image string linux-image-2.6.32-21-generic + +# Choices: Dialog, Readline, Gnome, Kde, Editor, Noninteractive +d-i debconf debconf/frontend select Noninteractive + +d-i pkgsel/install-language-support boolean false +tasksel tasksel/first multiselect standard, ubuntu-server + +#d-i partman-auto/method string regular +d-i partman-auto/method string lvm +d-i partman-auto-lvm/no_boot boolean true +d-i partman-auto/disk string /dev/sda +d-i partman-auto-lvm/new_vg_name string devcloud +d-i partman-auto/purge_lvm_from_device boolean true +d-i partman-basicfilesystems/no_swap boolean false + +d-i partman-lvm/confirm boolean true +d-i partman-lvm/device_remove_lvm boolean true +d-i partman-auto/choose_recipe select devcloud + +d-i partman/confirm_write_new_label boolean true +d-i partman/confirm_nooverwrite boolean true +d-i partman/choose_partition select finish +d-i partman/confirm boolean true +d-i partman-auto/expert_recipe string \ +devcloud :: \ +4000 4500 4500 ext4 method{ lvm } \ +$lvmok{ } mountpoint{ / } lv_name{ root } \ +format{ } use_filesystem{ } filesystem{ ext4 } \ +.\ +15000 15000 15000 ext4 method{ lvm } \ +$lvmok{ } mountpoint{ /opt } lv_name{ data } \ +format{ } use_filesystem{ } filesystem{ ext4 } \ +. + +#http://ubuntu-virginia.ubuntuforums.org/showthread.php?p=9626883 +#Message: "write the changes to disk and configure lvm preseed" +#http://serverfault.com/questions/189328/ubuntu-kickstart-installation-using-lvm-waits-for-input +#preseed partman-lvm/confirm_nooverwrite boolean true + +# Write the changes to disks and configure LVM? +d-i partman-lvm/confirm boolean true +d-i partman-lvm/confirm_nooverwrite boolean true +d-i partman-partitioning/confirm_write_new_label boolean true +d-i partman/choose_partition select Finish +d-i partman/confirm_nooverwrite boolean true +d-i partman/confirm boolean true +d-i partman-auto-lvm/guided_size string max + +## Default user, we can get away with a recipe to change this +d-i passwd/user-fullname string devcloud +d-i passwd/username string devcloud +d-i passwd/user-password password devcloud +d-i passwd/user-password-again password devcloud +d-i user-setup/encrypt-home boolean false +d-i user-setup/allow-password-weak boolean true + +## minimum is puppet and ssh and ntp +# Individual additional packages to install +d-i pkgsel/include string openssh-server ntp + +# Whether to upgrade packages after debootstrap. +# Allowed values: none, safe-upgrade, full-upgrade +d-i pkgsel/upgrade select full-upgrade + +d-i grub-installer/only_debian boolean true +d-i grub-installer/with_other_os boolean true +d-i finish-install/reboot_in_progress note + +#For the update +d-i pkgsel/update-policy select none + +# debconf-get-selections --install +#Use mirror +#d-i apt-setup/use_mirror boolean true +#d-i mirror/country string manual +#choose-mirror-bin mirror/protocol string http +#choose-mirror-bin mirror/http/hostname string 192.168.4.150 +#choose-mirror-bin mirror/http/directory string /ubuntu +#choose-mirror-bin mirror/suite select maverick +#d-i debian-installer/allow_unauthenticated string true + +choose-mirror-bin mirror/http/proxy string From 65551cff82b646911bccdb3764951e65a9684e42 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 23 Jul 2012 10:32:56 -0700 Subject: [PATCH 18/79] Resource tags: CS-15647 - delete resource tags when SG is expunged --- .../network/security/dao/SecurityGroupDaoImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java index 0c9bdc57995..81c20e3ccdb 100644 --- a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java +++ b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java @@ -113,5 +113,19 @@ public class SecurityGroupDaoImpl extends GenericDaoBase boolean result = super.remove(id); txn.commit(); return result; + } + + @Override + @DB + public boolean expunge(Long id) { + Transaction txn = Transaction.currentTxn(); + txn.start(); + SecurityGroupVO entry = findById(id); + if (entry != null) { + _tagsDao.removeByIdAndType(id, TaggedResourceType.SecurityGroup); + } + boolean result = super.expunge(id); + txn.commit(); + return result; } } From 7bef9a961d968e4187d1bf843404b29992c21a67 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 23 Jul 2012 10:50:21 -0700 Subject: [PATCH 19/79] Resource tags: CS-15661 - don't accept NULL or empty key value when create resource tag --- api/src/com/cloud/api/commands/CreateTagsCmd.java | 1 + .../com/cloud/tags/TaggedResourceManagerImpl.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/api/commands/CreateTagsCmd.java b/api/src/com/cloud/api/commands/CreateTagsCmd.java index f87ae6e96d8..a981363cc89 100644 --- a/api/src/com/cloud/api/commands/CreateTagsCmd.java +++ b/api/src/com/cloud/api/commands/CreateTagsCmd.java @@ -33,6 +33,7 @@ import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.SuccessResponse; import com.cloud.event.EventTypes; +import com.cloud.exception.InvalidParameterValueException; import com.cloud.server.ResourceTag; import com.cloud.server.ResourceTag.TaggedResourceType; diff --git a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java index f79eba4a17f..84a26924a71 100644 --- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java +++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java @@ -233,7 +233,7 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager Transaction txn = Transaction.currentTxn(); txn.start(); - for (String tag : tags.keySet()) { + for (String key : tags.keySet()) { for (String resourceId : resourceIds) { Long id = getResourceId(resourceId, resourceType); String resourceUuid = getUuid(resourceId, resourceType); @@ -254,10 +254,16 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager _accountMgr.checkAccess(caller, _domainMgr.getDomain(domainId)); } else { throw new PermissionDeniedException("Account " + caller + " doesn't have permissions to create tags" + - " for resource " + tag); + " for resource " + key); + } + + String value = tags.get(key); + + if (value == null || value.isEmpty()) { + throw new InvalidParameterValueException("Value for the key " + key + " is either null or empty"); } - ResourceTagVO resourceTag = new ResourceTagVO(tag, tags.get(tag), accountDomainPair.first(), + ResourceTagVO resourceTag = new ResourceTagVO(key, value, accountDomainPair.first(), accountDomainPair.second(), id, resourceType, customer, resourceUuid); resourceTag = _resourceTagDao.persist(resourceTag); From 9e5fb17e3d1caed094dd962029b206294618303d Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 23 Jul 2012 11:16:11 -0700 Subject: [PATCH 20/79] CS-15077: fixed listPublicIpAddresses in basic zone Conflicts: server/src/com/cloud/api/ApiResponseHelper.java server/src/com/cloud/server/ManagementServerImpl.java --- .../src/com/cloud/api/ApiResponseHelper.java | 4 ++- .../cloud/server/ManagementServerImpl.java | 35 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 4c88e2b2be6..433d2637e52 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -760,7 +760,9 @@ public class ApiResponseHelper implements ResponseGenerator { ipResponse.setIsSystem(ipAddress.getSystem()); // get account information - populateOwner(ipResponse, ipAddress); + if (ipAddress.getAllocatedToAccountId() != null) { + populateOwner(ipResponse, ipAddress); + } ipResponse.setForVirtualNetwork(forVirtualNetworks); ipResponse.setStaticNat(ipAddress.isOneToOneNat()); diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 93c2f4ca2a9..047305ed249 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1691,23 +1691,30 @@ public class ManagementServerImpl implements ManagementServer { Boolean staticNat = cmd.getIsStaticNat(); Map tags = cmd.getTags(); - Account caller = UserContext.current().getCaller(); - List permittedAccounts = new ArrayList(); - + Boolean isAllocated = cmd.isAllocatedOnly(); if (isAllocated == null) { isAllocated = Boolean.TRUE; } - - Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); - _accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); - Long domainId = domainIdRecursiveListProject.first(); - Boolean isRecursive = domainIdRecursiveListProject.second(); - ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); - + Filter searchFilter = new Filter(IPAddressVO.class, "address", false, cmd.getStartIndex(), cmd.getPageSizeVal()); SearchBuilder sb = _publicIpAddressDao.createSearchBuilder(); - _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + Long domainId = null; + Boolean isRecursive = null; + List permittedAccounts = new ArrayList(); + ListProjectResourcesCriteria listProjectResourcesCriteria = null; + if (isAllocated) { + Account caller = UserContext.current().getCaller(); + + Ternary domainIdRecursiveListProject = + new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); + _accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), + permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); + domainId = domainIdRecursiveListProject.first(); + isRecursive = domainIdRecursiveListProject.second(); + listProjectResourcesCriteria = domainIdRecursiveListProject.third(); + _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + } sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); sb.and("address", sb.entity().getAddress(), SearchCriteria.Op.EQ); @@ -1760,11 +1767,13 @@ public class ManagementServerImpl implements ManagementServer { // don't show SSVM/CPVM ips if (vlanType == VlanType.VirtualNetwork && (allocatedOnly)) { - sb.and("associatedNetworkId", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.NNULL); + sb.and("associatedNetworkId", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.NNULL); } SearchCriteria sc = sb.create(); - _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + if (isAllocated) { + _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); + } sc.setJoinParameters("vlanSearch", "vlanType", vlanType); From c60e4b4a9e3b7403b8e04b2e2223f12a04463133 Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Thu, 12 Jul 2012 17:12:23 -0700 Subject: [PATCH 21/79] Adding support in AWSAPI for CloudStack API's that implement the tags feature. Verified the output of, 1. ec2-create-tags for all 4 supported ec2 resources(image, instance, volume and snapshot) with and without tag-value. 2. ec2-delete-tags for all types of created tags. 3. ec2-describe-tags with and without all supported filter. --- .../bridge/service/EC2SoapServiceImpl.java | 182 ++++++++++++++++-- .../service/core/ec2/EC2DescribeTags.java | 34 ++++ .../core/ec2/EC2DescribeTagsResponse.java | 37 ++++ .../bridge/service/core/ec2/EC2Engine.java | 105 ++++++++++ .../service/core/ec2/EC2ResourceTag.java | 64 ++++++ .../service/core/ec2/EC2TagKeyValue.java | 44 +++++ .../bridge/service/core/ec2/EC2TagTypeId.java | 47 +++++ .../bridge/service/core/ec2/EC2Tags.java | 44 +++++ .../service/core/ec2/EC2TagsFilterSet.java | 107 ++++++++++ awsapi/src/com/cloud/stack/CloudStackApi.java | 77 +++++++- .../com/cloud/stack/models/ApiConstants.java | 10 + .../stack/models/CloudStackResourceTag.java | 50 +++++ 12 files changed, 784 insertions(+), 17 deletions(-) create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTags.java create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTagsResponse.java create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2ResourceTag.java create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagKeyValue.java create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagTypeId.java create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2Tags.java create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagsFilterSet.java create mode 100644 awsapi/src/com/cloud/stack/models/CloudStackResourceTag.java diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index 9e10e0929a3..9a8e777f6dd 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -33,6 +33,7 @@ import com.cloud.bridge.service.core.ec2.EC2CreateImage; import com.cloud.bridge.service.core.ec2.EC2CreateImageResponse; import com.cloud.bridge.service.core.ec2.EC2CreateKeyPair; import com.cloud.bridge.service.core.ec2.EC2CreateVolume; +import com.cloud.bridge.service.core.ec2.EC2Tags; import com.cloud.bridge.service.core.ec2.EC2DeleteKeyPair; import com.cloud.bridge.service.core.ec2.EC2DescribeAddresses; import com.cloud.bridge.service.core.ec2.EC2DescribeAddressesResponse; @@ -46,10 +47,13 @@ import com.cloud.bridge.service.core.ec2.EC2DescribeInstances; import com.cloud.bridge.service.core.ec2.EC2DescribeInstancesResponse; import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairs; import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairsResponse; +import com.cloud.bridge.service.core.ec2.EC2ResourceTag; import com.cloud.bridge.service.core.ec2.EC2DescribeSecurityGroups; import com.cloud.bridge.service.core.ec2.EC2DescribeSecurityGroupsResponse; import com.cloud.bridge.service.core.ec2.EC2DescribeSnapshots; import com.cloud.bridge.service.core.ec2.EC2DescribeSnapshotsResponse; +import com.cloud.bridge.service.core.ec2.EC2DescribeTags; +import com.cloud.bridge.service.core.ec2.EC2DescribeTagsResponse; import com.cloud.bridge.service.core.ec2.EC2DescribeVolumes; import com.cloud.bridge.service.core.ec2.EC2DescribeVolumesResponse; import com.cloud.bridge.service.core.ec2.EC2DisassociateAddress; @@ -69,6 +73,8 @@ import com.cloud.bridge.service.core.ec2.EC2PasswordData; import com.cloud.bridge.service.core.ec2.EC2RebootInstances; import com.cloud.bridge.service.core.ec2.EC2RegisterImage; import com.cloud.bridge.service.core.ec2.EC2ReleaseAddress; +import com.cloud.bridge.service.core.ec2.EC2TagKeyValue; +import com.cloud.bridge.service.core.ec2.EC2TagTypeId; import com.cloud.bridge.service.core.ec2.EC2RunInstances; import com.cloud.bridge.service.core.ec2.EC2RunInstancesResponse; import com.cloud.bridge.service.core.ec2.EC2SSHKeyPair; @@ -79,6 +85,7 @@ import com.cloud.bridge.service.core.ec2.EC2StartInstances; import com.cloud.bridge.service.core.ec2.EC2StartInstancesResponse; import com.cloud.bridge.service.core.ec2.EC2StopInstances; import com.cloud.bridge.service.core.ec2.EC2StopInstancesResponse; +import com.cloud.bridge.service.core.ec2.EC2TagsFilterSet; import com.cloud.bridge.service.core.ec2.EC2Volume; import com.cloud.bridge.service.core.ec2.EC2VolumeFilterSet; import com.cloud.bridge.service.exception.EC2ServiceException; @@ -199,6 +206,89 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { return toCreateVolumeResponse( engine.createVolume( request )); } + public CreateTagsResponse createTags(CreateTags createTags) { + EC2Tags request = new EC2Tags(); + CreateTagsType ctt = createTags.getCreateTags(); + + ResourceIdSetType resourceIds = ctt.getResourcesSet(); + ResourceTagSetType resourceTags = ctt.getTagSet(); + request = toResourceTypeAndIds(resourceIds); + //add resource tag's to the request + if (resourceTags != null) { + ResourceTagSetItemType[] items = resourceTags.getItem(); + if (items != null) { + for( int i=0; i < items.length; i++ ) { + EC2TagKeyValue param1 = new EC2TagKeyValue(); + param1.setKey(items[i].getKey()); + param1.setValue(items[i].getValue()); + request.addResourceTag(param1); + } + } + } + return toCreateTagsResponse( engine.modifyTags( request, "create")); + } + + public DeleteTagsResponse deleteTags(DeleteTags deleteTags) { + EC2Tags request = new EC2Tags(); + DeleteTagsType dtt = deleteTags.getDeleteTags(); + + ResourceIdSetType resourceIds = dtt.getResourcesSet(); + DeleteTagsSetType resourceTags = dtt.getTagSet(); + request = toResourceTypeAndIds(resourceIds); + //add resource tag's to the request + if (resourceTags != null) { + DeleteTagsSetItemType[] items = resourceTags.getItem(); + if (items != null) { + for( int i=0; i < items.length; i++ ) { + EC2TagKeyValue param1 = new EC2TagKeyValue(); + param1.setKey(items[i].getKey()); + if (items[i].getValue() != null) + param1.setValue(items[i].getValue()); + request.addResourceTag(param1); + } + } + } + return toDeleteTagsResponse( engine.modifyTags( request, "delete")); + } + + private EC2Tags toResourceTypeAndIds(ResourceIdSetType resourceIds) { + EC2Tags request = new EC2Tags(); + //add resource-type and resource-id's to the request + if (resourceIds != null) { + ResourceIdSetItemType[] items = resourceIds.getItem(); + List resourceTypeList = new ArrayList(); + if (items != null) { + for( int i=0; i < items.length; i++ ) { + String resourceType = items[i].getResourceId().split(":")[0]; + if (resourceTypeList.isEmpty()) + resourceTypeList.add(resourceType); + else { + Boolean existsInList = false; + for (String addedResourceType : resourceTypeList) { + if (addedResourceType.equalsIgnoreCase(resourceType)) { + existsInList = true; + break; + } + } + if (!existsInList) + resourceTypeList.add(resourceType); + } + } + for (String resourceType : resourceTypeList){ + EC2TagTypeId param1 = new EC2TagTypeId(); + param1.setResourceType(resourceType); + for( int i=0; i < items.length; i++ ) { + String[] resourceTag = items[i].getResourceId().split(":"); + if (resourceType.equals(resourceTag[0])) + param1.addResourceId(resourceTag[1]); + } + request.addResourceType(param1); + } + } + } + return request; + } + public DeleteSecurityGroupResponse deleteSecurityGroup(DeleteSecurityGroup deleteSecurityGroup) { DeleteSecurityGroupType sgt = deleteSecurityGroup.getDeleteSecurityGroup(); return toDeleteSecurityGroupResponse( engine.deleteSecurityGroup( sgt.getGroupName())); @@ -434,7 +524,18 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { return toDescribeSnapshotsResponse(engine.handleRequest(request)); } - + public DescribeTagsResponse describeTags(DescribeTags decsribeTags) { + EC2DescribeTags request = new EC2DescribeTags(); + DescribeTagsType dtt = decsribeTags.getDescribeTags(); + + FilterSetType fst = dtt.getFilterSet(); + + if (fst != null) + request.setFilterSet( toTagsFilterSet( fst )); + + return toDescribeTagsResponse(engine.describeTags(request)); + } + public DescribeVolumesResponse describeVolumes(DescribeVolumes describeVolumes) { EC2DescribeVolumes request = new EC2DescribeVolumes(); @@ -1094,8 +1195,28 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { } return azfs; } - - + + private EC2TagsFilterSet toTagsFilterSet( FilterSetType fst ) { + EC2TagsFilterSet tfs = new EC2TagsFilterSet(); + + FilterType[] items = fst.getItem(); + if (items != null) { + for (FilterType item : items) { + EC2Filter oneFilter = new EC2Filter(); + String filterName = item.getName(); + oneFilter.setName( filterName ); + + ValueSetType vft = item.getValueSet(); + ValueType[] valueItems = vft.getItem(); + for (ValueType valueItem : valueItems) { + oneFilter.addValueEncoded( valueItem.getValue()); + } + tfs.addFilter( oneFilter ); + } + } + return tfs; + } + // toMethods public static DescribeVolumesResponse toDescribeVolumesResponse( EC2DescribeVolumesResponse engineResponse ) { @@ -1931,7 +2052,48 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { response.setRevokeSecurityGroupIngressResponse( param1 ); return response; } - + + public static CreateTagsResponse toCreateTagsResponse( boolean success ) { + CreateTagsResponse response = new CreateTagsResponse(); + CreateTagsResponseType param1 = new CreateTagsResponseType(); + + param1.set_return(success); + param1.setRequestId( UUID.randomUUID().toString()); + response.setCreateTagsResponse(param1); + return response; + } + + public static DeleteTagsResponse toDeleteTagsResponse( boolean success ) { + DeleteTagsResponse response = new DeleteTagsResponse(); + DeleteTagsResponseType param1 = new DeleteTagsResponseType(); + + param1.set_return(success); + param1.setRequestId( UUID.randomUUID().toString()); + response.setDeleteTagsResponse(param1); + return response; + } + + public static DescribeTagsResponse toDescribeTagsResponse( EC2DescribeTagsResponse engineResponse) { + DescribeTagsResponse response = new DescribeTagsResponse(); + DescribeTagsResponseType param1 = new DescribeTagsResponseType(); + + EC2ResourceTag[] tags = engineResponse.getTagsSet(); + TagSetType param2 = new TagSetType(); + for (EC2ResourceTag tag : tags) { + TagSetItemType param3 = new TagSetItemType(); + param3.setResourceId(tag.getResourceId()); + param3.setResourceType(tag.getResourceType()); + param3.setKey(tag.getKey()); + if (tag.getValue() != null) + param3.setValue(tag.getValue()); + param2.addItem(param3); + } + param1.setTagSet(param2); + param1.setRequestId( UUID.randomUUID().toString()); + response.setDescribeTagsResponse(param1); + return response; + } + public DescribeKeyPairsResponse describeKeyPairs(DescribeKeyPairs describeKeyPairs) { EC2DescribeKeyPairs ec2Request = new EC2DescribeKeyPairs(); @@ -2116,10 +2278,6 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { public CreateSubnetResponse createSubnet(CreateSubnet createSubnet) { throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); } - - public CreateTagsResponse createTags(CreateTags createTags) { - throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); - } public CreateVpcResponse createVpc(CreateVpc createVpc) { throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); @@ -2156,10 +2314,6 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { public DeleteSubnetResponse deleteSubnet(DeleteSubnet deleteSubnet) { throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); } - - public DeleteTagsResponse deleteTags(DeleteTags deleteTags) { - throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); - } public DeleteVpcResponse deleteVpc(DeleteVpc deleteVpc) { throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); @@ -2229,10 +2383,6 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); } - public DescribeTagsResponse describeTags(DescribeTags describeTags) { - throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); - } - public DescribeVpcsResponse describeVpcs(DescribeVpcs describeVpcs) { throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available"); } diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTags.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTags.java new file mode 100644 index 00000000000..1ce65277c75 --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTags.java @@ -0,0 +1,34 @@ +// 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.bridge.service.core.ec2; + +public class EC2DescribeTags { + + private EC2TagsFilterSet tfs = null; + + public EC2DescribeTags() { + } + + public EC2TagsFilterSet getFilterSet() { + return tfs; + } + + public void setFilterSet( EC2TagsFilterSet param ) { + tfs = param; + } +} diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTagsResponse.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTagsResponse.java new file mode 100644 index 00000000000..9559e65a373 --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeTagsResponse.java @@ -0,0 +1,37 @@ +// 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.bridge.service.core.ec2; + +import java.util.ArrayList; +import java.util.List; + +public class EC2DescribeTagsResponse { + + private List tagsSet = new ArrayList(); + + public EC2DescribeTagsResponse() { + } + + public void addTags( EC2ResourceTag param ) { + tagsSet.add( param ); + } + + public EC2ResourceTag[] getTagsSet() { + return tagsSet.toArray(new EC2ResourceTag[0]); + } +} diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index 5f4584759f9..36d2b686909 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -59,6 +59,7 @@ import com.cloud.stack.models.CloudStackNic; import com.cloud.stack.models.CloudStackOsType; import com.cloud.stack.models.CloudStackPasswordData; import com.cloud.stack.models.CloudStackResourceLimit; +import com.cloud.stack.models.CloudStackResourceTag; import com.cloud.stack.models.CloudStackSecurityGroup; import com.cloud.stack.models.CloudStackSecurityGroupIngress; import com.cloud.stack.models.CloudStackServiceOffering; @@ -1311,6 +1312,80 @@ public class EC2Engine { } } + /** + * Create/Delete tags + * + * @param request + * @param operation + * @return + */ + public boolean modifyTags( EC2Tags request, String operation) { + try { + List resourceTagList = new ArrayList(); + for ( EC2TagKeyValue resourceTag : request.getResourceTags()){ + CloudStackKeyValue pair = new CloudStackKeyValue(); + pair.setKeyValue(resourceTag.getKey(), resourceTag.getValue()); + resourceTagList.add(pair); + } + EC2TagTypeId[] resourceTypeSet = request.getResourceTypeSet(); + for (EC2TagTypeId resourceType : resourceTypeSet) { + String cloudStackResourceType = mapToCloudStackResourceType(resourceType.getResourceType()); + List resourceIdList = new ArrayList(); + for ( String resourceId : resourceType.getResourceIds()) + resourceIdList.add(resourceId); + CloudStackInfoResponse resp = new CloudStackInfoResponse(); + if (operation.equalsIgnoreCase("create")) + resp = getApi().createTags(cloudStackResourceType, resourceIdList, resourceTagList); + else if(operation.equalsIgnoreCase("delete")) + resp = getApi().deleteTags(cloudStackResourceType, resourceIdList, resourceTagList); + else + throw new EC2ServiceException( ServerError.InternalError, "Unknown operation." ); + if (resp.getSuccess() == false) + return false; + } + return true; + } catch (Exception e){ + logger.error( "EC2 Create/Delete Tags - ", e); + throw new EC2ServiceException(ServerError.InternalError, e.getMessage() != null ? + e.getMessage() : "An unexpected error occurred."); + } + } + + /** + * Describe tags + * + * @param request + * @return + */ + public EC2DescribeTagsResponse describeTags (EC2DescribeTags request) { + try { + EC2DescribeTagsResponse tagResponse = new EC2DescribeTagsResponse(); + List resourceTagList = getApi().listTags(null, null, null, true, null); + + List tagList = new ArrayList(); + if (resourceTagList != null && resourceTagList.size() > 0) { + for (CloudStackResourceTag resourceTag: resourceTagList) { + EC2ResourceTag tag = new EC2ResourceTag(); + tag.setResourceId(resourceTag.getResourceId()); + tag.setResourceType(mapToAmazonResourceType(resourceTag.getResourceType())); + tag.setKey(resourceTag.getKey()); + if (resourceTag.getValue() != null) + tag.setValue(resourceTag.getValue()); + tagResponse.addTags(tag); + } + } + + EC2TagsFilterSet tfs = request.getFilterSet(); + if (tfs == null) + return tagResponse; + else + return tfs.evaluate(tagResponse); + } catch(Exception e) { + logger.error("EC2 DescribeTags - ", e); + throw new EC2ServiceException(ServerError.InternalError, e.getMessage()); + } + } + /** * Reboot an instance or instances * @@ -2245,6 +2320,36 @@ public class EC2Engine { return "error"; } + /** + * Map Amazon resourceType to CloudStack resourceType + * + * @param Amazon resourceType + * @return CloudStack resourceType + */ + private String mapToCloudStackResourceType( String resourceType) { + if (resourceType.equalsIgnoreCase("image")) + return("template"); + else if(resourceType.equalsIgnoreCase("instance")) + return("userVm"); + else + return resourceType; + } + + /** + * Map Amazon resourceType to CloudStack resourceType + * + * @param CloudStack resourceType + * @return Amazon resourceType + */ + private String mapToAmazonResourceType( String resourceType) { + if (resourceType.equalsIgnoreCase("template")) + return("image"); + else if(resourceType.equalsIgnoreCase("userVm")) + return("instance"); + else + return (resourceType.toLowerCase()); + } + /** * Stop an instance * Wait until one specific VM has stopped diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2ResourceTag.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2ResourceTag.java new file mode 100644 index 00000000000..e3c5881909a --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2ResourceTag.java @@ -0,0 +1,64 @@ +// 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.bridge.service.core.ec2; + +public class EC2ResourceTag { + private String resourceId; + private String resourceType; + private String key; + private String value; + + public EC2ResourceTag() { + resourceId = null; + resourceType = null; + key = null; + value = null; + } + + public void setResourceId( String resourceId ) { + this.resourceId = resourceId; + } + + public String getResourceId() { + return this.resourceId; + } + + public void setResourceType( String resourceType ) { + this.resourceType = resourceType; + } + + public String getResourceType() { + return this.resourceType; + } + + public void setKey( String key ) { + this.key = key; + } + + public String getKey() { + return this.key; + } + + public void setValue( String value ) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagKeyValue.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagKeyValue.java new file mode 100644 index 00000000000..beb2af9d99f --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagKeyValue.java @@ -0,0 +1,44 @@ +// 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.bridge.service.core.ec2; + +public class EC2TagKeyValue { + private String key; + private String value; + + public EC2TagKeyValue() { + key = null; + value = null; + } + + public void setKey( String key ) { + this.key = key; + } + + public String getKey() { + return this.key; + } + + public void setValue( String value ) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagTypeId.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagTypeId.java new file mode 100644 index 00000000000..3a0666edf82 --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagTypeId.java @@ -0,0 +1,47 @@ +// 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.bridge.service.core.ec2; + +import java.util.ArrayList; +import java.util.List; + +public class EC2TagTypeId { + + private String resourceType; + private List resourceIdSet = new ArrayList(); + + public EC2TagTypeId() { + resourceType = null; + } + + public void setResourceType( String resourceType ) { + this.resourceType = resourceType; + } + + public String getResourceType() { + return this.resourceType; + } + + public void addResourceId( String param ) { + resourceIdSet.add( param ); + } + + public String[] getResourceIds() { + return resourceIdSet.toArray(new String[0]); + } +} diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Tags.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Tags.java new file mode 100644 index 00000000000..80c9f8a5afc --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Tags.java @@ -0,0 +1,44 @@ +// 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.bridge.service.core.ec2; + +import java.util.ArrayList; +import java.util.List; + +public class EC2Tags { + + private List resourceTypeSet = new ArrayList(); + private List resourceTagSet = new ArrayList(); + + public void addResourceType( EC2TagTypeId param ) { + resourceTypeSet.add( param ); + } + + public EC2TagTypeId[] getResourceTypeSet() { + return resourceTypeSet.toArray(new EC2TagTypeId[0]); + } + + public void addResourceTag( EC2TagKeyValue param ) { + resourceTagSet.add( param ); + } + + public EC2TagKeyValue[] getResourceTags() { + return resourceTagSet.toArray(new EC2TagKeyValue[0]); + } +} + diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagsFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagsFilterSet.java new file mode 100644 index 00000000000..c2d33c39ea1 --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2TagsFilterSet.java @@ -0,0 +1,107 @@ +// 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.bridge.service.core.ec2; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.cloud.bridge.service.exception.EC2ServiceException; + +public class EC2TagsFilterSet { + protected final static Logger logger = Logger.getLogger(EC2TagsFilterSet.class); + + protected List filterSet = new ArrayList(); + + private Map filterTypes = new HashMap(); + + public EC2TagsFilterSet() { + filterTypes.put( "resource-id", "String" ); + filterTypes.put( "resource-type", "String" ); + filterTypes.put( "key", "String" ); + filterTypes.put( "value", "String" ); + } + + public void addFilter( EC2Filter param ) { + String filterName = param.getName(); + String value = (String) filterTypes.get( filterName ); + + if (null == value) + throw new EC2ServiceException( "Unsupported filter [" + filterName + "] - 1", 501 ); + + if (null != value && value.equalsIgnoreCase( "null" )) + throw new EC2ServiceException( "Unsupported filter [" + filterName + "] - 2", 501 ); + + filterSet.add( param ); + } + + public EC2Filter[] getFilterSet() { + return filterSet.toArray(new EC2Filter[0]); + } + + public EC2DescribeTagsResponse evaluate( EC2DescribeTagsResponse sampleList) throws ParseException { + EC2DescribeTagsResponse resultList = new EC2DescribeTagsResponse(); + + boolean matched; + + EC2ResourceTag[] tagSet = sampleList.getTagsSet(); + EC2Filter[] filterSet = getFilterSet(); + for (EC2ResourceTag tag : tagSet) { + matched = true; + for (EC2Filter filter : filterSet) { + if (!filterMatched(tag, filter)) { + matched = false; + break; + } + } + if (matched == true) + resultList.addTags(tag); + } + return resultList; + } + + private boolean filterMatched( EC2ResourceTag tag, EC2Filter filter ) throws ParseException { + String filterName = filter.getName(); + String[] valueSet = filter.getValueSet(); + + if ( filterName.equalsIgnoreCase("resource-id")) { + return containsString(tag.getResourceId(), valueSet); + } else if ( filterName.equalsIgnoreCase("resource-type")) { + return containsString(tag.getResourceType(), valueSet); + } else if ( filterName.equalsIgnoreCase("key")) { + return containsString(tag.getKey(), valueSet); + } else if ( filterName.equalsIgnoreCase("value")) { + return containsString(tag.getValue(), valueSet); + } else + return false; + } + + private boolean containsString( String lookingFor, String[] set ){ + if (lookingFor == null) + return false; + + for (String filter: set) { + if (lookingFor.matches( filter )) return true; + } + return false; + } +} diff --git a/awsapi/src/com/cloud/stack/CloudStackApi.java b/awsapi/src/com/cloud/stack/CloudStackApi.java index e46ebddb546..50b2b25af40 100644 --- a/awsapi/src/com/cloud/stack/CloudStackApi.java +++ b/awsapi/src/com/cloud/stack/CloudStackApi.java @@ -42,6 +42,7 @@ import com.cloud.stack.models.CloudStackOsType; import com.cloud.stack.models.CloudStackPasswordData; import com.cloud.stack.models.CloudStackPortForwardingRule; import com.cloud.stack.models.CloudStackResourceLimit; +import com.cloud.stack.models.CloudStackResourceTag; import com.cloud.stack.models.CloudStackSecurityGroup; import com.cloud.stack.models.CloudStackSecurityGroupIngress; import com.cloud.stack.models.CloudStackServiceOffering; @@ -973,7 +974,81 @@ public class CloudStackApi { } return _client.call(cmd, apiKey, secretKey, true, ApiConstants.EXTRACT_VOLUME_RESPONSE, ApiConstants.VOLUME, CloudStackExtractTemplate.class); } - + + //Tags + /** + * Create tags + * + * @param resource type + * @param resource id's + * @param tags + * @return + * @throws Exception + * + */ + public CloudStackInfoResponse createTags(String resourceType, ListresourceIds, + List resourceTags) throws Exception { + CloudStackCommand cmd = new CloudStackCommand(ApiConstants.CREATE_TAGS); + cmd = setParams(cmd, resourceType, resourceIds, resourceTags); + return _client.call(cmd, apiKey, secretKey, true, ApiConstants.CREATE_TAGS_RESPONSE, + null, CloudStackInfoResponse.class); + } + + /** + * Delete tags + * + * @param resource type + * @param resource id's + * @param tags + * @return + * @throws Exception + * + */ + public CloudStackInfoResponse deleteTags(String resourceType, ListresourceIds, + List resourceTags) throws Exception { + CloudStackCommand cmd = new CloudStackCommand(ApiConstants.DELETE_TAGS); + cmd = setParams(cmd, resourceType, resourceIds, resourceTags); + return _client.call(cmd, apiKey, secretKey, true, ApiConstants.DELETE_TAGS_RESPONSE, + null, CloudStackInfoResponse.class); + } + + public List listTags(String account, String domainId, + Boolean isRecursive, Boolean listAll, String keyWord) throws Exception { + CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_TAGS); + if (cmd != null) { + if (account != null) cmd.setParam(ApiConstants.ACCOUNT, account); + if (domainId != null) cmd.setParam(ApiConstants.DOMAIN_ID, domainId); + if (isRecursive != null) cmd.setParam(ApiConstants.IS_RECURSIVE, isRecursive.toString()); + if (listAll != null) cmd.setParam(ApiConstants.LIST_ALL, listAll.toString()); + if (keyWord != null) cmd.setParam(ApiConstants.KEYWORD, keyWord); + } + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_TAGS_RESPONSE, + ApiConstants.TAG , new TypeToken>() {}.getType()); + } + + private CloudStackCommand setParams(CloudStackCommand cmd, String resourceType, ListresourceIds, + List resourceTags) { + if (cmd != null) { + cmd.setParam(ApiConstants.RESOURCE_TYPE, resourceType); + if (resourceIds != null && resourceIds.size() > 0) { + String resourceIdList = resourceIds.get(0); + for (int i=1 ; i 0) { + int i=0; + for (CloudStackKeyValue resourceTag : resourceTags) { + cmd.setParam(ApiConstants.TAGS+"["+i+"].key", resourceTag.getKey()); + if (resourceTag.getValue() != null) + cmd.setParam(ApiConstants.TAGS+"["+i+"].value", resourceTag.getValue()); + i++; + } + } + } + return cmd; + } + // Security Groups /** * Creates a security group diff --git a/awsapi/src/com/cloud/stack/models/ApiConstants.java b/awsapi/src/com/cloud/stack/models/ApiConstants.java index e00a9b90859..2097ab6f135 100644 --- a/awsapi/src/com/cloud/stack/models/ApiConstants.java +++ b/awsapi/src/com/cloud/stack/models/ApiConstants.java @@ -85,6 +85,8 @@ public class ApiConstants { public static final String CREATE_SNAPSHOT_RESPONSE = "createsnapshotresponse"; public static final String CREATE_SSH_KEY_PAIR = "createSSHKeyPair"; public static final String CREATE_SSH_KEY_PAIR_RESPONSE = "createsshkeypairresponse"; + public static final String CREATE_TAGS = "createTags"; + public static final String CREATE_TAGS_RESPONSE = "createtagsresponse"; public static final String CREATE_TEMPLATE = "createTemplate"; public static final String CREATE_TEMPLATE_RESPONSE = "createtemplateresponse"; public static final String CREATE_VOLUME = "createVolume"; @@ -114,6 +116,8 @@ public class ApiConstants { public static final String DELETE_SNAPSHOT_RESPONSE = "deletesnapshotresponse"; public static final String DELETE_SSH_KEY_PAIR = "deleteSSHKeyPair"; public static final String DELETE_SSH_KEY_PAIR_RESPONSE = "deletesshkeypairresponse"; + public static final String DELETE_TAGS = "deleteTags"; + public static final String DELETE_TAGS_RESPONSE = "deletetagsresponse"; public static final String DELETE_TEMPLATE = "deleteTemplate"; public static final String DELETE_TEMPLATE_RESPONSE = "deletetemplateresponse"; public static final String DELETE_VOLUME = "deleteVolume"; @@ -228,6 +232,7 @@ public class ApiConstants { public static final String ISOLATION_URI = "isolationuri"; public static final String JOB_ID = "jobid"; public static final String JOB_STATUS = "jobstatus"; + public static final String KEY = "key"; public static final String KEY_PAIR = "keypair"; public static final String KEYWORD = "keyword"; public static final String LASTNAME = "lastname"; @@ -290,6 +295,8 @@ public class ApiConstants { public static final String LIST_SSH_KEY_PAIRS = "listSSHKeyPairs"; public static final String LIST_SSH_KEY_PAIRS_RESPONSE = "listsshkeypairsresponse"; public static final String LIST_TEMPLATE_PERMISSIONS = "listTemplatePermissions"; + public static final String LIST_TAGS = "listTags"; + public static final String LIST_TAGS_RESPONSE = "listtagsresponse"; public static final String LIST_TEMPLATE_PERMISSIONS_RESPONSE = "listtemplatepermissionsresponse"; public static final String LIST_TEMPLATES = "listTemplates"; public static final String LIST_TEMPLATES_RESPONSE = "listtemplatesresponse"; @@ -380,6 +387,8 @@ public class ApiConstants { public static final String REQUIRES_HVM = "requireshvm"; public static final String RESET_PASSWORD_FOR_VIRTUAL_MACHINE = "resetPasswordForVirtualMachine"; public static final String RESET_PASSWORD_FOR_VIRTUAL_MACHINE_RESPONSE = "resetpasswordforvirtualmachineresponse"; + public static final String RESOURCE_ID = "resourceid"; + public static final String RESOURCE_IDS = "resourceIds"; public static final String RESOURCE_LIMIT = "resourcelimit"; public static final String RESOURCE_TYPE = "resourcetype"; public static final String RESTART_NETWORK = "restartNetwork"; @@ -433,6 +442,7 @@ public class ApiConstants { public static final String STORAGE_TYPE = "storagetype"; public static final String SUCCESS = "success"; public static final String SYSTEM_VM_TYPE = "systemvmtype"; + public static final String TAG = "tag"; public static final String TAGS = "tags"; public static final String TARGET_IQN = "targetiqn"; public static final String TEMPLATE = "template"; diff --git a/awsapi/src/com/cloud/stack/models/CloudStackResourceTag.java b/awsapi/src/com/cloud/stack/models/CloudStackResourceTag.java new file mode 100644 index 00000000000..8dd75c5a41b --- /dev/null +++ b/awsapi/src/com/cloud/stack/models/CloudStackResourceTag.java @@ -0,0 +1,50 @@ +// 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.stack.models; + +import com.google.gson.annotations.SerializedName; + +public class CloudStackResourceTag { + @SerializedName(ApiConstants.RESOURCE_ID) + private String resourceId; + @SerializedName(ApiConstants.RESOURCE_TYPE) + private String resourceType; + @SerializedName(ApiConstants.KEY) + private String key; + @SerializedName(ApiConstants.VALUE) + private String value; + + public CloudStackResourceTag() { + } + + public String getResourceId() { + return resourceId; + } + + public String getResourceType() { + return resourceType; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +} From dade14aab13b7f308ad2f6f739f9b400a42f9570 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Tue, 24 Jul 2012 01:25:05 +0530 Subject: [PATCH 22/79] CS-15540: Shared Networks IPs in Advanced Zone appear as 'Direct IP' in System-Wide-Capacity Dashboard --- client/WEB-INF/classes/resources/messages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 35fe56849d9..0ce3d4442c4 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -320,7 +320,7 @@ state.Ready=Ready label.vm.display.name=VM display name label.select-view=Select view label.local.storage=Local Storage -label.direct.ips=Direct IPs +label.direct.ips=Shared Network IPs label.view.all=View all label.zone.details=Zone details message.alert.state.detected=Alert state detected From 88f7872b81c824d2a547d6ca03b95261188c2857 Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Mon, 23 Jul 2012 14:46:56 -0700 Subject: [PATCH 23/79] CS-15279 Issue happens when ROOT volume gets created and there is subsequent failure in starting the VM. During retry if allocator assigns a different storage pool the scenario was not handled. Now in case of local storage the volume get recreated on the newly assigned pool and old one gets cleaned up. In case of shared storage the existing volume is migrated to new storage pool. --- .../com/cloud/storage/StorageManagerImpl.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 27d8cb71e83..d94bada2866 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -3210,10 +3210,25 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag } else { if (assignedPool.getId() != vol.getPoolId()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Volume " + vol + " is not recreatable! Cannot recreate on storagepool: " + assignedPool); + s_logger.debug("Mismatch in storage pool " + assignedPool + " assigned by deploymentPlanner and the one associated with volume " + vol); + } + if (vm.getServiceOffering().getUseLocalStorage()) + { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Local volume " + vol + " will be recreated on storage pool " + assignedPool + " assigned by deploymentPlanner"); + } + recreateVols.add(vol); + } else { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner"); + } + try { + Volume migratedVol = migrateVolume(vol.getId(), assignedPool.getId()); + vm.addDisk(new VolumeTO(migratedVol, assignedPool)); + } catch (ConcurrentOperationException e) { + throw new StorageUnavailableException("Volume migration failed for " + vol, Volume.class, vol.getId()); + } } - throw new StorageUnavailableException("Volume is not recreatable, Unable to create " + vol, Volume.class, vol.getId()); - // copy volume usecase - not yet developed. } else { StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId()); vm.addDisk(new VolumeTO(vol, pool)); From 5e94b0d12e50c6ba3a7defd00aeb04c79286f14f Mon Sep 17 00:00:00 2001 From: bfederle Date: Mon, 23 Jul 2012 13:26:52 -0700 Subject: [PATCH 24/79] Implement tag UI widget Create UI for handling new tag API. This currently supports the detail view and multi-edit To enable tags UI, add a 'tags' object to each detailView/multiEdit configuration: tabs: { ... details: { ... tags: { actions: { add: function(args) { setTimeout(function() { args.response.success({ notification: { desc: 'Add tags for instance', poll: testData.notifications.testPoll } }); }, 500); }, remove: function(args) { args.response.success({ notification: { desc: 'Remove tags for instance', poll: testData.notifications.testPoll } }); } }, dataProvider: function(args) { args.response.success({ data: [ { id: '1', key: 'user', value: 'brian' }, { id: '2', key: 'region', value: 'usa' } ] }); } } ... Conflicts: ui/css/cloudstack3.css ui/scripts/ui/widgets/tagger.js --- ui/css/cloudstack3.css | 198 ++++++++++++++++++++++++++++ ui/scripts/ui/widgets/detailView.js | 48 ++++++- ui/scripts/ui/widgets/multiEdit.js | 12 +- ui/scripts/ui/widgets/tagger.js | 197 +++++++++++++++++++++++++++ 4 files changed, 446 insertions(+), 9 deletions(-) create mode 100644 ui/scripts/ui/widgets/tagger.js diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index ef81697e464..e405fbf4fcb 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -8952,6 +8952,204 @@ div.panel.ui-dialog div.list-view div.fixed-header { background: #DFE1E3; } +/*Tagger*/ +.tagger { + width: 94%; + margin: auto; + padding-bottom: 12px; + background: #F2F0F0; + border: 1px solid #CFC9C9; + /*+placement:shift -4px 0px;*/ + position: relative; + left: -4px; + top: 0px; +} + +.tagger .field { + width: 179px; + float: left; + position: relative; +} + +.tagger .tag-info { + font-size: 11px; + color: #757575; + margin-top: 12px; + margin-left: 8px; +} + +.tagger .tag-info.title { + font-size: 11px; + color: #6F9BF0; + margin-bottom: 5px; +} + +.tagger form { + margin: 12px 9px 0px; +} + +.tagger.readonly form { + display: none; +} + +.tagger form label { + display: block; + float: left; + width: 28px; + text-align: right; + font-size: 10px; + color: #394552; + margin-right: 9px; + /*+placement:shift 5px 8px;*/ + position: relative; + left: 5px; + top: 8px; +} + +.tagger form label.error { + position: absolute; + color: #FF0000; + left: 42px; + top: 29px; + /*[empty]background-color:;*/ +} + +.tagger form input { + padding: 4px; + background: #FFFFFF; + border: 1px solid #808080; + /*+border-radius:4px;*/ + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + -khtml-border-radius: 4px; + border-radius: 4px; +} + +.tagger form input[type=submit] { + background: url(../images/bg-gradients.png) repeat-x 0px -220px; + cursor: pointer; + color: #FFFFFF; + /*+text-shadow:0px -1px 2px #000000;*/ + -moz-text-shadow: 0px -1px 2px #000000; + -webkit-text-shadow: 0px -1px 2px #000000; + -o-text-shadow: 0px -1px 2px #000000; + text-shadow: 0px -1px 2px #000000; + border: none; + /*+border-radius:4px;*/ + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + -khtml-border-radius: 4px; + border-radius: 4px; + padding: 7px 25px 7px 26px; + margin-left: 16px; +} + +.tagger form input[type=submit]:hover { + background-position: 0px -946px; +} + +.tagger ul { + display: block; + width: 96%; + margin: 16px auto auto; + /*+border-radius:2px;*/ + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; + overflow: auto; + padding-bottom: 10px; + border: 1px solid #D2D2D2; + background: #FFFFFF; + /*+box-shadow:inset 0px 0px 10px #DCDCDC;*/ + -moz-box-shadow: inset 0px 0px 10px #DCDCDC; + -webkit-box-shadow: inset 0px 0px 10px #DCDCDC; + -o-box-shadow: inset 0px 0px 10px #DCDCDC; + box-shadow: inset 0px 0px 10px #DCDCDC; +} + +.tagger.readonly ul { +} + +.tagger ul li { + background: #DFDFDF 0px 4px; + height: 15px; + padding: 0px 18px 0 7px; + display: inline-block; + float: left; + margin-left: 7px; + margin-right: 2px; + margin-top: 5px; + /*+border-radius:4px;*/ + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + -khtml-border-radius: 4px; + border-radius: 4px; + /*+placement:shift 0px 2px;*/ + position: relative; + left: 0px; + top: 2px; +} + +.tagger ul li span { + color: #000000; +} + +.tagger ul li span.label { + font-size: 10px; + position: relative; + left: 15px; + top: -2px; +} + +.tagger.readonly ul li span.label { + left: 6px; +} + +.tagger ul li span.remove { + width: 15px !important; + overflow: hidden !important; + height: 11px !important; + background: #DFDFDF url(../images/sprites.png) no-repeat -596px -1183px; + display: block; + top: 0px !important; + left: -3px !important; + text-indent: 4px; + padding: 4px 0px 0px 8px; + font-size: 8px; + font-weight: bold; + cursor: pointer; + position: absolute !important; + color: #5B5B5B; +} + +.tagger.readonly ul li span.remove { + display: none; +} + +.tagger ul li span.remove:hover { + color: #000000; +} + +/** Dialog tagger*/ +.ui-dialog .tagger { +} + +.ui-dialog .tagger .field { + width: 119px !important; +} + +.ui-dialog .tagger input.key, +.ui-dialog .tagger input.value { + width: 66px !important; + height: 15px; + font-size: 11px !important; +} + +.ui-dialog .tagger input[type=submit] { + padding: 6px 15px; +} + /*VPC / vApps*/ .vpc-chart { width: 100%; diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index b1e9a68c8a9..086f66d3e23 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -287,10 +287,14 @@ * @param callback */ edit: function($detailView, args) { + $detailView.addClass('edit-mode'); + if ($detailView.find('.button.done').size()) return false; // Convert value TDs - var $inputs = $detailView.find('input, select'); + var $inputs = $detailView.find('input, select').filter(function() { + return !$(this).closest('.tagger').size() && !$(this).attr('type') == 'submit'; + }); var action = args.actions[args.actionName]; var id = $detailView.data('view-args').id; var $editButton = $('
').addClass('button done').html(_l('label.apply')).hide(); @@ -302,9 +306,14 @@ $detailView.find('.ui-tabs-panel .detail-group.actions') ).fadeIn(); + $detailView.find('.tagger').removeClass('readonly'); + $detailView.find('.tagger').find('input[type=text]').val(''); + var convertInputs = function($inputs) { // Save and turn back into labels $inputs.each(function() { + if ($(this).closest('.tagger').size()) return true; + var $input = $(this); var $value = $input.closest('td.value span'); @@ -328,8 +337,12 @@ }; var removeEditForm = function() { + $detailView.removeClass('edit-mode'); + // Remove Edit form - var $form = $detailView.find('form'); + var $form = $detailView.find('form').filter(function() { + return !$(this).closest('.tagger').size(); + }); if ($form.size()) { var $mainGroups = $form.find('div.main-groups').detach(); $form.parent('div').append($mainGroups); @@ -337,11 +350,15 @@ } //Remove required labels $detailView.find('span.field-required').remove(); - } + $detailView.find('.tagger').addClass('readonly'); + + }; // Put in original values var cancelEdits = function($inputs, $editButton) { $inputs.each(function() { + if ($(this).closest('.tagger').size()) return true; + var $input = $(this); var $value = $input.closest('td.value span'); var originalValue = $input.data('original-value'); @@ -424,8 +441,12 @@ }; $editButton.click(function() { - var $inputs = $detailView.find('input, select'), - $form = $detailView.find('form'); + var $inputs = $detailView.find('input, select').filter(function() { + return !$(this).closest('.tagger').size(); + }); + var $form = $detailView.find('form').filter(function() { + return !$(this).closest('.tagger').size(); + }); if ($(this).hasClass('done')) { if (!$form.valid()) { @@ -438,6 +459,8 @@ } else { // Cancel cancelEdits($inputs, $editButton); } + + return true; }); $detailView.find('td.value span').each(function() { @@ -511,8 +534,11 @@ } // Setup form validation - $detailView.find('form').validate(); - $detailView.find('form').find('input, select').each(function() { + var $form = $detailView.find('form').filter(function() { + return !$(this).closest('.tagger').size(); + }); + $form.validate(); + $form.find('input, select').each(function() { var data = $(this).parent('span').data('validation-rules'); if (data) { $(this).rules('add', data); @@ -934,6 +960,14 @@ actionFilter: actionFilter }).appendTo($tabContent); + if (tabs.tags) { + $('
').tagger( + $.extend(true, {}, tabs.tags, { + context: $detailView.data('view-args').context + }) + ).appendTo($tabContent).addClass('readonly'); + } + return true; }, error: function() { diff --git a/ui/scripts/ui/widgets/multiEdit.js b/ui/scripts/ui/widgets/multiEdit.js index 64d94f6dd90..89d260300eb 100644 --- a/ui/scripts/ui/widgets/multiEdit.js +++ b/ui/scripts/ui/widgets/multiEdit.js @@ -332,10 +332,16 @@ after: function(args) { var $loading = $('
').addClass('loading-overlay').prependTo($dataItem); performAction({ data: args.data, complete: function() { - $multi.multiEdit('refresh'); + $multi.trigger('refresh'); } }); } }); + + if (options.tags) { + $(':ui-dialog').append( + $('
').addClass('multi-edit-tags').tagger(options.tags) + ); + } } }) ); @@ -652,6 +658,7 @@ $.fn.multiEdit = function(args) { var dataProvider = args.dataProvider; var multipleAdd = args.multipleAdd; + var tags = args.tags; var $multi = $('
').addClass('multi-edit').appendTo(this); var $multiForm = $('
').appendTo($multi); var $inputTable = $('').addClass('multi-edit').appendTo($multiForm); @@ -918,7 +925,8 @@ context: $.extend(true, {}, context, this._context), ignoreEmptyFields: ignoreEmptyFields, preFilter: actionPreFilter, - listView: listView + listView: listView, + tags: tags } ).appendTo($dataBody); }); diff --git a/ui/scripts/ui/widgets/tagger.js b/ui/scripts/ui/widgets/tagger.js new file mode 100644 index 00000000000..b6d2f0a0dea --- /dev/null +++ b/ui/scripts/ui/widgets/tagger.js @@ -0,0 +1,197 @@ +(function($, cloudStack) { + var elems = { + inputArea: function(args) { + var $form = $('').addClass('tag-input'); + var $keyField = $('
').addClass('field key'); + var $keyLabel = $('