diff --git a/.gitignore b/.gitignore index 15f7f91c864..f41862895ec 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,11 @@ docs/runbook/tmp docs/runbook/publish .project Gemfile.lock +debian/tmp +debian/files +debian/cloudstack-*/* +debian/*.substvars +debian/*.debhelper +replace.properties.tmp +build-indep-stamp +configure-stamp diff --git a/LICENSE b/LICENSE index 6b81a9140e9..2094d029e90 100644 --- a/LICENSE +++ b/LICENSE @@ -180,70 +180,6 @@ Copyright (c) 2013 The Apache Software Foundation This distribution contains third party resources. -Within the . directory - licensed under the BSD (3-clause) http://www.opensource.org/licenses/BSD-3-Clause (as follows) - - Copyright (c) 2005-2010 Thomas Nagy - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. - - from Thomas Nagy http://code.google.com/p/waf/ - waf - -Within the awsapi directory - licensed under the BSD (3-clause) http://www.opensource.org/licenses/BSD-3-Clause (as follows) - - Copyright (c) 2005-2010 Thomas Nagy - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. - - from Thomas Nagy http://code.google.com/p/waf/ - waf - Within the console-proxy/js directory licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows) diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties index f7eac674712..e49afbf2aaf 100644 --- a/agent/conf/agent.properties +++ b/agent/conf/agent.properties @@ -80,3 +80,12 @@ domr.scripts.dir=scripts/network/domr/kvm # native = com.cloud.hypervisor.kvm.resource.BridgeVifDriver # openvswitch = com.cloud.hypervisor.kvm.resource.OvsBridgeDriver #libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.BridgeVifDriver + +# set the hypervisor type, values are: kvm, lxc +# hypervisor.type=kvm + +# settings to enable direct networking in libvirt, should not be used +# on hosts that run system vms, values for mode are: private, bridge, vepa +# libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.DirectVifDriver +# network.direct.source.mode=private +# network.direct.device=eth0 diff --git a/api/src/com/cloud/agent/api/Command.java b/api/src/com/cloud/agent/api/Command.java index 9cd67495e04..aadbeaf0def 100755 --- a/api/src/com/cloud/agent/api/Command.java +++ b/api/src/com/cloud/agent/api/Command.java @@ -27,6 +27,8 @@ import com.cloud.agent.api.LogLevel.Log4jLevel; */ public abstract class Command { + public static final String HYPERVISOR_TYPE = "hypervisorType"; + // allow command to carry over hypervisor or other environment related context info @LogLevel(Log4jLevel.Trace) protected Map contextMap = new HashMap(); diff --git a/api/src/com/cloud/agent/api/RebootCommand.java b/api/src/com/cloud/agent/api/RebootCommand.java index 299e61b76af..49712b6fce5 100755 --- a/api/src/com/cloud/agent/api/RebootCommand.java +++ b/api/src/com/cloud/agent/api/RebootCommand.java @@ -16,6 +16,7 @@ // under the License. package com.cloud.agent.api; +import com.cloud.hypervisor.Hypervisor; import com.cloud.vm.VirtualMachine; public class RebootCommand extends Command { diff --git a/api/src/com/cloud/agent/api/StopCommand.java b/api/src/com/cloud/agent/api/StopCommand.java index 9ee7ce3c874..1c67f3816ca 100755 --- a/api/src/com/cloud/agent/api/StopCommand.java +++ b/api/src/com/cloud/agent/api/StopCommand.java @@ -38,10 +38,9 @@ public class StopCommand extends RebootCommand { super(vm); this.vnet = vnet; } - - public StopCommand(VirtualMachine vm, String vmName, String vnet) { - super(vmName); - this.vnet = vnet; + + public StopCommand(VirtualMachine vm) { + super(vm); } public StopCommand(String vmName) { diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 704a1bfc02c..5671f995c70 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -142,6 +142,9 @@ public class EventTypes { //registering SSH keypair events public static final String EVENT_REGISTER_SSH_KEYPAIR = "REGISTER.SSH.KEYPAIR"; + //register for user API and secret keys + public static final String EVENT_REGISTER_FOR_SECRET_API_KEY = "REGISTER.USER.KEY"; + // Template Events public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE"; public static final String EVENT_TEMPLATE_DELETE = "TEMPLATE.DELETE"; diff --git a/api/src/com/cloud/hypervisor/Hypervisor.java b/api/src/com/cloud/hypervisor/Hypervisor.java index 2e0012dca6f..a4ee5b98fd9 100644 --- a/api/src/com/cloud/hypervisor/Hypervisor.java +++ b/api/src/com/cloud/hypervisor/Hypervisor.java @@ -29,6 +29,7 @@ public class Hypervisor { BareMetal, Simulator, Ovm, + LXC, Any; /*If you don't care about the hypervisor type*/ @@ -54,6 +55,8 @@ public class Hypervisor { return HypervisorType.Simulator; } else if (hypervisor.equalsIgnoreCase("Ovm")) { return HypervisorType.Ovm; + } else if (hypervisor.equalsIgnoreCase("LXC")) { + return HypervisorType.LXC; } else if (hypervisor.equalsIgnoreCase("Any")) { return HypervisorType.Any; } else { diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index c2ab655b103..c0b0117fc7e 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -136,8 +136,7 @@ public interface Network extends ControlledEntity, StateObject, I public static final Provider VPCVirtualRouter = new Provider("VpcVirtualRouter", false); public static final Provider None = new Provider("None", false); // NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking - public static final Provider NiciraNvp = new Provider("NiciraNvp", false); - public static final Provider MidokuraMidonet = new Provider("MidokuraMidonet", true); + public static final Provider NiciraNvp = new Provider("NiciraNvp", false); private String name; private boolean isExternal; diff --git a/api/src/com/cloud/network/NetworkModel.java b/api/src/com/cloud/network/NetworkModel.java index 916f28a00f2..4d7d714a7ae 100644 --- a/api/src/com/cloud/network/NetworkModel.java +++ b/api/src/com/cloud/network/NetworkModel.java @@ -260,5 +260,7 @@ public interface NetworkModel { String getStartIpv6Address(long id); - Nic getPlaceholderNic(Network network, Long podId); + boolean isProviderEnabledInZone(long zoneId, String provider); + + Nic getPlaceholderNicForRouter(Network network, Long podId); } \ No newline at end of file diff --git a/api/src/com/cloud/network/Networks.java b/api/src/com/cloud/network/Networks.java index e3d21584ad8..f085e9f3029 100755 --- a/api/src/com/cloud/network/Networks.java +++ b/api/src/com/cloud/network/Networks.java @@ -62,6 +62,7 @@ public class Networks { Vnet("vnet", Long.class), Storage("storage", Integer.class), Lswitch("lswitch", String.class), + Mido("mido", String.class), UnDecided(null, null); private String scheme; diff --git a/api/src/com/cloud/network/PhysicalNetwork.java b/api/src/com/cloud/network/PhysicalNetwork.java index 343a2b14e33..a2044a61047 100644 --- a/api/src/com/cloud/network/PhysicalNetwork.java +++ b/api/src/com/cloud/network/PhysicalNetwork.java @@ -36,7 +36,8 @@ public interface PhysicalNetwork extends Identity, InternalIdentity { L3, GRE, STT, - VNS; + VNS, + MIDO; } public enum BroadcastDomainRange { diff --git a/api/src/com/cloud/network/vpc/Vpc.java b/api/src/com/cloud/network/vpc/Vpc.java index c07077f7b7e..249e80f1aff 100644 --- a/api/src/com/cloud/network/vpc/Vpc.java +++ b/api/src/com/cloud/network/vpc/Vpc.java @@ -20,32 +20,63 @@ import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; -import com.cloud.network.Network; - public interface Vpc extends ControlledEntity, Identity, InternalIdentity { + public enum State { Enabled, Inactive } - public static final String _supportedProviders = Network.Provider.VPCVirtualRouter.getName(); - - boolean readyToUse(); - + /** + * + * @return VPC name + */ String getName(); + + /** + * @return the id of the zone the VPC belongs to + */ long getZoneId(); + + /** + * @return super CIDR of the VPC. All the networks participating in VPC, should have CIDRs that are the part of the super cidr + */ String getCidr(); + /** + * + * @return VPC state + */ State getState(); + + /** + * + * @return VPC offering id - the offering that VPC is created from + */ long getVpcOfferingId(); + + /** + * + * @return VPC display text + */ String getDisplayText(); + + /** + * + * @return VPC network domain. All networks participating in the VPC, become the part of the same network domain + */ String getNetworkDomain(); + + /** + * + * @return true if restart is required for the VPC; false otherwise + */ boolean isRestartRequired(); } diff --git a/api/src/com/cloud/network/vpc/VpcOffering.java b/api/src/com/cloud/network/vpc/VpcOffering.java index 1acfcd21418..3961d0aaba7 100644 --- a/api/src/com/cloud/network/vpc/VpcOffering.java +++ b/api/src/com/cloud/network/vpc/VpcOffering.java @@ -27,18 +27,33 @@ public interface VpcOffering extends InternalIdentity, Identity { public static final String defaultVPCOfferingName = "Default VPC offering"; + /** + * + * @return VPC offering name + */ String getName(); - String getUniqueName(); - + + /** + * @return VPC offering display text + */ String getDisplayText(); + + /** + * + * @return VPC offering state + */ State getState(); + /** + * + * @return true if offering is default - came with the cloudStack fresh install; false otherwise + */ boolean isDefault(); /** - * @return + * @return service offering id used by VPC virutal router */ Long getServiceOfferingId(); diff --git a/api/src/com/cloud/network/vpc/VpcProvisioningService.java b/api/src/com/cloud/network/vpc/VpcProvisioningService.java new file mode 100644 index 00000000000..70676ce07ab --- /dev/null +++ b/api/src/com/cloud/network/vpc/VpcProvisioningService.java @@ -0,0 +1,46 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.network.vpc; + +import java.util.List; +import java.util.Map; + +public interface VpcProvisioningService { + + public VpcOffering getVpcOffering(long vpcOfferingId); + + public VpcOffering createVpcOffering(String name, String displayText, List supportedServices, Map> serviceProviders); + + List listVpcOfferings(Long id, String name, String displayText, List supportedServicesStr, + Boolean isDefault, String keyword, String state, Long startIndex, Long pageSizeVal); + + /** + * @param offId + * @return + */ + public boolean deleteVpcOffering(long offId); + + /** + * @param vpcOffId + * @param vpcOfferingName + * @param displayText + * @param state + * @return + */ + public VpcOffering updateVpcOffering(long vpcOffId, String vpcOfferingName, String displayText, String state); + +} diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java index 9bf1beea5f0..07ce89b0a3f 100644 --- a/api/src/com/cloud/network/vpc/VpcService.java +++ b/api/src/com/cloud/network/vpc/VpcService.java @@ -18,7 +18,6 @@ package com.cloud.network.vpc; import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd; import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd; @@ -31,45 +30,29 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; import com.cloud.network.Network; -import com.cloud.network.Network.Provider; -import com.cloud.network.Network.Service; -import com.cloud.user.Account; -import com.cloud.user.User; import com.cloud.utils.Pair; public interface VpcService { - public VpcOffering getVpcOffering(long vpcOfferingId); - - public VpcOffering createVpcOffering(String name, String displayText, List supportedServices, Map> serviceProviders); - + /**Returns existing VPC found by id + * + * @param vpcId + * @return + */ public Vpc getVpc(long vpcId); - public Vpc getActiveVpc(long vpcId); - + + /** + * Returns all the Guest networks that are part of VPC + * + * @param vpcId + * @return + */ public List getVpcNetworks(long vpcId); - Map> getVpcOffSvcProvidersMap(long vpcOffId); - - List listVpcOfferings(Long id, String name, String displayText, List supportedServicesStr, - Boolean isDefault, String keyword, String state, Long startIndex, Long pageSizeVal); - - /** - * @param offId - * @return - */ - public boolean deleteVpcOffering(long offId); - - /** - * @param vpcOffId - * @param vpcOfferingName - * @param displayText - * @param state - * @return - */ - public VpcOffering updateVpcOffering(long vpcOffId, String vpcOfferingName, String displayText, String state); - /** + * Persists VPC record in the database + * * @param zoneId * @param vpcOffId * @param vpcOwnerId @@ -83,7 +66,10 @@ public interface VpcService { public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain) throws ResourceAllocationException; + /** + * Deletes a VPC + * * @param vpcId * @return * @throws InsufficientCapacityException @@ -92,7 +78,10 @@ public interface VpcService { */ public boolean deleteVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException; + /** + * Updates VPC with new name/displayText + * * @param vpcId * @param vpcName * @param displayText @@ -100,7 +89,10 @@ public interface VpcService { */ public Vpc updateVpc(long vpcId, String vpcName, String displayText); + /** + * Lists VPC(s) based on the parameters passed to the method call + * * @param id * @param vpcName * @param displayText @@ -127,6 +119,8 @@ public interface VpcService { Boolean restartRequired, Map tags, Long projectId); /** + * Starts VPC which includes starting VPC provider and applying all the neworking rules on the backend + * * @param vpcId * @param destroyOnFailure TODO * @return @@ -138,6 +132,8 @@ public interface VpcService { ResourceUnavailableException, InsufficientCapacityException; /** + * Shuts down the VPC which includes shutting down all VPC provider and rules cleanup on the backend + * * @param vpcId * @return * @throws ConcurrentOperationException @@ -145,16 +141,28 @@ public interface VpcService { */ boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException; + /** + * Restarts the VPC. VPC gets shutdown and started as a part of it + * * @param id * @return * @throws InsufficientCapacityException */ boolean restartVpc(long id) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; + /** + * Returns a Private gateway found in the VPC by id + * + * @param id + * @return + */ PrivateGateway getVpcPrivateGateway(long id); + /** + * Persists VPC private gateway in the Database. + * * @param vpcId TODO * @param physicalNetworkId * @param vlan @@ -172,6 +180,8 @@ public interface VpcService { ConcurrentOperationException, InsufficientCapacityException; /** + * Applies VPC private gateway on the backend, so it becomes functional + * * @param gatewayId * @param destroyOnFailure TODO * @return @@ -180,7 +190,10 @@ public interface VpcService { */ public PrivateGateway applyVpcPrivateGateway(long gatewayId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException; + /** + * Deletes VPC private gateway + * * @param id * @return * @throws ResourceUnavailableException @@ -188,52 +201,76 @@ public interface VpcService { */ boolean deleteVpcPrivateGateway(long gatewayId) throws ConcurrentOperationException, ResourceUnavailableException; + /** + * Returns the list of Private gateways existing in the VPC + * * @param listPrivateGatewaysCmd * @return */ public Pair, Integer> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd); + /** + * Returns Static Route found by Id + * * @param routeId * @return */ StaticRoute getStaticRoute(long routeId); + /** + * Applies existing Static Routes to the VPC elements + * * @param vpcId * @return * @throws ResourceUnavailableException */ public boolean applyStaticRoutes(long vpcId) throws ResourceUnavailableException; + /** + * Deletes static route from the backend and the database + * * @param routeId * @return TODO * @throws ResourceUnavailableException */ public boolean revokeStaticRoute(long routeId) throws ResourceUnavailableException; + /** + * Persists static route entry in the Database + * * @param gatewayId * @param cidr * @return */ public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException; + /** + * Lists static routes based on parameters passed to the call + * * @param listStaticRoutesCmd * @return */ public Pair, Integer> listStaticRoutes(ListStaticRoutesCmd cmd); + /** + * Returns gateway (VPN or Public) existign in the VPC + * * @param id * @return */ VpcGateway getVpcGateway(long id); + /** + * Associates IP address from the Public network, to the VPC + * * @param ipId * @param vpcId * @return @@ -245,6 +282,4 @@ public interface VpcService { IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException, ConcurrentOperationException; - public Network updateVpcGuestNetwork(long networkId, String name, String displayText, Account callerAccount, - User callerUser, String domainSuffix, Long ntwkOffId, Boolean changeCidr, String guestVmCidr); } diff --git a/api/src/com/cloud/storage/Storage.java b/api/src/com/cloud/storage/Storage.java index fba12b62d3d..c130fe222bf 100755 --- a/api/src/com/cloud/storage/Storage.java +++ b/api/src/com/cloud/storage/Storage.java @@ -26,7 +26,8 @@ public class Storage { VHD(true, true, true), ISO(false, false, false), OVA(true, true, true, "ova"), - BAREMETAL(false, false, false); + BAREMETAL(false, false, false), + TAR(false, false, false); private final boolean thinProvisioned; private final boolean supportSparse; diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java index 7ccb72e8fb9..78a2af36aa2 100644 --- a/api/src/org/apache/cloudstack/api/BaseCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseCmd.java @@ -52,6 +52,7 @@ import com.cloud.network.firewall.NetworkACLService; import com.cloud.network.lb.LoadBalancingRulesService; import com.cloud.network.rules.RulesService; import com.cloud.network.security.SecurityGroupService; +import com.cloud.network.vpc.VpcProvisioningService; import com.cloud.network.vpc.VpcService; import com.cloud.network.vpn.RemoteAccessVpnService; import com.cloud.network.vpn.Site2SiteVpnService; @@ -132,6 +133,7 @@ public abstract class BaseCmd { @Inject public NetworkUsageService _networkUsageService; @Inject public VMSnapshotService _vmSnapshotService; @Inject public DataStoreProviderApiService dataStoreProviderApiService; + @Inject public VpcProvisioningService _vpcProvSvc; public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException; diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java index 89673ea6123..95d0d07d9ce 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java @@ -63,7 +63,7 @@ public class CreateAccountCmd extends BaseCmd { @Parameter(name=ApiConstants.LASTNAME, type=CommandType.STRING, required=true, description="lastname") private String lastName; - @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.") + @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="Clear text password (Default hashed to SHA256SALT). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.") private String password; @Parameter(name=ApiConstants.TIMEZONE, type=CommandType.STRING, description="Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.") diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java index fb29e1a2629..7b3f230d1ec 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java @@ -56,7 +56,7 @@ public class CreateUserCmd extends BaseCmd { @Parameter(name=ApiConstants.LASTNAME, type=CommandType.STRING, required=true, description="lastname") private String lastname; - @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.") + @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="Clear text password (Default hashed to SHA256SALT). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.") private String password; @Parameter(name=ApiConstants.TIMEZONE, type=CommandType.STRING, description="Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.") diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java index 1f31662e8ca..5ea2dbdef55 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java @@ -59,7 +59,7 @@ public class UpdateUserCmd extends BaseCmd { @Parameter(name=ApiConstants.LASTNAME, type=CommandType.STRING, description="last name") private String lastname; - @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="Hashed password (default is MD5). If you wish to use any other hasing algorithm, you would need to write a custom authentication adapter") + @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="Clear text password (default hashed to SHA256SALT). If you wish to use any other hasing algorithm, you would need to write a custom authentication adapter") private String password; @Parameter(name=ApiConstants.SECRET_KEY, type=CommandType.STRING, description="The secret key for the user. Must be specified with userApiKey") diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java index 3c7956b7d7e..4a3a92a211c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java @@ -98,7 +98,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{ @Override public void create() throws ResourceAllocationException { - VpcOffering vpcOff = _vpcService.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices(), getServiceProviders()); + VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices(), getServiceProviders()); if (vpcOff != null) { this.setEntityId(vpcOff.getId()); this.setEntityUuid(vpcOff.getUuid()); @@ -109,7 +109,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{ @Override public void execute() { - VpcOffering vpc = _vpcService.getVpcOffering(this.getEntityId()); + VpcOffering vpc = _vpcProvSvc.getVpcOffering(this.getEntityId()); if (vpc != null) { VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(vpc); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java index 9e2968e66fe..4b16fa5fcb9 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java @@ -66,7 +66,7 @@ public class DeleteVPCOfferingCmd extends BaseAsyncCmd{ @Override public void execute(){ - boolean result = _vpcService.deleteVpcOffering(getId()); + boolean result = _vpcProvSvc.deleteVpcOffering(getId()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java index de61ee74b31..9bbae064376 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java @@ -88,7 +88,7 @@ public class UpdateVPCOfferingCmd extends BaseAsyncCmd{ @Override public void execute(){ - VpcOffering result = _vpcService.updateVpcOffering(getId(), getVpcOfferingName(), getDisplayText(), getState()); + VpcOffering result = _vpcProvSvc.updateVpcOffering(getId(), getVpcOfferingName(), getDisplayText(), getState()); if (result != null) { VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(result); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java index 41aaaaada12..a61474e69d0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java @@ -129,14 +129,9 @@ public class UpdateNetworkCmd extends BaseAsyncCmd { throw new InvalidParameterValueException("Couldn't find network by id"); } - Network result = null; - if (network.getVpcId() != null) { - result = _vpcService.updateVpcGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, + Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr()); - } else { - result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, - callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr()); - } + if (result != null) { NetworkResponse response = _responseGenerator.createNetworkResponse(result); diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java index dae861a35b1..d75de57f7d1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java @@ -45,7 +45,7 @@ public class ListGlobalLoadBalancerRuleCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GlobalLoadBalancerResponse.class, description = "the ID of the global load balancer rule") private Long id; - @Parameter(name = ApiConstants.REGION_ID, type = CommandType.UUID, entityType = RegionResponse.class, description = "region ID") + @Parameter(name = ApiConstants.REGION_ID, type = CommandType.INTEGER, entityType = RegionResponse.class, description = "region ID") private Integer regionId; // /////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java index 9aef26f016c..ddae7998784 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java @@ -92,7 +92,7 @@ public class ListVPCOfferingsCmd extends BaseListCmd{ @Override public void execute(){ - List offerings = _vpcService.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), + List offerings = _vpcProvSvc.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), getSupportedServices(), isDefault, this.getKeyword(), getState(), this.getStartIndex(), this.getPageSizeVal()); ListResponse response = new ListResponse(); List offeringResponses = new ArrayList(); diff --git a/api/src/org/apache/cloudstack/api/response/ServiceResponse.java b/api/src/org/apache/cloudstack/api/response/ServiceResponse.java index 445afcfcf5b..c93c55ee16a 100644 --- a/api/src/org/apache/cloudstack/api/response/ServiceResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ServiceResponse.java @@ -16,13 +16,12 @@ // under the License. package org.apache.cloudstack.api.response; -import java.util.List; - +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; -import com.cloud.serializer.Param; -import com.google.gson.annotations.SerializedName; +import java.util.List; @SuppressWarnings("unused") public class ServiceResponse extends BaseResponse { @@ -30,7 +29,7 @@ public class ServiceResponse extends BaseResponse { @SerializedName(ApiConstants.NAME) @Param(description="the service name") private String name; - @SerializedName(ApiConstants.PROVIDER) @Param(description="the service provider name") + @SerializedName(ApiConstants.PROVIDER) @Param(description="the service provider name", responseObject = ProviderResponse.class) private List providers; @SerializedName("capability") @Param(description="the list of capabilities", responseObject = CapabilityResponse.class) diff --git a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java index 66dde3655f0..0b1622640d0 100644 --- a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java +++ b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java @@ -79,9 +79,26 @@ public class StoragePoolResponse extends BaseResponse { @SerializedName(ApiConstants.STATE) @Param(description="the state of the storage pool") private StoragePoolStatus state; + + @SerializedName(ApiConstants.SCOPE) @Param(description="the scope of the storage pool") + private String scope; + /** + * @return the scope + */ + public String getScope() { + return scope; + } + + /** + * @param scope the scope to set + */ + public void setScope(String scope) { + this.scope = scope; + } + @Override public String getObjectId() { return this.getId(); diff --git a/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java b/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java index bc22804ae06..aeed81d2011 100644 --- a/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java +++ b/api/src/org/apache/cloudstack/network/ExternalNetworkDeviceManager.java @@ -43,7 +43,6 @@ public interface ExternalNetworkDeviceManager extends Manager { public static final NetworkDevice F5BigIpLoadBalancer = new NetworkDevice("F5BigIpLoadBalancer", Network.Provider.F5BigIp.getName()); public static final NetworkDevice JuniperSRXFirewall = new NetworkDevice("JuniperSRXFirewall", Network.Provider.JuniperSRX.getName()); public static final NetworkDevice NiciraNvp = new NetworkDevice("NiciraNvp", Network.Provider.NiciraNvp.getName()); - public static final NetworkDevice MidokuraMidonet = new NetworkDevice("MidokuraMidonet", Network.Provider.MidokuraMidonet.getName()); public NetworkDevice(String deviceName, String ntwkServiceprovider) { _name = deviceName; diff --git a/client/pom.xml b/client/pom.xml index 61cda76aa2e..9323d0fb20f 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -65,16 +65,6 @@ cloud-plugin-network-nvp ${project.version} - - org.apache.cloudstack - cloud-plugin-syslog-alerts - ${project.version} - - - org.apache.cloudstack - cloud-plugin-snmp-alerts - ${project.version} - org.apache.cloudstack cloud-plugin-network-ovs @@ -90,6 +80,11 @@ cloud-plugin-network-vns ${project.version} + + org.apache.cloudstack + cloud-plugin-network-midonet + ${project.version} + org.apache.cloudstack cloud-plugin-hypervisor-xen @@ -224,16 +219,21 @@ cloud-plugin-hypervisor-simulator ${project.version} - - org.apache.cloudstack - cloud-plugin-hypervisor-ucs - ${project.version} - org.apache.cloudstack cloud-plugin-storage-volume-default ${project.version} + + org.apache.cloudstack + cloud-plugin-syslog-alerts + ${project.version} + + + org.apache.cloudstack + cloud-plugin-snmp-alerts + ${project.version} + install @@ -279,6 +279,26 @@ maven-antrun-plugin 1.7 + + + copy-systemvm + package + + run + + + + + + + + + + + + generate-resource generate-resources @@ -306,12 +326,6 @@ - - - - - - @@ -391,22 +405,38 @@ - - process-nonoss - process-resources - - run - - - - test - - - - + + process-nonoss + process-resources + + run + + + + test + + + + + + process-simulator-context + process-resources + + run + + + + test + + + + process-nonoss-spring-context process-resources @@ -495,6 +525,21 @@ + + developer + + + simulator + + + + + org.apache.cloudstack + cloud-plugin-hypervisor-simulator + ${project.version} + + + netapp diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index e492f182df4..9eda42636c4 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -32,6 +32,12 @@ + + + + + + @@ -379,6 +385,12 @@ + + + + + + + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -637,9 +705,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in index 9d95e150129..bea2f787c17 100644 --- a/client/tomcatconf/componentContext.xml.in +++ b/client/tomcatconf/componentContext.xml.in @@ -1,3 +1,4 @@ + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + + - + - + - - + + + @@ -125,7 +136,10 @@ - + + + + @@ -134,28 +148,73 @@ - - - - - - - + + + - + - + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -166,55 +225,29 @@ + + - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/client/tomcatconf/db-enc.properties.in b/client/tomcatconf/db-enc.properties.in deleted file mode 100644 index a9404fa4932..00000000000 --- a/client/tomcatconf/db-enc.properties.in +++ /dev/null @@ -1,68 +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. - -# management server clustering parameters, change cluster.node.IP to the machine IP address -# in which the management server(Tomcat) is running -cluster.node.IP=127.0.0.1 -cluster.servlet.port=9090 - -# CloudStack database settings -db.cloud.username=@DBUSER@ -db.cloud.password=@DBPW@ -db.cloud.host=@DBHOST@ -db.cloud.port=3306 -db.cloud.name=cloud - -# CloudStack database tuning parameters -db.cloud.maxActive=250 -db.cloud.maxIdle=30 -db.cloud.maxWait=10000 -db.cloud.autoReconnect=true -db.cloud.validationQuery=SELECT 1 -db.cloud.testOnBorrow=true -db.cloud.testWhileIdle=true -db.cloud.timeBetweenEvictionRunsMillis=40000 -db.cloud.minEvictableIdleTimeMillis=240000 -db.cloud.poolPreparedStatements=false -db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true - -# CloudStack database SSL settings -db.cloud.useSSL=false -db.cloud.keyStore= -db.cloud.keyStorePassword= -db.cloud.trustStore= -db.cloud.trustStorePassword= - -# Encryption Settings -db.cloud.encryption.type=file -db.cloud.encrypt.secret=password - -# usage database settings -db.usage.username=@DBUSER@ -db.usage.password=@DBPW@ -db.usage.host=@DBHOST@ -db.usage.port=3306 -db.usage.name=cloud_usage - -# usage database tuning parameters -db.usage.maxActive=100 -db.usage.maxIdle=30 -db.usage.maxWait=10000 -db.usage.autoReconnect=true - -# awsapi database settings -db.awsapi.name=cloudbridge diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in index 0b02eb687c9..fc8a9cd5409 100644 --- a/client/tomcatconf/nonossComponentContext.xml.in +++ b/client/tomcatconf/nonossComponentContext.xml.in @@ -32,11 +32,23 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + - + + + + + + @@ -78,6 +90,10 @@ + + @@ -128,73 +144,59 @@ - - - + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -204,12 +206,13 @@ --> - + - - + + + @@ -218,7 +221,10 @@ - + + + + @@ -228,26 +234,73 @@ - - - - - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -258,51 +311,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + + + + diff --git a/client/tomcatconf/server-ssl.xml.in b/client/tomcatconf/server-ssl.xml.in index 5d68f1d3d8b..37bc53d25d4 100755 --- a/client/tomcatconf/server-ssl.xml.in +++ b/client/tomcatconf/server-ssl.xml.in @@ -94,7 +94,7 @@ maxThreads="150" scheme="https" secure="true" URIEncoding="UTF-8" clientAuth="false" sslProtocol="TLS" keystoreType="JKS" - keystoreFile="/etc/cloud/management/cloudmanagementserver.keystore" + keystoreFile="/etc/cloudstack/management/cloudmanagementserver.keystore" keystorePass="vmops.com"/> @@ -200,7 +200,7 @@ maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreType="JKS" - keystoreFile="/etc/cloud/management/cloudmanagementserver.keystore" + keystoreFile="/etc/cloudstack/management/cloudmanagementserver.keystore" keystorePass="vmops.com"/> diff --git a/client/tomcatconf/server.xml.in b/client/tomcatconf/server.xml.in deleted file mode 100644 index 30e6a6cd6f9..00000000000 --- a/client/tomcatconf/server.xml.in +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/client/tomcatconf/simulatorComponentContext.xml.in b/client/tomcatconf/simulatorComponentContext.xml.in new file mode 100644 index 00000000000..fc5cf540bd0 --- /dev/null +++ b/client/tomcatconf/simulatorComponentContext.xml.in @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/tomcatconf/tomcat6-ssl.conf.in b/client/tomcatconf/tomcat6-ssl.conf.in index 84b6d6275bb..0d2650871b6 100644 --- a/client/tomcatconf/tomcat6-ssl.conf.in +++ b/client/tomcatconf/tomcat6-ssl.conf.in @@ -40,7 +40,7 @@ CATALINA_TMPDIR="@MSENVIRON@/temp" # Use JAVA_OPTS to set java.library.path for libtcnative.so #JAVA_OPTS="-Djava.library.path=/usr/lib64" -JAVA_OPTS="-Djava.awt.headless=true -Djavax.net.ssl.trustStore=/etc/cloud/management/cloudmanagementserver.keystore -Djavax.net.ssl.trustStorePassword=vmops.com -Dcom.sun.management.jmxremote.port=45219 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=@MSLOGDIR@ -XX:MaxPermSize=800m -XX:PermSize=512M" +JAVA_OPTS="-Djava.awt.headless=true -Djavax.net.ssl.trustStore=/etc/cloudstack/management/cloudmanagementserver.keystore -Djavax.net.ssl.trustStorePassword=vmops.com -Dcom.sun.management.jmxremote.port=45219 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=@MSLOGDIR@ -XX:MaxPermSize=800m -XX:PermSize=512M" # What user should run tomcat TOMCAT_USER="@MSUSER@" diff --git a/debian/cloudstack-agent.install b/debian/cloudstack-agent.install index 02501855354..a3cc86964dd 100644 --- a/debian/cloudstack-agent.install +++ b/debian/cloudstack-agent.install @@ -5,9 +5,9 @@ # 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 @@ -20,7 +20,7 @@ /etc/cloudstack/agent/log4j-cloud.xml /etc/init.d/cloudstack-agent /usr/bin/cloudstack-setup-agent -/usr/bin/cloud-ssh +/usr/bin/cloudstack-ssh /var/log/cloudstack/agent /usr/share/cloudstack-agent/lib/* /usr/share/cloudstack-agent/plugins diff --git a/debian/cloudstack-common.install b/debian/cloudstack-common.install index 9677f871cf0..7e01adadedf 100644 --- a/debian/cloudstack-common.install +++ b/debian/cloudstack-common.install @@ -5,9 +5,9 @@ # 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 @@ -26,6 +26,7 @@ /usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/* /usr/share/cloudstack-common/scripts/vm/hypervisor/versions.sh /usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/* -/usr/bin/cloud-set-guest-password -/usr/bin/cloud-set-guest-sshkey +/usr/share/cloudstack-common/lib/* +/usr/bin/cloudstack-set-guest-password +/usr/bin/cloudstack-set-guest-sshkey /usr/lib/python2.?/*-packages/* diff --git a/debian/cloudstack-management.install b/debian/cloudstack-management.install index e80701d0a78..5a682d45862 100644 --- a/debian/cloudstack-management.install +++ b/debian/cloudstack-management.install @@ -15,7 +15,6 @@ # specific language governing permissions and limitations # under the License. -/etc/cloudstack/server/* /etc/cloudstack/management/* /etc/init.d/cloudstack-management /etc/security/limits.d/cloudstack-limits.conf @@ -26,10 +25,10 @@ /var/log/cloudstack/management /var/lib/cloudstack/mnt /var/lib/cloudstack/management -/usr/bin/cloud-update-xenserver-licenses -/usr/bin/cloud-setup-management -/usr/bin/cloud-setup-databases -/usr/bin/cloud-migrate-databases +/usr/bin/cloudstack-update-xenserver-licenses +/usr/bin/cloudstack-setup-management +/usr/bin/cloudstack-setup-databases +/usr/bin/cloudstack-migrate-databases +/usr/bin/cloudstack-setup-encryption +/usr/bin/cloudstack-sysvmadm /usr/share/cloudstack-management/* -/usr/share/java/* -/usr/share/tomcat6/lib/* diff --git a/debian/cloudstack-management.postinst b/debian/cloudstack-management.postinst index 4e9b046caff..a1219cc789f 100644 --- a/debian/cloudstack-management.postinst +++ b/debian/cloudstack-management.postinst @@ -6,9 +6,9 @@ # 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 @@ -20,22 +20,33 @@ if [ "$1" = configure ]; then if ! getent passwd cloud >/dev/null; then adduser --quiet --system --group --no-create-home --home /var/lib/cloudstack/management cloud else - usermod -m -d /var/lib/cloudstack/management cloud + usermod -m -d /var/lib/cloudstack/management cloud || true fi for i in /var/cache/cloudstack/management \ /var/cache/cloudstack/management/work \ /var/cache/cloudstack/management/temp \ /var/log/cloudstack/management \ - /etc/cloudstack/management/Catalina \ - /etc/cloudstack/management/Catalina/localhost \ - /var/lib/cloudstack/management \ - /etc/cloudstack/management/Catalina/localhost/client + /var/lib/cloudstack/management do chmod 0770 $i chgrp cloud $i done + OLDCONFDIR="/etc/cloud/management" + NEWCONFDIR="/etc/cloudstack/management" + CONFFILES="db.properties cloud.keystore key" + + # Copy old configuration so the admin doesn't have to do that + # Only do so when we are installing for the first time + if [ -z "$2" ]; then + for FILE in $CONFFILES; do + if [ -f "$OLDCONFDIR/${FILE}" ]; then + cp -a $OLDCONFDIR/$FILE $NEWCONFDIR/$FILE + fi + done + fi + chmod 0640 /etc/cloudstack/management/db.properties chgrp cloud /etc/cloudstack/management/db.properties fi diff --git a/debian/control b/debian/control index 8f82fc3ab2f..eec9ca25c7b 100644 --- a/debian/control +++ b/debian/control @@ -15,14 +15,14 @@ Description: A common package which contains files which are shared by several C Package: cloudstack-management Architecture: all -Depends: cloudstack-common (= ${source:Version}), tomcat6, sysvinit-utils, chkconfig, sudo, jsvc, python-mysqldb, python-paramiko, augeas-tools +Depends: cloudstack-common (= ${source:Version}), tomcat6, sysvinit-utils, sudo, jsvc, python-mysqldb, python-paramiko, augeas-tools Conflicts: cloud-server, cloud-client, cloud-client-ui Description: CloudStack server library The CloudStack management server Package: cloudstack-agent Architecture: all -Depends: openjdk-6-jre | openjdk-7-jre, cloudstack-common (= ${source:Version}), lsb-base (>= 3.2), libcommons-daemon-java, libjna-java, openssh-client, libvirt0, sysvinit-utils, chkconfig, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, perl-base, perl-modules, ebtables, vlan, wget, jsvc +Depends: openjdk-6-jre | openjdk-7-jre, cloudstack-common (= ${source:Version}), lsb-base (>= 3.2), libcommons-daemon-java, libjna-java, openssh-client, libvirt0, sysvinit-utils, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, perl-base, perl-modules, ebtables, vlan, wget, jsvc, ipset Conflicts: cloud-agent, cloud-agent-libs, cloud-agent-deps, cloud-agent-scripts Description: CloudStack agent The CloudStack agent is in charge of managing shared computing resources in diff --git a/debian/rules b/debian/rules index 3804d8d49e9..4e55c71048c 100755 --- a/debian/rules +++ b/debian/rules @@ -69,7 +69,7 @@ install: install -D plugins/hypervisors/kvm/target/dependencies/* $(DESTDIR)/usr/share/$(PACKAGE)-agent/lib/ install -D packaging/debian/init/cloud-agent $(DESTDIR)/$(SYSCONFDIR)/init.d/$(PACKAGE)-agent install -D agent/bindir/cloud-setup-agent.in $(DESTDIR)/usr/bin/cloudstack-setup-agent - install -D agent/bindir/cloud-ssh.in $(DESTDIR)/usr/bin/cloud-ssh + install -D agent/bindir/cloud-ssh.in $(DESTDIR)/usr/bin/cloudstack-ssh install -D agent/target/transformed/* $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/agent # cloudstack-management @@ -98,16 +98,15 @@ install: chmod 0440 $(DESTDIR)/$(SYSCONFDIR)/sudoers.d/cloudstack ln -s tomcat6-nonssl.conf $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/tomcat6.conf - mkdir -p $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/Catalina/localhost/client - mkdir -p ${DESTDIR}/usr/share/tomcat6/lib - mkdir -p ${DESTDIR}/usr/share/java + ln -s server-nonssl.xml $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/server.xml install -D packaging/debian/init/cloud-management $(DESTDIR)/$(SYSCONFDIR)/init.d/$(PACKAGE)-management - install -D client/bindir/cloud-update-xenserver-licenses.in $(DESTDIR)/usr/bin/cloud-update-xenserver-licenses - install -D server/target/cloud-server-$(VERSION)-SNAPSHOT.jar $(DESTDIR)/usr/share/java/$(PACKAGE)-server.jar + install -D client/bindir/cloud-update-xenserver-licenses.in $(DESTDIR)/usr/bin/cloudstack-update-xenserver-licenses ln -s /usr/share/tomcat6/bin $(DESTDIR)/usr/share/$(PACKAGE)-management/bin + # Remove configuration in /ur/share/cloudstack-management/webapps/client/WEB-INF + # This should all be in /etc/cloudstack/management + rm $(DESTDIR)/usr/share/$(PACKAGE)-management/webapps/client/WEB-INF/classes/*.* ln -s ../../..$(SYSCONFDIR)/$(PACKAGE)/management $(DESTDIR)/usr/share/$(PACKAGE)-management/conf ln -s ../../../usr/share/tomcat6/lib $(DESTDIR)/usr/share/$(PACKAGE)-management/lib - ln -s ../../java/$(PACKAGE)-server.jar $(DESTDIR)/usr/share/tomcat6/lib/$(PACKAGE)-server.jar ln -s ../../../var/log/$(PACKAGE)/management $(DESTDIR)/usr/share/$(PACKAGE)-management/logs ln -s ../../../var/cache/$(PACKAGE)/management/temp $(DESTDIR)/usr/share/$(PACKAGE)-management/temp ln -s ../../../var/cache/$(PACKAGE)/management/work $(DESTDIR)/usr/share/$(PACKAGE)-management/work @@ -116,17 +115,22 @@ install: mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-common mkdir $(DESTDIR)/usr/share/$(PACKAGE)-common/scripts mkdir $(DESTDIR)/usr/share/$(PACKAGE)-common/setup + mkdir $(DESTDIR)/usr/share/$(PACKAGE)-common/lib cp -r scripts/installer $(DESTDIR)/usr/share/$(PACKAGE)-common/scripts cp -r scripts/network $(DESTDIR)/usr/share/$(PACKAGE)-common/scripts cp -r scripts/storage $(DESTDIR)/usr/share/$(PACKAGE)-common/scripts cp -r scripts/util $(DESTDIR)/usr/share/$(PACKAGE)-common/scripts cp -r scripts/vm $(DESTDIR)/usr/share/$(PACKAGE)-common/scripts - install -D client/target/utilities/bin/cloud-migrate-databases $(DESTDIR)/usr/bin - install -D client/target/utilities/bin/cloud-set-guest-password $(DESTDIR)/usr/bin - install -D client/target/utilities/bin/cloud-set-guest-sshkey $(DESTDIR)/usr/bin - install -D client/target/utilities/bin/cloud-setup-databases $(DESTDIR)/usr/bin - install -D client/target/utilities/bin/cloud-setup-management $(DESTDIR)/usr/bin - install -D client/target/cloud-client-ui-$(VERSION)-SNAPSHOT/WEB-INF/classes/vms/systemvm.iso $(DESTDIR)/usr/share/$(PACKAGE)-common/vms/systemvm.iso + install -D client/target/utilities/bin/cloud-migrate-databases $(DESTDIR)/usr/bin/cloudstack-migrate-databases + install -D client/target/utilities/bin/cloud-set-guest-password $(DESTDIR)/usr/bin/cloudstack-set-guest-password + install -D client/target/utilities/bin/cloud-set-guest-sshkey $(DESTDIR)/usr/bin/cloudstack-set-guest-sshkey + install -D client/target/utilities/bin/cloud-setup-databases $(DESTDIR)/usr/bin/cloudstack-setup-databases + install -D client/target/utilities/bin/cloud-setup-management $(DESTDIR)/usr/bin/cloudstack-setup-management + install -D client/target/utilities/bin/cloud-setup-encryption $(DESTDIR)/usr/bin/cloudstack-setup-encryption + install -D client/target/utilities/bin/cloud-sysvmadm $(DESTDIR)/usr/bin/cloudstack-sysvmadm + install -D services/console-proxy/server/dist/systemvm.iso $(DESTDIR)/usr/share/$(PACKAGE)-common/vms/systemvm.iso + # We need jasypt for cloud-install-sys-tmplt, so this is a nasty hack to get it into the right place + install -D agent/target/dependencies/jasypt-1.9.0.jar $(DESTDIR)/usr/share/$(PACKAGE)-common/lib # cloudstack-python mkdir -p $(DESTDIR)/usr/lib/python2.7/dist-packages @@ -152,10 +156,7 @@ install: binary: install dh_install dh_installchangelogs - dh_installdocs LICENSE - dh_installdocs DISCLAIMER - dh_installdocs NOTICE - dh_installdocs INSTALL.md + dh_installdocs -A tools/whisker/LICENSE tools/whisker/NOTICE INSTALL.md dh_installman dh_link dh_strip diff --git a/developer/developer-prefill.sql b/developer/developer-prefill.sql index 6300d35df64..e4f90cad6e8 100644 --- a/developer/developer-prefill.sql +++ b/developer/developer-prefill.sql @@ -36,7 +36,7 @@ INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, -- Add system user with encrypted password=password INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, email, state, created) VALUES (2, UUID(), 'admin', '5f4dcc3b5aa765d61d8327deb882cf99', - '2', 'Admin', 'User', 'admin@mailprovider.com', 'enabled', NOW()); + '2', 'Admin', 'User', 'admin@mailprovider.com', 'disabled', NOW()); -- Add configurations INSERT INTO `cloud`.`configuration` (category, instance, component, name, value) diff --git a/docs/en-US/Book_Info.xml b/docs/en-US/Book_Info.xml index be8bcdd7544..c125ab8de2b 100644 --- a/docs/en-US/Book_Info.xml +++ b/docs/en-US/Book_Info.xml @@ -22,23 +22,26 @@ specific language governing permissions and limitations under the License. --> + - &PRODUCT; Guide - Revised August 9, 2012 10:48 pm Pacific - Apache CloudStack - 4.0.0 - 1 - - - Complete technical documentation of &PRODUCT;. - - - - - - - - - - + &PRODUCT; Guide + Revised August 9, 2012 10:48 pm Pacific + Apache CloudStack + 4.0.0-incubating + 1 + + + + Complete technical documentation of &PRODUCT;. + + + + + + + + + + + diff --git a/docs/en-US/Book_Info_Release_Notes_4-0.xml b/docs/en-US/Book_Info_Release_Notes_4-0.xml index 0d57fb6d9a8..9655986cc99 100644 --- a/docs/en-US/Book_Info_Release_Notes_4-0.xml +++ b/docs/en-US/Book_Info_Release_Notes_4-0.xml @@ -18,14 +18,13 @@ specific language governing permissions and limitations under the License. --> - - Version 4.0.0-incubating Release Notes - Revised October 17, 2012 19:49 UTC + + Version 4.1.0 Release Notes Apache CloudStack - Release notes for the Apache CloudStack 4.0.0-incubating release. + Release notes for the Apache CloudStack 4.1.0 release. diff --git a/docs/en-US/Installation_Guide.xml b/docs/en-US/Installation_Guide.xml index fed53fc4a1d..6ce5527e86c 100644 --- a/docs/en-US/Installation_Guide.xml +++ b/docs/en-US/Installation_Guide.xml @@ -11,7 +11,9 @@ 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 @@ -50,6 +52,7 @@ + diff --git a/docs/en-US/Release_Notes.xml b/docs/en-US/Release_Notes.xml index 2cedb90a763..00cbc49c881 100644 --- a/docs/en-US/Release_Notes.xml +++ b/docs/en-US/Release_Notes.xml @@ -4,2929 +4,1260 @@ %BOOK_ENTITIES; ]> - - - Submitting Feedback and Getting Help - The Apache CloudStack project has mailing lists for users and developers. These are the - official channels of communication for the project and are the best way to get answers about - using and contributing to CloudStack. It's a good idea to subscribe to the cloudstack-users - mailing list if you've deployed or are deploying CloudStack into production, and even for test - deployments. - The CloudStack developer's mailing list (cloudstack-dev) is for discussions about - CloudStack development, and is the best list for discussing possible bugs in CloudStack. - Anyone contributing to CloudStack should be on this mailing list. - You can also report bugs in CloudStack using the Apache Defect Tracking - System. - To posts to the lists, you'll need to be subscribed. See the CloudStack Web site - for instructions. - - - Upgrade Instructions -
- Upgrade from 3.0.2 to 4.0.0-incubating - Perform the following to upgrade from version 3.0.2 to version 4.0.0-incubating. Note - that some of the steps here are only required if you're using a specific hypervisor. The - steps that are hypervisor-specific are called out with a note. - - - Ensure that you query your IP address usage records and process them or make a - backup. During the upgrade you will lose the old IP address usage records. - Starting in 3.0.2, the usage record format for IP addresses is the same as the rest - of the usage types. Instead of a single record with the assignment and release dates, - separate records are generated per aggregation period with start and end dates. After - upgrading, any existing IP address usage records in the old format will no longer be - available. - - - - The following upgrade instructions apply only if you're using VMware hosts. If - you're not using VMware hosts, skip this step and move on to step 3: stopping all - usage servers. - - In each zone that includes VMware hosts, you need to add a new system VM template. - - - While running the existing 3.0.2 system, log in to the UI as root - administrator. - - - In the left navigation bar, click Templates. - - - In Select view, click Templates. - - - Click Register template. - The Register template dialog box is displayed. - - - In the Register template dialog box, specify the following values (do not change - these): - - - - - - - Field - Value - - - - - Name - systemvm-vmware-4.0 - - - Description - systemvm-vmware-4.0 - - - URL - http://download.cloud.com/templates/burbank/burbank-systemvm-08012012.ova - - - Zone - Choose the zone where this hypervisor is used - - - Hypervisor - VMware - - - Format - OVA - - - OS Type - Debian GNU/Linux 5.0 (32-bit) - - - Extractable - no - - - Password Enabled - no - - - Public - no - - - Featured - no - - - - - - - Watch the screen to be sure that the template downloads successfully and enters - the READY state. Do not proceed until this is successful. - - - - - Stop all Usage Servers if running. Run this on all Usage Server hosts. - # service cloud-usage stop - - - Stop the Management Servers. Run this on all Management Server hosts. - # service cloud-management stop - - - On the MySQL master, take a backup of the MySQL databases. We recommend performing - this step even in test upgrades. If there is an issue, this will assist with - debugging. - In the following commands, it is assumed that you have set the root password on the - database, which is a CloudStack recommended best practice. Substitute your own MySQL - root password. - # mysqldump -u root -pmysql_password cloud > cloud-backup.dmp -# mysqldump -u root -pmysql_password cloud_usage > cloud-usage-backup.dmp - - - Either build RPM/DEB packages as detailed in the Installation Guide, or use one of - the community provided yum/apt repositories to gain access to the &PRODUCT; - binaries. - - - After you have configured an appropriate yum or apt repository, you may execute the - one of the following commands as appropriate for your environment in order to upgrade - &PRODUCT;: # yum update cloud-* - # apt-get update -# apt-get upgrade cloud-* - - You will, of course, have to agree to the changes suggested by Yum or APT. - - If the upgrade output includes a message similar to the following, then some - custom content was found in your old components.xml, and you need to merge the two - files: - warning: /etc/cloud/management/components.xml created as /etc/cloud/management/components.xml.rpmnew - Instructions follow in the next step. - - - - If you have made changes to your copy of - /etc/cloud/management/components.xml the changes will be - preserved in the upgrade. However, you need to do the following steps to place these - changes in a new version of the file which is compatible with version - 4.0.0-incubating. - - - Make a backup copy of /etc/cloud/management/components.xml. - For example: - # mv /etc/cloud/management/components.xml /etc/cloud/management/components.xml-backup - - - Copy /etc/cloud/management/components.xml.rpmnew to create - a new /etc/cloud/management/components.xml: - # cp -ap /etc/cloud/management/components.xml.rpmnew /etc/cloud/management/components.xml - - - Merge your changes from the backup file into the new - components.xml. - # vi /etc/cloud/management/components.xml - - - - If you have more than one management server node, repeat the upgrade steps on each - node. - - - - Start the first Management Server. Do not start any other Management Server nodes - yet. - # service cloud-management start - Wait until the databases are upgraded. Ensure that the database upgrade is complete. - After confirmation, start the other Management Servers one at a time by running the same - command on each node. - - Failing to restart the Management Server indicates a problem in the upgrade. - Having the Management Server restarted without any issues indicates that the upgrade - is successfully completed. - - - - Start all Usage Servers (if they were running on your previous version). Perform - this on each Usage Server host. - # service cloud-usage start - - - - Additional steps are required for each KVM host. These steps will not affect - running guests in the cloud. These steps are required only for clouds using KVM as - hosts and only on the KVM hosts. - - - - Configure a yum or apt respository containing the &PRODUCT; packages as outlined - in the Installation Guide. - - - Stop the running agent. - # service cloud-agent stop - - - Update the agent software with one of the following command sets as appropriate - for your environment. - # yum update cloud-* - # apt-get update - # apt-get upgrade cloud-* - - - Start the agent. - # service cloud-agent start - - - Edit /etc/cloud/agent/agent.properties to change the - resource parameter from - "com.cloud.agent.resource.computing.LibvirtComputingResource" to - "com.cloud.hypervisor.kvm.resource.LibvirtComputingResource". - - - Start the cloud agent and cloud management services. - - - When the Management Server is up and running, log in to the CloudStack UI and - restart the virtual router for proper functioning of all the features. - - - - - Log in to the CloudStack UI as administrator, and check the status of the hosts. All - hosts should come to Up state (except those that you know to be offline). You may need - to wait 20 or 30 minutes, depending on the number of hosts. - - Troubleshooting: If login fails, clear your browser cache and reload the - page. - - - Do not proceed to the next step until the hosts show in Up state. - - - If you are upgrading from 3.0.2, perform the following: - - - Ensure that the admin port is set to 8096 by using the "integration.api.port" - global parameter. - This port is used by the cloud-sysvmadm script at the end of the upgrade - procedure. For information about how to set this parameter, see "Setting Global - Configuration Parameters" in the Installation Guide. - - - Restart the Management Server. - - If you don't want the admin port to remain open, you can set it to null after - the upgrade is done and restart the management server. - - - - - - Run the cloud-sysvmadm script to stop, then start, all Secondary - Storage VMs, Console Proxy VMs, and virtual routers. Run the script once on each - management server. Substitute your own IP address of the MySQL instance, the MySQL user - to connect as, and the password to use for that user. In addition to those parameters, - provide the -c and -r arguments. For - example: - # nohup cloud-sysvmadm -d 192.168.1.5 -u cloud -p password -c -r > - sysvm.log 2>&1 & - # tail -f sysvm.log - This might take up to an hour or more to run, depending on the number of accounts in - the system. - - - If needed, upgrade all Citrix XenServer hypervisor hosts in your cloud to a version - supported by CloudStack 4.0.0-incubating. The supported versions are XenServer 5.6 SP2 - and 6.0.2. Instructions for upgrade can be found in the CloudStack 4.0.0-incubating - Installation Guide. - - - Now apply the XenServer hotfix XS602E003 (and any other needed hotfixes) to - XenServer v6.0.2 hypervisor hosts. - - - Disconnect the XenServer cluster from CloudStack. - In the left navigation bar of the CloudStack UI, select Infrastructure. Under - Clusters, click View All. Select the XenServer cluster and click Actions - - Unmanage. - This may fail if there are hosts not in one of the states Up, Down, - Disconnected, or Alert. You may need to fix that before unmanaging this - cluster. - Wait until the status of the cluster has reached Unmanaged. Use the CloudStack - UI to check on the status. When the cluster is in the unmanaged state, there is no - connection to the hosts in the cluster. - - - To clean up the VLAN, log in to one XenServer host and run: - /opt/xensource/bin/cloud-clean-vlan.sh - - - Now prepare the upgrade by running the following on one XenServer host: - /opt/xensource/bin/cloud-prepare-upgrade.sh - If you see a message like "can't eject CD", log in to the VM and unmount the CD, - then run this script again. - - - Upload the hotfix to the XenServer hosts. Always start with the Xen pool master, - then the slaves. Using your favorite file copy utility (e.g. WinSCP), copy the - hotfixes to the host. Place them in a temporary folder such as /tmp. - On the Xen pool master, upload the hotfix with this command: - xe patch-upload file-name=XS602E003.xsupdate - Make a note of the output from this command, which is a UUID for the hotfix - file. You'll need it in another step later. - - (Optional) If you are applying other hotfixes as well, you can repeat the - commands in this section with the appropriate hotfix number. For example, - XS602E004.xsupdate. - - - - Manually live migrate all VMs on this host to another host. First, get a list of - the VMs on this host: - # xe vm-list - Then use this command to migrate each VM. Replace the example host name and VM - name with your own: - # xe vm-migrate live=true host=host-name - vm=VM-name - - Troubleshooting - If you see a message like "You attempted an operation on a VM which requires - PV drivers to be installed but the drivers were not detected," run: - /opt/xensource/bin/make_migratable.sh - b6cf79c8-02ee-050b-922f-49583d9f1a14. - - - - Apply the hotfix. First, get the UUID of this host: - # xe host-list - Then use the following command to apply the hotfix. Replace the example host - UUID with the current host ID, and replace the hotfix UUID with the output from the - patch-upload command you ran on this machine earlier. You can also get the hotfix - UUID by running xe patch-list. - xe patch-apply host-uuid=host-uuid uuid=hotfix-uuid - - - Copy the following files from the CloudStack Management Server to the - host. - - - - - - - Copy from here... - ...to here - - - - - /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py - /opt/xensource/sm/NFSSR.py - - - /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/setupxenserver.sh - /opt/xensource/bin/setupxenserver.sh - - - /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/make_migratable.sh - /opt/xensource/bin/make_migratable.sh - - - - - - - (Only for hotfixes XS602E005 and XS602E007) You need to apply a new Cloud - Support Pack. - + + + + Welcome to &PRODUCT; 4.1 + Welcome to the 4.1.0 release of &PRODUCT;, the first major release from the Apache CloudStack project since its graduation from the Apache Incubator. + This document contains information specific to this release of &PRODUCT;, including upgrade instructions from prior releases, new features added to &PRODUCT;, API changes, and issues fixed in the release. For installation instructions, please see the Installation Guide. For usage and administration instructions, please see the &PRODUCT; Administrator's Guide. Developers and users who wish to work with the API will find instruction in the &PRODUCT; API Developer's Guide + If you find any errors or problems in this guide, please see . We hope you enjoy working with &PRODUCT;! + + + Upgrade Instructions + This section contains upgrade instructions from prior versions of CloudStack to Apache CloudStack 4.1.0. We include instructions on upgrading to Apache CloudStack from pre-Apache versions of Citrix CloudStack (last version prior to Apache is 3.0.2) and from the releases made while CloudStack was in the Apache Incubator. + If you run into any issues during upgrades, please feel free to ask questions on users@apache.cloudstack.org or dev@apache.cloudstack.org. +
+ Upgrade from 4.0.x to 4.1.0 + This section will guide you from Apache CloudStack 4.0.x versions (4.0.0-incubating, 4.0.1-incubating, and 4.0.2) to &PRODUCT; 4.1.0. + Any steps that are hypervisor-specific will be called out with a note. + Package Structure Changes + The package structure for &PRODUCT; has changed significantly since the 4.0.x releases. If you've compiled your own packages, you'll notice that the package names and the number of packages has changed. This is not a bug. + However, this does mean that the procedure is not as simple as an apt-get upgrade or yum update, so please follow this section carefully. + + We recommend reading through this section once or twice before beginning your upgrade procedure, and working through it on a test system before working on a production system. + - Download the CSP software onto the XenServer host from one of the following - links: - For hotfix XS602E005: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E005/56710/xe-phase-2/xenserver-cloud-supp.tgz - For hotfix XS602E007: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E007/57824/xe-phase-2/xenserver-cloud-supp.tgz + Most users of &PRODUCT; manage the installation and upgrades of &PRODUCT; with one of Linux's predominant package systems, RPM or APT. This guide assumes you'll be using RPM and Yum (for Red Hat Enterprise Linux or CentOS), or APT and Debian packages (for Ubuntu). + Create RPM or Debian packages (as appropriate) and a repository from the 4.1.0 source, or check the Apache CloudStack downloads page at http://cloudstack.apache.org/downloads.html for package repositories supplied by community members. You will need them for step or step . + Instructions for creating packages from the &PRODUCT; source are in the Installation Guide. - Extract the file: - # tar xf xenserver-cloud-supp.tgz + Stop your management server or servers. Run this on all management server hosts: + # service cloud-management stop - Run the following script: - # xe-install-supplemental-pack xenserver-cloud-supp.iso + Make a backup of your MySQL database. If you run into any issues or need to roll back the upgrade, this will assist in debugging or restoring your existing environment. You'll be prompted for your password. + # mysqldump -u root -p cloud > cloudstack-backup.sql - If the XenServer host is part of a zone that uses basic networking, disable - Open vSwitch (OVS): - # xe-switch-network-backend bridge - - - - - Reboot this XenServer host. - - - Run the following: - /opt/xensource/bin/setupxenserver.sh - - If the message "mv: cannot stat `/etc/cron.daily/logrotate': No such file or - directory" appears, you can safely ignore it. - - - - Run the following: - for pbd in `xe pbd-list currently-attached=false| grep ^uuid | awk '{print $NF}'`; do xe pbd-plug uuid=$pbd ; - - - On each slave host in the Xen pool, repeat these steps, starting from "manually - live migrate VMs." - - - - - - Troubleshooting Tip - If passwords which you know to be valid appear not to work after upgrade, or other UI - issues are seen, try clearing your browser cache and reloading the UI page. - -
-
- Upgrade from 2.2.14 to 4.0.0-incubating - - - Ensure that you query your IPaddress usage records and process them; for example, - issue invoices for any usage that you have not yet billed users for. - Starting in 3.0.2, the usage record format for IP addresses is the same as the rest - of the usage types. Instead of a single record with the assignment and release dates, - separate records are generated per aggregation period with start and end dates. After - upgrading to 4.0.0-incubating, any existing IP address usage records in the old format - will no longer be available. - - - If you are using version 2.2.0 - 2.2.13, first upgrade to 2.2.14 by using the - instructions in the 2.2.14 Release Notes. - - KVM Hosts - If KVM hypervisor is used in your cloud, be sure you completed the step to insert - a valid username and password into the host_details table on each KVM node as - described in the 2.2.14 Release Notes. This step is critical, as the database will be - encrypted after the upgrade to 4.0.0-incubating. - - - - While running the 2.2.14 system, log in to the UI as root administrator. - - - Using the UI, add a new System VM template for each hypervisor type that is used in - your cloud. In each zone, add a system VM template for each hypervisor used in that - zone - - - In the left navigation bar, click Templates. - - - In Select view, click Templates. - - - Click Register template. - The Register template dialog box is displayed. - - - In the Register template dialog box, specify the following values depending on - the hypervisor type (do not change these): - - - - - - - Hypervisor - Description - - - - - XenServer - Name: systemvm-xenserver-3.0.0 - Description: systemvm-xenserver-3.0.0 - URL: - http://download.cloud.com/templates/acton/acton-systemvm-02062012.vhd.bz2 - Zone: Choose the zone where this hypervisor is used - Hypervisor: XenServer - Format: VHD - OS Type: Debian GNU/Linux 5.0 (32-bit) - Extractable: no - Password Enabled: no - Public: no - Featured: no - - - - KVM - Name: systemvm-kvm-3.0.0 - Description: systemvm-kvm-3.0.0 - URL: - http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2 - Zone: Choose the zone where this hypervisor is used - Hypervisor: KVM - Format: QCOW2 - OS Type: Debian GNU/Linux 5.0 (32-bit) - Extractable: no - Password Enabled: no - Public: no - Featured: no - - - - VMware - Name: systemvm-vmware-3.0.0 - Description: systemvm-vmware-3.0.0 - URL: - http://download.cloud.com/templates/burbank/burbank-systemvm-08012012.ova - Zone: Choose the zone where this hypervisor is used - Hypervisor: VMware - Format: OVA - OS Type: Debian GNU/Linux 5.0 (32-bit) - Extractable: no - Password Enabled: no - Public: no - Featured: no - - - - - - - - - - Watch the screen to be sure that the template downloads successfully and enters the - READY state. Do not proceed until this is successful - - - WARNING: If you use more than one type of - hypervisor in your cloud, be sure you have repeated these steps to download the system - VM template for each hypervisor type. Otherwise, the upgrade will fail. - - - Stop all Usage Servers if running. Run this on all Usage Server hosts. - # service cloud-usage stop - - - Stop the Management Servers. Run this on all Management Server hosts. - # service cloud-management stop - - - On the MySQL master, take a backup of the MySQL databases. We recommend performing - this step even in test upgrades. If there is an issue, this will assist with - debugging. - In the following commands, it is assumed that you have set the root password on the - database, which is a CloudStack recommended best practice. Substitute your own MySQL - root password. - # mysqldump -u root -pmysql_password cloud > cloud-backup.dmp -# mysqldump -u root -pmysql_password cloud_usage > cloud-usage-backup.dmp - - - - Either build RPM/DEB packages as detailed in the Installation Guide, or use one of - the community provided yum/apt repositories to gain access to the &PRODUCT; binaries. - - - - After you have configured an appropriate yum or apt repository, you may execute the - one of the following commands as appropriate for your environment in order to upgrade - &PRODUCT;: # yum update cloud-* - # apt-get update -# apt-get upgrade cloud-* - - You will, of course, have to agree to the changes suggested by Yum or APT. - - - If you have made changes to your existing copy of the file components.xml in your - previous-version CloudStack installation, the changes will be preserved in the upgrade. - However, you need to do the following steps to place these changes in a new version of - the file which is compatible with version 4.0.0-incubating. - - How will you know whether you need to do this? If the upgrade output in the - previous step included a message like the following, then some custom content was - found in your old components.xml, and you need to merge the two files: - - warning: /etc/cloud/management/components.xml created as /etc/cloud/management/components.xml.rpmnew - - - Make a backup copy of your - /etc/cloud/management/components.xml file. For - example: - # mv /etc/cloud/management/components.xml /etc/cloud/management/components.xml-backup - - - Copy /etc/cloud/management/components.xml.rpmnew to create - a new /etc/cloud/management/components.xml: - # cp -ap /etc/cloud/management/components.xml.rpmnew /etc/cloud/management/components.xml - - - Merge your changes from the backup file into the new components.xml file. - # vi /etc/cloud/management/components.xml - - - - - - If you have made changes to your existing copy of the - /etc/cloud/management/db.properties file in your previous-version - CloudStack installation, the changes will be preserved in the upgrade. However, you need - to do the following steps to place these changes in a new version of the file which is - compatible with version 4.0.0-incubating. - - - Make a backup copy of your file - /etc/cloud/management/db.properties. For example: - # mv /etc/cloud/management/db.properties /etc/cloud/management/db.properties-backup - - - Copy /etc/cloud/management/db.properties.rpmnew to create a - new /etc/cloud/management/db.properties: - # cp -ap /etc/cloud/management/db.properties.rpmnew etc/cloud/management/db.properties - - - Merge your changes from the backup file into the new db.properties file. - # vi /etc/cloud/management/db.properties - - - - - On the management server node, run the following command. It is recommended that you - use the command-line flags to provide your own encryption keys. See Password and Key - Encryption in the Installation Guide. - # cloud-setup-encryption -e encryption_type -m management_server_key -k database_key - When used without arguments, as in the following example, the default encryption - type and keys will be used: - - - (Optional) For encryption_type, use file or web to indicate the technique used - to pass in the database encryption password. Default: file. - - - (Optional) For management_server_key, substitute the default key that is used to - encrypt confidential parameters in the properties file. Default: password. It is - highly recommended that you replace this with a more secure value - - - (Optional) For database_key, substitute the default key that is used to encrypt - confidential parameters in the CloudStack database. Default: password. It is highly - recommended that you replace this with a more secure value. - - - - - Repeat steps 10 - 14 on every management server node. If you provided your own - encryption key in step 14, use the same key on all other management servers. - - - Start the first Management Server. Do not start any other Management Server nodes - yet. - # service cloud-management start - Wait until the databases are upgraded. Ensure that the database upgrade is complete. - You should see a message like "Complete! Done." After confirmation, start the other - Management Servers one at a time by running the same command on each node. - - - Start all Usage Servers (if they were running on your previous version). Perform - this on each Usage Server host. - # service cloud-usage start - - - (KVM only) Additional steps are required for each KVM host. These steps will not - affect running guests in the cloud. These steps are required only for clouds using KVM - as hosts and only on the KVM hosts. - - - Configure your CloudStack package repositories as outlined in the Installation - Guide - - - Stop the running agent. - # service cloud-agent stop - - - Update the agent software with one of the following command sets as - appropriate. - # yum update cloud-* - - # apt-get update -# apt-get upgrade cloud-* - - - - Start the agent. - # service cloud-agent start - - - Copy the contents of the agent.properties file to the new - agent.properties file by using the following command - sed -i 's/com.cloud.agent.resource.computing.LibvirtComputingResource/com.cloud.hypervisor.kvm.resource.LibvirtComputingResource/g' /etc/cloud/agent/agent.properties - - - Start the cloud agent and cloud management services. - - - When the Management Server is up and running, log in to the CloudStack UI and - restart the virtual router for proper functioning of all the features. - - - - - Log in to the CloudStack UI as admin, and check the status of the hosts. All hosts - should come to Up state (except those that you know to be offline). You may need to wait - 20 or 30 minutes, depending on the number of hosts. - Do not proceed to the next step until the hosts show in the Up state. If the hosts - do not come to the Up state, contact support. - - - Run the following script to stop, then start, all Secondary Storage VMs, Console - Proxy VMs, and virtual routers. - - - Run the command once on one management server. Substitute your own IP address of - the MySQL instance, the MySQL user to connect as, and the password to use for that - user. In addition to those parameters, provide the "-c" and "-r" arguments. For - example: - # nohup cloud-sysvmadm -d 192.168.1.5 -u cloud -p password -c -r > sysvm.log 2>&1 & -# tail -f sysvm.log - This might take up to an hour or more to run, depending on the number of - accounts in the system. - - - After the script terminates, check the log to verify correct execution: - # tail -f sysvm.log - The content should be like the following: - -Stopping and starting 1 secondary storage vm(s)... -Done stopping and starting secondary storage vm(s) -Stopping and starting 1 console proxy vm(s)... -Done stopping and starting console proxy vm(s). -Stopping and starting 4 running routing vm(s)... -Done restarting router(s). - - - - - - If you would like additional confirmation that the new system VM templates were - correctly applied when these system VMs were rebooted, SSH into the System VM and check - the version. - Use one of the following techniques, depending on the hypervisor. - - XenServer or KVM: - SSH in by using the link local IP address of the system VM. For example, in the - command below, substitute your own path to the private key used to log in to the - system VM and your own link local IP. - - Run the following commands on the XenServer or KVM host on which the system VM is - present: - # ssh -i private-key-path link-local-ip -p 3922 -# cat /etc/cloudstack-release - The output should be like the following: - Cloudstack Release 4.0.0-incubating Mon Oct 9 15:10:04 PST 2012 - - ESXi - SSH in using the private IP address of the system VM. For example, in the command - below, substitute your own path to the private key used to log in to the system VM and - your own private IP. - - Run the following commands on the Management Server: - # ssh -i private-key-path private-ip -p 3922 -# cat /etc/cloudstack-release - - The output should be like the following: - Cloudstack Release 4.0.0-incubating Mon Oct 9 15:10:04 PST 2012 - - - If needed, upgrade all Citrix XenServer hypervisor hosts in your cloud to a version - supported by CloudStack 4.0.0-incubating. The supported versions are XenServer 5.6 SP2 - and 6.0.2. Instructions for upgrade can be found in the CloudStack 4.0.0-incubating - Installation Guide. - - - Apply the XenServer hotfix XS602E003 (and any other needed hotfixes) to XenServer - v6.0.2 hypervisor hosts. - - - Disconnect the XenServer cluster from CloudStack. - In the left navigation bar of the CloudStack UI, select Infrastructure. Under - Clusters, click View All. Select the XenServer cluster and click Actions - - Unmanage. - This may fail if there are hosts not in one of the states Up, Down, - Disconnected, or Alert. You may need to fix that before unmanaging this - cluster. - Wait until the status of the cluster has reached Unmanaged. Use the CloudStack - UI to check on the status. When the cluster is in the unmanaged state, there is no - connection to the hosts in the cluster. - - - To clean up the VLAN, log in to one XenServer host and run: - /opt/xensource/bin/cloud-clean-vlan.sh - - - Prepare the upgrade by running the following on one XenServer host: - /opt/xensource/bin/cloud-prepare-upgrade.sh - If you see a message like "can't eject CD", log in to the VM and umount the CD, - then run this script again. - - - Upload the hotfix to the XenServer hosts. Always start with the Xen pool master, - then the slaves. Using your favorite file copy utility (e.g. WinSCP), copy the - hotfixes to the host. Place them in a temporary folder such as /root or /tmp. - On the Xen pool master, upload the hotfix with this command: - xe patch-upload file-name=XS602E003.xsupdate - Make a note of the output from this command, which is a UUID for the hotfix - file. You'll need it in another step later. - - (Optional) If you are applying other hotfixes as well, you can repeat the - commands in this section with the appropriate hotfix number. For example, - XS602E004.xsupdate. - - - - Manually live migrate all VMs on this host to another host. First, get a list of - the VMs on this host: - # xe vm-list - Then use this command to migrate each VM. Replace the example host name and VM - name with your own: - # xe vm-migrate live=true host=host-name vm=VM-name - - Troubleshooting - If you see a message like "You attempted an operation on a VM which requires - PV drivers to be installed but the drivers were not detected," run: - /opt/xensource/bin/make_migratable.sh - b6cf79c8-02ee-050b-922f-49583d9f1a14. - - - - Apply the hotfix. First, get the UUID of this host: - # xe host-list - Then use the following command to apply the hotfix. Replace the example host - UUID with the current host ID, and replace the hotfix UUID with the output from the - patch-upload command you ran on this machine earlier. You can also get the hotfix - UUID by running xe patch-list. - xe patch-apply host-uuid=host-uuid - uuid=hotfix-uuid - - - Copy the following files from the CloudStack Management Server to the - host. - - - - - - - Copy from here... - ...to here - - - - - /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py - /opt/xensource/sm/NFSSR.py - - - /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/setupxenserver.sh - /opt/xensource/bin/setupxenserver.sh - - - /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/make_migratable.sh - /opt/xensource/bin/make_migratable.sh - - - - - - - (Only for hotfixes XS602E005 and XS602E007) You need to apply a new Cloud - Support Pack. - - - Download the CSP software onto the XenServer host from one of the following - links: - For hotfix XS602E005: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E005/56710/xe-phase-2/xenserver-cloud-supp.tgz - For hotfix XS602E007: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E007/57824/xe-phase-2/xenserver-cloud-supp.tgz + Whether you're upgrading a Red Hat/CentOS based system or Ubuntu based system, you're going to need to stop the CloudStack management server before proceeding. + # service cloud-management stop - Extract the file: - # tar xf xenserver-cloud-supp.tgz + If you have made changes to /etc/cloud/management/components.xml, you'll need to carry these over manually to the new file, /etc/cloudstack/management/componentContext.xml. This is not done automatically. (If you're unsure, we recommend making a backup of the original components.xml to be on the safe side. - Run the following script: - # xe-install-supplemental-pack - xenserver-cloud-supp.iso + For AWS API Users Only + This step is only necessary if you're using the AWS APIs with &PRODUCT;. If not, you can skip this step. + + The file /etc/cloud/management/db.properties will be carried over to etc/cloudstack/management/db.properties, but the parameters for the AWS API are not carried over. You'll need to add these parameters to the new file manually: + +db.awsapi.username= +db.awsapi.password= +db.awsapi.host= +db.awsapi.port= + + For the AWS API queries to work, you'll need to copy those over to /etc/cloudstack/management/db.properties (with the values you have currently). - - If the XenServer host is part of a zone that uses basic networking, disable - Open vSwitch (OVS): - # xe-switch-network-backend bridge - - - - - Reboot this XenServer host. - - - Run the following: - /opt/xensource/bin/setupxenserver.sh - - If the message "mv: cannot stat `/etc/cron.daily/logrotate': No such file or - directory" appears, you can safely ignore it. - - - - Run the following: - for pbd in `xe pbd-list currently-attached=false| grep ^uuid | awk - '{print $NF}'`; do xe pbd-plug uuid=$pbd ; - - - - On each slave host in the Xen pool, repeat these steps, starting from "manually - live migrate VMs." - - - - -
-
- - Version 4.0.0-incubating -
- What’s New in 4.0.0-incubating - Apache CloudStack 4.0.0-incubating includes the following new features: -
- Inter-VLAN Routing - Inter-VLAN Routing is the capability to route network traffic between VLANs. This - feature enables you to set up Virtual Private Clouds (VPC) that can hold multi-tier - applications. These tiers are deployed on different VLANs that can communicate with each - other. You can provision VLANs to the tiers your create, and VMs can be deployed on - different tiers, such as Web, Application, or Database. The VLANs are connected to a - virtual router, which facilitates communication between the VMs. In effect, you can - segment VMs by means of VLANs into different networks that can host multi-tier - applications. Such segmentation by means of VLANs logically separate application VMs for - higher security and lower broadcasts, while remaining physically connected to the same - device. - This feature is supported on XenServer and VMware hypervisors. -
-
- Site-to-Site VPN - A Site-to-Site VPN connection helps you establish a secure connection from an - enterprise datacenter to the cloud infrastructure. This allows users to access the guest - VMs by establishing a VPN connection to the virtual router of the account from a device in - the datacenter of the enterprise. Having this facility eliminates the need to establish - VPN connections to individual VMs. - The supported endpoints on the remote datacenters are: - - - Cisco ISR with IOS 12.4 or later - - - Juniper J-Series routers with JunOS 9.5 or later - - -
-
- Local Storage Support for Data Volumes - You can now create data volumes on local storage. The data volume is placed on the - same XenServer host as the VM instance that is attached to the data volume. These local - data volumes can be attached to virtual machines, detached, re-attached, and deleted just - as with the other types of data volume. In earlier releases of CloudStack, only the root - disk could be placed in local storage. - Local storage is ideal for scenarios where persistence of data volumes and HA is not - required. Some of the benefits include reduced disk I/O latency and cost reduction from - using inexpensive local disks. - In order for local volumes to be used, the feature must be enabled for the - zone. - You can create a data disk offering for local storage. When a user creates a new VM, - they can select this disk offering in order to cause the data disk volume to be placed in - local storage. - You can not migrate a VM that has a volume in local storage to a different host, nor - migrate the volume itself away to a different host. If you want to put a host into - maintenance mode, you must first stop any VMs with local data volumes on that host. - Local storage support for volumes is available for XenServer, KVM, and VMware - hypervisors. -
-
- Tags - A tag is a key-value pair that stores metadata about a resource in the cloud. Tags are - useful for categorizing resources. For example, you can tag a user VM with a value that - indicates the user's city of residence. In this case, the key would be "city" and the - value might be "Toronto" or "Tokyo." You can then request CloudStack to find all resources - that have a given tag; for example, VMs for users in a given city. - You can tag a user virtual machine, volume, snapshot, guest network, template, ISO, - firewall rule, port forwarding rule, public IP address, security group, load balancer - rule, project, VPC, network ACL, or static route. You can not tag a remote access - VPN. - You can work with tags through the UI or through the new API commands createTags, - deleteTags, and listTags. You can define multiple tags for each resource. There is no - limit on the number of tags you can define. Each tag can be up to 255 characters long. - Users can define tags on the resources they own, and administrators can define tags on any - resources in the cloud. - A new optional input parameter, "tags," has been added to many of the list* API - commands. The following example shows how to use this new parameter to find all the - volumes having tag region=canada OR tag city=Toronto: - command=listVolumes -&listAll=true -&tags[0].key=region -&tags[0].value=canada -&tags[1].key=city -&tags[1].value=Toronto - The following API commands have the new "tags" input parameter: - - - listVirtualMachines - - - listVolumes - - - listSnapshots - - - listNetworks - - - listTemplates - - - listIsos - - - listFirewallRules - - - listPortForwardingRules - - - listPublicIpAddresses - - - listSecurityGroups - - - listLoadBalancerRules - - - listProjects - - - listVPCs - - - listNetworkACLs - - - listStaticRoutes - - -
-
- AWS API Changes for Tags - Some changes have been made to the Amazon Web Services API compatibility support in - order to accommodate the new tagging feature. - New APIs: - - - - - - - - New API - - - Description - - - - - - - ec2-create-tags - - - Add tags to one or more resources. - - - - - ec2-delete-tags - - - Remove tags from one or more resources. - - - - ec2-describe-tags - - Show currently defined tags. - - - - - - Changed APIs: - - - - - - - - Changed API - - - Description - - - - - - ec2-describe-images - - Output now shows tags defined for each image. - - - - - ec2-describe-instances - - - Output now shows tags defined for each image. - The following filters can now be passed in to limit the output result set: - tag-key, tag-value and tag:key - - - - - ec2-describe-snapshots - - - Output now shows tags defined for each image. - The following filters can now be passed in to limit the output result set: - tag-key, tag-value and tag:key - - - - ec2-describe-volumes - - Output now shows tags defined for each image. - The following filters can now be passed in to limit the output result set: - tag-key, tag-value and tag:key - - - - - -
-
- Secure Console Access on XenServer - With the addition of Secure Console feature, users can now securely access the VM - consoles on the XenServer hypervisor. You can either SSH or use the View Console option in - the Management Server to securely connect to the VMs on the XenServer host. The Management - Server uses the xapi API to stream the VM consoles. However, there is no change in the way - you can access the console of a VM. This feature is supported on XenServer 5.6 and 6.0 - versions. -
-
- Stopped VM - This release supports creating VMs without starting them on the backend. You can - determine whether the VM needs to be started as part of the VM deployment. A VM can be - deployed in two ways: create and start a VM (the default method); create a VM and leave it - in the stopped state. - A new request parameter, startVM, is introduced in the deployVm API to support the - stopped VM feature. The possible values are: - - - true - The VM starts as a part of the VM deployment - - - false - The VM is left in stopped state at the end of the VM deployment - - -
-
- Uploading an Existing Volume to a Virtual Machine - Existing data can now be made accessible to a virtual machine. This is called - uploading a volume to the VM. For example, this is useful to upload data from a local file - system and attach it to a VM. Root administrators, domain administrators, and end users - can all upload existing volumes to VMs. The upload is performed by using HTTP. The - uploaded volume is placed in the zone's secondary storage. - This functionality is supported for the following hypervisors: - - - Hypervisor : Disk Image Format - - - XenServer : VHD - - - VMware : OVA - - - KVM : QCOW2 - - - -
-
- Dedicated High-Availability Hosts - One or more hosts can now be designated for use only by high-availability (HA) enabled - VMs that are restarted due to a host failure. Setting up a pool of such dedicated HA hosts - as the recovery destination for all HA-enabled VMs make it easier to determine which VMs - are restarted as part of the high-availability function. You can designate a host as a - dedicated-HA restart node only if the Dedicated HA Hosts feature is enabled by setting the - appropriate global configuration parameter. -
-
- Support for Amazon Web Services API - This release supports Amazon Web Services APIs, including Elastic Compute Cloud (EC2) - API. Fidelity with the EC2 API and the installation experience for this functionality are - both enhanced. In prior releases, users were required to install a separate component - called CloudBridge, in addition to installing the Management Server. For new installations - of CloudStack 4.0.0-incubating, this software is installed automatically along with - CloudStack and runs in a more closely integrated fashion. The feature is disabled by - default, but can be easily enabled by setting the appropriate global configuration - parameter and performing a few setup steps. -
-
- The Nicira NVP Plugin - The Nicira NVP plug-in allows CloudStack to use the Nicira solution for virtualized - network as a provider for CloudStack networks and services. In CloudStack 4.0.0-incubating - this plug-in supports the Connectivity service. This service is responsible for creating - Layer 2 networks supporting the networks created by guests. When a tenant creates a new - network, instead of a traditional VLAN, a logical network will be created by sending the - appropriate calls to the Nicira NVP Controller. The plug-in has been tested with Nicira - NVP versions 2.1.0, 2.2.0 and 2.2.1. -
-
- The BigSwitch Controller Plugin - The BigSwitch Controller plug-in adds OpenFlow based solution for network virtualization - to CloudStack. The plugin supports both BigSwitch commercial controller and the opensource - Floodlight controller. The plugin functions as a provider for CloudStack networks and Connectivity - service. This service is responsible for creating Layer 2 networks supporting the networks - created by guests. When a tenant creates a new network, a virutal network segment will be - created by sending the appropriate calls to the BigSwitch Controller. -
-
- Support for CAStor Cluster - CloudStack 4.0.0-incubating supports using a CAStor cluster as the back-end storage - system for a CloudStack S3 front-end. The CAStor back-end storage for CloudStack extends - the existing storage classes and allows the storage configuration attribute to point to a - CAStor cluster. This feature makes use of the CloudStack server's local disk to spool - files before writing them to CAStor when handling the PUT operations. However, a file must - be successfully written into the CAStor cluster prior to the return of a success code to - the S3 client to ensure that the transaction outcome is correctly reported. - The S3 multipart file upload is not supported in this release. You are prompted with - proper error message if a multipart upload is attempted. -
-
- Clustered Logical Volume Manager Support for KVM - This release adds Clustered Logical Volume Manager (CLVM) storage support for KVM - hosts. With this support, you can use CLVM as primary storage. - The CLVM support for KVM allows root and data disks (primary storage) to reside on - Linux logical volumes. The administrators are required to configure CLVM on the KVM hosts - independent of CloudStack. When the volume groups are available, an administrator can - simply add primary storage of type CLVM, providing the volume group name. Then CloudStack - creates and manages logical volumes as needed. - CLVM also supports Snapshots. CloudStack creates an LVM snapshot, copy the applicable - logical volume to the secondary storage in the qcow2 format, and then delete the LVM - snapshot. -
-
- Rados Block Device Support for KVM - You can now use Rados Block Device (RBD) to run instances on Apache CloudStack - 4.0.0-incubating. This can be done by adding a RBD pool as primary storage. Before using - RBD, ensure that Qemu is compiled with RBD enabled, and the libvirt version is at least - 0.10 with RBD enabled on the KVM host - Create a disk offering for RBD so that you can ensure that StoragePoolAllocator - chooses the RBD pool to deploy instances. -
-
-
- Issues Fixed in 4.0.0-incubating - Many bugs include a defect number that reflects the bug number that was held in the bug - tracker run by Citrix (bugs.cloudstack.org). The Apache CloudStack project now uses Jira to manage its bugs, so - some of the bugs that are referenced here may not be available to view. However, we are - still including them for completeness. - - - - - - - - Defect - - - Description - - - - - - Many - vSphere 5.0 now has GA support. Formerly only Beta support was - provided. - - - CS-16135 - Creating volumes after upgrading from snapshot taken in 2.2.14 no longer - deletes the snapshot physically from the secondary storage. - - - CS-16122 - In a site-to-site VPN setup, alerts are generated when the VPC virtual - router is rebooted with multiple vpn connections. - - - CS-16022 - If host connection fails due to a database error, host now disconnects - and the Managerment Server id is removed. - - - CS-16011 - Name of network offering is no longer truncated due to too-narrow field - width in Add Guest Network dialog box. - - - - CS-15978 - When the virtual router and its host go down, the high availability - mechanism now works for the virtual router. - - - - CS-15921 - The 2.2.x security group script now accounts for the VMs created in the - version 2.1 timeframe. - - - - CS-15919 - A level parameter is added to the listVolumes command; therefore queries - return the response more quickly. - - - CS-15904 - Upgrade from version 2.2.14 to CloudStack-3.0.5-0.2944-rhel5 works as - expected. The upgrade script, - /usr/share/cloud/setup/db/schema-2214to30-cleanup.sql, works as - expected. - - - CS-15879 - The database upgrade from version 3.0.4 to 3.0.5 works as - expected. - - - - CS-15807 - Network label for OVM now available in UI. - - - - CS-15779 - When the thumbnail is requested, the console session will not be - terminated. - - - - CS-15778 - Fetching a VM thumbnail now gets a thumbnail of appropriate visual - dimensions. - - - - CS-15734 - KVM Snapshots no longer shows incorrect disk usage. - - - CS-15733 - The domainId parameter for the listNetworks command now lists the - resources belonging to the domain specified. - - - CS-15676 - Stopping the router no longer fails with the null pointer - exception. - - - - CS-15648 - If creating a volume from a snapshot fails, the error is reported on the - UI but the volume is stuck in the creating state. - - - - CS-15646 - createFirewallRule API no longer causes null pointer - exception. - - - CS-15628 - In a KVM host, the high availability mechanism no longer takes a long - time to migrate VMs to another KVM host if there are multiple storage - pools. - - - CS-15627 - Metadata instance-id and vm-id for existing VMs stays the same after - upgrade. - - - CS-15621 - Solved difficulty with allocating disk volumes when running multiple VM - deployment in parallel. - - - CS-15603 - CloudStack now stop the VMs when destroyVM command is - called. - - - CS-15586 - Public Vlan for an account no longer fails if multiple physical networks - are present. - - - CS-15582 - The dns-name filter is now supported for ec2-describe-instances in the - Amazon Web Services API compatibility commands. The filter maps to the name of a - user VM. - - - CS-15503 - An IP address which has static NAT rules can now be released. - Subsequently, restarting this network after it was shutdown can - succeed. - - - CS-15464 - Can now delete static route whose state is set to Revoke. - - - CS-15443 - Creating a firewall rule no longer fails with an internal server - error. - - - CS-15398 - Corrected technique for programming DNS on the user VMs. - - - CS-15356 - Internal DNS 2 entry now correctly shown in UI. - - - CS-15335 - The CloudBridge S3 Engine now connects to the database by using the - deciphered password in the db.properties file. - - - CS-15318 - UI now correctly prevents the user from stopping a VM that is in the - Starting state. - - - CS-15307 - Fixed Japanese localization of instance statuses in the Instances - menu. - - - CS-15278 - The deployment planner no longer takes long time to locate a suitable - host to deploy VMs when large number of clusters are present. - - - CS-15274 - Creating a VLAN range using Zone ID without network ID now - succeeds. - - - CS-15243 - Now check to be sure source NAT and VPN have same - provider. - - - CS-15232 - Ensure that networks using external load balancer/firewall in 2.2.14 or - earlier can properly upgrade. - - - CS-15200 - No exception when trying to attach the same volume while attaching the - first volume is in progress. - - - CS-15173 - Additional cluster can no longer be added with same VSM IP address as - another cluster. - - - CS-15167 - AWS API calls now honor the admin account's ability to view or act on the - resources owned by the regular users. - - - CS-15163 - The minimum limit is not honored when there is not enough capacity to - deploy all the VMs and the ec2-run-instances command with the -n >n1 -n2> - option is used to deploy multiple VMs. - - - CS-15157 - Can now add/enable service providers for multiple physical networks - through the UI. - - - CS-15145 - AWS API call ec2-register has better error handling for negative - cases. - - - CS-15122 - Filters now supported for AWS API call - ec2-describe-availability-zones. - - - CS-15120 - Actions column in UI of Volume page now shows action - links. - - - CS-15099 - Buttons no longer overlap text on Account Deletion confirmation page in - UI. - - - CS-15095 - Ensures you can not create a VM with a CPU frequency greater than the - host CPU frequency. - - - CS-15094 - CPU cap now set properly in VMware. - - - CS-15077 - NullPointerException is no longer observed while executing the command to - list the public IP in a basic zone created with the default shared NetScaler EIP - and ELB network offering. - - - CS-15044 - UI now provides option to view the list of instances which are part of - the guest network. - - - CS-15026 - UI in Deploy VM dialog now lists only templates or ISOs depending on - which is selected in previous dialog. - - - CS-14989 - In KVM, the Create Instance wizard now shows only templates from the - current (KVM) zone. - - - CS-14986, CS-14985 - Listing filters works as expected in the ec2-describe-volumes and - ec2-describe-snapshots commands. - - - CS-14964 - Automatically starting the Console Proxy no longer fails due to its - missing volume on the primary storage - - - CS-14907 - User is now correctly prevented from trying to download an uploaded - volume which has not yet been moved to primary storage. - - - CS-14879 - When a user VM is stopped or terminated, the static NAT associated with - this VM is now disabled. This public IP address is no longer owned by this account - and can be associated to any other user VM. - - - CS-14854 - Only the admin user can change the template permission to Public, so this - option is removed from the UI for domain Admins and regular Users. - - - CS-14817 - While checking if network has any external provider, CloudStack will - consider all providers in the network. - - - CS-14796 - When deploying a VM with ec2-run-instances, userdata is now - encoded. - - - CS-14770 - The API returns the keypair information when a VM is deployed with - sshkey. This affects the API commands related to virtual machines - (deployVirtualMachine, listVirtualMachines, ... *VirtualMachine), as well as the - corresponding AWS APIs. - - - CS-14724 - UI no longer displays the dropdown list of isolation method choices if - sdn.ovs.controller is false. - - - CS-14345 - Logout API returns XML header. - - - CS-14724 - Host IPs now associated with appropriate IPs according to traffic - type. - - - CS-14253 - Can now delete and re-create port forwarding rule on same - firewall. - - - CS-14724 - UI no longer displays the dropdown list of isolation method choices if - sdn.ovs.controller is false. - - - CS-14452 - Data disk volumes are now automatically copied from one cluster to - another. - - - CS-13539 - Windows VM can get IP after reboot. - - - CS-13537 - When user tries to delete a domain that contains sub-domains, an error - message is now sent to convey the reason for the delete failure. - - - CS-13153 - System VMs support HTTP proxy. - - - CS-12642 - Added Close button to Select Project list view popup in - UI. - - - CS-12510 - Deleting and reinserting host_details no longer causes - deadlocks. - - - CS-12407 - F5 and Netscaler - when dedicated is selected, capacity field is - disabled. - - - CS-12111 - Email validation for edit user form. - - - CS-10928 - Network read/write values now always positive numbers. - - - CS-15376, CS-15373 - The AWS APIs (EC2 and S3) now listen on the 7080 port and send request to - CloudStack on the 8080 port just as any other clients of - CloudStack. - - - CS-13944 - The CloudStack 2.2.x to 3.0.x database upgrade for multiple physical - networks is now supported. - - - CS-15300 - The admin accounts of a domain now honour the limits imposed on that - domain just like the regular accounts do. A domain admin now is not allowed to - create an unlimited number of instances, volumes, snapshots, and so - on. - - - CS-15396 - The CloudStack database now contain the UUD information after the 2.2.14 - to 3.0.4 upgrade. - - - CS-15450 - Upgrade from 2.2.14 to 3.0.4 no longer fails on a VMware - host. - - - CS-15449 - Running cloudstack-aws-api-register no longer fails with the "User - registration failed with error: [Errno 113] No route to host" - error. - - - CS-15455 - The iptable rules are configured to open the awsapi port (7080) as part - of the installation. - - - CS-15429 - While creating an instance with data volume, disk offering also is - considered while checking the account limit on volume resources. - - - CS-15414 - After the 2.2.14 to 3.0.4 upgrade, the value of the global parameter - xen.guest.network.device is now decrypted before setting the traffic - label. - - - CS-15382 - During 2.2.14 to 3.0.4 upgrade, the hosts no longer go to the Alert state - if destroyed networks existed with non-existent tags prior to - upgrade. - - - CS-15323 - CloudStack supports the following Citrix XenServer hotfixes: XS602E003, - XS602E004, and XS602E005. - - - CS-15430 - Create snapshot now fails if creating a snapshot exceeds the snapshot - resource limit for a domain admin or a user account. - - - CS-14256 - Virtual Router no longer remains in starting state for subdomain or user - on a KVM 3.0.1 prerlease host on RHEL 6.2. - - - CS-7495 - Implemented a variety of Xen management host improvements. - - - CS-8105 - NFS v4 for primary storage now works as expected on KVM - hosts. - - - CS-9989 - The error messages returned during VM deployment failure will have much - more details than before. - - - CS-12584 - You can no longer add security groups not supported by the hypervisor in - use. - - - CS-12705 - When creating a Network offering by using SRX as the service provider for - SourceNAT servcies, an option is given in the CloudStack UI now to set the - source_nat type to "per Zone"/"per account". - - - CS-12782 - Assigning a VM from Basic to Advanced zone no longer ignores the network - ID. A warning message is displayed for VM movements across zones. - - - CS-12591 - Broadcast Address on the Second Public IP NIC is now - corrected. - - - CS-13272 - When a user is deleted, all the associated properties, such as IPs and - virtual routers, are now deleted. - - - CS-13377 - Creating template from a root disk of a stopped instance now provides an - option to make it a "Featured template". - - - CS-13500 - Reaching the first guest VM by using its public IP from the second guest - VM no longer fails. - - - CS-13853 - The default gateway can no longer be 0.0.0.0 in the Secondary Storage VM - (SSVM). - - - CS-13863 - The queryAsyncJobResult command in XML format now returns the correct - UUIDs. - - - CS-13867 - Corrected CSP xenserver-cloud-supp.tgz for XenServer 5.6 and - 6.0. - - - CS-13904 - Labels and values for the service offerings CPU and memory are now - consistent. - - - CS-13998 - The SSVM kernel panic issue is fixed on XenServer. - - - CS-14090 - The issue is fixed where running the VMware snapshots randomly fails with - the ArrayIndexOutOfBoundsException error. - - - CS-14021 - The java.lang.OutOfMemoryError is fixed on the Management - Server. - - - CS-14025 - The Python Eggs are provided to easily package the test client for each - branch of CloudStack. - - - CS-14068 - Resetting the VM password through the CloudStack UI no longer causes any - error. - - - CS-14156 - The pod which has the administrator's virtual router is no longer - selected while creating the virtual routers for guests. - - - CS-14182 - The users can now delete their ISOs as normal users. - - - CS-14185 - The listOSTypes API now filters out the types of operating system by - using the keywords. - - - CS-14204 - The cloud-setup-bonding.sh command no longer generates the "command not - found" error. - - - CS-14214 - The Specify VLAN option cannot be enabled now for an isolated Network - offering with SourceNAT enabled. - - - CS-14234 - Sending project invite email to an account now requires SMTP configured - in CloudStack. - - - CS-14237 - The garbage collector of the primary storage no longer fails when the - first host in the cluster is not up. - - - CS-14241 - Custom Volume Disk Offering is now matching the Global configuration - value. - - - CS-14270 - The listNetworks API no longer assumes that the broadcast type is always - VLAN. - - - CS-14319 - The internal name of the VM is no longer present in the error message - that is displayed to a domain administrator. - - - CS-14321 - The listVolumes API call now returns a valid value for the isExtractable - parameter for the ISO-derived disk and data disk volumes. - - - CS-14323 - Invalid API calls will now give valid response in json/xml - format. - - - CS-14339 - Custom Disk Size will now allow values larger than 100GB. - - - CS-14357 - The ConsoleProxyLoadReportCommand is no longer fired - continuously. - - - CS-14421 - Fixed the issue of virtual router deployments. The DHCP entries can now - be assigned to the router. - - - CS-14555 - Unzipped downloaded template MD5SUM will no longer override the zipped - template MD5SUM in the database. - - - CS-14598 - The complete screen of the running VM is now displayed in the console - proxy. - - - CS-14600 - Windows or Linux based consoles are no longer lost upon rebooting - VMs. - - - CS-14784 - Multiple subnets with the same VLAN now work as expected. - - - CS-13303, 14874, 13897, 13944, 14088, 14190 - A variety of upgrade issues have been fixed in release - 3.0.3. - - - CS-15080 - Setting a private network on a VLAN for VMWare environment is now - supported. - - - CS-15168 - The console proxy now works as expected and no exception is shown in the - log after upgrading from version 2.2.14 to 3.0.2. - - - CS-15172 - Version 3.0.2 now accepts the valid public key. - - - - -
-
- Known Issues in 4.0.0-incubating - - - - - - - - Issue ID - - - Description - - - - - - CLOUDSTACK-301 - Nexus 1000v DVS integration is not functional - This source code release includes some partial functionality to support the - Cisco Nexus 1000v Distributed Virtual Switch within a VMware hypervisor - environment. The functionality is not complete at this time. - - - - CLOUDSTACK-368 - OVM - cannot create guest VM - This source code release has regressed from the CloudStack 2.2.x code - and is unable to support Oracle VM (OVM). - - - - CLOUDSTACK-279 - Deleting a project fails when executed by the regular user. This works as - expected for root/domain admin. To workaround, perform either of the - following: - - Use the account cleanup thread which will eventually complete the project - deletion. - - - Execute the call as the root/domain admin on behalf of the regular - user. - - - - - - CS-16067 - The command=listTags&key=city command does not work as expected. The - command does not return tags for the resources of the account with the tag, city - - - - - CS-16063 - The current values of volumes and snapshots are incorrect when using KVM - as a host. To fix this, the database upgrade codes, volumes.size and - snapshots.size, should be changed to show the virtual sizes. - - - - CS-16058 - Null pointer Exception while deleting the host after moving the host to - maintenance state. - - - - CS-16045 - Only the root administrator can handle the API keys. The domain - administrators are not allowed to create, delete, or retrieve API keys for the - users in their domain. - - - - CS-16019 - CIDR list in the Add VPN Customer Gateway dialog does not prompt the user - that they can provide a comma separated CIDRs if multiple CIDRs have to be - supplied. - - - - CS-16015 - Deleting a network is not supported when its network providers are - disabled. - - - - CS-16012 - Unable to delete a zone in the UI because the necessary cleanup cannot be - completed. When the hosts are removed, the expunge process fails to delete the - volumes as no hosts are present to send the commands to. Therefore, the storage - pool removal fails, and zone can't be cleaned and deleted. - - - - CS-16011 - Name of network offering might be truncated due to too-narrow field width - in Add Guest Network dialog box. - - - - CS-15789 - Invalid global setting prevents management server to restart. For - example, if you configure the "project.invite.timeout" parameter to "300" and - attempt to restart management server, it fails without throwing a warning or - setting the value to the default. - - - - CS-15749 - Restarting VPC is resulting in intermittent connection loss to the port - forwarding and StaticNAT rules. - - - - CS-15690 - The IpAssoc command failed as a part of starting the virtual router, but - the final start result is reported as succes. - - - - CS-15672, CS-15635 - The FQDN of the VM is not configured if it is deployed as a part of - default shared network and isolated guest network - (DefaultIsolatedNetworkOfferingWithSourceNatService). - - - - CS-15634 - The FQDN of a VM that is deployed as a part of both a shared network and - default isolated guest network has the suffix of the shared network instead of the - default isolated guest network. - - - - CS-15576 - Stopping a VM on XenServer creates a backlog of API commands. For - example, the Attach volume calls become delayed while waiting for the - stopVirtualMachine command to be executed. - - - - CS-15569 - Misleading error message in the exception when creating a StaticNAT rule - fails in a VPC. - - - - CS-15566 - External device such as Netscaler is not supported in VPC. - - - CS-15557 - Intermittent traffic loss in the VPN connection if Juniper is the remote - router and the life time is 300 seconds. - - - - CS-15361 - Egress rules are not working in NetScaler loadbalancer. - - - - CS-15163 - The minimum limit is not honored when there is not enough capacity to - deploy all the VMs and the ec2-run-instances command with the -n >n1 -n2> - option is used to deploy multiple VMs. - - - CS-15105 - The cloud-sysvmadm script does not work if the integration.api.port - parameter is set to any port other than 8096. - - - CS-15092 - Connecting to the guest VMs through SSH is extremely slow, and it results - in connection timeout. - - - CS-15037 - Hairpin NAT is not supported when NetScaler is used for - EIP. - - - CS-15009 - The port_profile table will not be populated with port profile - information. In this release, CloudStack directly connects to the VSM for all the - port profile operations; therefore, no port profile information is - cached. - - - CS-14939 - Adding a VMware cluster is not supported when the Management Network is - migrated to the Distributed Virtual Switch environment. - - - CS-14780 - You are allowed to ping the elastic IP address of the VM even though no - ingress rule is set that allows the ICMP protocol. - - - CS-14756 - Installing KVM on RHEL 6.2 will result in unreliable network performance. - Workaround: blacklist vhost-net. Edit /etc/modprobe.d/blacklist-kvm.conf and - include vhost-net. - - - CS-14346 - The UpdateVirtualMachine API call does not check whether the VM is - stopped. Therefore, stop the VM manually before issuing this call. - - - CS-14303 (was 14537) - The IP addresses for a shared network are still being consumed even if no - services are defined for that network. - - - CS-14296 (was 14530) - OVM: Network traffic labels are not supported. - - - CS-14291 (was 14523) - The EIP/ELB network offering for basic zones does not support multiple - NetScalers. - - - CS-14275 (was 14506) - F5: Unable to properly remove a F5 device. - - - CS-14201 (was 14430) - VMWare: Template sizes are being reported different depending on whether - the primary storage is using ISCSI or NFS. - - - CS-13758 (was 13963) - vSphere: template download from templates created off of the root volume - does not work properly. - - - CS-13733 (was 13935) - vSphere: detaching an ISO from a restored VM instance - fails. - - - CS-13682 (was 13883) - Multiple NetScalers are not supported in Basic Networking. - - - CS-13599 (was 13359) - Programming F5/NetScaler rules can be better optimized. - - - CS-13337 (was 13518) - Security Groups are not supported in Advanced Networking - - - CS-13173 (was 13336) - vSphere: cross cluster volume migration does not work - properly. - - - CS-12714 (was 12840) - Capacity view is not available for pods or clusters. - - - CS-12624 (was 12741) - vSphere: maintenance mode will not live migrate system VM to another - host. - - - - CS-15476 - - - The 2.2.14 to 4.0.0-incubating upgrade fails if multiple untagged physical - networks exist before the upgrade. - - - - - CS-15407 - - - After the 2.2.14 to 4.0.0-incubating upgrade, VLAN allocation on multiple - physical networks does not happen as expected. - To workaround this issue, follow the instructions given below: - - - Revert to your 2.2.14 setup. - - - Stop all the VMs with the isolated virtual networks in your cloud - setup. - - - Run following query to find if any networks still have the NICs - allocated: - - - Check if any virtual guest networks have the NICs allocated: - #SELECT DISTINCT op.id from `cloud`.`op_networks` op JOIN `cloud`.`networks` n on op.id=n.id WHERE nics_count != 0 AND guest_type = 'Virtual'; - - - If this returns any network IDs, then ensure the following: - - - All the VMs are stopped. - - - No new VM is started. - - - Shutdown the Management Server. - - - - - Remove the NICs count for the virtual network IDs returned in step - (a), and set the NIC count to 0: - UPDATE `cloud`.`op_networks` SET nics_count = 0 WHERE id = enter id of virtual network - - - Restart the Management Server, and wait for all the networks to shut - down. - - Networks shutdown is determined by the network.gc.interval and - network.gc.wait parameters. - - + + If you are using Ubuntu, follow this procedure to upgrade your packages. If not, skip to step . + Community Packages + This section assumes you're using the community supplied packages for &PRODUCT;. If you've created your own packages and APT repository, substitute your own URL for the ones used in these examples. + + + + The first order of business will be to change the sources list for each system with &PRODUCT; packages. This means all management servers, and any hosts that have the KVM agent. (No changes should be necessary for hosts that are running VMware or Xen.) + Start by opening /etc/apt/sources.list.d/cloudstack.list on any systems that have &PRODUCT; packages installed. + This file should have one line, which contains: + deb http://cloudstack.apt-get.eu/ubuntu precise 4.0 + We'll change it to point to the new package repository: + deb http://cloudstack.apt-get.eu/ubuntu precise 4.1 + If you're using your own package repository, change this line to read as appropriate for your 4.1.0 repository. + + + Now update your apt package list: + $ sudo apt-get update + + + Now that you have the repository configured, it's time to install the cloudstack-management package. This will pull in any other dependencies you need. + $ sudo apt-get install cloudstack-management + + + You will need to manually install the cloudstack-agent package: + $ sudo apt-get install cloudstack-agent + During the installation of cloudstack-agent, APT will copy your agent.properties, log4j-cloud.xml, and environment.properties from /etc/cloud/agent to /etc/cloudstack/agent. + When prompted whether you wish to keep your configuration, say Yes. + + + Verify that the file /etc/cloudstack/agent/environment.properties has a line that reads: + paths.script=/usr/share/cloudstack-common + If not, add the line. + + + Restart the agent: + - - - Ensure that all the networks are shut down and all the guest VNETs are - free. - - - Run the upgrade script. - This allocates all your guest VNET ranges to the first physical - network. - - - By using the updatePhysicalNetwork API, reconfigure the VNET ranges for - each physical network as desired. - - - Start all the VMs. - - - - - - - CS-14680 - - - CloudStack and LDAP user validation cannot happen simultaneously because the - user password is hashed and stored in the database, and LDAP requires the - passwords in plain text. - To work with the LDAP user, the MD5 hash should be disabled in the login - process by commenting the following variable in sharedFunctions.js file available - at /usr/share/cloud/management/webapps/client/scripts, and restart the - cloud-management service. - var md5HashedLogin = false; - However, if md5HashedLogin is set to false, the end user can login with the - LDAP credentials but not with the CloudStack user credentials. - - - - CS-14346 - The UpdateVirtualMachine API call does not check whether the VM is - stopped. Therefore, stop the VM manually before issuing this call. - - - CS-15130 - Data disk volumes are not automatically copied from one cluster to - another. - - - CS-14780 - You are allowed to ping the elastic IP address of the VM even though no - ingress rule is set that allows the ICMP protocol. - - - CS-14939 - Adding a VMware cluster is not supported when the Management Network is - migrated to the Distributed Virtual Switch environment. - - - CS-15009 - The port_profile table will not be populated with port profile - information. In this release, CloudStack directly connects to the VSM for all the - port profile operations; therefore, no port profile information is - cached. - - - CS-15037 - Hairpin NAT is not supported when NetScaler is used for - EIP. - - - CS-15092 - Connecting to the guest VMs through SSH is extremely slow, and it results - in connection timeout. - - - CS-15105 - The cloud-sysvmadm script does not work if the integration.api.port - parameter is set to any port other than 8096. - - - CS-15163 - The minimum limit is not honored when there is not enough capacity to - deploy all the VMs and the ec2-run-instances command with the -n >n1 -n2> - option is used to deploy multiple VMs. - - - - -
-
- - API Changes from 3.0.2 to 4.0.0-incubating -
- New API Commands in 4.0.0-incubating - - - createCounter (Adds metric counter) - - - deleteCounter (Deletes a counter) - - - listCounters (List the counters) - - - createCondition (Creates a condition) - - - deleteCondition (Removes a condition) - - - listConditions (List Conditions for the specific user) - - - createTags. Add tags to one or more resources. Example: - command=createTags -&resourceIds=1,10,12 -&resourceType=userVm -&tags[0].key=region -&tags[0].value=canada -&tags[1].key=city -&tags[1].value=Toronto - - - deleteTags. Remove tags from one or more resources. Example: - command=deleteTags -&resourceIds=1,12 -&resourceType=Snapshot -&tags[0].key=city - - - listTags (Show currently defined resource tags) - - - createVPC (Creates a VPC) - - - listVPCs (Lists VPCs) - - - deleteVPC (Deletes a VPC) - - - updateVPC (Updates a VPC) - - - restartVPC (Restarts a VPC) - - - createVPCOffering (Creates VPC offering) - - - updateVPCOffering (Updates VPC offering) - - - deleteVPCOffering (Deletes VPC offering) - - - listVPCOfferings (Lists VPC offerings) - - - createPrivateGateway (Creates a private gateway) - - - listPrivateGateways (List private gateways) - - - deletePrivateGateway (Deletes a Private gateway) - - - createNetworkACL (Creates a ACL rule the given network (the network has to belong to - VPC)) - - - deleteNetworkACL (Deletes a Network ACL) - - - listNetworkACLs (Lists all network ACLs) - - - createStaticRoute (Creates a static route) - - - deleteStaticRoute (Deletes a static route) - - - listStaticRoutes (Lists all static routes) - - - createVpnCustomerGateway (Creates site to site vpn customer gateway) - - - createVpnGateway (Creates site to site vpn local gateway) - - - createVpnConnection (Create site to site vpn connection) - - - deleteVpnCustomerGateway (Delete site to site vpn customer gateway) - - - deleteVpnGateway (Delete site to site vpn gateway) - - - deleteVpnConnection (Delete site to site vpn connection) - - - updateVpnCustomerGateway (Update site to site vpn customer gateway) - - - resetVpnConnection (Reset site to site vpn connection) - - - listVpnCustomerGateways (Lists site to site vpn customer gateways) - - - listVpnGateways (Lists site 2 site vpn gateways) - - - listVpnConnections (Lists site to site vpn connection gateways) - - - markDefaultZoneForAccount (Marks a default zone for the current account) - - - uploadVolume (Uploads a data disk) - - -
-
- Changed API Commands in 4.0.0-incubating - - - - - - - API Commands - Description - - - - - - copyTemplate - prepareTemplate - registerTemplate - updateTemplate - createProject - activateProject - suspendProject - updateProject - listProjectAccounts - createVolume - migrateVolume - attachVolume - detachVolume - uploadVolume - createSecurityGroup - registerIso - copyIso - updateIso - createIpForwardingRule - listIpForwardingRules - createLoadBalancerRule - updateLoadBalancerRule - createSnapshot - - - The commands in this list have a single new response parameter, and no other - changes. - New response parameter: tags(*) - - Many other commands also have the new tags(*) parameter in addition to other - changes; those commands are listed separately. - - - - - rebootVirtualMachine - attachIso - detachIso - listLoadBalancerRuleInstances - resetPasswordForVirtualMachine - changeServiceForVirtualMachine - recoverVirtualMachine - startVirtualMachine - migrateVirtualMachine - deployVirtualMachine - assignVirtualMachine - updateVirtualMachine - restoreVirtualMachine - stopVirtualMachine - destroyVirtualMachine - - - The commands in this list have two new response parameters, and no other - changes. - New response parameters: keypair, tags(*) - - - - - listSecurityGroups - listFirewallRules - listPortForwardingRules - listSnapshots - listIsos - listProjects - listTemplates - listLoadBalancerRules - - The commands in this list have the following new parameters, and no other - changes. - New request parameter: tags (optional) - New response parameter: tags(*) - - - - - listF5LoadBalancerNetworks - listNetscalerLoadBalancerNetworks - listSrxFirewallNetworks - updateNetwork - - - The commands in this list have three new response parameters, and no other - changes. - New response parameters: canusefordeploy, vpcid, tags(*) - - - - - createZone - updateZone - - The commands in this list have the following new parameters, and no other - changes. - New request parameter: localstorageenabled (optional) - New response parameter: localstorageenabled - - - - listZones - New response parameter: localstorageenabled - - - - rebootRouter - changeServiceForRouter - startRouter - destroyRouter - stopRouter - - The commands in this list have two new response parameters, and no other - changes. - New response parameters: vpcid, nic(*) - - - - updateAccount - disableAccount - listAccounts - markDefaultZoneForAccount - enableAccount - - The commands in this list have three new response parameters, and no - other changes. - New response parameters: vpcavailable, vpclimit, vpctotal - - - listRouters - - New request parameters: forvpc (optional), vpcid (optional) - New response parameters: vpcid, nic(*) - - - - listNetworkOfferings - - New request parameters: forvpc (optional) - New response parameters: forvpc - - - - listVolumes - - New request parameters: details (optional), tags (optional) - New response parameters: tags(*) - - - - addTrafficMonitor - - New request parameters: excludezones (optional), includezones - (optional) - - - - createNetwork - - New request parameters: vpcid (optional) - New response parameters: canusefordeploy, vpcid, tags(*) - - - - listPublicIpAddresses - - New request parameters: tags (optional), vpcid (optional) - New response parameters: vpcid, tags(*) - - - - listNetworks - - New request parameters: canusefordeploy (optional), forvpc (optional), tags - (optional), vpcid (optional) - New response parameters: canusefordeploy, vpcid, tags(*) - - - - restartNetwork - - New response parameters: vpcid, tags(*) - - - - enableStaticNat - - New request parameter: networkid (optional) - - - - createDiskOffering - - New request parameter: storagetype (optional) - New response parameter: storagetype - - - - listDiskOfferings - - New response parameter: storagetype - - - - updateDiskOffering - - New response parameter: storagetype - - - - createFirewallRule - - Changed request parameters: ipaddressid (old version - optional, new version - - required) - New response parameter: tags(*) - - - - listVirtualMachines - - New request parameters: isoid (optional), tags (optional), templateid - (optional) - New response parameters: keypair, tags(*) - - - - updateStorageNetworkIpRange - - New response parameters: id, endip, gateway, netmask, networkid, podid, - startip, vlan, zoneid - - - - reconnectHost - A new response parameter is added: hahost. - - - addCluster - The following request parameters are added: - - - vsmipaddress (optional) - - - vsmpassword (optional) - - - vsmusername (optional) - - - The following parameter is made mandatory: podid - - - - listVolumes - A new response parameter is added: status - - - migrateVolume - A new response parameter is added: status - - - prepareHostForMaintenance - A new response parameter is added: hahost. - - - addSecondaryStorage - A new response parameter is added: hahost. - - - enableAccount - A new response parameter is added: defaultzoneid - - - attachVolume - A new response parameter is added: status - - - cancelHostMaintenance - A new response parameter is added: hahost - - - addSwift - A new response parameter is added: hahost - - - listSwifts - A new response parameter is added: hahost - - - listExternalLoadBalancers - A new response parameter is added: hahost - - - createVolume - A new response parameter is added: status - - - listCapabilities - A new response parameter is added: - customdiskofferingmaxsize - - - disableAccount - A new response parameter is added: defaultzoneid - - - deployVirtualMachine - A new request parameter is added: startvm (optional) - - - deleteStoragePool - A new request parameter is added: forced (optional) - - - updateAccount - A new response parameter is added: defaultzoneid - - - addHost - A new response parameter is added: hahost - - - updateHost - A new response parameter is added: hahost - - - detachVolume - A new response parameter is added: status - - - listAccounts - A new response parameter is added: defaultzoneid - - - listHosts - A new response parameter is added: hahostA new request - parameter is added: hahost (optional) - - - - -
-
+
+ + ### + +
+
+
+ Upgrade from 3.0.2 to 4.1.0 + This section will guide you from Citrix CloudStack 3.0.2 to Apache CloudStack 4.1.0. Sections that are hypervisor-specific will be called out with a note. + + + Ensure that you query your IP address usage records and process them or make a + backup. During the upgrade you will lose the old IP address usage records. + Starting in 3.0.2, the usage record format for IP addresses is the same as the rest + of the usage types. Instead of a single record with the assignment and release dates, + separate records are generated per aggregation period with start and end dates. After + upgrading, any existing IP address usage records in the old format will no longer be + available. + + + + The following upgrade instructions apply only if you're using VMware hosts. If + you're not using VMware hosts, skip this step and move on to . + + In each zone that includes VMware hosts, you need to add a new system VM template. + + + While running the existing 3.0.2 system, log in to the UI as root administrator. + + + In the left navigation bar, click Templates. + + + In Select view, click Templates. + + + Click Register template. + The Register template dialog box is displayed. + + + In the Register template dialog box, specify the following values (do not change these): + + + + + + + Field + Value + + + + + Name + systemvm-vmware-4.0 + + + Description + systemvm-vmware-4.0 + + + URL + http://download.cloud.com/templates/burbank/burbank-systemvm-08012012.ova + + + Zone + Choose the zone where this hypervisor is used + + + Hypervisor + VMware + + + Format + OVA + + + OS Type + Debian GNU/Linux 5.0 (32-bit) + + + Extractable + no + + + Password Enabled + no + + + Public + no + + + Featured + no + + + + + + + Watch the screen to be sure that the template downloads successfully and enters + the READY state. Do not proceed until this is successful. + + + + + Stop all Usage Servers if running. Run this on all Usage Server hosts. + # service cloud-usage stop + + + Stop the Management Servers. Run this on all Management Server hosts. + # service cloud-management stop + + + On the MySQL master, take a backup of the MySQL databases. We recommend performing + this step even in test upgrades. If there is an issue, this will assist with + debugging. + In the following commands, it is assumed that you have set the root password on the + database, which is a CloudStack recommended best practice. Substitute your own MySQL + root password. + # mysqldump -u root -pmysql_password cloud > cloud-backup.dmp + # mysqldump -u root -pmysql_password cloud_usage > cloud-usage-backup.dmp + + + Either build RPM/DEB packages as detailed in the Installation Guide, or use one of + the community provided yum/apt repositories to gain access to the &PRODUCT; + binaries. + + + After you have configured an appropriate yum or apt repository, you may execute the + one of the following commands as appropriate for your environment in order to upgrade + &PRODUCT;: # yum update cloud-* + # apt-get update + # apt-get upgrade cloud-* + + You will, of course, have to agree to the changes suggested by Yum or APT. + + If the upgrade output includes a message similar to the following, then some + custom content was found in your old components.xml, and you need to merge the two + files: + warning: /etc/cloud/management/components.xml created as /etc/cloud/management/components.xml.rpmnew + Instructions follow in the next step. + + + + If you have made changes to your copy of + /etc/cloud/management/components.xml the changes will be + preserved in the upgrade. However, you need to do the following steps to place these + changes in a new version of the file which is compatible with version + 4.1.0. + + + Make a backup copy of /etc/cloud/management/components.xml. + For example: + # mv /etc/cloud/management/components.xml /etc/cloud/management/components.xml-backup + + + Copy /etc/cloud/management/components.xml.rpmnew to create + a new /etc/cloud/management/components.xml: + # cp -ap /etc/cloud/management/components.xml.rpmnew /etc/cloud/management/components.xml + + + Merge your changes from the backup file into the new + components.xml. + # vi /etc/cloud/management/components.xml + + + + If you have more than one management server node, repeat the upgrade steps on each + node. + + + + Start the first Management Server. Do not start any other Management Server nodes + yet. + # service cloud-management start + Wait until the databases are upgraded. Ensure that the database upgrade is complete. + After confirmation, start the other Management Servers one at a time by running the same + command on each node. + + Failing to restart the Management Server indicates a problem in the upgrade. + Having the Management Server restarted without any issues indicates that the upgrade + is successfully completed. + + + + Start all Usage Servers (if they were running on your previous version). Perform + this on each Usage Server host. + # service cloud-usage start + + + + Additional steps are required for each KVM host. These steps will not affect + running guests in the cloud. These steps are required only for clouds using KVM as + hosts and only on the KVM hosts. + + + + Configure a yum or apt respository containing the &PRODUCT; packages as outlined + in the Installation Guide. + + + Stop the running agent. + # service cloud-agent stop + + + Update the agent software with one of the following command sets as appropriate + for your environment. + # yum update cloud-* + # apt-get update + # apt-get upgrade cloud-* + + + Start the agent. + # service cloud-agent start + + + Edit /etc/cloud/agent/agent.properties to change the + resource parameter from + "com.cloud.agent.resource.computing.LibvirtComputingResource" to + "com.cloud.hypervisor.kvm.resource.LibvirtComputingResource". + + + Start the cloud agent and cloud management services. + + + When the Management Server is up and running, log in to the CloudStack UI and + restart the virtual router for proper functioning of all the features. + + + + + Log in to the CloudStack UI as administrator, and check the status of the hosts. All + hosts should come to Up state (except those that you know to be offline). You may need + to wait 20 or 30 minutes, depending on the number of hosts. + + Troubleshooting: If login fails, clear your browser cache and reload the + page. + + + Do not proceed to the next step until the hosts show in Up state. + + + If you are upgrading from 3.0.2, perform the following: + + + Ensure that the admin port is set to 8096 by using the "integration.api.port" + global parameter. + This port is used by the cloud-sysvmadm script at the end of the upgrade + procedure. For information about how to set this parameter, see "Setting Global + Configuration Parameters" in the Installation Guide. + + + Restart the Management Server. + + If you don't want the admin port to remain open, you can set it to null after + the upgrade is done and restart the management server. + + + + + + Run the cloud-sysvmadm script to stop, then start, all Secondary + Storage VMs, Console Proxy VMs, and virtual routers. Run the script once on each + management server. Substitute your own IP address of the MySQL instance, the MySQL user + to connect as, and the password to use for that user. In addition to those parameters, + provide the -c and -r arguments. For + example: + # nohup cloud-sysvmadm -d 192.168.1.5 -u cloud -p password -c -r > + sysvm.log 2>&1 & + # tail -f sysvm.log + This might take up to an hour or more to run, depending on the number of accounts in + the system. + + + If needed, upgrade all Citrix XenServer hypervisor hosts in your cloud to a version + supported by CloudStack 4.1.0. The supported versions are XenServer 5.6 SP2 + and 6.0.2. Instructions for upgrade can be found in the CloudStack 4.1.0 + Installation Guide under "Upgrading XenServer Versions." + + + Now apply the XenServer hotfix XS602E003 (and any other needed hotfixes) to + XenServer v6.0.2 hypervisor hosts. + + + Disconnect the XenServer cluster from CloudStack. + In the left navigation bar of the CloudStack UI, select Infrastructure. Under + Clusters, click View All. Select the XenServer cluster and click Actions - + Unmanage. + This may fail if there are hosts not in one of the states Up, Down, + Disconnected, or Alert. You may need to fix that before unmanaging this + cluster. + Wait until the status of the cluster has reached Unmanaged. Use the CloudStack + UI to check on the status. When the cluster is in the unmanaged state, there is no + connection to the hosts in the cluster. + + + To clean up the VLAN, log in to one XenServer host and run: + /opt/xensource/bin/cloud-clean-vlan.sh + + + Now prepare the upgrade by running the following on one XenServer host: + /opt/xensource/bin/cloud-prepare-upgrade.sh + If you see a message like "can't eject CD", log in to the VM and unmount the CD, + then run this script again. + + + Upload the hotfix to the XenServer hosts. Always start with the Xen pool master, + then the slaves. Using your favorite file copy utility (e.g. WinSCP), copy the + hotfixes to the host. Place them in a temporary folder such as /tmp. + On the Xen pool master, upload the hotfix with this command: + xe patch-upload file-name=XS602E003.xsupdate + Make a note of the output from this command, which is a UUID for the hotfix + file. You'll need it in another step later. + + (Optional) If you are applying other hotfixes as well, you can repeat the + commands in this section with the appropriate hotfix number. For example, + XS602E004.xsupdate. + + + + Manually live migrate all VMs on this host to another host. First, get a list of + the VMs on this host: + # xe vm-list + Then use this command to migrate each VM. Replace the example host name and VM + name with your own: + # xe vm-migrate live=true host=host-name + vm=VM-name + + Troubleshooting + If you see a message like "You attempted an operation on a VM which requires + PV drivers to be installed but the drivers were not detected," run: + /opt/xensource/bin/make_migratable.sh + b6cf79c8-02ee-050b-922f-49583d9f1a14. + + + + Apply the hotfix. First, get the UUID of this host: + # xe host-list + Then use the following command to apply the hotfix. Replace the example host + UUID with the current host ID, and replace the hotfix UUID with the output from the + patch-upload command you ran on this machine earlier. You can also get the hotfix + UUID by running xe patch-list. + xe patch-apply host-uuid=host-uuid uuid=hotfix-uuid + + + Copy the following files from the CloudStack Management Server to the + host. + + + + + + + Copy from here... + ...to here + + + + + /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py + /opt/xensource/sm/NFSSR.py + + + /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/setupxenserver.sh + /opt/xensource/bin/setupxenserver.sh + + + /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/make_migratable.sh + /opt/xensource/bin/make_migratable.sh + + + + + + + (Only for hotfixes XS602E005 and XS602E007) You need to apply a new Cloud + Support Pack. + + + Download the CSP software onto the XenServer host from one of the following + links: + For hotfix XS602E005: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E005/56710/xe-phase-2/xenserver-cloud-supp.tgz + For hotfix XS602E007: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E007/57824/xe-phase-2/xenserver-cloud-supp.tgz + + + Extract the file: + # tar xf xenserver-cloud-supp.tgz + + + Run the following script: + # xe-install-supplemental-pack xenserver-cloud-supp.iso + + + If the XenServer host is part of a zone that uses basic networking, disable + Open vSwitch (OVS): + # xe-switch-network-backend bridge + + + + + Reboot this XenServer host. + + + Run the following: + /opt/xensource/bin/setupxenserver.sh + + If the message "mv: cannot stat `/etc/cron.daily/logrotate': No such file or + directory" appears, you can safely ignore it. + + + + Run the following: + for pbd in `xe pbd-list currently-attached=false| grep ^uuid | awk '{print $NF}'`; do xe pbd-plug uuid=$pbd ; + + + On each slave host in the Xen pool, repeat these steps, starting from "manually + live migrate VMs." + + + + + + Troubleshooting Tip + If passwords which you know to be valid appear not to work after upgrade, or other UI + issues are seen, try clearing your browser cache and reloading the UI page. + +
+
+ Upgrade from 2.2.14 to 4.1.0 + + + Ensure that you query your IPaddress usage records and process them; for example, + issue invoices for any usage that you have not yet billed users for. + Starting in 3.0.2, the usage record format for IP addresses is the same as the rest + of the usage types. Instead of a single record with the assignment and release dates, + separate records are generated per aggregation period with start and end dates. After + upgrading to 4.1.0, any existing IP address usage records in the old format + will no longer be available. + + + If you are using version 2.2.0 - 2.2.13, first upgrade to 2.2.14 by using the + instructions in the 2.2.14 Release Notes. + + KVM Hosts + If KVM hypervisor is used in your cloud, be sure you completed the step to insert + a valid username and password into the host_details table on each KVM node as + described in the 2.2.14 Release Notes. This step is critical, as the database will be + encrypted after the upgrade to 4.1.0. + + + + While running the 2.2.14 system, log in to the UI as root administrator. + + + Using the UI, add a new System VM template for each hypervisor type that is used in + your cloud. In each zone, add a system VM template for each hypervisor used in that + zone + + + In the left navigation bar, click Templates. + + + In Select view, click Templates. + + + Click Register template. + The Register template dialog box is displayed. + + + In the Register template dialog box, specify the following values depending on + the hypervisor type (do not change these): + + + + + + + Hypervisor + Description + + + + + XenServer + Name: systemvm-xenserver-4.1.0 + Description: systemvm-xenserver-4.1.0 + URL: + http://download.cloud.com/templates/acton/acton-systemvm-02062012.vhd.bz2 + Zone: Choose the zone where this hypervisor is used + Hypervisor: XenServer + Format: VHD + OS Type: Debian GNU/Linux 5.0 (32-bit) + Extractable: no + Password Enabled: no + Public: no + Featured: no + + + + KVM + Name: systemvm-kvm-4.1.0 + Description: systemvm-kvm-4.1.0 + URL: + http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2 + Zone: Choose the zone where this hypervisor is used + Hypervisor: KVM + Format: QCOW2 + OS Type: Debian GNU/Linux 5.0 (32-bit) + Extractable: no + Password Enabled: no + Public: no + Featured: no + + + + VMware + Name: systemvm-vmware-4.1.0 + Description: systemvm-vmware-4.1.0 + URL: + http://download.cloud.com/templates/burbank/burbank-systemvm-08012012.ova + Zone: Choose the zone where this hypervisor is used + Hypervisor: VMware + Format: OVA + OS Type: Debian GNU/Linux 5.0 (32-bit) + Extractable: no + Password Enabled: no + Public: no + Featured: no + + + + + + + + + + Watch the screen to be sure that the template downloads successfully and enters the + READY state. Do not proceed until this is successful + + + WARNING: If you use more than one type of + hypervisor in your cloud, be sure you have repeated these steps to download the system + VM template for each hypervisor type. Otherwise, the upgrade will fail. + + + Stop all Usage Servers if running. Run this on all Usage Server hosts. + # service cloud-usage stop + + + Stop the Management Servers. Run this on all Management Server hosts. + # service cloud-management stop + + + On the MySQL master, take a backup of the MySQL databases. We recommend performing + this step even in test upgrades. If there is an issue, this will assist with + debugging. + In the following commands, it is assumed that you have set the root password on the + database, which is a CloudStack recommended best practice. Substitute your own MySQL + root password. + # mysqldump -u root -pmysql_password cloud > cloud-backup.dmp + # mysqldump -u root -pmysql_password cloud_usage > cloud-usage-backup.dmp + + + + Either build RPM/DEB packages as detailed in the Installation Guide, or use one of + the community provided yum/apt repositories to gain access to the &PRODUCT; binaries. + + + + After you have configured an appropriate yum or apt repository, you may execute the + one of the following commands as appropriate for your environment in order to upgrade + &PRODUCT;: # yum update cloud-* + # apt-get update + # apt-get upgrade cloud-* + + You will, of course, have to agree to the changes suggested by Yum or APT. + + + If you have made changes to your existing copy of the file components.xml in your + previous-version CloudStack installation, the changes will be preserved in the upgrade. + However, you need to do the following steps to place these changes in a new version of + the file which is compatible with version 4.0.0-incubating. + + How will you know whether you need to do this? If the upgrade output in the + previous step included a message like the following, then some custom content was + found in your old components.xml, and you need to merge the two files: + + warning: /etc/cloud/management/components.xml created as /etc/cloud/management/components.xml.rpmnew + + + Make a backup copy of your + /etc/cloud/management/components.xml file. For + example: + # mv /etc/cloud/management/components.xml /etc/cloud/management/components.xml-backup + + + Copy /etc/cloud/management/components.xml.rpmnew to create + a new /etc/cloud/management/components.xml: + # cp -ap /etc/cloud/management/components.xml.rpmnew /etc/cloud/management/components.xml + + + Merge your changes from the backup file into the new components.xml file. + # vi /etc/cloud/management/components.xml + + + + + + If you have made changes to your existing copy of the + /etc/cloud/management/db.properties file in your previous-version + CloudStack installation, the changes will be preserved in the upgrade. However, you need + to do the following steps to place these changes in a new version of the file which is + compatible with version 4.0.0-incubating. + + + Make a backup copy of your file + /etc/cloud/management/db.properties. For example: + # mv /etc/cloud/management/db.properties /etc/cloud/management/db.properties-backup + + + Copy /etc/cloud/management/db.properties.rpmnew to create a + new /etc/cloud/management/db.properties: + # cp -ap /etc/cloud/management/db.properties.rpmnew etc/cloud/management/db.properties + + + Merge your changes from the backup file into the new db.properties file. + # vi /etc/cloud/management/db.properties + + + + + On the management server node, run the following command. It is recommended that you + use the command-line flags to provide your own encryption keys. See Password and Key + Encryption in the Installation Guide. + # cloud-setup-encryption -e encryption_type -m management_server_key -k database_key + When used without arguments, as in the following example, the default encryption + type and keys will be used: + + + (Optional) For encryption_type, use file or web to indicate the technique used + to pass in the database encryption password. Default: file. + + + (Optional) For management_server_key, substitute the default key that is used to + encrypt confidential parameters in the properties file. Default: password. It is + highly recommended that you replace this with a more secure value + + + (Optional) For database_key, substitute the default key that is used to encrypt + confidential parameters in the CloudStack database. Default: password. It is highly + recommended that you replace this with a more secure value. + + + + + Repeat steps 10 - 14 on every management server node. If you provided your own + encryption key in step 14, use the same key on all other management servers. + + + Start the first Management Server. Do not start any other Management Server nodes + yet. + # service cloud-management start + Wait until the databases are upgraded. Ensure that the database upgrade is complete. + You should see a message like "Complete! Done." After confirmation, start the other + Management Servers one at a time by running the same command on each node. + + + Start all Usage Servers (if they were running on your previous version). Perform + this on each Usage Server host. + # service cloud-usage start + + + (KVM only) Additional steps are required for each KVM host. These steps will not + affect running guests in the cloud. These steps are required only for clouds using KVM + as hosts and only on the KVM hosts. + + + Configure your CloudStack package repositories as outlined in the Installation + Guide + + + Stop the running agent. + # service cloud-agent stop + + + Update the agent software with one of the following command sets as + appropriate. + # yum update cloud-* + + # apt-get update + # apt-get upgrade cloud-* + + + + Start the agent. + # service cloud-agent start + + + Copy the contents of the agent.properties file to the new + agent.properties file by using the following command + sed -i 's/com.cloud.agent.resource.computing.LibvirtComputingResource/com.cloud.hypervisor.kvm.resource.LibvirtComputingResource/g' /etc/cloud/agent/agent.properties + + + Start the cloud agent and cloud management services. + + + When the Management Server is up and running, log in to the CloudStack UI and + restart the virtual router for proper functioning of all the features. + + + + + Log in to the CloudStack UI as admin, and check the status of the hosts. All hosts + should come to Up state (except those that you know to be offline). You may need to wait + 20 or 30 minutes, depending on the number of hosts. + Do not proceed to the next step until the hosts show in the Up state. If the hosts + do not come to the Up state, contact support. + + + Run the following script to stop, then start, all Secondary Storage VMs, Console + Proxy VMs, and virtual routers. + + + Run the command once on one management server. Substitute your own IP address of + the MySQL instance, the MySQL user to connect as, and the password to use for that + user. In addition to those parameters, provide the "-c" and "-r" arguments. For + example: + # nohup cloud-sysvmadm -d 192.168.1.5 -u cloud -p password -c -r > sysvm.log 2>&1 & + # tail -f sysvm.log + This might take up to an hour or more to run, depending on the number of + accounts in the system. + + + After the script terminates, check the log to verify correct execution: + # tail -f sysvm.log + The content should be like the following: + + Stopping and starting 1 secondary storage vm(s)... + Done stopping and starting secondary storage vm(s) + Stopping and starting 1 console proxy vm(s)... + Done stopping and starting console proxy vm(s). + Stopping and starting 4 running routing vm(s)... + Done restarting router(s). + + + + + + If you would like additional confirmation that the new system VM templates were + correctly applied when these system VMs were rebooted, SSH into the System VM and check + the version. + Use one of the following techniques, depending on the hypervisor. + + XenServer or KVM: + SSH in by using the link local IP address of the system VM. For example, in the + command below, substitute your own path to the private key used to log in to the + system VM and your own link local IP. + + Run the following commands on the XenServer or KVM host on which the system VM is + present: + # ssh -i private-key-path link-local-ip -p 3922 + # cat /etc/cloudstack-release + The output should be like the following: + Cloudstack Release 4.0.0-incubating Mon Oct 9 15:10:04 PST 2012 + + ESXi + SSH in using the private IP address of the system VM. For example, in the command + below, substitute your own path to the private key used to log in to the system VM and + your own private IP. + + Run the following commands on the Management Server: + # ssh -i private-key-path private-ip -p 3922 + # cat /etc/cloudstack-release + + The output should be like the following: + Cloudstack Release 4.0.0-incubating Mon Oct 9 15:10:04 PST 2012 + + + If needed, upgrade all Citrix XenServer hypervisor hosts in your cloud to a version + supported by CloudStack 4.0.0-incubating. The supported versions are XenServer 5.6 SP2 + and 6.0.2. Instructions for upgrade can be found in the CloudStack 4.0.0-incubating + Installation Guide. + + + Apply the XenServer hotfix XS602E003 (and any other needed hotfixes) to XenServer + v6.0.2 hypervisor hosts. + + + Disconnect the XenServer cluster from CloudStack. + In the left navigation bar of the CloudStack UI, select Infrastructure. Under + Clusters, click View All. Select the XenServer cluster and click Actions - + Unmanage. + This may fail if there are hosts not in one of the states Up, Down, + Disconnected, or Alert. You may need to fix that before unmanaging this + cluster. + Wait until the status of the cluster has reached Unmanaged. Use the CloudStack + UI to check on the status. When the cluster is in the unmanaged state, there is no + connection to the hosts in the cluster. + + + To clean up the VLAN, log in to one XenServer host and run: + /opt/xensource/bin/cloud-clean-vlan.sh + + + Prepare the upgrade by running the following on one XenServer host: + /opt/xensource/bin/cloud-prepare-upgrade.sh + If you see a message like "can't eject CD", log in to the VM and umount the CD, + then run this script again. + + + Upload the hotfix to the XenServer hosts. Always start with the Xen pool master, + then the slaves. Using your favorite file copy utility (e.g. WinSCP), copy the + hotfixes to the host. Place them in a temporary folder such as /root or /tmp. + On the Xen pool master, upload the hotfix with this command: + xe patch-upload file-name=XS602E003.xsupdate + Make a note of the output from this command, which is a UUID for the hotfix + file. You'll need it in another step later. + + (Optional) If you are applying other hotfixes as well, you can repeat the + commands in this section with the appropriate hotfix number. For example, + XS602E004.xsupdate. + + + + Manually live migrate all VMs on this host to another host. First, get a list of + the VMs on this host: + # xe vm-list + Then use this command to migrate each VM. Replace the example host name and VM + name with your own: + # xe vm-migrate live=true host=host-name vm=VM-name + + Troubleshooting + If you see a message like "You attempted an operation on a VM which requires + PV drivers to be installed but the drivers were not detected," run: + /opt/xensource/bin/make_migratable.sh + b6cf79c8-02ee-050b-922f-49583d9f1a14. + + + + Apply the hotfix. First, get the UUID of this host: + # xe host-list + Then use the following command to apply the hotfix. Replace the example host + UUID with the current host ID, and replace the hotfix UUID with the output from the + patch-upload command you ran on this machine earlier. You can also get the hotfix + UUID by running xe patch-list. + xe patch-apply host-uuid=host-uuid + uuid=hotfix-uuid + + + Copy the following files from the CloudStack Management Server to the + host. + + + + + + + Copy from here... + ...to here + + + + + /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py + /opt/xensource/sm/NFSSR.py + + + /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/setupxenserver.sh + /opt/xensource/bin/setupxenserver.sh + + + /usr/lib64/cloud/common/scripts/vm/hypervisor/xenserver/make_migratable.sh + /opt/xensource/bin/make_migratable.sh + + + + + + + (Only for hotfixes XS602E005 and XS602E007) You need to apply a new Cloud + Support Pack. + + + Download the CSP software onto the XenServer host from one of the following + links: + For hotfix XS602E005: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E005/56710/xe-phase-2/xenserver-cloud-supp.tgz + For hotfix XS602E007: http://coltrane.eng.hq.xensource.com/release/XenServer-6.x/XS-6.0.2/hotfixes/XS602E007/57824/xe-phase-2/xenserver-cloud-supp.tgz + + + Extract the file: + # tar xf xenserver-cloud-supp.tgz + + + Run the following script: + # xe-install-supplemental-pack + xenserver-cloud-supp.iso + + + If the XenServer host is part of a zone that uses basic networking, disable + Open vSwitch (OVS): + # xe-switch-network-backend bridge + + + + + Reboot this XenServer host. + + + Run the following: + /opt/xensource/bin/setupxenserver.sh + + If the message "mv: cannot stat `/etc/cron.daily/logrotate': No such file or + directory" appears, you can safely ignore it. + + + + Run the following: + for pbd in `xe pbd-list currently-attached=false| grep ^uuid | awk + '{print $NF}'`; do xe pbd-plug uuid=$pbd ; + + + + On each slave host in the Xen pool, repeat these steps, starting from "manually + live migrate VMs." + + + + +
+
+ + Version 4.1.0 +
+ What’s New in 4.1 + Apache CloudStack 4.1.0 includes many new features. This section covers the most prominent new features and changes. +
+
+ Issues Fixed in 4.1.0 + Apache CloudStack uses Jira + to track its issues. All new features and bugs for 4.1.0 have been tracked in Jira, and have + a standard naming convention of "CLOUDSTACK-NNNN" where "NNNN" is the issue number. + This section includes a summary of known issues against 4.0.0 that were fixed in 4.1.0. + + + + + + + + Defect + + + Description + + + + + + CS-16135 + Creating volumes after upgrading from snapshot taken in 2.2.14 no longer + deletes the snapshot physically from the secondary storage. + + + + +
+
+ Known Issues in 4.1.0 + + + + + + + + Issue ID + + + Description + + + + + + CLOUDSTACK-1747 + mvn deploydb only creates 4.0 DB, not 4.1 + Due to tooling changes between 4.1 and 4.2, CloudStack's database is created using the 4.0 schema and updated to the 4.1 schema when the management server starts for the first time. It's OK to see the same schema if the management server has not started yet. + + + + CLOUDSTACK-1824 + Service CloudStack-Management is being displayed as cloud-management service + Many scripts and text entries have references to cloud-management rather than cloudstack-management due to the changeover between 4.0 and 4.1 to rename services. This is a minor issue and should be corrected by 4.2. + + + + + CLOUDSTACK-1824 + Service CloudStack-Management is being displayed as cloud-management service + + + + + CLOUDSTACK-1510 + + + NPE when primary storage is added with wrong path + + + + + CLOUDSTACK-1428 + + + [UI] Instance which are created without display name are not visible when added to LB + + + + + CLOUDSTACK-1306 + + + Better Error message when trying to deploy Vm by passing static Ipv4 addresses that are assigned to another VM/IP4 address is outside the iprange. + + + + + CLOUDSTACK-1236 + + + Warning while adding Xen 6.1 host [Unable to create local link network] + + + + + CLOUDSTACK-969 + + + api: zone response lists vlan in it as "vlan range of zone" but the vlan belongs to physical network + + + + + CLOUDSTACK-963 + + + [cloud.utils.AnnotationHelper] class java.lang.Stringdoes not have a Table annotation + + + + + CLOUDSTACK-458 + + + xen:snapshots:Storage gc fail to clean the failed snapshot images from secondarystorage + + + + + CLOUDSTACK-315 + + + Infrastructure view does not show capacity values + + + + + CLOUDSTACK-300 + + + Creation of compute offering allow combination of local storage + HA + + + + + CLOUDSTACK-282 + + + Virtual Routers do not properly resolve DNS SRV Records + + + + + CLOUDSTACK-276 + + + SSVM ID is exposed in the Error Message thrown by AddTrafficType API + + + + + CLOUDSTACK-270 + + + Ui should not ask for a vlan range if the physical network isolation type is not VLAN + + + + + CLOUDSTACK-245 + + + VPC ACLs are not stored and programmed consistently + + + + + CLOUDSTACK-231 + + + Tag creation using special charecters + + + + + CLOUDSTACK-124 + + + NetworkGarbageCollector not cleaning up networks + + + + + CLOUDSTACK-62 + + + console proxy does not support any keymaps besides us, jp + + + + + +
+
+
diff --git a/docs/en-US/add-clusters-vsphere.xml b/docs/en-US/add-clusters-vsphere.xml index ca36ee108c4..6b2dff2a595 100644 --- a/docs/en-US/add-clusters-vsphere.xml +++ b/docs/en-US/add-clusters-vsphere.xml @@ -73,105 +73,36 @@ Provide the following information in the dialog. The fields below make reference to values from vCenter. - - - - - - addcluster.png: add a cluster - - - There might be a slight delay while the cluster is provisioned. It will automatically - display in the UI. - Cluster Name: Enter the name of the cluster you - created in vCenter. For example, "cloud.cluster.2.2.1" + Cluster Name. Enter the name of the cluster you created in vCenter. For example, + "cloud.cluster.2.2.1" - vCenter Username: Enter the username that &PRODUCT; - should use to connect to vCenter. This user must have all the administrative - privileges. + vCenter Host. Enter the hostname or IP address of the vCenter server. - CPU overcommit ratio: Enter the CPU overcommit - ratio for the cluster. The value you enter determines the CPU consumption of each VM in - the selected cluster. By increasing the over-provisioning ratio, more resource capacity - will be used. If no value is specified, the value is defaulted to 1, which implies no - over-provisioning is done. + vCenter Username. Enter the username that &PRODUCT; should use to connect to + vCenter. This user must have all administrative privileges. - RAM overcommit ratio: Enter the RAM overcommit - ratio for the cluster. The value you enter determines the memory consumption of each VM - in the selected cluster. By increasing the over-provisioning ratio, more resource - capacity will be used. If no value is specified, the value is defaulted to 1, which - implies no over-provisioning is done. + vCenter Password. Enter the password for the user named above - vCenter Host: Enter the hostname or IP address of - the vCenter server. - - - vCenter Password: Enter the password for the user - named above. - - - vCenter Datacenter: Enter the vCenter datacenter - that the cluster is in. For example, "cloud.dc.VM". - - - Override Public Traffic: Enable this option to - override the zone-wide public traffic for the cluster you are creating. - - - Public Traffic vSwitch Type: This option is - displayed only if you enable the Override Public Traffic option. Select a desirable - switch. If the vmware.use.dvswitch global parameter is true, the default option will be - VMware vNetwork Distributed Virtual Switch. - If you have enabled Nexus dvSwitch in the environment, the following parameters for - dvSwitch configuration are displayed: - - - Nexus dvSwitch IP Address: The IP address of the Nexus VSM appliance. - - - Nexus dvSwitch Username: The username required to access the Nexus VSM - applicance. - - - Nexus dvSwitch Password: The password associated with the username specified - above. - - - - - Override Guest Traffic: Enable this option to - override the zone-wide guest traffic for the cluster you are creating. - - - Guest Traffic vSwitch Type: This option is - displayed only if you enable the Override Guest Traffic option. Select a desirable - switch. If the vmware.use.dvswitch global parameter is true, the default option will be - VMware vNetwork Distributed Virtual Switch. - If you have enabled Nexus dvSwitch in the environment, the following parameters for - dvSwitch configuration are displayed: - - - Nexus dvSwitch IP Address: The IP address of the Nexus VSM appliance. - - - Nexus dvSwitch Username: The username required to access the Nexus VSM - applicance. - - - Nexus dvSwitch Password: The password associated with the username specified - above. - - + vCenter Datacenter. Enter the vCenter datacenter that the cluster is in. For + example, "cloud.dc.VM". + + + + + + addcluster.png: add cluster + + There might be a slight delay while the cluster is provisioned. It will - automatically display in the UI. + automatically display in the UI diff --git a/docs/en-US/choosing-a-hypervisor.xml b/docs/en-US/choosing-a-hypervisor.xml new file mode 100644 index 00000000000..bf83fe3d17f --- /dev/null +++ b/docs/en-US/choosing-a-hypervisor.xml @@ -0,0 +1,136 @@ + +%BOOK_ENTITIES; +]> + + + + Choosing a Hypervisor: Supported Features + &PRODUCT; supports many popular hypervisors. Your cloud can consist entirely of hosts running a single hypervisor, or you can use multiple hypervisors. Each cluster of hosts must run the same hypervisor. + You might already have an installed base of nodes running a particular hypervisor, in which case, your choice of hypervisor has already been made. If you are starting from scratch, you need to decide what hypervisor software best suits your needs. A discussion of the relative advantages of each hypervisor is outside the scope of our documentation. However, it will help you to know which features of each hypervisor are supported by &PRODUCT;. The following table provides this information. + + + + + + + + + + + + Feature + XenServer 6.0.2 + vSphere 4.1/5.0 + KVM - RHEL 6.2 + OVM 2.3 + Bare Metal + + + + + Network Throttling + Yes + Yes + No + No + N/A + + + Security groups in zones that use basic networking + Yes + No + Yes + No + No + + + iSCSI + Yes + Yes + Yes + Yes + N/A + + + FibreChannel + Yes + Yes + Yes + No + N/A + + + Local Disk + Yes + Yes + Yes + No + Yes + + + HA + Yes + Yes (Native) + Yes + Yes + N/A + + + Snapshots of local disk + Yes + Yes + Yes + No + N/A + + + Local disk as data disk + No + No + No + No + N/A + + + Work load balancing + No + DRS + No + No + N/A + + + Manual live migration of VMs from host to host + Yes + Yes + Yes + Yes + N/A + + + Conserve management traffic IP address by using link local network to communicate with virtual router + Yes + No + Yes + Yes + N/A + + + + + diff --git a/docs/en-US/global-config.xml b/docs/en-US/global-config.xml index 2f6ad105c0d..11952c382ac 100644 --- a/docs/en-US/global-config.xml +++ b/docs/en-US/global-config.xml @@ -19,6 +19,8 @@ under the License. --> + Global Configuration Parameters +
Setting Global Configuration Parameters &PRODUCT; provides parameters that you can set to control many aspects of the cloud. When &PRODUCT; is first installed, and periodically thereafter, you might need to modify these @@ -51,4 +53,81 @@ must click the name of the hypervisor first to display the editing screen. +
+
+ About Global Configuration Parameters + &PRODUCT; provides a variety of settings you can use to set limits, configure features, + and enable or disable features in the cloud. Once your Management Server is running, you might + need to set some of these global configuration parameters, depending on what optional features + you are setting up. + To modify global configuration parameters, use the steps in "Setting Global Configuration + Parameters." + The documentation for each &PRODUCT; feature should direct you to the names of the applicable + parameters. Many of them are discussed in the &PRODUCT; Administration Guide. The following table + shows a few of the more useful parameters. + + + + + + + Field + Value + + + + + management.network.cidr + A CIDR that describes the network that the management CIDRs reside on. This + variable must be set for deployments that use vSphere. It is recommended to be set for + other deployments as well. Example: 192.168.3.0/24. + + + xen.setup.multipath + For XenServer nodes, this is a true/false variable that instructs CloudStack to + enable iSCSI multipath on the XenServer Hosts when they are added. This defaults to false. + Set it to true if you would like CloudStack to enable multipath. + If this is true for a NFS-based deployment multipath will still be enabled on the + XenServer host. However, this does not impact NFS operation and is harmless. + + + secstorage.allowed.internal.sites + This is used to protect your internal network from rogue attempts to download + arbitrary files using the template download feature. This is a comma-separated list of CIDRs. + If a requested URL matches any of these CIDRs the Secondary Storage VM will use the private + network interface to fetch the URL. Other URLs will go through the public interface. + We suggest you set this to 1 or 2 hardened internal machines where you keep your templates. + For example, set it to 192.168.1.66/32. + + + use.local.storage + Determines whether CloudStack will use storage that is local to the Host for data + disks, templates, and snapshots. By default CloudStack will not use this storage. You should + change this to true if you want to use local storage and you understand the reliability and + feature drawbacks to choosing local storage. + + + host + This is the IP address of the Management Server. If you are using multiple + Management Servers you should enter a load balanced IP address that is reachable via + the private network. + + + default.page.size + Maximum number of items per page that can be returned by a CloudStack API command. + The limit applies at the cloud level and can vary from cloud to cloud. You can override this + with a lower value on a particular API call by using the page and pagesize API command parameters. + For more information, see the Developer's Guide. Default: 500. + + + ha.tag + The label you want to use throughout the cloud to designate certain hosts as dedicated + HA hosts. These hosts will be used only for HA-enabled VMs that are restarting due to the failure + of another host. For example, you could set this to ha_host. Specify the ha.tag value as a host tag + when you add a new host to the cloud. + + + + +
diff --git a/docs/en-US/hypervisor-host-install-firewall.xml b/docs/en-US/hypervisor-host-install-firewall.xml index ae82fc47afa..c6658731819 100644 --- a/docs/en-US/hypervisor-host-install-firewall.xml +++ b/docs/en-US/hypervisor-host-install-firewall.xml @@ -34,7 +34,7 @@ 49152 - 49216 (libvirt live migration) It depends on the firewall you are using how to open these ports. Below you'll find examples how to open these ports in RHEL/CentOS and Ubuntu. -
+
Open ports in RHEL/CentOS RHEL and CentOS use iptables for firewalling the system, you can open extra ports by executing the following iptable commands: $ iptables -I INPUT -p tcp -m tcp --dport 22 -j ACCEPT @@ -45,7 +45,7 @@ These iptable settings are not persistent accross reboots, we have to save them first. $ iptables-save > /etc/sysconfig/iptables
-
+
Open ports in Ubuntu The default firewall under Ubuntu is UFW (Uncomplicated FireWall), which is a Python wrapper around iptables. To open the required ports, execute the following commands: diff --git a/docs/en-US/hypervisor-host-install-network.xml b/docs/en-US/hypervisor-host-install-network.xml index 3a6dfac48bd..54cdc27c450 100644 --- a/docs/en-US/hypervisor-host-install-network.xml +++ b/docs/en-US/hypervisor-host-install-network.xml @@ -29,7 +29,7 @@ In order to forward traffic to your instances you will need at least two bridges: public and private. By default these bridges are called cloudbr0 and cloudbr1, but you do have to make sure they are available on each hypervisor. The most important factor is that you keep the configuration consistent on all your hypervisors. -
+
Network example There are many ways to configure your network. In the Basic networking mode you should have two (V)LAN's, one for your private network and one for the public network. We assume that the hypervisor has one NIC (eth0) with three tagged VLAN's: @@ -41,11 +41,11 @@ On VLAN 100 we give the Hypervisor the IP-Address 192.168.42.11/24 with the gateway 192.168.42.1 The Hypervisor and Management server don't have to be in the same subnet!
-
+
Configuring the network bridges It depends on the distribution you are using how to configure these, below you'll find examples for RHEL/CentOS and Ubuntu. The goal is to have two bridges called 'cloudbr0' and 'cloudbr1' after this section. This should be used as a guideline only. The exact configuration will depend on your network layout. -
+
Configure in RHEL or CentOS The required packages were installed when libvirt was installed, we can proceed to configuring the network. First we configure eth0 @@ -111,7 +111,7 @@ STP=yes]]> With this configuration you should be able to restart the network, although a reboot is recommended to see if everything works properly. Make sure you have an alternative way like IPMI or ILO to reach the machine in case you made a configuration error and the network stops functioning!
-
+
Configure in Ubuntu All the required packages were installed when you installed libvirt, so we only have to configure the network. vi /etc/network/interfaces diff --git a/docs/en-US/hypervisor-installation.xml b/docs/en-US/hypervisor-installation.xml index b0fc9f46ddb..5ee7dea696a 100644 --- a/docs/en-US/hypervisor-installation.xml +++ b/docs/en-US/hypervisor-installation.xml @@ -28,4 +28,5 @@ + diff --git a/docs/en-US/images/add-cluster.png b/docs/en-US/images/add-cluster.png index 4b24ec721d8..383f375ebed 100644 Binary files a/docs/en-US/images/add-cluster.png and b/docs/en-US/images/add-cluster.png differ diff --git a/docs/en-US/images/dvswitch-config.png b/docs/en-US/images/dvswitch-config.png deleted file mode 100644 index edce6e8b90e..00000000000 Binary files a/docs/en-US/images/dvswitch-config.png and /dev/null differ diff --git a/docs/en-US/images/dvswitchconfig.png b/docs/en-US/images/dvswitchconfig.png deleted file mode 100644 index 55b1ef7daf3..00000000000 Binary files a/docs/en-US/images/dvswitchconfig.png and /dev/null differ diff --git a/docs/en-US/lxc-install.xml b/docs/en-US/lxc-install.xml new file mode 100644 index 00000000000..a80c18afdd6 --- /dev/null +++ b/docs/en-US/lxc-install.xml @@ -0,0 +1,110 @@ + + + %BOOK_ENTITIES; + ]> + + + +
+ LXC Installation and Configuration +
+ System Requirements for LXC Hosts + LXC requires the Linux kernel cgroups functionality which is available starting 2.6.24. Although you are not required to run these distributions, the following are recommended: + + CentOS / RHEL: 6.3 + Ubuntu: 12.04(.1) + + The main requirement for LXC hypervisors is the libvirt and Qemu version. No matter what + Linux distribution you are using, make sure the following requirements are met: + + libvirt: 1.0.0 or higher + Qemu/KVM: 1.0 or higher + + The default bridge in &PRODUCT; is the Linux native bridge implementation (bridge module). &PRODUCT; includes an option to work with OpenVswitch, the requirements are listed below + + libvirt: 1.0.0 or higher + openvswitch: 1.7.1 or higher + + In addition, the following hardware requirements apply: + + Within a single cluster, the hosts must be of the same distribution version. + All hosts within a cluster must be homogenous. The CPUs must be of the same type, count, and feature flags. + Must support HVM (Intel-VT or AMD-V enabled) + 64-bit x86 CPU (more cores results in better performance) + 4 GB of memory + At least 1 NIC + When you deploy &PRODUCT;, the hypervisor host must not have any VMs already running + +
+
+ LXC Installation Overview + LXC does not have any native system VMs, instead KVM will be used to run system VMs. This means that your host will need to support both LXC and KVM, thus most of the installation and configuration will be identical to the KVM installation. The material in this section doesn't duplicate KVM installation docs. It provides the &PRODUCT;-specific steps that are needed to prepare a KVM host to work with &PRODUCT;. + Before continuing, make sure that you have applied the latest updates to your host. + It is NOT recommended to run services on this host not controlled by &PRODUCT;. + The procedure for installing an LXC Host is: + + Prepare the Operating System + Install and configure libvirt + Configure Security Policies (AppArmor and SELinux) + Install and configure the Agent + +
+
+ +
+
+ Install and configure the Agent + To manage LXC instances on the host &PRODUCT; uses a Agent. This Agent communicates with the Management server and controls all the instances on the host. + First we start by installing the agent: + In RHEL or CentOS: + $ yum install cloud-agent + In Ubuntu: + $ apt-get install cloud-agent + Next step is to update the Agent configuration setttings. The settings are in /etc/cloudstack/agent/agent.properties + + + Set the Agent to run in LXC mode: + hypervisor.type=lxc + + + Optional: If you would like to use direct networking (instead of the default bridge networking), configure these lines: + libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.DirectVifDriver + network.direct.source.mode=private + network.direct.device=eth0 + + + The host is now ready to be added to a cluster. This is covered in a later section, see . It is recommended that you continue to read the documentation before adding the host! +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
diff --git a/docs/en-US/lxc-topology-req.xml b/docs/en-US/lxc-topology-req.xml new file mode 100644 index 00000000000..315863dd34c --- /dev/null +++ b/docs/en-US/lxc-topology-req.xml @@ -0,0 +1,24 @@ + + +%BOOK_ENTITIES; +]> + +
+ LXC Topology Requirements + The Management Servers communicate with LXC hosts on port 22 (ssh). +
diff --git a/docs/en-US/management-server-install-systemvm.xml b/docs/en-US/management-server-install-systemvm.xml index 8dc73deb992..928b95618fa 100644 --- a/docs/en-US/management-server-install-systemvm.xml +++ b/docs/en-US/management-server-install-systemvm.xml @@ -53,6 +53,10 @@ For KVM: # /usr/lib64/cloud/common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/secondary -u http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2 -h kvm -s <optional-management-server-secret-key> -F + + For LXC: + # /usr/lib64/cloud/common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/secondary -u http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2 -h lxc -s <optional-management-server-secret-key> -F + On Ubuntu, use the following path instead: # /usr/lib/cloud/common/scripts/storage/secondary/cloud-install-sys-tmplt diff --git a/docs/en-US/minimum-system-requirements.xml b/docs/en-US/minimum-system-requirements.xml index 0e497dd33f1..de1bc222023 100644 --- a/docs/en-US/minimum-system-requirements.xml +++ b/docs/en-US/minimum-system-requirements.xml @@ -68,6 +68,7 @@ +
diff --git a/docs/en-US/prepare-system-vm-template.xml b/docs/en-US/prepare-system-vm-template.xml index b53a509b4a1..35cc7e979bc 100644 --- a/docs/en-US/prepare-system-vm-template.xml +++ b/docs/en-US/prepare-system-vm-template.xml @@ -60,6 +60,10 @@ For KVM: # /usr/lib64/cloud/common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/secondary -u http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2 -h kvm -s <optional-management-server-secret-key> -F + + For LXC: + # /usr/lib64/cloud/common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/secondary -u http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2 -h lxc -s <optional-management-server-secret-key> -F + diff --git a/docs/en-US/topology-req.xml b/docs/en-US/topology-req.xml index 65c9c2ea5c6..75fe69b41a4 100644 --- a/docs/en-US/topology-req.xml +++ b/docs/en-US/topology-req.xml @@ -28,4 +28,5 @@ -
+ +
diff --git a/docs/en-US/vmware-cluster-config-dvswitch.xml b/docs/en-US/vmware-cluster-config-dvswitch.xml deleted file mode 100644 index 3e1e37c0941..00000000000 --- a/docs/en-US/vmware-cluster-config-dvswitch.xml +++ /dev/null @@ -1,192 +0,0 @@ - - -%BOOK_ENTITIES; -]> - - -
- Configuring a vSphere Cluster with VMware Distributed Virtual Switch - &PRODUCT;supports VMware vNetwork Distributed Switch (VDS) for virtual network configuration - in a VMware vSphere environment. This section helps you configure VMware VDS in a &PRODUCT; - deployment. Each vCenter server instance can support up to 128 VDS instances and each VDS - instance can manage up to 500 VMware hosts. -
- About VMware Distributed Virtual Switch - VMware VDS is an aggregation of host-level virtual switches on a VMware vCenter server. - VDS abstracts the configuration of individual virtual switches that span across a large number - of hosts, and enables centralized provisioning, administration, and monitoring for your entire - datacenter from a centralized interface. In effect, a VDS acts as a single virtual switch at - the datacenter level and manages networking for a number of hosts in a datacenter from a - centralized VMware vCenter server. Each VDS maintains network runtime state for VMs as they - move across multiple hosts, enabling inline monitoring and centralized firewall services. A - VDS can be deployed with or without Virtual Standard Switch and a Nexus 1000V virtual - switch. -
-
- Prerequisites and Guidelines - - - Do not attempt to configure VDS by altering VMware traffic label when configuring - physical networks. This will only work for Standard Virtual Switch and should not be - distributed. - - - VMware VDS does not support multiple VDS per traffic type. If a user has many VDS - switches, only one can be used for Guest traffic and one for Public traffic. - - - Management and Storage network does not support VDS and use Standard Switch for these - networks. - - -
-
- Enabling Virtual Distributed Switch in &PRODUCT; - To make a &PRODUCT; deployment VDS enabled, set the vmware.use.dvswitch parameter to true - by using the Global Settings page in the &PRODUCT; UI and restart the Management Server. - Unless you enable the vmware.use.dvswitch parameter, you cannot see any UI options specific to - VDS, and &PRODUCT; ignores the VDS-specific parameters given in the AddClusterCmd API call. - Additionally, &PRODUCT; uses VDS for virtual network infrastructure if the value of - vmware.use.dvswitch parameter is true and the value of vmware.use.nexus.dvswitch parameter is - false. - &PRODUCT; supports configuring virtual networks in a deployment with a mix of Virtual - Distributed Switch, Standard Virtual Switch and Nexus 1000v Virtual Switch. -
-
- Configuring Distributed Virtual Switch in &PRODUCT; - You can configure VDS by adding the necessary resources while a zone is created. - - - - - - dvSwitchConfig.png: Configuring dvSwitch - - - Alternatively, you can create an additional cluster with VDS enabled in the existing zone. - Use the Add Cluster option. For information as given in . - In both these cases, you must specify the following parameters to configure VDS: - - - - - - - Parameters - Description - - - - - Cluster Name - Enter the name of the cluster you created in vCenter. For example, - "cloud.cluster". - - - vCenter Host - Enter the host name or the IP address of the vCenter host where you have - deployed the Nexus virtual switch. - - - vCenter User name - Enter the username that &PRODUCT; should use to connect to vCenter. This - user must have all administrative privileges. - - - vCenter Password - Enter the password for the user named above. - - - vCenter Datacenter - Enter the vCenter datacenter that the cluster is in. For example, - "cloud.dc.VM". - - - Override Public Traffic - Enable this option to override the zone-wide public traffic for the cluster - you are creating. - - - Public Traffic vSwitch Type - This option is displayed only if you enable the Override Public Traffic - option. Select VMware vNetwork Distributed Virtual Switch. If the - vmware.use.dvswitch global parameter is true, the default option will be VMware - vNetwork Distributed Virtual Switch. - - - Public Traffic vSwitch Name - Specify a name to identify the switch. - - - Override Guest Traffic - Enable the option to override the zone-wide guest traffic for the cluster - you are creating. - - - Guest Traffic vSwitch Type - This option is displayed only if you enable the Override Guest Traffic - option. Select VMware vNetwork Distributed Virtual Switch. If the - vmware.use.dvswitch global parameter is true, the default option will be VMware - vNetwork Distributed Virtual Switch. - - - Guest Traffic vSwitch Name - Specify a name to identify the switch. - - - - -
-
- Removing Nexus Virtual Switch - - - In the vCenter datacenter that is served by the VMware dvSwitch, ensure that you - delete all the hosts in the corresponding cluster. - - - Log in with Admin permissions to the &PRODUCT; administrator UI. - - - In the left navigation bar, select Infrastructure. - - - In the Infrastructure page, click View all under Clusters. - - - Select the cluster where you want to remove the virtual switch. - - - In the VMware dvSwitch tab, click the name of the virtual switch. - - - In the Details page, click Delete VMware dvSwitch icon. - - - - - DeleteButton.png: button to delete dvSwitch - - - - Click Yes in the confirmation dialog box. - - -
-
diff --git a/docs/en-US/vmware-install.xml b/docs/en-US/vmware-install.xml index 81c9a49b038..467e1358638 100644 --- a/docs/en-US/vmware-install.xml +++ b/docs/en-US/vmware-install.xml @@ -1,5 +1,5 @@ - %BOOK_ENTITIES; ]> @@ -11,7 +11,9 @@ 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 @@ -325,439 +327,282 @@ esxcfg-firewall -o 59000-60000,tcp,out,vncextras guide.
-
+
Storage Preparation for vSphere (iSCSI only) Use of iSCSI requires preparatory work in vCenter. You must add an iSCSI target and create diff --git a/docs/publican-cloudstack/defaults.cfg b/docs/publican-cloudstack/defaults.cfg index 9e27bdd309d..b288b33af47 100644 --- a/docs/publican-cloudstack/defaults.cfg +++ b/docs/publican-cloudstack/defaults.cfg @@ -16,6 +16,6 @@ # specific language governing permissions and limitations # under the License. -doc_url: "http://incubator.apache.org/cloudstack/docs" -prod_url: "http://cloudstack.org" +doc_url: "http://cloudstack.apache.org/docs" +prod_url: "http://cloudstack.apache.org" diff --git a/docs/publican-cloudstack/en-US/Feedback.xml b/docs/publican-cloudstack/en-US/Feedback.xml index fb457a9ca86..8aa5f67dc2b 100644 --- a/docs/publican-cloudstack/en-US/Feedback.xml +++ b/docs/publican-cloudstack/en-US/Feedback.xml @@ -2,33 +2,43 @@ -
- We Need Feedback! - +
+ Submitting Feedback and Getting Help + feedback1 - contact information for this brand + contact information for this brand - If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a bug: https://issues.apache.org/jira/browse/CLOUDSTACK against the component Doc. + If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a bug: https://issues.apache.org/jira/browse/CLOUDSTACK against the component Doc. If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. If you have found an error, please include the section number and some of the surrounding text so we can find it easily. - Better yet, feel free to submit a patch if you would like to enhance the documentation. Our documentation is, along with the rest of the CloudStack source code, kept in the project's git repository. + Better yet, feel free to submit a patch if you would like to enhance the documentation. Our documentation is, along with the rest of the &PRODUCT; source code, kept in the project's git repository. + The most efficient way to get help with &PRODUCT; is to ask on the mailing lists. + The Apache CloudStack project has mailing lists for users and developers. These are the + official channels of communication for the project and are the best way to get answers about + using and contributing to CloudStack. It's a good idea to subscribe to the + users@cloudstack.apache.org mailing list if you've deployed or are deploying + CloudStack into production, and even for test deployments. + The CloudStack developer's mailing list (dev@cloudstack.apache.org) is for discussions + about CloudStack development, and is the best list for discussing possible bugs in CloudStack. + Anyone contributing to CloudStack should be on this mailing list. + To posts to the lists, you'll need to be subscribed. See the + CloudStack Web site + for instructions.
- - diff --git a/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntity.java b/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntity.java index 99f3120f93a..68a2ed2807b 100644 --- a/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntity.java +++ b/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntity.java @@ -14,48 +14,47 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.datacenter.entity.api; - -import com.cloud.hypervisor.Hypervisor.HypervisorType; - -public interface HostEntity extends DataCenterResourceEntity { - - /** - * @return total amount of memory. - */ - Long getTotalMemory(); - - /** - * @return # of cores in a machine. Note two cpus with two cores each returns 4. - */ - Integer getCpus(); - - /** - * @return speed of each cpu in mhz. - */ - Long getSpeed(); - - /** - * @return the pod. - */ - Long getPodId(); - - /** - * @return availability zone. - */ - long getDataCenterId(); - - /** - * @return type of hypervisor - */ - HypervisorType getHypervisorType(); - - /** - * @return the mac address of the host. - */ - String getGuid(); - - Long getClusterId(); - -} - +package org.apache.cloudstack.engine.datacenter.entity.api; + +import com.cloud.hypervisor.Hypervisor.HypervisorType; + +public interface HostEntity extends DataCenterResourceEntity { + + /** + * @return total amount of memory. + */ + Long getTotalMemory(); + + /** + * @return # of cores in a machine. Note two cpus with two cores each returns 4. + */ + Integer getCpus(); + + /** + * @return speed of each cpu in mhz. + */ + Long getSpeed(); + + /** + * @return the pod. + */ + Long getPodId(); + + /** + * @return availability zone. + */ + long getDataCenterId(); + + /** + * @return type of hypervisor + */ + HypervisorType getHypervisorType(); + + /** + * @return the mac address of the host. + */ + String getGuid(); + + Long getClusterId(); + +} diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java index 216cfa81d0e..2718e2fdbc8 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java @@ -1,86 +1,86 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.rest.service.api; - -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; -import org.apache.cloudstack.engine.service.api.ProvisioningService; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -@Component -@Service("ClusterRestService") -@Produces("application/json") -public class ClusterRestService { -// @Inject - ProvisioningService _provisioningService; - - @GET @Path("/clusters") - public List listAll() { - return null; - } - - - @GET @Path("/cluster/{clusterid}") - public ClusterEntity get(@PathParam("clusterid") String clusterId) { - return null; - } - - @POST @Path("/cluster/{clusterid}/enable") - public String enable(@PathParam("clusterid") String clusterId) { - return null; - } - - @POST @Path("/cluster/{clusterid}/disable") - public String disable(@PathParam("clusterid") String clusterId) { - return null; - } - - @POST @Path("/cluster/{clusterid}/deactivate") - public String deactivate(@PathParam("clusterid") String clusterId) { - return null; - } - - @POST @Path("/cluster/{clusterid}/reactivate") - public String reactivate(@PathParam("clusterid") String clusterId) { - return null; - } - - @PUT @Path("/cluster/create") - public ClusterEntity create( - @QueryParam("xid") String xid, - @QueryParam("display-name") String displayName) { - return null; - } - - @PUT @Path("/cluster/{clusterid}/update") - public ClusterEntity update( - @QueryParam("display-name") String displayName) { - return null; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.rest.service.api; + +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; +import org.apache.cloudstack.engine.service.api.ProvisioningService; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +@Component +@Service("ClusterRestService") +@Produces("application/json") +public class ClusterRestService { +// @Inject + ProvisioningService _provisioningService; + + @GET @Path("/clusters") + public List listAll() { + return null; + } + + + @GET @Path("/cluster/{clusterid}") + public ClusterEntity get(@PathParam("clusterid") String clusterId) { + return null; + } + + @POST @Path("/cluster/{clusterid}/enable") + public String enable(@PathParam("clusterid") String clusterId) { + return null; + } + + @POST @Path("/cluster/{clusterid}/disable") + public String disable(@PathParam("clusterid") String clusterId) { + return null; + } + + @POST @Path("/cluster/{clusterid}/deactivate") + public String deactivate(@PathParam("clusterid") String clusterId) { + return null; + } + + @POST @Path("/cluster/{clusterid}/reactivate") + public String reactivate(@PathParam("clusterid") String clusterId) { + return null; + } + + @PUT @Path("/cluster/create") + public ClusterEntity create( + @QueryParam("xid") String xid, + @QueryParam("display-name") String displayName) { + return null; + } + + @PUT @Path("/cluster/{clusterid}/update") + public ClusterEntity update( + @QueryParam("display-name") String displayName) { + return null; + } +} diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java index 3e81a443115..b75600e08fe 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java @@ -1,62 +1,62 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.rest.service.api; - -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -@Service("NetworkRestService") -@Component -@Produces("application/json") -public class NetworkRestService { - @PUT @Path("/network/create") - public NetworkEntity create( - @QueryParam("xid") String xid, - @QueryParam("display-name") String displayName) { - return null; - } - - @GET @Path("/network/{network-id}") - public NetworkEntity get(@PathParam("network-id") String networkId) { - return null; - } - - @GET @Path("/networks") - public List listAll() { - return null; - } - - @POST @Path("/network/{network-id}/") - public String deploy(@PathParam("network-id") String networkId) { - return null; - } - - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.rest.service.api; + +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +@Service("NetworkRestService") +@Component +@Produces("application/json") +public class NetworkRestService { + @PUT @Path("/network/create") + public NetworkEntity create( + @QueryParam("xid") String xid, + @QueryParam("display-name") String displayName) { + return null; + } + + @GET @Path("/network/{network-id}") + public NetworkEntity get(@PathParam("network-id") String networkId) { + return null; + } + + @GET @Path("/networks") + public List listAll() { + return null; + } + + @POST @Path("/network/{network-id}/") + public String deploy(@PathParam("network-id") String networkId) { + return null; + } + + +} diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java index 0811f0b9cf9..9c009b9aea2 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java @@ -1,79 +1,79 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.rest.service.api; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity; -import org.apache.cloudstack.engine.service.api.ProvisioningService; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -@Component -@Service("PodService") -@Produces({"application/json"}) -public class PodRestService { -// @Inject - ProvisioningService _provisioningService; - - @GET @Path("/pod/{pod-id}") - public PodEntity getPod(@PathParam("pod-id") String podId) { - return null; - } - - @POST @Path("/pod/{pod-id}/enable") - public String enable(@PathParam("pod-id") String podId) { - return null; - } - - @POST @Path("/pod/{pod-id}/disable") - public String disable(@PathParam("pod-id") String podId) { - return null; - } - - @POST @Path("/pod/{pod-id}/deactivate") - public String deactivate(@PathParam("pod-id") String podId) { - return null; - } - - @POST @Path("/pod/{pod-id}/reactivate") - public String reactivate(@PathParam("pod-id") String podId) { - return null; - } - - @PUT @Path("/pod/create") - public PodEntity create( - @QueryParam("xid") String xid, - @QueryParam("display-name") String displayName) { - return null; - } - - @PUT @Path("/pod/{pod-id}") - public PodEntity update( - @PathParam("pod-id") String podId, - @QueryParam("display-name") String displayName) { - return null; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.rest.service.api; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity; +import org.apache.cloudstack.engine.service.api.ProvisioningService; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +@Component +@Service("PodService") +@Produces({"application/json"}) +public class PodRestService { +// @Inject + ProvisioningService _provisioningService; + + @GET @Path("/pod/{pod-id}") + public PodEntity getPod(@PathParam("pod-id") String podId) { + return null; + } + + @POST @Path("/pod/{pod-id}/enable") + public String enable(@PathParam("pod-id") String podId) { + return null; + } + + @POST @Path("/pod/{pod-id}/disable") + public String disable(@PathParam("pod-id") String podId) { + return null; + } + + @POST @Path("/pod/{pod-id}/deactivate") + public String deactivate(@PathParam("pod-id") String podId) { + return null; + } + + @POST @Path("/pod/{pod-id}/reactivate") + public String reactivate(@PathParam("pod-id") String podId) { + return null; + } + + @PUT @Path("/pod/create") + public PodEntity create( + @QueryParam("xid") String xid, + @QueryParam("display-name") String displayName) { + return null; + } + + @PUT @Path("/pod/{pod-id}") + public PodEntity update( + @PathParam("pod-id") String podId, + @QueryParam("display-name") String displayName) { + return null; + } +} diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java index 2124a81261f..f3f7bad1936 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java @@ -1,56 +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. - */ -package org.apache.cloudstack.engine.rest.service.api; - -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -@Component -@Service("VirtualMachineRestService") -@Produces("application/xml") -public class VirtualMachineRestService { - - @GET @Path("/vm/{vmid}") - public VirtualMachineEntity get(@PathParam("vmid") String vmId) { - return null; - } - - @PUT @Path("/vm/create") - public VirtualMachineEntity create( - @QueryParam("xid") String xid, - @QueryParam("hostname") String hostname, - @QueryParam("display-name") String displayName) { - return null; - } - - @GET @Path("/vms") - public List listAll() { - return null; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.rest.service.api; + +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +@Component +@Service("VirtualMachineRestService") +@Produces("application/xml") +public class VirtualMachineRestService { + + @GET @Path("/vm/{vmid}") + public VirtualMachineEntity get(@PathParam("vmid") String vmId) { + return null; + } + + @PUT @Path("/vm/create") + public VirtualMachineEntity create( + @QueryParam("xid") String xid, + @QueryParam("hostname") String hostname, + @QueryParam("display-name") String displayName) { + return null; + } + + @GET @Path("/vms") + public List listAll() { + return null; + } +} diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java index 3e5174b9d90..cb1a0d3dc47 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java @@ -1,76 +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 org.apache.cloudstack.engine.rest.service.api; - -import java.util.List; - -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -@Component -@Service("VolumeRestService") -@Produces("application/json") -public class VolumeRestService { - - @PUT @Path("/vol/create") - public VolumeEntity create( - @QueryParam("xid") String xid, - @QueryParam("display-name") String displayName) { - return null; - } - - @POST @Path("/vol/{volid}/deploy") - public String deploy(@PathParam("volid") String volumeId) { - return null; - } - - @GET @Path("/vols") - public List listAll() { - return null; - } - - @POST @Path("/vol/{volid}/attach-to") - public String attachTo( - @PathParam("volid") String volumeId, - @QueryParam("vmid") String vmId, - @QueryParam("device-order") short device) { - return null; - } - - @DELETE @Path("/vol/{volid}") - public String delete(@PathParam("volid") String volumeId) { - return null; - } - - @POST @Path("/vol/{volid}/detach") - public String detach(@QueryParam("volid") String volumeId) { - return null; - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.rest.service.api; + +import java.util.List; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +@Component +@Service("VolumeRestService") +@Produces("application/json") +public class VolumeRestService { + + @PUT @Path("/vol/create") + public VolumeEntity create( + @QueryParam("xid") String xid, + @QueryParam("display-name") String displayName) { + return null; + } + + @POST @Path("/vol/{volid}/deploy") + public String deploy(@PathParam("volid") String volumeId) { + return null; + } + + @GET @Path("/vols") + public List listAll() { + return null; + } + + @POST @Path("/vol/{volid}/attach-to") + public String attachTo( + @PathParam("volid") String volumeId, + @QueryParam("vmid") String vmId, + @QueryParam("device-order") short device) { + return null; + } + + @DELETE @Path("/vol/{volid}") + public String delete(@PathParam("volid") String volumeId) { + return null; + } + + @POST @Path("/vol/{volid}/detach") + public String detach(@QueryParam("volid") String volumeId) { + return null; + } + +} diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java index 7170f00747d..bd6980e064a 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java @@ -1,87 +1,87 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.rest.service.api; - -import java.util.List; - -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; -import org.apache.cloudstack.engine.service.api.ProvisioningService; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -@Component -@Service("zoneService") -@Produces({"application/json"}) -public class ZoneRestService { -// @Inject - ProvisioningService _provisioningService; - - @GET @Path("/zones") - public List listAll() { - return _provisioningService.listZones(); - } - - @GET @Path("/zone/{zone-id}") - public ZoneEntity get(@PathParam("zone-id") String zoneId) { - return _provisioningService.getZone(zoneId); - } - - @POST @Path("/zone/{zone-id}/enable") - public String enable(String zoneId) { - return null; - } - - @POST @Path("/zone/{zone-id}/disable") - public String disable(@PathParam("zone-id") String zoneId) { - ZoneEntity zoneEntity = _provisioningService.getZone(zoneId); - zoneEntity.disable(); - return null; - } - - @POST @Path("/zone/{zone-id}/deactivate") - public String deactivate(@PathParam("zone-id") String zoneId) { - return null; - } - - @POST @Path("/zone/{zone-id}/activate") - public String reactivate(@PathParam("zone-id") String zoneId) { - return null; - } - - - @PUT @Path("/zone/create") - public ZoneEntity createZone(@QueryParam("xid") String xid, - @QueryParam("display-name") String displayName) { - return null; - } - - @DELETE @Path("/zone/{zone-id}") - public String deleteZone(@QueryParam("zone-id") String xid) { - return null; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.rest.service.api; + +import java.util.List; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; +import org.apache.cloudstack.engine.service.api.ProvisioningService; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +@Component +@Service("zoneService") +@Produces({"application/json"}) +public class ZoneRestService { +// @Inject + ProvisioningService _provisioningService; + + @GET @Path("/zones") + public List listAll() { + return _provisioningService.listZones(); + } + + @GET @Path("/zone/{zone-id}") + public ZoneEntity get(@PathParam("zone-id") String zoneId) { + return _provisioningService.getZone(zoneId); + } + + @POST @Path("/zone/{zone-id}/enable") + public String enable(String zoneId) { + return null; + } + + @POST @Path("/zone/{zone-id}/disable") + public String disable(@PathParam("zone-id") String zoneId) { + ZoneEntity zoneEntity = _provisioningService.getZone(zoneId); + zoneEntity.disable(); + return null; + } + + @POST @Path("/zone/{zone-id}/deactivate") + public String deactivate(@PathParam("zone-id") String zoneId) { + return null; + } + + @POST @Path("/zone/{zone-id}/activate") + public String reactivate(@PathParam("zone-id") String zoneId) { + return null; + } + + + @PUT @Path("/zone/create") + public ZoneEntity createZone(@QueryParam("xid") String xid, + @QueryParam("display-name") String displayName) { + return null; + } + + @DELETE @Path("/zone/{zone-id}") + public String deleteZone(@QueryParam("zone-id") String xid) { + return null; + } +} diff --git a/engine/components-api/src/org/apache/cloudstack/compute/ComputeGuru.java b/engine/components-api/src/org/apache/cloudstack/compute/ComputeGuru.java index 5dbe0c6f931..73aa84c6152 100644 --- a/engine/components-api/src/org/apache/cloudstack/compute/ComputeGuru.java +++ b/engine/components-api/src/org/apache/cloudstack/compute/ComputeGuru.java @@ -1,34 +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 org.apache.cloudstack.compute; - -import com.cloud.vm.VirtualMachineProfile; - -/** - * ComputeGuru understands everything about the hypervisor. - * - */ -public interface ComputeGuru { - String getVersion(); - String getHypervisor(); - void start(VirtualMachineProfile vm); - void stop(VirtualMachineProfile vm); - - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.compute; + +import com.cloud.vm.VirtualMachineProfile; + +/** + * ComputeGuru understands everything about the hypervisor. + * + */ +public interface ComputeGuru { + String getVersion(); + String getHypervisor(); + void start(VirtualMachineProfile vm); + void stop(VirtualMachineProfile vm); + + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java index a36ca3a3aba..82c580fd506 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java @@ -14,32 +14,32 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; - -import com.cloud.deploy.DeploymentPlan; -import com.cloud.deploy.DeploymentPlanner.ExcludeList; -import com.cloud.exception.AgentUnavailableException; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.OperationTimedoutException; -import com.cloud.exception.ResourceUnavailableException; +package org.apache.cloudstack.engine.cloud.entity.api; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; + +import com.cloud.deploy.DeploymentPlan; +import com.cloud.deploy.DeploymentPlanner.ExcludeList; +import com.cloud.exception.AgentUnavailableException; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.OperationTimedoutException; +import com.cloud.exception.ResourceUnavailableException; import com.cloud.vm.VirtualMachineProfile; import java.util.Map; - -public interface VMEntityManager { - - VMEntityVO loadVirtualMachine(String vmId); - - void saveVirtualMachine(VMEntityVO vmInstanceVO); - - String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException; - + +public interface VMEntityManager { + + VMEntityVO loadVirtualMachine(String vmId); + + void saveVirtualMachine(VMEntityVO vmInstanceVO); + + String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException; + void deployVirtualMachine(String reservationId, String caller, Map params) throws InsufficientCapacityException, ResourceUnavailableException; - - boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException; - - boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException; -} + + boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException; + + boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException; +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java index 508b0b9a746..c2ca729c909 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java @@ -14,33 +14,33 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api; - -import java.lang.reflect.Method; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; +package org.apache.cloudstack.engine.cloud.entity.api; + +import java.lang.reflect.Method; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; import org.springframework.stereotype.Component; - -import com.cloud.deploy.DeploymentPlan; -import com.cloud.deploy.DeploymentPlanner.ExcludeList; -import com.cloud.exception.AgentUnavailableException; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.OperationTimedoutException; -import com.cloud.exception.ResourceUnavailableException; + +import com.cloud.deploy.DeploymentPlan; +import com.cloud.deploy.DeploymentPlanner.ExcludeList; +import com.cloud.exception.AgentUnavailableException; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.OperationTimedoutException; +import com.cloud.exception.ResourceUnavailableException; import com.cloud.vm.VirtualMachineProfile; @Component -public class VirtualMachineEntityImpl implements VirtualMachineEntity { - - @Inject private VMEntityManager manager; - - private VMEntityVO vmEntityVO; +public class VirtualMachineEntityImpl implements VirtualMachineEntity { + + @Inject private VMEntityManager manager; + + private VMEntityVO vmEntityVO; public VirtualMachineEntityImpl() { } @@ -61,204 +61,204 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity { manager.saveVirtualMachine(vmEntityVO); } - - public VirtualMachineEntityImpl(String vmId, VMEntityManager manager) { - this.manager = manager; - this.vmEntityVO = this.manager.loadVirtualMachine(vmId); - } - - public VirtualMachineEntityImpl(String vmId, String owner, String hostName, String displayName, int cpu, int speed, long memory, List computeTags, List rootDiskTags, List networks, VMEntityManager manager) { - this(vmId, manager); - this.vmEntityVO.setOwner(owner); - this.vmEntityVO.setHostname(hostName); - this.vmEntityVO.setDisplayname(displayName); - this.vmEntityVO.setSpeed(speed); - this.vmEntityVO.setComputeTags(computeTags); - this.vmEntityVO.setRootDiskTags(rootDiskTags); - this.vmEntityVO.setNetworkIds(networks); - - manager.saveVirtualMachine(vmEntityVO); - } - - @Override - public String getUuid() { - return vmEntityVO.getUuid(); - } - - @Override - public long getId() { - return vmEntityVO.getId(); - } - - @Override - public String getCurrentState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getDesiredState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Date getCreatedTime() { - return vmEntityVO.getCreated(); - } - - @Override - public Date getLastUpdatedTime() { - return vmEntityVO.getUpdateTime(); - } - - @Override - public String getOwner() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getDetails() { - return vmEntityVO.getDetails(); - } - - @Override - public void addDetail(String name, String value) { - vmEntityVO.setDetail(name, value); - } - - @Override - public void delDetail(String name, String value) { - // TODO Auto-generated method stub - } - - @Override - public void updateDetail(String name, String value) { - // TODO Auto-generated method stub - } - - @Override - public List getApplicableActions() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List listVolumeIds() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List listVolumes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List listNicUuids() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List listNics() { - // TODO Auto-generated method stub - return null; - } - - @Override - public TemplateEntity getTemplate() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List listTags() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void addTag() { - // TODO Auto-generated method stub - - } - - @Override - public void delTag() { - // TODO Auto-generated method stub - - } - - @Override - public String reserve(String plannerToUse, DeploymentPlan plan, - ExcludeList exclude, String caller) throws InsufficientCapacityException, ResourceUnavailableException { - return manager.reserveVirtualMachine(this.vmEntityVO, plannerToUse, plan, exclude); - } - - @Override - public void migrateTo(String reservationId, String caller) { - // TODO Auto-generated method stub - - } - - @Override + + public VirtualMachineEntityImpl(String vmId, VMEntityManager manager) { + this.manager = manager; + this.vmEntityVO = this.manager.loadVirtualMachine(vmId); + } + + public VirtualMachineEntityImpl(String vmId, String owner, String hostName, String displayName, int cpu, int speed, long memory, List computeTags, List rootDiskTags, List networks, VMEntityManager manager) { + this(vmId, manager); + this.vmEntityVO.setOwner(owner); + this.vmEntityVO.setHostname(hostName); + this.vmEntityVO.setDisplayname(displayName); + this.vmEntityVO.setSpeed(speed); + this.vmEntityVO.setComputeTags(computeTags); + this.vmEntityVO.setRootDiskTags(rootDiskTags); + this.vmEntityVO.setNetworkIds(networks); + + manager.saveVirtualMachine(vmEntityVO); + } + + @Override + public String getUuid() { + return vmEntityVO.getUuid(); + } + + @Override + public long getId() { + return vmEntityVO.getId(); + } + + @Override + public String getCurrentState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getDesiredState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getCreatedTime() { + return vmEntityVO.getCreated(); + } + + @Override + public Date getLastUpdatedTime() { + return vmEntityVO.getUpdateTime(); + } + + @Override + public String getOwner() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getDetails() { + return vmEntityVO.getDetails(); + } + + @Override + public void addDetail(String name, String value) { + vmEntityVO.setDetail(name, value); + } + + @Override + public void delDetail(String name, String value) { + // TODO Auto-generated method stub + } + + @Override + public void updateDetail(String name, String value) { + // TODO Auto-generated method stub + } + + @Override + public List getApplicableActions() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List listVolumeIds() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List listVolumes() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List listNicUuids() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List listNics() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TemplateEntity getTemplate() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List listTags() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void addTag() { + // TODO Auto-generated method stub + + } + + @Override + public void delTag() { + // TODO Auto-generated method stub + + } + + @Override + public String reserve(String plannerToUse, DeploymentPlan plan, + ExcludeList exclude, String caller) throws InsufficientCapacityException, ResourceUnavailableException { + return manager.reserveVirtualMachine(this.vmEntityVO, plannerToUse, plan, exclude); + } + + @Override + public void migrateTo(String reservationId, String caller) { + // TODO Auto-generated method stub + + } + + @Override public void deploy(String reservationId, String caller, Map params) throws InsufficientCapacityException, ResourceUnavailableException{ manager.deployVirtualMachine(reservationId, caller, params); - } - - @Override - public boolean stop(String caller) throws ResourceUnavailableException{ - return manager.stopvirtualmachine(this.vmEntityVO, caller); - } - - @Override - public void cleanup() { - // TODO Auto-generated method stub - - } - - @Override - public boolean destroy(String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException { - return manager.destroyVirtualMachine(this.vmEntityVO, caller); - } - - @Override - public VirtualMachineEntity duplicate(String externalId) { - // TODO Auto-generated method stub - return null; - } - - @Override - public SnapshotEntity takeSnapshotOf() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void attach(VolumeEntity volume, short deviceId) { - // TODO Auto-generated method stub - - } - - @Override - public void detach(VolumeEntity volume) { - // TODO Auto-generated method stub - - } - - @Override - public void connectTo(NetworkEntity network, short nicId) { - // TODO Auto-generated method stub - - } - - @Override - public void disconnectFrom(NetworkEntity netowrk, short nicId) { - // TODO Auto-generated method stub - - } - -} + } + + @Override + public boolean stop(String caller) throws ResourceUnavailableException{ + return manager.stopvirtualmachine(this.vmEntityVO, caller); + } + + @Override + public void cleanup() { + // TODO Auto-generated method stub + + } + + @Override + public boolean destroy(String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException { + return manager.destroyVirtualMachine(this.vmEntityVO, caller); + } + + @Override + public VirtualMachineEntity duplicate(String externalId) { + // TODO Auto-generated method stub + return null; + } + + @Override + public SnapshotEntity takeSnapshotOf() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void attach(VolumeEntity volume, short deviceId) { + // TODO Auto-generated method stub + + } + + @Override + public void detach(VolumeEntity volume) { + // TODO Auto-generated method stub + + } + + @Override + public void connectTo(NetworkEntity network, short nicId) { + // TODO Auto-generated method stub + + } + + @Override + public void disconnectFrom(NetworkEntity netowrk, short nicId) { + // TODO Auto-generated method stub + + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java index c367ee95483..e4fc2283349 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java @@ -14,54 +14,54 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -import org.apache.cloudstack.api.InternalIdentity; - -@Entity -@Table(name = "vm_compute_tags") -public class VMComputeTagVO implements InternalIdentity{ - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private long id; - - @Column(name = "vm_id") - private long vmId; - - @Column(name = "compute_tag") - private String computeTag; - - /** - * There should never be a public constructor for this class. Since it's - * only here to define the table for the DAO class. - */ - protected VMComputeTagVO() { - } - - public VMComputeTagVO(long vmId, String tag) { - this.vmId = vmId; - this.computeTag = tag; - } - - public long getId() { - return id; - } - - public long getVmId() { - return vmId; - } - - public String getComputeTag() { - return computeTag; - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name = "vm_compute_tags") +public class VMComputeTagVO implements InternalIdentity{ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "vm_id") + private long vmId; + + @Column(name = "compute_tag") + private String computeTag; + + /** + * There should never be a public constructor for this class. Since it's + * only here to define the table for the DAO class. + */ + protected VMComputeTagVO() { + } + + public VMComputeTagVO(long vmId, String tag) { + this.vmId = vmId; + this.computeTag = tag; + } + + public long getId() { + return id; + } + + public long getVmId() { + return vmId; + } + + public String getComputeTag() { + return computeTag; + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java index 4fe6718e33a..4748215e3c6 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java @@ -574,4 +574,4 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject poolId - @Transient - Map volumeReservationMap; - - /** - * There should never be a public constructor for this class. Since it's - * only here to define the table for the DAO class. - */ - protected VMReservationVO() { - } - - public VMReservationVO(long vmId, long dataCenterId, long podId, long clusterId, long hostId) { - this.vmId = vmId; - this.dataCenterId = dataCenterId; - this.podId = podId; - this.clusterId = clusterId; - this.hostId = hostId; - this.uuid = UUID.randomUUID().toString(); - } - - - public long getId() { - return id; - } - - public long getVmId() { - return vmId; - } - - @Override - public String getUuid() { - return uuid; - } - - public long getDataCenterId() { - return dataCenterId; - } - - public Long getPodId() { - return podId; - } - - public Long getClusterId() { - return clusterId; - } - - public Long getHostId() { - return hostId; - } - - public Map getVolumeReservation(){ - return volumeReservationMap; - } - - public void setVolumeReservation(Map volumeReservationMap){ - this.volumeReservationMap = volumeReservationMap; - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db; + +import java.util.Date; +import java.util.Map; +import java.util.UUID; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +import com.cloud.utils.db.GenericDao; + +@Entity +@Table(name = "vm_reservation") +public class VMReservationVO implements Identity, InternalIdentity{ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "vm_id") + private long vmId; + + @Column(name="uuid") + private String uuid; + + @Column(name="data_center_id") + private long dataCenterId; + + @Column(name="pod_id") + private long podId; + + @Column(name="cluster_id") + private long clusterId; + + @Column(name="host_id") + private long hostId; + + @Column(name=GenericDao.CREATED_COLUMN) + private Date created; + + @Column(name=GenericDao.REMOVED_COLUMN) + private Date removed; + + // VolumeId -> poolId + @Transient + Map volumeReservationMap; + + /** + * There should never be a public constructor for this class. Since it's + * only here to define the table for the DAO class. + */ + protected VMReservationVO() { + } + + public VMReservationVO(long vmId, long dataCenterId, long podId, long clusterId, long hostId) { + this.vmId = vmId; + this.dataCenterId = dataCenterId; + this.podId = podId; + this.clusterId = clusterId; + this.hostId = hostId; + this.uuid = UUID.randomUUID().toString(); + } + + + public long getId() { + return id; + } + + public long getVmId() { + return vmId; + } + + @Override + public String getUuid() { + return uuid; + } + + public long getDataCenterId() { + return dataCenterId; + } + + public Long getPodId() { + return podId; + } + + public Long getClusterId() { + return clusterId; + } + + public Long getHostId() { + return hostId; + } + + public Map getVolumeReservation(){ + return volumeReservationMap; + } + + public void setVolumeReservation(Map volumeReservationMap){ + this.volumeReservationMap = volumeReservationMap; + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java index a1cca3f9040..3c09e930693 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java @@ -14,54 +14,54 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -import org.apache.cloudstack.api.InternalIdentity; - -@Entity -@Table(name = "vm_root_disk_tags") -public class VMRootDiskTagVO implements InternalIdentity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private long id; - - @Column(name = "vm_id") - private long vmId; - - @Column(name = "root_disk_tag") - private String rootDiskTag; - - /** - * There should never be a public constructor for this class. Since it's - * only here to define the table for the DAO class. - */ - protected VMRootDiskTagVO() { - } - - public VMRootDiskTagVO(long vmId, String rootDiskTag) { - this.vmId = vmId; - this.rootDiskTag = rootDiskTag; - } - - public long getId() { - return id; - } - - public long getVmId() { - return vmId; - } - - public String getRootDiskTag() { - return rootDiskTag; - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name = "vm_root_disk_tags") +public class VMRootDiskTagVO implements InternalIdentity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "vm_id") + private long vmId; + + @Column(name = "root_disk_tag") + private String rootDiskTag; + + /** + * There should never be a public constructor for this class. Since it's + * only here to define the table for the DAO class. + */ + protected VMRootDiskTagVO() { + } + + public VMRootDiskTagVO(long vmId, String rootDiskTag) { + this.vmId = vmId; + this.rootDiskTag = rootDiskTag; + } + + public long getId() { + return id; + } + + public long getVmId() { + return vmId; + } + + public String getRootDiskTag() { + return rootDiskTag; + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java index cbad9aba568..f064623f887 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java @@ -14,87 +14,87 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db; - -import java.util.Date; -import java.util.Map; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; - -import org.apache.cloudstack.api.Identity; -import org.apache.cloudstack.api.InternalIdentity; - -import com.cloud.utils.db.GenericDao; - -@Entity -@Table(name = "volume_reservation") -public class VolumeReservationVO implements InternalIdentity{ - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private long id; - - @Column(name = "vm_reservation_id") - private Long vmReservationId; - - @Column(name = "vm_id") - private long vmId; - - @Column(name="volume_id") - private long volumeId; - - @Column(name="pool_id") - private long poolId; - - // VolumeId -> poolId - @Transient - Map volumeReservationMap; - - /** - * There should never be a public constructor for this class. Since it's - * only here to define the table for the DAO class. - */ - protected VolumeReservationVO() { - } - - public VolumeReservationVO(long vmId, long volumeId, long poolId, Long vmReservationId) { - this.vmId = vmId; - this.volumeId = volumeId; - this.poolId = poolId; - this.vmReservationId = vmReservationId; - } - - - public long getId() { - return id; - } - - public long getVmId() { - return vmId; - } - - public Long geVmReservationId() { - return vmReservationId; - } - - public long getVolumeId() { - return volumeId; - } - - public Long getPoolId() { - return poolId; - } - - - public Map getVolumeReservation(){ - return volumeReservationMap; - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db; + +import java.util.Date; +import java.util.Map; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +import com.cloud.utils.db.GenericDao; + +@Entity +@Table(name = "volume_reservation") +public class VolumeReservationVO implements InternalIdentity{ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "vm_reservation_id") + private Long vmReservationId; + + @Column(name = "vm_id") + private long vmId; + + @Column(name="volume_id") + private long volumeId; + + @Column(name="pool_id") + private long poolId; + + // VolumeId -> poolId + @Transient + Map volumeReservationMap; + + /** + * There should never be a public constructor for this class. Since it's + * only here to define the table for the DAO class. + */ + protected VolumeReservationVO() { + } + + public VolumeReservationVO(long vmId, long volumeId, long poolId, Long vmReservationId) { + this.vmId = vmId; + this.volumeId = volumeId; + this.poolId = poolId; + this.vmReservationId = vmReservationId; + } + + + public long getId() { + return id; + } + + public long getVmId() { + return vmId; + } + + public Long geVmReservationId() { + return vmReservationId; + } + + public long getVolumeId() { + return volumeId; + } + + public Long getPoolId() { + return poolId; + } + + + public Map getVolumeReservation(){ + return volumeReservationMap; + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java index d01bf2f12d3..d8178d4a8f4 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java @@ -14,18 +14,18 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - -import java.util.List; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO; - -import com.cloud.utils.db.GenericDao; - -public interface VMComputeTagDao extends GenericDao{ - - void persist(long vmId, List computeTags); - - List getComputeTags(long vmId); - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + +import java.util.List; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO; + +import com.cloud.utils.db.GenericDao; + +public interface VMComputeTagDao extends GenericDao{ + + void persist(long vmId, List computeTags); + + List getComputeTags(long vmId); + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java index 6037ad4ec26..6f70b353176 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java @@ -14,76 +14,76 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.PostConstruct; -import javax.ejb.Local; - - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO; - -import org.springframework.stereotype.Component; - -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.Transaction; - -@Component -@Local(value = { VMComputeTagDao.class }) -public class VMComputeTagDaoImpl extends GenericDaoBase implements VMComputeTagDao { - - protected SearchBuilder VmIdSearch; - - public VMComputeTagDaoImpl() { - } - - @PostConstruct - public void init() { - VmIdSearch = createSearchBuilder(); - VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); - VmIdSearch.done(); - - } - - @Override - public void persist(long vmId, List computeTags) { - Transaction txn = Transaction.currentTxn(); - - txn.start(); - SearchCriteria sc = VmIdSearch.create(); - sc.setParameters("vmId", vmId); - expunge(sc); - - for (String tag : computeTags) { - if(tag != null){ - tag = tag.trim(); - if(tag.length() > 0) { - VMComputeTagVO vo = new VMComputeTagVO(vmId, tag); - persist(vo); - } - } - } - txn.commit(); - } - - @Override - public List getComputeTags(long vmId) { - - SearchCriteria sc = VmIdSearch.create(); - sc.setParameters("vmId", vmId); - - List results = search(sc, null); - List computeTags = new ArrayList(results.size()); - for (VMComputeTagVO result : results) { - computeTags.add(result.getComputeTag()); - } - - return computeTags; - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.ejb.Local; + + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO; + +import org.springframework.stereotype.Component; + +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; + +@Component +@Local(value = { VMComputeTagDao.class }) +public class VMComputeTagDaoImpl extends GenericDaoBase implements VMComputeTagDao { + + protected SearchBuilder VmIdSearch; + + public VMComputeTagDaoImpl() { + } + + @PostConstruct + public void init() { + VmIdSearch = createSearchBuilder(); + VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); + VmIdSearch.done(); + + } + + @Override + public void persist(long vmId, List computeTags) { + Transaction txn = Transaction.currentTxn(); + + txn.start(); + SearchCriteria sc = VmIdSearch.create(); + sc.setParameters("vmId", vmId); + expunge(sc); + + for (String tag : computeTags) { + if(tag != null){ + tag = tag.trim(); + if(tag.length() > 0) { + VMComputeTagVO vo = new VMComputeTagVO(vmId, tag); + persist(vo); + } + } + } + txn.commit(); + } + + @Override + public List getComputeTags(long vmId) { + + SearchCriteria sc = VmIdSearch.create(); + sc.setParameters("vmId", vmId); + + List results = search(sc, null); + List computeTags = new ArrayList(results.size()); + for (VMComputeTagVO result : results) { + computeTags.add(result.getComputeTag()); + } + + return computeTags; + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java index baa0920162b..59c41c298ac 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java @@ -14,18 +14,18 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - -import java.util.List; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO; - -import com.cloud.utils.db.GenericDao; - -public interface VMNetworkMapDao extends GenericDao{ - - void persist(long vmId, List networks); - - List getNetworks(long vmId); - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + +import java.util.List; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO; + +import com.cloud.utils.db.GenericDao; + +public interface VMNetworkMapDao extends GenericDao{ + + void persist(long vmId, List networks); + + List getNetworks(long vmId); + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java index 378f16d519f..0f2c4ccb77e 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java @@ -14,72 +14,72 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - - -import java.util.ArrayList; -import java.util.List; -import javax.annotation.PostConstruct; -import javax.ejb.Local; -import javax.inject.Inject; -import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO; -import org.springframework.stereotype.Component; -import com.cloud.network.dao.NetworkDao; -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.Transaction; - -@Component -@Local(value = { VMNetworkMapDao.class }) -public class VMNetworkMapDaoImpl extends GenericDaoBase implements VMNetworkMapDao { - - protected SearchBuilder VmIdSearch; - - @Inject - protected NetworkDao _networkDao; - - public VMNetworkMapDaoImpl() { - } - - @PostConstruct - public void init() { - VmIdSearch = createSearchBuilder(); - VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); - VmIdSearch.done(); - - } - - @Override - public void persist(long vmId, List networks) { - Transaction txn = Transaction.currentTxn(); - - txn.start(); - SearchCriteria sc = VmIdSearch.create(); - sc.setParameters("vmId", vmId); - expunge(sc); - - for (Long networkId : networks) { - VMNetworkMapVO vo = new VMNetworkMapVO(vmId, networkId); - persist(vo); - } - - txn.commit(); - } - - @Override - public List getNetworks(long vmId) { - - SearchCriteria sc = VmIdSearch.create(); - sc.setParameters("vmId", vmId); - - List results = search(sc, null); - List networks = new ArrayList(results.size()); - for (VMNetworkMapVO result : results) { - networks.add(result.getNetworkId()); - } - - return networks; - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.ejb.Local; +import javax.inject.Inject; +import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO; +import org.springframework.stereotype.Component; +import com.cloud.network.dao.NetworkDao; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; + +@Component +@Local(value = { VMNetworkMapDao.class }) +public class VMNetworkMapDaoImpl extends GenericDaoBase implements VMNetworkMapDao { + + protected SearchBuilder VmIdSearch; + + @Inject + protected NetworkDao _networkDao; + + public VMNetworkMapDaoImpl() { + } + + @PostConstruct + public void init() { + VmIdSearch = createSearchBuilder(); + VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); + VmIdSearch.done(); + + } + + @Override + public void persist(long vmId, List networks) { + Transaction txn = Transaction.currentTxn(); + + txn.start(); + SearchCriteria sc = VmIdSearch.create(); + sc.setParameters("vmId", vmId); + expunge(sc); + + for (Long networkId : networks) { + VMNetworkMapVO vo = new VMNetworkMapVO(vmId, networkId); + persist(vo); + } + + txn.commit(); + } + + @Override + public List getNetworks(long vmId) { + + SearchCriteria sc = VmIdSearch.create(); + sc.setParameters("vmId", vmId); + + List results = search(sc, null); + List networks = new ArrayList(results.size()); + for (VMNetworkMapVO result : results) { + networks.add(result.getNetworkId()); + } + + return networks; + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java index a312578a4ed..721a8c48326 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java @@ -14,21 +14,21 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - - -import java.util.Map; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; - -import com.cloud.utils.db.GenericDao; - -public interface VMReservationDao extends GenericDao{ - - VMReservationVO findByVmId(long vmId); - - void loadVolumeReservation(VMReservationVO reservation); - - VMReservationVO findByReservationId(String reservationId); - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + + +import java.util.Map; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; + +import com.cloud.utils.db.GenericDao; + +public interface VMReservationDao extends GenericDao{ + + VMReservationVO findByVmId(long vmId); + + void loadVolumeReservation(VMReservationVO reservation); + + VMReservationVO findByReservationId(String reservationId); + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java index dc346cc2423..73b4dd2194c 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java @@ -14,98 +14,98 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.ejb.Local; -import javax.inject.Inject; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; -import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; -import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO; -import org.springframework.stereotype.Component; - -import com.cloud.host.dao.HostTagsDaoImpl; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.Transaction; - -@Component -@Local(value = { VMReservationDao.class }) -public class VMReservationDaoImpl extends GenericDaoBase implements VMReservationDao { - - protected SearchBuilder VmIdSearch; - - @Inject protected VolumeReservationDao _volumeReservationDao; - - public VMReservationDaoImpl() { - } - - @PostConstruct - public void init() { - VmIdSearch = createSearchBuilder(); - VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); - VmIdSearch.done(); - } - - @Override - public VMReservationVO findByVmId(long vmId) { - SearchCriteria sc = VmIdSearch.create("vmId", vmId); - VMReservationVO vmRes = findOneBy(sc); - loadVolumeReservation(vmRes); - return vmRes; - } - - - @Override - public void loadVolumeReservation(VMReservationVO reservation){ - if(reservation != null){ - List volumeResList = _volumeReservationDao.listVolumeReservation(reservation.getId()); - Map volumeReservationMap = new HashMap(); - - for(VolumeReservationVO res : volumeResList){ - volumeReservationMap.put(res.getVolumeId(), res.getPoolId()); - } - reservation.setVolumeReservation(volumeReservationMap); - } - } - - @Override - @DB - public VMReservationVO persist(VMReservationVO reservation) { - Transaction txn = Transaction.currentTxn(); - txn.start(); - - VMReservationVO dbVO = super.persist(reservation); - - saveVolumeReservation(reservation); - loadVolumeReservation(dbVO); - - txn.commit(); - - return dbVO; - } - - private void saveVolumeReservation(VMReservationVO reservation) { - if(reservation.getVolumeReservation() != null){ - for(Long volumeId : reservation.getVolumeReservation().keySet()){ - VolumeReservationVO volumeReservation = new VolumeReservationVO(reservation.getVmId(), volumeId, reservation.getVolumeReservation().get(volumeId), reservation.getId()); - _volumeReservationDao.persist(volumeReservation); - } - } - } - - @Override - public VMReservationVO findByReservationId(String reservationId) { - VMReservationVO vmRes = super.findByUuid(reservationId); - loadVolumeReservation(vmRes); - return vmRes; - } -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; +import javax.ejb.Local; +import javax.inject.Inject; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; +import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; +import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO; +import org.springframework.stereotype.Component; + +import com.cloud.host.dao.HostTagsDaoImpl; +import com.cloud.utils.db.DB; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; + +@Component +@Local(value = { VMReservationDao.class }) +public class VMReservationDaoImpl extends GenericDaoBase implements VMReservationDao { + + protected SearchBuilder VmIdSearch; + + @Inject protected VolumeReservationDao _volumeReservationDao; + + public VMReservationDaoImpl() { + } + + @PostConstruct + public void init() { + VmIdSearch = createSearchBuilder(); + VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); + VmIdSearch.done(); + } + + @Override + public VMReservationVO findByVmId(long vmId) { + SearchCriteria sc = VmIdSearch.create("vmId", vmId); + VMReservationVO vmRes = findOneBy(sc); + loadVolumeReservation(vmRes); + return vmRes; + } + + + @Override + public void loadVolumeReservation(VMReservationVO reservation){ + if(reservation != null){ + List volumeResList = _volumeReservationDao.listVolumeReservation(reservation.getId()); + Map volumeReservationMap = new HashMap(); + + for(VolumeReservationVO res : volumeResList){ + volumeReservationMap.put(res.getVolumeId(), res.getPoolId()); + } + reservation.setVolumeReservation(volumeReservationMap); + } + } + + @Override + @DB + public VMReservationVO persist(VMReservationVO reservation) { + Transaction txn = Transaction.currentTxn(); + txn.start(); + + VMReservationVO dbVO = super.persist(reservation); + + saveVolumeReservation(reservation); + loadVolumeReservation(dbVO); + + txn.commit(); + + return dbVO; + } + + private void saveVolumeReservation(VMReservationVO reservation) { + if(reservation.getVolumeReservation() != null){ + for(Long volumeId : reservation.getVolumeReservation().keySet()){ + VolumeReservationVO volumeReservation = new VolumeReservationVO(reservation.getVmId(), volumeId, reservation.getVolumeReservation().get(volumeId), reservation.getId()); + _volumeReservationDao.persist(volumeReservation); + } + } + } + + @Override + public VMReservationVO findByReservationId(String reservationId) { + VMReservationVO vmRes = super.findByUuid(reservationId); + loadVolumeReservation(vmRes); + return vmRes; + } +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java index 5a4c2be07d4..dc00880d79d 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java @@ -14,18 +14,18 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - -import java.util.List; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO; - -import com.cloud.utils.db.GenericDao; - -public interface VMRootDiskTagDao extends GenericDao{ - - void persist(long vmId, List diskTags); - - List getRootDiskTags(long vmId); - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + +import java.util.List; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO; + +import com.cloud.utils.db.GenericDao; + +public interface VMRootDiskTagDao extends GenericDao{ + + void persist(long vmId, List diskTags); + + List getRootDiskTags(long vmId); + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java index 60ea5479398..be194bbfcaa 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java @@ -14,75 +14,75 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.PostConstruct; -import javax.ejb.Local; - - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO; - -import org.springframework.stereotype.Component; - -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.Transaction; - -@Component -@Local(value = { VMRootDiskTagDao.class }) -public class VMRootDiskTagDaoImpl extends GenericDaoBase implements VMRootDiskTagDao { - - protected SearchBuilder VmIdSearch; - - public VMRootDiskTagDaoImpl() { - } - - @PostConstruct - public void init() { - VmIdSearch = createSearchBuilder(); - VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); - VmIdSearch.done(); - - } - - @Override - public void persist(long vmId, List rootDiskTags) { - Transaction txn = Transaction.currentTxn(); - - txn.start(); - SearchCriteria sc = VmIdSearch.create(); - sc.setParameters("vmId", vmId); - expunge(sc); - - for (String tag : rootDiskTags) { - if(tag != null){ - tag = tag.trim(); - if(tag.length() > 0) { - VMRootDiskTagVO vo = new VMRootDiskTagVO(vmId, tag); - persist(vo); - } - } - } - txn.commit(); - } - - - @Override - public List getRootDiskTags(long vmId) { - SearchCriteria sc = VmIdSearch.create(); - sc.setParameters("vmId", vmId); - - List results = search(sc, null); - List computeTags = new ArrayList(results.size()); - for (VMRootDiskTagVO result : results) { - computeTags.add(result.getRootDiskTag()); - } - return computeTags; - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.ejb.Local; + + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO; + +import org.springframework.stereotype.Component; + +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; + +@Component +@Local(value = { VMRootDiskTagDao.class }) +public class VMRootDiskTagDaoImpl extends GenericDaoBase implements VMRootDiskTagDao { + + protected SearchBuilder VmIdSearch; + + public VMRootDiskTagDaoImpl() { + } + + @PostConstruct + public void init() { + VmIdSearch = createSearchBuilder(); + VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); + VmIdSearch.done(); + + } + + @Override + public void persist(long vmId, List rootDiskTags) { + Transaction txn = Transaction.currentTxn(); + + txn.start(); + SearchCriteria sc = VmIdSearch.create(); + sc.setParameters("vmId", vmId); + expunge(sc); + + for (String tag : rootDiskTags) { + if(tag != null){ + tag = tag.trim(); + if(tag.length() > 0) { + VMRootDiskTagVO vo = new VMRootDiskTagVO(vmId, tag); + persist(vo); + } + } + } + txn.commit(); + } + + + @Override + public List getRootDiskTags(long vmId) { + SearchCriteria sc = VmIdSearch.create(); + sc.setParameters("vmId", vmId); + + List results = search(sc, null); + List computeTags = new ArrayList(results.size()); + for (VMRootDiskTagVO result : results) { + computeTags.add(result.getRootDiskTag()); + } + return computeTags; + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java index d6a9fe28146..fd709b0db0a 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java @@ -14,18 +14,18 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - -import java.util.List; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO; - -import com.cloud.utils.db.GenericDao; - -public interface VolumeReservationDao extends GenericDao{ - - VolumeReservationVO findByVmId(long vmId); - - List listVolumeReservation(long vmReservationId); - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + +import java.util.List; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO; + +import com.cloud.utils.db.GenericDao; + +public interface VolumeReservationDao extends GenericDao{ + + VolumeReservationVO findByVmId(long vmId); + + List listVolumeReservation(long vmReservationId); + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java index 4b1b1e667d6..26bc65f35c1 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java @@ -14,55 +14,55 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.cloud.entity.api.db.dao; - - -import java.util.List; - -import javax.annotation.PostConstruct; -import javax.ejb.Local; -import javax.inject.Inject; - -import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; -import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO; -import org.springframework.stereotype.Component; - -import com.cloud.host.dao.HostTagsDaoImpl; -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; - -@Component -@Local(value = { VolumeReservationDao.class }) -public class VolumeReservationDaoImpl extends GenericDaoBase implements VolumeReservationDao { - - protected SearchBuilder VmIdSearch; - protected SearchBuilder VmReservationIdSearch; - - public VolumeReservationDaoImpl() { - } - - @PostConstruct - public void init() { - VmIdSearch = createSearchBuilder(); - VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); - VmIdSearch.done(); - - VmReservationIdSearch = createSearchBuilder(); - VmReservationIdSearch.and("vmReservationId", VmReservationIdSearch.entity().geVmReservationId(), SearchCriteria.Op.EQ); - VmReservationIdSearch.done(); - } - - @Override - public VolumeReservationVO findByVmId(long vmId) { - SearchCriteria sc = VmIdSearch.create("vmId", vmId); - return findOneBy(sc); - } - - @Override - public List listVolumeReservation(long vmReservationId) { - SearchCriteria sc = VmReservationIdSearch.create("vmReservationId", vmReservationId); - return listBy(sc); - } - -} +package org.apache.cloudstack.engine.cloud.entity.api.db.dao; + + +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.ejb.Local; +import javax.inject.Inject; + +import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; +import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO; +import org.springframework.stereotype.Component; + +import com.cloud.host.dao.HostTagsDaoImpl; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +@Component +@Local(value = { VolumeReservationDao.class }) +public class VolumeReservationDaoImpl extends GenericDaoBase implements VolumeReservationDao { + + protected SearchBuilder VmIdSearch; + protected SearchBuilder VmReservationIdSearch; + + public VolumeReservationDaoImpl() { + } + + @PostConstruct + public void init() { + VmIdSearch = createSearchBuilder(); + VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); + VmIdSearch.done(); + + VmReservationIdSearch = createSearchBuilder(); + VmReservationIdSearch.and("vmReservationId", VmReservationIdSearch.entity().geVmReservationId(), SearchCriteria.Op.EQ); + VmReservationIdSearch.done(); + } + + @Override + public VolumeReservationVO findByVmId(long vmId) { + SearchCriteria sc = VmIdSearch.create("vmId", vmId); + return findOneBy(sc); + } + + @Override + public List listVolumeReservation(long vmReservationId) { + SearchCriteria sc = VmReservationIdSearch.create("vmReservationId", vmReservationId); + return listBy(sc); + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java index 3471b7ae376..46dd21d28eb 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java @@ -14,196 +14,196 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. - -package org.apache.cloudstack.engine.datacenter.entity.api; - -import java.lang.reflect.Method; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; -import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.org.Cluster.ClusterType; -import com.cloud.org.Grouping.AllocationState; -import com.cloud.org.Managed.ManagedState; -import com.cloud.utils.fsm.NoTransitionException; - - -public class ClusterEntityImpl implements ClusterEntity { - - - private DataCenterResourceManager manager; - - private EngineClusterVO clusterVO; - - - public ClusterEntityImpl(String clusterId, DataCenterResourceManager manager) { - this.manager = manager; - this.clusterVO = this.manager.loadCluster(clusterId); - } - - @Override - public boolean enable() { - try { - manager.changeState(this, Event.EnableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean disable() { - try { - manager.changeState(this, Event.DisableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean deactivate() { - try { - manager.changeState(this, Event.DeactivateRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - - @Override - public boolean reactivate() { - try { - manager.changeState(this, Event.ActivatedRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - - @Override - public State getState() { - return clusterVO.getState(); - } - - @Override - public void persist() { - manager.saveCluster(clusterVO); - } - - @Override - public String getUuid() { - return clusterVO.getUuid(); - } - - @Override - public long getId() { - return clusterVO.getId(); - } - - @Override - public String getCurrentState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getDesiredState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Date getCreatedTime() { - return clusterVO.getCreated(); - } - - @Override - public Date getLastUpdatedTime() { - return clusterVO.getLastUpdated(); - } - - @Override - public String getOwner() { - return clusterVO.getOwner(); - } - - @Override - public Map getDetails() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void addDetail(String name, String value) { - // TODO Auto-generated method stub - - } - - @Override - public void delDetail(String name, String value) { - // TODO Auto-generated method stub - - } - - @Override - public void updateDetail(String name, String value) { - // TODO Auto-generated method stub - - } - - @Override - public List getApplicableActions() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getName() { - return clusterVO.getName(); - } - - @Override - public long getDataCenterId() { - return clusterVO.getDataCenterId(); - } - - @Override - public long getPodId() { - return clusterVO.getPodId(); - } - - @Override - public HypervisorType getHypervisorType() { - return clusterVO.getHypervisorType(); - } - - @Override - public ClusterType getClusterType() { - return clusterVO.getClusterType(); - } - - @Override - public AllocationState getAllocationState() { - return clusterVO.getAllocationState(); - } - - @Override - public ManagedState getManagedState() { - return clusterVO.getManagedState(); - } - - public void setOwner(String owner) { - clusterVO.setOwner(owner); - } - - public void setName(String name) { - clusterVO.setName(name); - } - -} + +package org.apache.cloudstack.engine.datacenter.entity.api; + +import java.lang.reflect.Method; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.org.Cluster.ClusterType; +import com.cloud.org.Grouping.AllocationState; +import com.cloud.org.Managed.ManagedState; +import com.cloud.utils.fsm.NoTransitionException; + + +public class ClusterEntityImpl implements ClusterEntity { + + + private DataCenterResourceManager manager; + + private EngineClusterVO clusterVO; + + + public ClusterEntityImpl(String clusterId, DataCenterResourceManager manager) { + this.manager = manager; + this.clusterVO = this.manager.loadCluster(clusterId); + } + + @Override + public boolean enable() { + try { + manager.changeState(this, Event.EnableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean disable() { + try { + manager.changeState(this, Event.DisableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean deactivate() { + try { + manager.changeState(this, Event.DeactivateRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + + @Override + public boolean reactivate() { + try { + manager.changeState(this, Event.ActivatedRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + + @Override + public State getState() { + return clusterVO.getState(); + } + + @Override + public void persist() { + manager.saveCluster(clusterVO); + } + + @Override + public String getUuid() { + return clusterVO.getUuid(); + } + + @Override + public long getId() { + return clusterVO.getId(); + } + + @Override + public String getCurrentState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getDesiredState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getCreatedTime() { + return clusterVO.getCreated(); + } + + @Override + public Date getLastUpdatedTime() { + return clusterVO.getLastUpdated(); + } + + @Override + public String getOwner() { + return clusterVO.getOwner(); + } + + @Override + public Map getDetails() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void addDetail(String name, String value) { + // TODO Auto-generated method stub + + } + + @Override + public void delDetail(String name, String value) { + // TODO Auto-generated method stub + + } + + @Override + public void updateDetail(String name, String value) { + // TODO Auto-generated method stub + + } + + @Override + public List getApplicableActions() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getName() { + return clusterVO.getName(); + } + + @Override + public long getDataCenterId() { + return clusterVO.getDataCenterId(); + } + + @Override + public long getPodId() { + return clusterVO.getPodId(); + } + + @Override + public HypervisorType getHypervisorType() { + return clusterVO.getHypervisorType(); + } + + @Override + public ClusterType getClusterType() { + return clusterVO.getClusterType(); + } + + @Override + public AllocationState getAllocationState() { + return clusterVO.getAllocationState(); + } + + @Override + public ManagedState getManagedState() { + return clusterVO.getManagedState(); + } + + public void setOwner(String owner) { + clusterVO.setOwner(owner); + } + + public void setName(String name) { + clusterVO.setName(name); + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java index ab1cbe6b0b1..a5f6d5e8108 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java @@ -14,37 +14,37 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.datacenter.entity.api; - - -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; - -import com.cloud.utils.fsm.NoTransitionException; - - - -public interface DataCenterResourceManager { - - EngineDataCenterVO loadDataCenter(String dataCenterId); - - void saveDataCenter(EngineDataCenterVO dc); - - void savePod(EngineHostPodVO dc); - - void saveCluster(EngineClusterVO cluster); - - boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException; - - EngineHostPodVO loadPod(String uuid); - - EngineClusterVO loadCluster(String uuid); - - EngineHostVO loadHost(String uuid); - - void saveHost(EngineHostVO hostVO); - -} +package org.apache.cloudstack.engine.datacenter.entity.api; + + +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; + +import com.cloud.utils.fsm.NoTransitionException; + + + +public interface DataCenterResourceManager { + + EngineDataCenterVO loadDataCenter(String dataCenterId); + + void saveDataCenter(EngineDataCenterVO dc); + + void savePod(EngineHostPodVO dc); + + void saveCluster(EngineClusterVO cluster); + + boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException; + + EngineHostPodVO loadPod(String uuid); + + EngineClusterVO loadCluster(String uuid); + + EngineHostVO loadHost(String uuid); + + void saveHost(EngineHostVO hostVO); + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java index 3cfca3b9369..c267e5515f1 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java @@ -14,116 +14,116 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.datacenter.entity.api; - -import javax.inject.Inject; - -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State; -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao; -import org.springframework.stereotype.Component; - - -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.utils.fsm.NoTransitionException; -import com.cloud.utils.fsm.StateMachine2; - -@Component -public class DataCenterResourceManagerImpl implements DataCenterResourceManager { - - @Inject - EngineDataCenterDao _dataCenterDao; - - @Inject - EngineHostPodDao _podDao; - - @Inject - EngineClusterDao _clusterDao; - - @Inject - EngineHostDao _hostDao; - - - protected StateMachine2 _stateMachine = DataCenterResourceEntity.State.s_fsm; - - @Override - public EngineDataCenterVO loadDataCenter(String dataCenterId) { - EngineDataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId); - if(dataCenterVO == null){ - throw new InvalidParameterValueException("Zone does not exist"); - } - return dataCenterVO; - } - - @Override - public void saveDataCenter(EngineDataCenterVO dc) { - _dataCenterDao.persist(dc); - - } - - @Override - public boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException { - - if(entity instanceof ZoneEntity){ - return _stateMachine.transitTo(entity, event, null, _dataCenterDao); - }else if(entity instanceof PodEntity){ - return _stateMachine.transitTo(entity, event, null, _podDao); - }else if(entity instanceof ClusterEntity){ - return _stateMachine.transitTo(entity, event, null, _clusterDao); - }else if(entity instanceof HostEntity){ - return _stateMachine.transitTo(entity, event, null, _hostDao); - } - - return false; - } - - @Override - public EngineHostPodVO loadPod(String uuid) { - EngineHostPodVO pod = _podDao.findByUuid(uuid); - if(pod == null){ - throw new InvalidParameterValueException("Pod does not exist"); - } - return pod; - } - - @Override - public EngineClusterVO loadCluster(String uuid) { - EngineClusterVO cluster = _clusterDao.findByUuid(uuid); - if(cluster == null){ - throw new InvalidParameterValueException("Pod does not exist"); - } - return cluster; - } - - @Override - public void savePod(EngineHostPodVO pod) { - _podDao.persist(pod); - } - - @Override - public void saveCluster(EngineClusterVO cluster) { - _clusterDao.persist(cluster); - } - - @Override - public EngineHostVO loadHost(String uuid) { - EngineHostVO host = _hostDao.findByUuid(uuid); - if(host == null){ - throw new InvalidParameterValueException("Host does not exist"); - } - return host; - } - - @Override - public void saveHost(EngineHostVO hostVO) { - _hostDao.persist(hostVO); - } - -} +package org.apache.cloudstack.engine.datacenter.entity.api; + +import javax.inject.Inject; + +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State; +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao; +import org.springframework.stereotype.Component; + + +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.utils.fsm.NoTransitionException; +import com.cloud.utils.fsm.StateMachine2; + +@Component +public class DataCenterResourceManagerImpl implements DataCenterResourceManager { + + @Inject + EngineDataCenterDao _dataCenterDao; + + @Inject + EngineHostPodDao _podDao; + + @Inject + EngineClusterDao _clusterDao; + + @Inject + EngineHostDao _hostDao; + + + protected StateMachine2 _stateMachine = DataCenterResourceEntity.State.s_fsm; + + @Override + public EngineDataCenterVO loadDataCenter(String dataCenterId) { + EngineDataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId); + if(dataCenterVO == null){ + throw new InvalidParameterValueException("Zone does not exist"); + } + return dataCenterVO; + } + + @Override + public void saveDataCenter(EngineDataCenterVO dc) { + _dataCenterDao.persist(dc); + + } + + @Override + public boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException { + + if(entity instanceof ZoneEntity){ + return _stateMachine.transitTo(entity, event, null, _dataCenterDao); + }else if(entity instanceof PodEntity){ + return _stateMachine.transitTo(entity, event, null, _podDao); + }else if(entity instanceof ClusterEntity){ + return _stateMachine.transitTo(entity, event, null, _clusterDao); + }else if(entity instanceof HostEntity){ + return _stateMachine.transitTo(entity, event, null, _hostDao); + } + + return false; + } + + @Override + public EngineHostPodVO loadPod(String uuid) { + EngineHostPodVO pod = _podDao.findByUuid(uuid); + if(pod == null){ + throw new InvalidParameterValueException("Pod does not exist"); + } + return pod; + } + + @Override + public EngineClusterVO loadCluster(String uuid) { + EngineClusterVO cluster = _clusterDao.findByUuid(uuid); + if(cluster == null){ + throw new InvalidParameterValueException("Pod does not exist"); + } + return cluster; + } + + @Override + public void savePod(EngineHostPodVO pod) { + _podDao.persist(pod); + } + + @Override + public void saveCluster(EngineClusterVO cluster) { + _clusterDao.persist(cluster); + } + + @Override + public EngineHostVO loadHost(String uuid) { + EngineHostVO host = _hostDao.findByUuid(uuid); + if(host == null){ + throw new InvalidParameterValueException("Host does not exist"); + } + return host; + } + + @Override + public void saveHost(EngineHostVO hostVO) { + _hostDao.persist(hostVO); + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java index b4a20801a79..17114e7ce07 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java @@ -14,202 +14,202 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.engine.datacenter.entity.api; - -import java.lang.reflect.Method; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; - -import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.utils.fsm.NoTransitionException; - -public class HostEntityImpl implements HostEntity { - - private DataCenterResourceManager manager; - - private EngineHostVO hostVO; - - public HostEntityImpl(String uuid, DataCenterResourceManager manager) { - this.manager = manager; - hostVO = manager.loadHost(uuid); - } - - @Override - public boolean enable() { - try { - manager.changeState(this, Event.EnableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean disable() { - try { - manager.changeState(this, Event.DisableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean deactivate() { - try { - manager.changeState(this, Event.DeactivateRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean reactivate() { - try { - manager.changeState(this, Event.ActivatedRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public State getState() { - return hostVO.getOrchestrationState(); - } - - @Override - public void persist() { - manager.saveHost(hostVO); - } - - @Override - public String getName() { - return hostVO.getName(); - } - - @Override - public String getUuid() { - return hostVO.getUuid(); - } - - @Override - public long getId() { - return hostVO.getId(); - } - - @Override - public String getCurrentState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getDesiredState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Date getCreatedTime() { - return hostVO.getCreated(); - } - - @Override - public Date getLastUpdatedTime() { - return hostVO.getLastUpdated(); - } - - @Override - public String getOwner() { - // TODO Auto-generated method stub - return hostVO.getOwner(); - } - - - public void setDetails(Map details) { - hostVO.setDetails(details); - } - - @Override - public Map getDetails() { - return hostVO.getDetails(); - } - - @Override - public void addDetail(String name, String value) { - hostVO.setDetail(name, value); - } - - @Override - public void delDetail(String name, String value) { - // TODO Auto-generated method stub - } - - @Override - public void updateDetail(String name, String value) { - // TODO Auto-generated method stub - - } - - @Override - public List getApplicableActions() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Long getTotalMemory() { - return hostVO.getTotalMemory(); - } - - @Override - public Integer getCpus() { - return hostVO.getCpus(); - } - - @Override - public Long getSpeed() { - return hostVO.getSpeed(); - } - - @Override - public Long getPodId() { - return hostVO.getPodId(); - } - - @Override - public long getDataCenterId() { - return hostVO.getDataCenterId(); - } - - @Override - public HypervisorType getHypervisorType() { - return hostVO.getHypervisorType(); - } - - @Override - public String getGuid() { - return hostVO.getGuid(); - } - - @Override - public Long getClusterId() { - return hostVO.getClusterId(); - } - - public void setOwner(String owner) { - hostVO.setOwner(owner); - } - - public void setName(String name) { - hostVO.setName(name); - } - - -} +package org.apache.cloudstack.engine.datacenter.entity.api; + +import java.lang.reflect.Method; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; + +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.utils.fsm.NoTransitionException; + +public class HostEntityImpl implements HostEntity { + + private DataCenterResourceManager manager; + + private EngineHostVO hostVO; + + public HostEntityImpl(String uuid, DataCenterResourceManager manager) { + this.manager = manager; + hostVO = manager.loadHost(uuid); + } + + @Override + public boolean enable() { + try { + manager.changeState(this, Event.EnableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean disable() { + try { + manager.changeState(this, Event.DisableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean deactivate() { + try { + manager.changeState(this, Event.DeactivateRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean reactivate() { + try { + manager.changeState(this, Event.ActivatedRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public State getState() { + return hostVO.getOrchestrationState(); + } + + @Override + public void persist() { + manager.saveHost(hostVO); + } + + @Override + public String getName() { + return hostVO.getName(); + } + + @Override + public String getUuid() { + return hostVO.getUuid(); + } + + @Override + public long getId() { + return hostVO.getId(); + } + + @Override + public String getCurrentState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getDesiredState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getCreatedTime() { + return hostVO.getCreated(); + } + + @Override + public Date getLastUpdatedTime() { + return hostVO.getLastUpdated(); + } + + @Override + public String getOwner() { + // TODO Auto-generated method stub + return hostVO.getOwner(); + } + + + public void setDetails(Map details) { + hostVO.setDetails(details); + } + + @Override + public Map getDetails() { + return hostVO.getDetails(); + } + + @Override + public void addDetail(String name, String value) { + hostVO.setDetail(name, value); + } + + @Override + public void delDetail(String name, String value) { + // TODO Auto-generated method stub + } + + @Override + public void updateDetail(String name, String value) { + // TODO Auto-generated method stub + + } + + @Override + public List getApplicableActions() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Long getTotalMemory() { + return hostVO.getTotalMemory(); + } + + @Override + public Integer getCpus() { + return hostVO.getCpus(); + } + + @Override + public Long getSpeed() { + return hostVO.getSpeed(); + } + + @Override + public Long getPodId() { + return hostVO.getPodId(); + } + + @Override + public long getDataCenterId() { + return hostVO.getDataCenterId(); + } + + @Override + public HypervisorType getHypervisorType() { + return hostVO.getHypervisorType(); + } + + @Override + public String getGuid() { + return hostVO.getGuid(); + } + + @Override + public Long getClusterId() { + return hostVO.getClusterId(); + } + + public void setOwner(String owner) { + hostVO.setOwner(owner); + } + + public void setName(String name) { + hostVO.setName(name); + } + + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java index 5c66a21a73e..758a99751ad 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java @@ -1,211 +1,211 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.datacenter.entity.api; - -import java.lang.reflect.Method; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; - -import com.cloud.org.Cluster; -import com.cloud.org.Grouping.AllocationState; -import com.cloud.utils.fsm.NoTransitionException; - -public class PodEntityImpl implements PodEntity { - - - private DataCenterResourceManager manager; - - private EngineHostPodVO podVO; - - public PodEntityImpl(String uuid, DataCenterResourceManager manager) { - this.manager = manager; - podVO = manager.loadPod(uuid); - } - - @Override - public boolean enable() { - try { - manager.changeState(this, Event.EnableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean disable() { - try { - manager.changeState(this, Event.DisableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean deactivate() { - try { - manager.changeState(this, Event.DeactivateRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean reactivate() { - try { - manager.changeState(this, Event.ActivatedRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public State getState() { - return podVO.getState(); - } - - @Override - public String getUuid() { - return podVO.getUuid(); - } - - @Override - public long getId() { - return podVO.getId(); - } - - @Override - public String getCurrentState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getDesiredState() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Date getCreatedTime() { - return podVO.getCreated(); - } - - @Override - public Date getLastUpdatedTime() { - return podVO.getLastUpdated(); - } - - @Override - public String getOwner() { - return podVO.getOwner(); - } - - - @Override - public List getApplicableActions() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getCidrAddress() { - return podVO.getCidrAddress(); - } - - @Override - public int getCidrSize() { - return podVO.getCidrSize(); - } - - @Override - public String getGateway() { - return podVO.getGateway(); - } - - @Override - public long getDataCenterId() { - return podVO.getDataCenterId(); - } - - @Override - public String getName() { - return podVO.getName(); - } - - @Override - public AllocationState getAllocationState() { - return podVO.getAllocationState(); - } - - @Override - public boolean getExternalDhcp() { - return podVO.getExternalDhcp(); - } - - @Override - public List listClusters() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void persist() { - manager.savePod(podVO); - - } - - @Override - public Map getDetails() { - return null; - } - - @Override - public void addDetail(String name, String value) { - // TODO Auto-generated method stub - - } - - @Override - public void delDetail(String name, String value) { - // TODO Auto-generated method stub - - } - - @Override - public void updateDetail(String name, String value) { - - } - - public void setOwner(String owner) { - podVO.setOwner(owner); - } - - public void setName(String name) { - podVO.setName(name); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.datacenter.entity.api; + +import java.lang.reflect.Method; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; + +import com.cloud.org.Cluster; +import com.cloud.org.Grouping.AllocationState; +import com.cloud.utils.fsm.NoTransitionException; + +public class PodEntityImpl implements PodEntity { + + + private DataCenterResourceManager manager; + + private EngineHostPodVO podVO; + + public PodEntityImpl(String uuid, DataCenterResourceManager manager) { + this.manager = manager; + podVO = manager.loadPod(uuid); + } + + @Override + public boolean enable() { + try { + manager.changeState(this, Event.EnableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean disable() { + try { + manager.changeState(this, Event.DisableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean deactivate() { + try { + manager.changeState(this, Event.DeactivateRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean reactivate() { + try { + manager.changeState(this, Event.ActivatedRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public State getState() { + return podVO.getState(); + } + + @Override + public String getUuid() { + return podVO.getUuid(); + } + + @Override + public long getId() { + return podVO.getId(); + } + + @Override + public String getCurrentState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getDesiredState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Date getCreatedTime() { + return podVO.getCreated(); + } + + @Override + public Date getLastUpdatedTime() { + return podVO.getLastUpdated(); + } + + @Override + public String getOwner() { + return podVO.getOwner(); + } + + + @Override + public List getApplicableActions() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getCidrAddress() { + return podVO.getCidrAddress(); + } + + @Override + public int getCidrSize() { + return podVO.getCidrSize(); + } + + @Override + public String getGateway() { + return podVO.getGateway(); + } + + @Override + public long getDataCenterId() { + return podVO.getDataCenterId(); + } + + @Override + public String getName() { + return podVO.getName(); + } + + @Override + public AllocationState getAllocationState() { + return podVO.getAllocationState(); + } + + @Override + public boolean getExternalDhcp() { + return podVO.getExternalDhcp(); + } + + @Override + public List listClusters() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void persist() { + manager.savePod(podVO); + + } + + @Override + public Map getDetails() { + return null; + } + + @Override + public void addDetail(String name, String value) { + // TODO Auto-generated method stub + + } + + @Override + public void delDetail(String name, String value) { + // TODO Auto-generated method stub + + } + + @Override + public void updateDetail(String name, String value) { + + } + + public void setOwner(String owner) { + podVO.setOwner(owner); + } + + public void setName(String name) { + podVO.setName(name); + } + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java index 333a2207d66..e2548803d61 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java @@ -1,201 +1,201 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.datacenter.entity.api; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; -import com.cloud.utils.fsm.FiniteStateObject; -import com.cloud.utils.fsm.NoTransitionException; - - -@Path("/zone/{id}") -public class ZoneEntityImpl implements ZoneEntity, FiniteStateObject { - - - private DataCenterResourceManager manager; - - private EngineDataCenterVO dataCenterVO; - - - public ZoneEntityImpl(String dataCenterId, DataCenterResourceManager manager) { - this.manager = manager; - this.dataCenterVO = this.manager.loadDataCenter(dataCenterId); - } - - @Override - @GET - public String getUuid() { - return dataCenterVO.getUuid(); - } - - @Override - public long getId() { - return dataCenterVO.getId(); - } - - @Override - public boolean enable() { - try { - manager.changeState(this, Event.EnableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean disable() { - try { - manager.changeState(this, Event.DisableRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean deactivate() { - try { - manager.changeState(this, Event.DeactivateRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public boolean reactivate() { - try { - manager.changeState(this, Event.ActivatedRequest); - } catch (NoTransitionException e) { - return false; - } - return true; - } - - @Override - public String getCurrentState() { - // TODO Auto-generated method stub - return "state"; - } - - @Override - public String getDesiredState() { - // TODO Auto-generated method stub - return "desired_state"; - } - - @Override - public Date getCreatedTime() { - return dataCenterVO.getCreated(); - } - - @Override - public Date getLastUpdatedTime() { - return dataCenterVO.getLastUpdated(); - } - - @Override - public String getOwner() { - return dataCenterVO.getOwner(); - } - - - public void setOwner(String owner) { - dataCenterVO.setOwner(owner); - } - - @Override - public Map getDetails() { - return dataCenterVO.getDetails(); - } - - public void setDetails(Map details) { - dataCenterVO.setDetails(details); - } - - - @Override - public void addDetail(String name, String value) { - dataCenterVO.setDetail(name, value); - } - - @Override - public void delDetail(String name, String value) { - // TODO Auto-generated method stub - } - - @Override - public void updateDetail(String name, String value) { - // TODO Auto-generated method stub - - } - - @Override - public List getApplicableActions() { - // TODO Auto-generated method stub - return null; - } - - @Override - public State getState() { - return dataCenterVO.getState(); - } - - - @Override - public List listPods() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setState(State state) { - //use FSM to set state. - } - - @Override - public void persist() { - manager.saveDataCenter(dataCenterVO); - } - - @Override - public String getName() { - return dataCenterVO.getName(); - } - - @Override - public List listPodIds() { - List podIds = new ArrayList(); - podIds.add("pod-uuid-1"); - podIds.add("pod-uuid-2"); - return podIds; - } - - public void setName(String name) { - dataCenterVO.setName(name); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.datacenter.entity.api; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; +import com.cloud.utils.fsm.FiniteStateObject; +import com.cloud.utils.fsm.NoTransitionException; + + +@Path("/zone/{id}") +public class ZoneEntityImpl implements ZoneEntity, FiniteStateObject { + + + private DataCenterResourceManager manager; + + private EngineDataCenterVO dataCenterVO; + + + public ZoneEntityImpl(String dataCenterId, DataCenterResourceManager manager) { + this.manager = manager; + this.dataCenterVO = this.manager.loadDataCenter(dataCenterId); + } + + @Override + @GET + public String getUuid() { + return dataCenterVO.getUuid(); + } + + @Override + public long getId() { + return dataCenterVO.getId(); + } + + @Override + public boolean enable() { + try { + manager.changeState(this, Event.EnableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean disable() { + try { + manager.changeState(this, Event.DisableRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean deactivate() { + try { + manager.changeState(this, Event.DeactivateRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public boolean reactivate() { + try { + manager.changeState(this, Event.ActivatedRequest); + } catch (NoTransitionException e) { + return false; + } + return true; + } + + @Override + public String getCurrentState() { + // TODO Auto-generated method stub + return "state"; + } + + @Override + public String getDesiredState() { + // TODO Auto-generated method stub + return "desired_state"; + } + + @Override + public Date getCreatedTime() { + return dataCenterVO.getCreated(); + } + + @Override + public Date getLastUpdatedTime() { + return dataCenterVO.getLastUpdated(); + } + + @Override + public String getOwner() { + return dataCenterVO.getOwner(); + } + + + public void setOwner(String owner) { + dataCenterVO.setOwner(owner); + } + + @Override + public Map getDetails() { + return dataCenterVO.getDetails(); + } + + public void setDetails(Map details) { + dataCenterVO.setDetails(details); + } + + + @Override + public void addDetail(String name, String value) { + dataCenterVO.setDetail(name, value); + } + + @Override + public void delDetail(String name, String value) { + // TODO Auto-generated method stub + } + + @Override + public void updateDetail(String name, String value) { + // TODO Auto-generated method stub + + } + + @Override + public List getApplicableActions() { + // TODO Auto-generated method stub + return null; + } + + @Override + public State getState() { + return dataCenterVO.getState(); + } + + + @Override + public List listPods() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setState(State state) { + //use FSM to set state. + } + + @Override + public void persist() { + manager.saveDataCenter(dataCenterVO); + } + + @Override + public String getName() { + return dataCenterVO.getName(); + } + + @Override + public List listPodIds() { + List podIds = new ArrayList(); + podIds.add("pod-uuid-1"); + podIds.add("pod-uuid-2"); + return podIds; + } + + public void setName(String name) { + dataCenterVO.setName(name); + } +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java index c4f1940c119..98b7a991a3f 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java @@ -1,23 +1,23 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package org.apache.cloudstack.engine.datacenter.entity.api.db; - -import com.cloud.org.Cluster; - -public interface EngineCluster extends Cluster { - -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.engine.datacenter.entity.api.db; + +import com.cloud.org.Cluster; + +public interface EngineCluster extends Cluster { + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java index 24e01a0b0af..240dddf1529 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java @@ -1,23 +1,23 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package org.apache.cloudstack.engine.datacenter.entity.api.db; - -import com.cloud.dc.DataCenter; - -public interface EngineDataCenter extends DataCenter { - -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.engine.datacenter.entity.api.db; + +import com.cloud.dc.DataCenter; + +public interface EngineDataCenter extends DataCenter { + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java index 15bed6f8c1d..cdf08cc5b9c 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java @@ -8,10 +8,10 @@ // 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 org.apache.cloudstack.engine.datacenter.entity.api.db; - +package org.apache.cloudstack.engine.datacenter.entity.api.db; + import java.util.Date; import java.util.Map; import java.util.UUID; @@ -39,43 +39,43 @@ import com.cloud.org.Grouping; import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.StateMachine; - -@Entity -@Table(name="data_center") -public class EngineDataCenterVO implements EngineDataCenter, Identity { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name="id") - private long id; - - @Column(name="name") - private String name = null; - - @Column(name="description") - private String description = null; - - @Column(name="dns1") - private String dns1 = null; - - @Column(name="dns2") - private String dns2 = null; - - @Column(name="ip6Dns1") - private String ip6Dns1 = null; - - @Column(name="ip6Dns2") - private String ip6Dns2 = null; - - @Column(name="internal_dns1") - private String internalDns1 = null; - - @Column(name="internal_dns2") - private String internalDns2 = null; - - @Column(name="router_mac_address", updatable = false, nullable=false) - private String routerMacAddress = "02:00:00:00:00:01"; - + +@Entity +@Table(name="data_center") +public class EngineDataCenterVO implements EngineDataCenter, Identity { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + private long id; + + @Column(name="name") + private String name = null; + + @Column(name="description") + private String description = null; + + @Column(name="dns1") + private String dns1 = null; + + @Column(name="dns2") + private String dns2 = null; + + @Column(name="ip6Dns1") + private String ip6Dns1 = null; + + @Column(name="ip6Dns2") + private String ip6Dns2 = null; + + @Column(name="internal_dns1") + private String internalDns1 = null; + + @Column(name="internal_dns2") + private String internalDns2 = null; + + @Column(name="router_mac_address", updatable = false, nullable=false) + private String routerMacAddress = "02:00:00:00:00:01"; + @Column(name="guest_network_cidr") private String guestNetworkCidr = null; @@ -207,13 +207,13 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity { } public EngineDataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) { - this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null); + this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null); this.id = id; this.allocationState = Grouping.AllocationState.Enabled; - this.uuid = UUID.randomUUID().toString(); - } - - public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) { + this.uuid = UUID.randomUUID().toString(); + } + + public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) { this.name = name; this.description = description; this.dns1 = dns1; @@ -285,72 +285,72 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity { public void setDomainId(Long domainId) { this.domainId = domainId; - } - + } + @Override - public String getDescription() { - return description; - } - - public String getRouterMacAddress() { - return routerMacAddress; - } - + public String getDescription() { + return description; + } + + public String getRouterMacAddress() { + return routerMacAddress; + } + @Override - public String getDns1() { - return dns1; - } - + public String getDns1() { + return dns1; + } + @Override - public String getDns2() { - return dns2; - } - + public String getDns2() { + return dns2; + } + @Override - public String getInternalDns1() { - return internalDns1; - } - + public String getInternalDns1() { + return internalDns1; + } + @Override - public String getInternalDns2() { - return internalDns2; - } - - protected EngineDataCenterVO() { - } - + public String getInternalDns2() { + return internalDns2; + } + + protected EngineDataCenterVO() { + } + @Override - public long getId() { - return id; - } - + public long getId() { + return id; + } + @Override - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void setDns1(String dns1) { - this.dns1 = dns1; - } - - public void setDns2(String dns2) { - this.dns2 = dns2; - } - - public void setInternalDns1(String dns3) { - this.internalDns1 = dns3; - } - - public void setInternalDns2(String dns4) { - this.internalDns2 = dns4; - } - - public void setRouterMacAddress(String routerMacAddress) { - this.routerMacAddress = routerMacAddress; + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void setDns1(String dns1) { + this.dns1 = dns1; + } + + public void setDns2(String dns2) { + this.dns2 = dns2; + } + + public void setInternalDns1(String dns3) { + this.internalDns1 = dns3; + } + + public void setInternalDns2(String dns4) { + this.internalDns2 = dns4; + } + + public void setRouterMacAddress(String routerMacAddress) { + this.routerMacAddress = routerMacAddress; } @Override @@ -501,4 +501,4 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity { public void setIp6Dns2(String ip6Dns2) { this.ip6Dns2 = ip6Dns2; } -} +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java index fe1b832633e..127c4457071 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java @@ -1,24 +1,24 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.apache.cloudstack.engine.datacenter.entity.api.db; - -import com.cloud.host.Host; - -public interface EngineHost extends Host { - -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.cloudstack.engine.datacenter.entity.api.db; + +import com.cloud.host.Host; + +public interface EngineHost extends Host { + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java index 99c95406f9e..65b9db53e93 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java @@ -8,10 +8,10 @@ // 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 org.apache.cloudstack.engine.datacenter.entity.api.db; - +package org.apache.cloudstack.engine.datacenter.entity.api.db; + import java.util.Date; import java.util.UUID; @@ -34,42 +34,42 @@ import com.cloud.org.Grouping; import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.StateMachine; - -@Entity -@Table(name = "host_pod_ref") -public class EngineHostPodVO implements EnginePod, Identity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - long id; - - @Column(name = "name") - private String name = null; - - @Column(name = "data_center_id") + +@Entity +@Table(name = "host_pod_ref") +public class EngineHostPodVO implements EnginePod, Identity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + long id; + + @Column(name = "name") + private String name = null; + + @Column(name = "data_center_id") private long dataCenterId; @Column(name = "gateway") - private String gateway; - - @Column(name = "cidr_address") - private String cidrAddress; - - @Column(name = "cidr_size") - private int cidrSize; - - @Column(name = "description") + private String gateway; + + @Column(name = "cidr_address") + private String cidrAddress; + + @Column(name = "cidr_size") + private int cidrSize; + + @Column(name = "description") private String description; @Column(name="allocation_state") @Enumerated(value=EnumType.STRING) - AllocationState allocationState; + AllocationState allocationState; @Column(name = "external_dhcp") private Boolean externalDhcp; @Column(name=GenericDao.REMOVED_COLUMN) private Date removed; - + @Column(name = "uuid") private String uuid; @@ -93,66 +93,66 @@ public class EngineHostPodVO implements EnginePod, Identity { @StateMachine(state=State.class, event=Event.class) @Column(name="engine_state", updatable=true, nullable=false, length=32) protected State engineState = null; - - public EngineHostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) { - this.name = name; + + public EngineHostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) { + this.name = name; this.dataCenterId = dcId; - this.gateway = gateway; - this.cidrAddress = cidrAddress; - this.cidrSize = cidrSize; + this.gateway = gateway; + this.cidrAddress = cidrAddress; + this.cidrSize = cidrSize; this.description = description; this.allocationState = Grouping.AllocationState.Enabled; this.externalDhcp = false; this.uuid = UUID.randomUUID().toString(); - this.engineState = State.Disabled; - } - - /* - * public HostPodVO(String name, long dcId) { this(null, name, dcId); } - */ - protected EngineHostPodVO() { + this.engineState = State.Disabled; + } + + /* + * public HostPodVO(String name, long dcId) { this(null, name, dcId); } + */ + protected EngineHostPodVO() { this.uuid = UUID.randomUUID().toString(); - } - + } + @Override - public long getId() { - return id; - } - + public long getId() { + return id; + } + @Override - public long getDataCenterId() { - return dataCenterId; - } - - public void setDataCenterId(long dataCenterId) { - this.dataCenterId = dataCenterId; - } - + public long getDataCenterId() { + return dataCenterId; + } + + public void setDataCenterId(long dataCenterId) { + this.dataCenterId = dataCenterId; + } + @Override - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + @Override - public String getCidrAddress() { - return cidrAddress; - } - - public void setCidrAddress(String cidrAddress) { - this.cidrAddress = cidrAddress; - } - + public String getCidrAddress() { + return cidrAddress; + } + + public void setCidrAddress(String cidrAddress) { + this.cidrAddress = cidrAddress; + } + @Override - public int getCidrSize() { - return cidrSize; - } - - public void setCidrSize(int cidrSize) { - this.cidrSize = cidrSize; + public int getCidrSize() { + return cidrSize; + } + + public void setCidrSize(int cidrSize) { + this.cidrSize = cidrSize; } @Override @@ -162,15 +162,15 @@ public class EngineHostPodVO implements EnginePod, Identity { public void setGateway(String gateway) { this.gateway = gateway; - } - + } + @Override - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; } @Override @@ -241,5 +241,5 @@ public class EngineHostPodVO implements EnginePod, Identity { public State getState() { return engineState; - } -} + } +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java index 3983dd90420..2adbca36af5 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java @@ -1,23 +1,23 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package org.apache.cloudstack.engine.datacenter.entity.api.db; - -import com.cloud.dc.Pod; - -public interface EnginePod extends Pod { - -} +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.engine.datacenter.entity.api.db; + +import com.cloud.dc.Pod; + +public interface EnginePod extends Pod { + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDao.java index a27ed505289..3a71fe2cf9f 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDao.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDao.java @@ -82,4 +82,4 @@ public interface EngineHostDao extends GenericDao, StateDao< * @return */ List listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag); -} +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java index 48e77739085..451723e5370 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java @@ -8,10 +8,10 @@ // 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 org.apache.cloudstack.engine.datacenter.entity.api.db.dao; - +package org.apache.cloudstack.engine.datacenter.entity.api.db.dao; + import java.util.HashMap; import java.util.List; @@ -21,13 +21,13 @@ import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; import com.cloud.utils.db.GenericDao; import com.cloud.utils.fsm.StateDao; - -public interface EngineHostPodDao extends GenericDao, StateDao { - public List listByDataCenterId(long id); - - public EngineHostPodVO findByName(String name, long dcId); - + +public interface EngineHostPodDao extends GenericDao, StateDao { + public List listByDataCenterId(long id); + + public EngineHostPodVO findByName(String name, long dcId); + public HashMap> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip); public List listDisabledPods(long zoneId); -} +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java index c5b4bd28de4..fee083a39a0 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java @@ -8,10 +8,10 @@ // 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 org.apache.cloudstack.engine.datacenter.entity.api.db.dao; - +package org.apache.cloudstack.engine.datacenter.entity.api.db.dao; + import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -39,27 +39,27 @@ import com.cloud.utils.db.UpdateBuilder; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.Transaction; -@Component(value="EngineHostPodDao") -@Local(value={EngineHostPodDao.class}) -public class EngineHostPodDaoImpl extends GenericDaoBase implements EngineHostPodDao { - private static final Logger s_logger = Logger.getLogger(EngineHostPodDaoImpl.class); - - protected SearchBuilder DataCenterAndNameSearch; +@Component(value="EngineHostPodDao") +@Local(value={EngineHostPodDao.class}) +public class EngineHostPodDaoImpl extends GenericDaoBase implements EngineHostPodDao { + private static final Logger s_logger = Logger.getLogger(EngineHostPodDaoImpl.class); + + protected SearchBuilder DataCenterAndNameSearch; protected SearchBuilder DataCenterIdSearch; protected SearchBuilder UUIDSearch; - protected SearchBuilder StateChangeSearch; - - protected EngineHostPodDaoImpl() { - DataCenterAndNameSearch = createSearchBuilder(); - DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); - DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ); - DataCenterAndNameSearch.done(); - - DataCenterIdSearch = createSearchBuilder(); - DataCenterIdSearch.and("dcId", DataCenterIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); + protected SearchBuilder StateChangeSearch; + + protected EngineHostPodDaoImpl() { + DataCenterAndNameSearch = createSearchBuilder(); + DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); + DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ); + DataCenterAndNameSearch.done(); + + DataCenterIdSearch = createSearchBuilder(); + DataCenterIdSearch.and("dcId", DataCenterIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); DataCenterIdSearch.done(); - - + + UUIDSearch = createSearchBuilder(); UUIDSearch.and("uuid", UUIDSearch.entity().getUuid(), SearchCriteria.Op.EQ); UUIDSearch.done(); @@ -67,56 +67,56 @@ public class EngineHostPodDaoImpl extends GenericDaoBase StateChangeSearch = createSearchBuilder(); StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ); StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ); - StateChangeSearch.done(); - - } - + StateChangeSearch.done(); + + } + @Override - public List listByDataCenterId(long id) { - SearchCriteria sc = DataCenterIdSearch.create(); - sc.setParameters("dcId", id); - - return listBy(sc); - } - + public List listByDataCenterId(long id) { + SearchCriteria sc = DataCenterIdSearch.create(); + sc.setParameters("dcId", id); + + return listBy(sc); + } + @Override - public EngineHostPodVO findByName(String name, long dcId) { - SearchCriteria sc = DataCenterAndNameSearch.create(); - sc.setParameters("dc", dcId); - sc.setParameters("name", name); - - return findOneBy(sc); - } - - @Override - public HashMap> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip) { - HashMap> currentPodCidrSubnets = new HashMap>(); - - String selectSql = "SELECT id, cidr_address, cidr_size FROM host_pod_ref WHERE data_center_id=" + zoneId +" and removed IS NULL"; - Transaction txn = Transaction.currentTxn(); - try { - PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql); - ResultSet rs = stmt.executeQuery(); - while (rs.next()) { - Long podId = rs.getLong("id"); - if (podId.longValue() == podIdToSkip) { + public EngineHostPodVO findByName(String name, long dcId) { + SearchCriteria sc = DataCenterAndNameSearch.create(); + sc.setParameters("dc", dcId); + sc.setParameters("name", name); + + return findOneBy(sc); + } + + @Override + public HashMap> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip) { + HashMap> currentPodCidrSubnets = new HashMap>(); + + String selectSql = "SELECT id, cidr_address, cidr_size FROM host_pod_ref WHERE data_center_id=" + zoneId +" and removed IS NULL"; + Transaction txn = Transaction.currentTxn(); + try { + PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql); + ResultSet rs = stmt.executeQuery(); + while (rs.next()) { + Long podId = rs.getLong("id"); + if (podId.longValue() == podIdToSkip) { continue; - } - String cidrAddress = rs.getString("cidr_address"); - long cidrSize = rs.getLong("cidr_size"); - List cidrPair = new ArrayList(); - cidrPair.add(0, cidrAddress); - cidrPair.add(1, new Long(cidrSize)); - currentPodCidrSubnets.put(podId, cidrPair); - } - } catch (SQLException ex) { - s_logger.warn("DB exception " + ex.getMessage(), ex); - return null; - } - - return currentPodCidrSubnets; - } - + } + String cidrAddress = rs.getString("cidr_address"); + long cidrSize = rs.getLong("cidr_size"); + List cidrPair = new ArrayList(); + cidrPair.add(0, cidrAddress); + cidrPair.add(1, new Long(cidrSize)); + currentPodCidrSubnets.put(podId, cidrPair); + } + } catch (SQLException ex) { + s_logger.warn("DB exception " + ex.getMessage(), ex); + return null; + } + + return currentPodCidrSubnets; + } + @Override public boolean remove(Long id) { Transaction txn = Transaction.currentTxn(); @@ -179,6 +179,6 @@ public class EngineHostPodDaoImpl extends GenericDaoBase return rows > 0; } - - -} + + +} diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java index 83e78b45fd0..863c181a9a7 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java @@ -1,170 +1,170 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.engine.service.api; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; -import javax.ws.rs.Path; - -import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntityImpl; -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManager; -import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.HostEntityImpl; -import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.PodEntityImpl; -import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntityImpl; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -import com.cloud.host.Host; -import com.cloud.host.Status; -import com.cloud.storage.StoragePool; - - -@Component -@Service("provisioningService") -@Path("/provisioning") -public class ProvisioningServiceImpl implements ProvisioningService { - - @Inject - DataCenterResourceManager manager; - - @Override - public StorageEntity registerStorage(String name, List tags, Map details) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ZoneEntity registerZone(String zoneUuid, String name, String owner, List tags, Map details) { - ZoneEntityImpl zoneEntity = new ZoneEntityImpl(zoneUuid, manager); - zoneEntity.setName(name); - zoneEntity.setOwner(owner); - zoneEntity.setDetails(details); - zoneEntity.persist(); - return zoneEntity; - } - - @Override - public PodEntity registerPod(String podUuid, String name, String owner, String zoneUuid, List tags, Map details) { - PodEntityImpl podEntity = new PodEntityImpl(podUuid, manager); - podEntity.setOwner(owner); - podEntity.setName(name); - podEntity.persist(); - return podEntity; - } - - @Override - public ClusterEntity registerCluster(String clusterUuid, String name, String owner, List tags, Map details) { - ClusterEntityImpl clusterEntity = new ClusterEntityImpl(clusterUuid, manager); - clusterEntity.setOwner(owner); - clusterEntity.setName(name); - clusterEntity.persist(); - return clusterEntity; - } - - @Override - public HostEntity registerHost(String hostUuid, String name, String owner, List tags, Map details) { - HostEntityImpl hostEntity = new HostEntityImpl(hostUuid, manager); - hostEntity.setOwner(owner); - hostEntity.setName(name); - hostEntity.setDetails(details); - - hostEntity.persist(); - return hostEntity; - } - - @Override - public void deregisterStorage(String uuid) { - // TODO Auto-generated method stub - - } - - @Override - public void deregisterZone(String uuid) { - ZoneEntityImpl zoneEntity = new ZoneEntityImpl(uuid, manager); - zoneEntity.disable(); - } - - @Override - public void deregisterPod(String uuid) { - PodEntityImpl podEntity = new PodEntityImpl(uuid, manager); - podEntity.disable(); - } - - @Override - public void deregisterCluster(String uuid) { - ClusterEntityImpl clusterEntity = new ClusterEntityImpl(uuid, manager); - clusterEntity.disable(); - - } - - @Override - public void deregisterHost(String uuid) { - HostEntityImpl hostEntity = new HostEntityImpl(uuid, manager); - hostEntity.disable(); - } - - @Override - public void changeState(String type, String entity, Status state) { - // TODO Auto-generated method stub - - } - - @Override - public List listHosts() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List listPods() { - List pods = new ArrayList(); - //pods.add(new PodEntityImpl("pod-uuid-1", "pod1")); - //pods.add(new PodEntityImpl("pod-uuid-2", "pod2")); - return null; - } - - @Override - public List listZones() { - List zones = new ArrayList(); - //zones.add(new ZoneEntityImpl("zone-uuid-1")); - //zones.add(new ZoneEntityImpl("zone-uuid-2")); - return zones; - } - - @Override - public List listStorage() { - // TODO Auto-generated method stub - return null; - } - - @Override - public ZoneEntity getZone(String uuid) { - ZoneEntityImpl impl = new ZoneEntityImpl(uuid, manager); - return impl; - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.service.api; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; +import javax.ws.rs.Path; + +import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntityImpl; +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManager; +import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.HostEntityImpl; +import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.PodEntityImpl; +import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntityImpl; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import com.cloud.host.Host; +import com.cloud.host.Status; +import com.cloud.storage.StoragePool; + + +@Component +@Service("provisioningService") +@Path("/provisioning") +public class ProvisioningServiceImpl implements ProvisioningService { + + @Inject + DataCenterResourceManager manager; + + @Override + public StorageEntity registerStorage(String name, List tags, Map details) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ZoneEntity registerZone(String zoneUuid, String name, String owner, List tags, Map details) { + ZoneEntityImpl zoneEntity = new ZoneEntityImpl(zoneUuid, manager); + zoneEntity.setName(name); + zoneEntity.setOwner(owner); + zoneEntity.setDetails(details); + zoneEntity.persist(); + return zoneEntity; + } + + @Override + public PodEntity registerPod(String podUuid, String name, String owner, String zoneUuid, List tags, Map details) { + PodEntityImpl podEntity = new PodEntityImpl(podUuid, manager); + podEntity.setOwner(owner); + podEntity.setName(name); + podEntity.persist(); + return podEntity; + } + + @Override + public ClusterEntity registerCluster(String clusterUuid, String name, String owner, List tags, Map details) { + ClusterEntityImpl clusterEntity = new ClusterEntityImpl(clusterUuid, manager); + clusterEntity.setOwner(owner); + clusterEntity.setName(name); + clusterEntity.persist(); + return clusterEntity; + } + + @Override + public HostEntity registerHost(String hostUuid, String name, String owner, List tags, Map details) { + HostEntityImpl hostEntity = new HostEntityImpl(hostUuid, manager); + hostEntity.setOwner(owner); + hostEntity.setName(name); + hostEntity.setDetails(details); + + hostEntity.persist(); + return hostEntity; + } + + @Override + public void deregisterStorage(String uuid) { + // TODO Auto-generated method stub + + } + + @Override + public void deregisterZone(String uuid) { + ZoneEntityImpl zoneEntity = new ZoneEntityImpl(uuid, manager); + zoneEntity.disable(); + } + + @Override + public void deregisterPod(String uuid) { + PodEntityImpl podEntity = new PodEntityImpl(uuid, manager); + podEntity.disable(); + } + + @Override + public void deregisterCluster(String uuid) { + ClusterEntityImpl clusterEntity = new ClusterEntityImpl(uuid, manager); + clusterEntity.disable(); + + } + + @Override + public void deregisterHost(String uuid) { + HostEntityImpl hostEntity = new HostEntityImpl(uuid, manager); + hostEntity.disable(); + } + + @Override + public void changeState(String type, String entity, Status state) { + // TODO Auto-generated method stub + + } + + @Override + public List listHosts() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List listPods() { + List pods = new ArrayList(); + //pods.add(new PodEntityImpl("pod-uuid-1", "pod1")); + //pods.add(new PodEntityImpl("pod-uuid-2", "pod2")); + return null; + } + + @Override + public List listZones() { + List zones = new ArrayList(); + //zones.add(new ZoneEntityImpl("zone-uuid-1")); + //zones.add(new ZoneEntityImpl("zone-uuid-2")); + return zones; + } + + @Override + public List listStorage() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ZoneEntity getZone(String uuid) { + ZoneEntityImpl impl = new ZoneEntityImpl(uuid, manager); + return impl; + } + +} diff --git a/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java b/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java index a3ef2768287..0976f838b3b 100644 --- a/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java +++ b/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java @@ -14,124 +14,124 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -/** - * - */ -package org.apache.cloudstack.engine.provisioning.test; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import javax.inject.Inject; - -import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State; -import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao; -import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao; -import org.apache.cloudstack.engine.service.api.ProvisioningService; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; -import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; - -import com.cloud.dc.DataCenter.NetworkType; - -import junit.framework.TestCase; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations="classpath:/resource/provisioningContext.xml") -public class ProvisioningTest extends TestCase { - - @Inject - ProvisioningService service; - - @Inject - EngineDataCenterDao dcDao; - - @Inject - EngineHostPodDao _podDao; - - @Inject - EngineClusterDao _clusterDao; - - @Inject - EngineHostDao _hostDao; - - @Before - public void setUp() { - EngineDataCenterVO dc = new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", - null, null, NetworkType.Basic, null, null, true, true, null, null); - Mockito.when(dcDao.findByUuid(Mockito.anyString())).thenReturn(dc); - Mockito.when(dcDao.persist((EngineDataCenterVO) Mockito.anyObject())).thenReturn(dc); - - EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test"); - Mockito.when(_podDao.findByUuid(Mockito.anyString())).thenReturn(pod); - Mockito.when(_podDao.persist((EngineHostPodVO) Mockito.anyObject())).thenReturn(pod); - - EngineClusterVO cluster = new EngineClusterVO(); - Mockito.when(_clusterDao.findByUuid(Mockito.anyString())).thenReturn(cluster); - Mockito.when(_clusterDao.persist((EngineClusterVO) Mockito.anyObject())).thenReturn(cluster); - - EngineHostVO host = new EngineHostVO("68765876598"); - Mockito.when(_hostDao.findByUuid(Mockito.anyString())).thenReturn(host); - Mockito.when(_hostDao.persist((EngineHostVO) Mockito.anyObject())).thenReturn(host); - - } - - private void registerAndEnableZone() { - ZoneEntity zone = service.registerZone("47547648", "lab","owner", null, new HashMap()); - State state = zone.getState(); - System.out.println("state:"+state); - boolean result = zone.enable(); - System.out.println("result:"+result); - - } - - private void registerAndEnablePod() { - PodEntity pod = service.registerPod("47547648", "lab","owner", "8709874074", null, new HashMap()); - State state = pod.getState(); - System.out.println("state:"+state); - boolean result = pod.enable(); - System.out.println("result:"+result); - } - - private void registerAndEnableCluster() { - ClusterEntity cluster = service.registerCluster("1265476542", "lab","owner", null, new HashMap()); - State state = cluster.getState(); - System.out.println("state:"+state); - boolean result = cluster.enable(); - System.out.println("result:"+result); - } - - private void registerAndEnableHost() { - HostEntity host = service.registerHost("1265476542", "lab","owner", null, new HashMap()); - State state = host.getState(); - System.out.println("state:"+state); - boolean result = host.enable(); - System.out.println("result:"+result); - } - - @Test - public void testProvisioning() { - registerAndEnableZone(); - registerAndEnablePod(); - registerAndEnableCluster(); - registerAndEnableHost(); - } - - -} +/** + * + */ +package org.apache.cloudstack.engine.provisioning.test; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.inject.Inject; + +import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State; +import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao; +import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao; +import org.apache.cloudstack.engine.service.api.ProvisioningService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO; +import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO; + +import com.cloud.dc.DataCenter.NetworkType; + +import junit.framework.TestCase; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations="classpath:/resource/provisioningContext.xml") +public class ProvisioningTest extends TestCase { + + @Inject + ProvisioningService service; + + @Inject + EngineDataCenterDao dcDao; + + @Inject + EngineHostPodDao _podDao; + + @Inject + EngineClusterDao _clusterDao; + + @Inject + EngineHostDao _hostDao; + + @Before + public void setUp() { + EngineDataCenterVO dc = new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", + null, null, NetworkType.Basic, null, null, true, true, null, null); + Mockito.when(dcDao.findByUuid(Mockito.anyString())).thenReturn(dc); + Mockito.when(dcDao.persist((EngineDataCenterVO) Mockito.anyObject())).thenReturn(dc); + + EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test"); + Mockito.when(_podDao.findByUuid(Mockito.anyString())).thenReturn(pod); + Mockito.when(_podDao.persist((EngineHostPodVO) Mockito.anyObject())).thenReturn(pod); + + EngineClusterVO cluster = new EngineClusterVO(); + Mockito.when(_clusterDao.findByUuid(Mockito.anyString())).thenReturn(cluster); + Mockito.when(_clusterDao.persist((EngineClusterVO) Mockito.anyObject())).thenReturn(cluster); + + EngineHostVO host = new EngineHostVO("68765876598"); + Mockito.when(_hostDao.findByUuid(Mockito.anyString())).thenReturn(host); + Mockito.when(_hostDao.persist((EngineHostVO) Mockito.anyObject())).thenReturn(host); + + } + + private void registerAndEnableZone() { + ZoneEntity zone = service.registerZone("47547648", "lab","owner", null, new HashMap()); + State state = zone.getState(); + System.out.println("state:"+state); + boolean result = zone.enable(); + System.out.println("result:"+result); + + } + + private void registerAndEnablePod() { + PodEntity pod = service.registerPod("47547648", "lab","owner", "8709874074", null, new HashMap()); + State state = pod.getState(); + System.out.println("state:"+state); + boolean result = pod.enable(); + System.out.println("result:"+result); + } + + private void registerAndEnableCluster() { + ClusterEntity cluster = service.registerCluster("1265476542", "lab","owner", null, new HashMap()); + State state = cluster.getState(); + System.out.println("state:"+state); + boolean result = cluster.enable(); + System.out.println("result:"+result); + } + + private void registerAndEnableHost() { + HostEntity host = service.registerHost("1265476542", "lab","owner", null, new HashMap()); + State state = host.getState(); + System.out.println("state:"+state); + boolean result = host.enable(); + System.out.println("result:"+result); + } + + @Test + public void testProvisioning() { + registerAndEnableZone(); + registerAndEnablePod(); + registerAndEnableCluster(); + registerAndEnableHost(); + } + + +} diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java index 747e2586fed..0dd55d1d325 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java @@ -51,6 +51,7 @@ public class ClusterScopeStoragePoolAllocator extends AbstractStoragePoolAllocat @Override protected List select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { + s_logger.debug("ClusterScopeStoragePoolAllocator looking for storage pool"); List suitablePools = new ArrayList(); long dcId = plan.getDataCenterId(); diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java index 91bc25c715d..02032ee4fbd 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/GarbageCollectingStoragePoolAllocator.java @@ -48,7 +48,7 @@ public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAl @Override public List select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { - + s_logger.debug("GarbageCollectingStoragePoolAllocator looking for storage pool"); if (!_storagePoolCleanupEnabled) { s_logger.debug("Storage pool cleanup is not enabled, so GarbageCollectingStoragePoolAllocator is being skipped."); return null; diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java index a8d5173cebe..7447d988a58 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java @@ -69,11 +69,12 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator { List suitablePools = new ArrayList(); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm"); - } + s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm"); + if (!dskCh.useLocalStorage()) { + return suitablePools; + } + // data disk and host identified from deploying vm (attach volume case) if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) { List hostPools = _poolHostDao.listByHostId(plan.getHostId()); diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java index c45f8a822a9..7c6c946765f 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java @@ -55,8 +55,9 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator { protected List select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { + s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool"); List suitablePools = new ArrayList(); - HypervisorType hypervisor = vmProfile.getHypervisorType(); + HypervisorType hypervisor = dskCh.getHypersorType(); if (hypervisor != null) { if (hypervisor != HypervisorType.KVM) { s_logger.debug("Only kvm supports zone wide storage"); diff --git a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationIntrospector.java b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationIntrospector.java index 998bfa084b3..6a26a6c5947 100644 --- a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationIntrospector.java +++ b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationIntrospector.java @@ -1,60 +1,60 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.framework.ws.jackson; - -import java.lang.reflect.AnnotatedElement; -import java.util.List; - -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.introspect.Annotated; -import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; - - -/** - * Adds introspectors for the annotations added specifically for CloudStack - * Web Services. - * - */ -public class CSJacksonAnnotationIntrospector extends NopAnnotationIntrospector { - - private static final long serialVersionUID = 5532727887216652602L; - - @Override - public Version version() { - return new Version(1, 7, 0, "abc", "org.apache.cloudstack", "cloudstack-framework-rest"); - } - - @Override - public Object findSerializer(Annotated a) { - AnnotatedElement ae = a.getAnnotated(); - Url an = ae.getAnnotation(Url.class); - if (an == null) { - return null; - } - - if (an.type() == String.class) { - return new UriSerializer(an); - } else if (an.type() == List.class){ - return new UrisSerializer(an); - } - - throw new UnsupportedOperationException("Unsupported type " + an.type()); - - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.framework.ws.jackson; + +import java.lang.reflect.AnnotatedElement; +import java.util.List; + +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.introspect.Annotated; +import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; + + +/** + * Adds introspectors for the annotations added specifically for CloudStack + * Web Services. + * + */ +public class CSJacksonAnnotationIntrospector extends NopAnnotationIntrospector { + + private static final long serialVersionUID = 5532727887216652602L; + + @Override + public Version version() { + return new Version(1, 7, 0, "abc", "org.apache.cloudstack", "cloudstack-framework-rest"); + } + + @Override + public Object findSerializer(Annotated a) { + AnnotatedElement ae = a.getAnnotated(); + Url an = ae.getAnnotation(Url.class); + if (an == null) { + return null; + } + + if (an.type() == String.class) { + return new UriSerializer(an); + } else if (an.type() == List.class){ + return new UrisSerializer(an); + } + + throw new UnsupportedOperationException("Unsupported type " + an.type()); + + } +} diff --git a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationModule.java b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationModule.java index 55debd9b7b2..d274b858c5f 100644 --- a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationModule.java +++ b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationModule.java @@ -1,47 +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 org.apache.cloudstack.framework.ws.jackson; - - -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.Module; - - -/** - * This module extends SimpleModle so that our annotations can be processed. - * - */ -public class CSJacksonAnnotationModule extends Module { - - @Override - public String getModuleName() { - return "CloudStackSupplementalModule"; - } - - @Override - public void setupModule(SetupContext ctx) { - ctx.appendAnnotationIntrospector(new CSJacksonAnnotationIntrospector()); - } - - @Override - public Version version() { - return new Version(1, 0, 0, "", "org.apache.cloudstack", "cloudstack-framework-rest"); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.framework.ws.jackson; + + +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.Module; + + +/** + * This module extends SimpleModle so that our annotations can be processed. + * + */ +public class CSJacksonAnnotationModule extends Module { + + @Override + public String getModuleName() { + return "CloudStackSupplementalModule"; + } + + @Override + public void setupModule(SetupContext ctx) { + ctx.appendAnnotationIntrospector(new CSJacksonAnnotationIntrospector()); + } + + @Override + public Version version() { + return new Version(1, 0, 0, "", "org.apache.cloudstack", "cloudstack-framework-rest"); + } + +} diff --git a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UriSerializer.java b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UriSerializer.java index 074d60f8a98..07951496419 100644 --- a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UriSerializer.java +++ b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UriSerializer.java @@ -1,58 +1,58 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.framework.ws.jackson; - -import java.io.IOException; - -import javax.ws.rs.core.UriBuilder; - -import org.apache.cxf.jaxrs.impl.tl.ThreadLocalUriInfo; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -public class UriSerializer extends JsonSerializer { - - Url _annotation; - - public UriSerializer(Url annotation) { - _annotation = annotation; - } - - protected UriSerializer() { - } - - @Override - public void serialize(String id, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { - jgen.writeStartObject(); - jgen.writeStringField("id", id); - jgen.writeFieldName("uri"); - jgen.writeString(buildUri(_annotation.clazz(), _annotation.method(), id)); - jgen.writeEndObject(); - } - - protected String buildUri(Class clazz, String method, String id) { - ThreadLocalUriInfo uriInfo = new ThreadLocalUriInfo(); - UriBuilder ub = uriInfo.getAbsolutePathBuilder().path(clazz, method); - ub.build(id); - return ub.toString(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.framework.ws.jackson; + +import java.io.IOException; + +import javax.ws.rs.core.UriBuilder; + +import org.apache.cxf.jaxrs.impl.tl.ThreadLocalUriInfo; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class UriSerializer extends JsonSerializer { + + Url _annotation; + + public UriSerializer(Url annotation) { + _annotation = annotation; + } + + protected UriSerializer() { + } + + @Override + public void serialize(String id, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeStartObject(); + jgen.writeStringField("id", id); + jgen.writeFieldName("uri"); + jgen.writeString(buildUri(_annotation.clazz(), _annotation.method(), id)); + jgen.writeEndObject(); + } + + protected String buildUri(Class clazz, String method, String id) { + ThreadLocalUriInfo uriInfo = new ThreadLocalUriInfo(); + UriBuilder ub = uriInfo.getAbsolutePathBuilder().path(clazz, method); + ub.build(id); + return ub.toString(); + } +} diff --git a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UrisSerializer.java b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UrisSerializer.java index 8b622123e3f..6ab3ced3cd4 100644 --- a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UrisSerializer.java +++ b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/UrisSerializer.java @@ -1,71 +1,71 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.framework.ws.jackson; - -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - -import javax.ws.rs.core.UriBuilder; - -import org.apache.cxf.jaxrs.impl.tl.ThreadLocalUriInfo; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - - -/** - * Serializer for a list of ids. - * - */ -public class UrisSerializer extends JsonSerializer> { - Url _annotation; - - public UrisSerializer(Url annotation) { - _annotation = annotation; - } - - protected UrisSerializer() { - } - - @Override - public void serialize(List lst, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { - Iterator it = lst.iterator(); - jgen.writeStartObject(); - while (it.hasNext()) { - Object id = it.next(); - jgen.writeStartObject(); - jgen.writeFieldName("id"); - jgen.writeObject(id); - jgen.writeFieldName("uri"); - jgen.writeString(buildUri(_annotation.clazz(), _annotation.method(), id)); - jgen.writeEndObject(); - } - jgen.writeEndObject(); - } - - protected String buildUri(Class clazz, String method, Object id) { - ThreadLocalUriInfo uriInfo = new ThreadLocalUriInfo(); - UriBuilder ub = uriInfo.getAbsolutePathBuilder().path(clazz, method); - ub.build(id); - return ub.toString(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.framework.ws.jackson; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import javax.ws.rs.core.UriBuilder; + +import org.apache.cxf.jaxrs.impl.tl.ThreadLocalUriInfo; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + + +/** + * Serializer for a list of ids. + * + */ +public class UrisSerializer extends JsonSerializer> { + Url _annotation; + + public UrisSerializer(Url annotation) { + _annotation = annotation; + } + + protected UrisSerializer() { + } + + @Override + public void serialize(List lst, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + Iterator it = lst.iterator(); + jgen.writeStartObject(); + while (it.hasNext()) { + Object id = it.next(); + jgen.writeStartObject(); + jgen.writeFieldName("id"); + jgen.writeObject(id); + jgen.writeFieldName("uri"); + jgen.writeString(buildUri(_annotation.clazz(), _annotation.method(), id)); + jgen.writeEndObject(); + } + jgen.writeEndObject(); + } + + protected String buildUri(Class clazz, String method, Object id) { + ThreadLocalUriInfo uriInfo = new ThreadLocalUriInfo(); + UriBuilder ub = uriInfo.getAbsolutePathBuilder().path(clazz, method); + ub.build(id); + return ub.toString(); + } +} diff --git a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/Url.java b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/Url.java index 7094fb07f84..9f9537c1cf3 100644 --- a/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/Url.java +++ b/framework/rest/src/org/apache/cloudstack/framework/ws/jackson/Url.java @@ -1,53 +1,53 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cloudstack.framework.ws.jackson; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Url can be placed onto a method to construct an URL from the returned - * results. - * - * This annotation is supplemental to JAX-RS 2.0's annotations. JAX-RS 2.0 - * annotations do not include a way to construct an URL. Of - * course, this only works with how CloudStack works. - * - */ -@Target({FIELD, METHOD}) -@Retention(RUNTIME) -public @interface Url { - /** - * @return the class that the path should belong to. - */ - Class clazz() default Object.class; - - /** - * @return the name of the method that the path should call back to. - */ - String method(); - - String name() default ""; - - Class type() default String.class; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.framework.ws.jackson; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Url can be placed onto a method to construct an URL from the returned + * results. + * + * This annotation is supplemental to JAX-RS 2.0's annotations. JAX-RS 2.0 + * annotations do not include a way to construct an URL. Of + * course, this only works with how CloudStack works. + * + */ +@Target({FIELD, METHOD}) +@Retention(RUNTIME) +public @interface Url { + /** + * @return the class that the path should belong to. + */ + Class clazz() default Object.class; + + /** + * @return the name of the method that the path should call back to. + */ + String method(); + + String name() default ""; + + Class type() default String.class; +} diff --git a/framework/rest/test/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationTest.java b/framework/rest/test/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationTest.java index 8869b218402..75e39046420 100644 --- a/framework/rest/test/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationTest.java +++ b/framework/rest/test/org/apache/cloudstack/framework/ws/jackson/CSJacksonAnnotationTest.java @@ -14,8 +14,8 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.cloudstack.framework.ws.jackson; - +package org.apache.cloudstack.framework.ws.jackson; + import java.io.IOException; import java.io.StringWriter; import java.util.ArrayList; @@ -35,84 +35,84 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule.Priority; - -public class CSJacksonAnnotationTest { - - @Before - public void setUp() throws Exception { - } - - @Test @Ignore - public void test() { - ObjectMapper mapper = new ObjectMapper(); - JaxbAnnotationModule jaxbModule = new JaxbAnnotationModule(); - jaxbModule.setPriority(Priority.SECONDARY); - mapper.registerModule(jaxbModule); - mapper.registerModule(new CSJacksonAnnotationModule()); - - StringWriter writer = new StringWriter(); - - TestVO vo = new TestVO(1000, "name"); - vo.names = new ArrayList(); - vo.names.add("name1"); - vo.names.add("name2"); - vo.values = new HashMap(); - vo.values.put("key1", 1000l); - vo.values.put("key2", 2000l); - vo.vo2.name = "testvoname2"; - vo.pods="abcde"; - - try { - mapper.writeValue(writer, vo); - } catch (JsonGenerationException e) { - e.printStackTrace(); - } catch (JsonMappingException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - System.out.print(writer.getBuffer().toString()); - - } - - @XmlRootElement(name="xml-test2") - public class Test2VO { - public String name; - } - - @XmlRootElement(name="abc") - public class TestVO { - public int id; - - public Map values; - - public String name; - - - public List names; - - public String pods; - - - @XmlElement(name="test2") - public Test2VO vo2 = new Test2VO(); - - public TestVO(int id, String name) { - this.id = id; - this.name = name; - } - - @Url(clazz=TestVO.class, method="getName") - public String getName() { - return name; - } - - @Url(clazz=TestVO.class, method="getNames", type=List.class) - public List getNames() { - return names; - } - - } - -} + +public class CSJacksonAnnotationTest { + + @Before + public void setUp() throws Exception { + } + + @Test @Ignore + public void test() { + ObjectMapper mapper = new ObjectMapper(); + JaxbAnnotationModule jaxbModule = new JaxbAnnotationModule(); + jaxbModule.setPriority(Priority.SECONDARY); + mapper.registerModule(jaxbModule); + mapper.registerModule(new CSJacksonAnnotationModule()); + + StringWriter writer = new StringWriter(); + + TestVO vo = new TestVO(1000, "name"); + vo.names = new ArrayList(); + vo.names.add("name1"); + vo.names.add("name2"); + vo.values = new HashMap(); + vo.values.put("key1", 1000l); + vo.values.put("key2", 2000l); + vo.vo2.name = "testvoname2"; + vo.pods="abcde"; + + try { + mapper.writeValue(writer, vo); + } catch (JsonGenerationException e) { + e.printStackTrace(); + } catch (JsonMappingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.print(writer.getBuffer().toString()); + + } + + @XmlRootElement(name="xml-test2") + public class Test2VO { + public String name; + } + + @XmlRootElement(name="abc") + public class TestVO { + public int id; + + public Map values; + + public String name; + + + public List names; + + public String pods; + + + @XmlElement(name="test2") + public Test2VO vo2 = new Test2VO(); + + public TestVO(int id, String name) { + this.id = id; + this.name = name; + } + + @Url(clazz=TestVO.class, method="getName") + public String getName() { + return name; + } + + @Url(clazz=TestVO.class, method="getNames", type=List.class) + public List getNames() { + return names; + } + + } + +} diff --git a/packaging/centos63/cloud-agent.rc b/packaging/centos63/cloud-agent.rc index 6d534732528..b3784882975 100755 --- a/packaging/centos63/cloud-agent.rc +++ b/packaging/centos63/cloud-agent.rc @@ -67,7 +67,8 @@ export CLASSPATH="/usr/share/java/commons-daemon.jar:/usr/share/java/jna.jar:$AC start() { echo -n $"Starting $PROGNAME: " if hostname --fqdn >/dev/null 2>&1 ; then - $JSVC -cp "$CLASSPATH" -pidfile "$PIDFILE" -errfile SYSLOG $CLASS + $JSVC -cp "$CLASSPATH" -pidfile "$PIDFILE" \ + -errfile $LOGDIR/cloudstack-agent.err -outfile $LOGDIR/cloudstack-agent.out $CLASS RETVAL=$? echo else diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec index 7d6e63880b1..9ce46c97c42 100644 --- a/packaging/centos63/cloud.spec +++ b/packaging/centos63/cloud.spec @@ -153,13 +153,9 @@ Provides: cloud-aws-api %description awsapi Apache Cloudstack AWS API compatibility wrapper -#%package docs -#Summary: Apache CloudStack documentation -#%description docs -#Apache CloudStack documentations - %prep echo Doing CloudStack build + %setup -q -n %{name}-%{_maventag} %build @@ -169,10 +165,10 @@ echo VERSION=%{_maventag} >> build/replace.properties echo PACKAGE=%{name} >> build/replace.properties if [ "%{_ossnoss}" == "NONOSS" -o "%{_ossnoss}" == "nonoss" ] ; then - echo "Packaging nonoss components" + echo "Executing mvn packaging for NONOSS ..." mvn -Pawsapi,systemvm -Dnonoss package else - echo "Packaging oss components" + echo "Executing mvn packaging for OSS ..." mvn -Pawsapi package -Dsystemvm fi @@ -236,7 +232,7 @@ rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/cl rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/vms for name in db.properties log4j-cloud.xml tomcat6-nonssl.conf tomcat6-ssl.conf server-ssl.xml server-nonssl.xml \ - catalina.policy catalina.properties db-enc.properties classpath.conf tomcat-users.xml web.xml environment.properties ; do + catalina.policy catalina.properties classpath.conf tomcat-users.xml web.xml environment.properties ; do mv ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/$name \ ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/$name done @@ -248,8 +244,7 @@ mv ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classe ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost/client install python/bindir/cloud-external-ipallocator.py ${RPM_BUILD_ROOT}%{_bindir}/%{name}-external-ipallocator.py -install -D client/target/pythonlibs/jasypt-1.9.0.jar ${RPM_BUILD_ROOT}%{_javadir}/jasypt-1.9.0.jar -install -D client/target/pythonlibs/jasypt-1.8.jar ${RPM_BUILD_ROOT}%{_javadir}/jasypt-1.8.jar +install -D client/target/pythonlibs/jasypt-1.9.0.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/jasypt-1.9.0.jar install -D packaging/centos63/cloud-ipallocator.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-ipallocator install -D packaging/centos63/cloud-management.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-management @@ -313,9 +308,27 @@ rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classe rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/NOTICE.txt rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/services.xml +#License files from whisker +install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-management-%{version}/NOTICE +install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-management-%{version}/LICENSE +install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-common-%{version}/NOTICE +install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-common-%{version}/LICENSE +install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-agent-%{version}/NOTICE +install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-agent-%{version}/LICENSE +install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-usage-%{version}/NOTICE +install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-usage-%{version}/LICENSE +install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-awsapi-%{version}/NOTICE +install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-awsapi-%{version}/LICENSE +install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-cli-%{version}/NOTICE +install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-cli-%{version}/LICENSE + %clean [ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT} +%pre awsapi +id cloud > /dev/null 2>&1 || /usr/sbin/useradd -M -c "CloudStack unprivileged user" \ + -r -s /bin/sh -d %{_localstatedir}/cloudstack/management cloud|| true + %preun management /sbin/service cloudstack-management stop || true if [ "$1" == "0" ] ; then @@ -363,9 +376,12 @@ if getent passwd cloud | grep -q /var/lib/cloud; then fi # if saved configs from upgrade exist, copy them over -if [ -d "%{_sysconfdir}/cloud.rpmsave/management" ]; then +if [ -f "%{_sysconfdir}/cloud.rpmsave/management/db.properties" ]; then + mv %{_sysconfdir}/%{name}/management/db.properties %{_sysconfdir}/%{name}/management/db.properties.rpmnew cp -p %{_sysconfdir}/cloud.rpmsave/management/db.properties %{_sysconfdir}/%{name}/management cp -p %{_sysconfdir}/cloud.rpmsave/management/key %{_sysconfdir}/%{name}/management + # make sure we only do this on the first install of this RPM, don't want to overwrite on a reinstall + mv %{_sysconfdir}/cloud.rpmsave/management/db.properties %{_sysconfdir}/cloud.rpmsave/management/db.properties.rpmsave fi # Choose server.xml and tomcat.conf links based on old config, if exists @@ -393,6 +409,13 @@ if [ -L $oldtomcatconf ] ; then fi fi +%preun agent +/sbin/service cloudstack-agent stop || true +if [ "$1" == "0" ] ; then + /sbin/chkconfig --del cloudstack-agent > /dev/null 2>&1 || true + /sbin/service cloudstack-agent stop > /dev/null 2>&1 || true +fi + %pre agent # save old configs if they exist (for upgrade). Otherwise we may lose them @@ -402,11 +425,17 @@ if [ -d "%{_sysconfdir}/cloud" ] ; then fi %post agent +if [ "$1" == "1" ] ; then + /sbin/chkconfig --add cloudstack-agent > /dev/null 2>&1 || true + /sbin/chkconfig --level 345 cloudstack-agent on > /dev/null 2>&1 || true +fi # if saved configs from upgrade exist, copy them over if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then mv %{_sysconfdir}/%{name}/agent/agent.properties %{_sysconfdir}/%{name}/agent/agent.properties.rpmnew cp -p %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/%{name}/agent + # make sure we only do this on the first install of this RPM, don't want to overwrite on a reinstall + mv %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/cloud.rpmsave/agent/agent.properties.rpmsave fi #%post awsapi @@ -438,7 +467,6 @@ fi %config(noreplace) %{_sysconfdir}/%{name}/management/catalina.policy %config(noreplace) %{_sysconfdir}/%{name}/management/catalina.properties %config(noreplace) %{_sysconfdir}/%{name}/management/classpath.conf -%config(noreplace) %{_sysconfdir}/%{name}/management/db-enc.properties %config(noreplace) %{_sysconfdir}/%{name}/management/server-nonssl.xml %config(noreplace) %{_sysconfdir}/%{name}/management/server-ssl.xml %config(noreplace) %{_sysconfdir}/%{name}/management/tomcat-users.xml @@ -470,13 +498,11 @@ fi %{_datadir}/%{name}-management/setup/db/*.sql %{_datadir}/%{name}-management/setup/*.sh %{_datadir}/%{name}-management/setup/server-setup.xml -%{_javadir}/jasypt-1.9.0.jar -%{_javadir}/jasypt-1.8.jar %attr(0755,root,root) %{_bindir}/%{name}-external-ipallocator.py %attr(0755,root,root) %{_initrddir}/%{name}-ipallocator %dir %attr(0770,root,root) %{_localstatedir}/log/%{name}/ipallocator -%doc LICENSE -%doc NOTICE +%{_defaultdocdir}/%{name}-management-%{version}/LICENSE +%{_defaultdocdir}/%{name}-management-%{version}/NOTICE %files agent %attr(0755,root,root) %{_bindir}/%{name}-setup-agent @@ -486,8 +512,8 @@ fi %dir %{_localstatedir}/log/%{name}/agent %attr(0644,root,root) %{_datadir}/%{name}-agent/lib/*.jar %dir %{_datadir}/%{name}-agent/plugins -%doc LICENSE -%doc NOTICE +%{_defaultdocdir}/%{name}-agent-%{version}/LICENSE +%{_defaultdocdir}/%{name}-agent-%{version}/NOTICE %files common %dir %attr(0755,root,root) %{_libdir}/python2.6/site-packages/cloudutils @@ -498,8 +524,9 @@ fi %attr(0644,root,root) %{_libdir}/python2.6/site-packages/cloud_utils.py %attr(0644,root,root) %{_libdir}/python2.6/site-packages/cloud_utils.pyc %attr(0644,root,root) %{_libdir}/python2.6/site-packages/cloudutils/* -%doc LICENSE -%doc NOTICE +%attr(0644, root, root) %{_datadir}/%{name}-common/lib/jasypt-1.9.0.jar +%{_defaultdocdir}/%{name}-common-%{version}/LICENSE +%{_defaultdocdir}/%{name}-common-%{version}/NOTICE %files usage %attr(0755,root,root) %{_sysconfdir}/init.d/%{name}-usage @@ -507,19 +534,15 @@ fi %attr(0644,root,root) %{_datadir}/%{name}-usage/lib/*.jar %dir /var/log/%{name}/usage %dir %{_sysconfdir}/%{name}/usage -%doc LICENSE -%doc NOTICE +%{_defaultdocdir}/%{name}-usage-%{version}/LICENSE +%{_defaultdocdir}/%{name}-usage-%{version}/NOTICE %files cli %attr(0644,root,root) %{_libdir}/python2.6/site-packages/cloudapis.py %attr(0644,root,root) %{_libdir}/python2.6/site-packages/cloudtool/__init__.py %attr(0644,root,root) %{_libdir}/python2.6/site-packages/cloudtool/utils.py -%doc LICENSE -%doc NOTICE - -#%files docs -#%doc LICENSE -#%doc NOTICE +%{_defaultdocdir}/%{name}-cli-%{version}/LICENSE +%{_defaultdocdir}/%{name}-cli-%{version}/NOTICE %files awsapi %defattr(0644,cloud,cloud,0755) @@ -527,8 +550,8 @@ fi %attr(0644,root,root) %{_datadir}/%{name}-bridge/setup/* %attr(0755,root,root) %{_bindir}/cloudstack-aws-api-register %attr(0755,root,root) %{_bindir}/cloudstack-setup-bridge -%doc LICENSE -%doc NOTICE +%{_defaultdocdir}/%{name}-awsapi-%{version}/LICENSE +%{_defaultdocdir}/%{name}-awsapi-%{version}/NOTICE %changelog diff --git a/packaging/centos63/package.sh b/packaging/centos63/package.sh index 802cf7e5e0b..d9d5b1c81f2 100755 --- a/packaging/centos63/package.sh +++ b/packaging/centos63/package.sh @@ -20,126 +20,134 @@ function usage() { echo "" echo "usage: ./package.sh [-p|--pack] [-h|--help] [ARGS]" echo "" - echo "oss|OSS To package oss components only" - echo "nonoss|NONOSS To package non-oss and oss components" + echo "The commonly used Arguments are:" + echo "oss|OSS To package OSS specific" + echo "nonoss|NONOSS To package NONOSS specific" echo "" echo "Examples: ./package.sh -p|--pack oss|OSS" echo " ./package.sh -p|--pack nonoss|NONOSS" echo " ./package.sh (Default OSS)" - echo "" exit 1 } function defaultPackaging() { - CWD=`pwd` - RPMDIR=$CWD/../../dist/rpmbuild - PACK_PROJECT=cloudstack - VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep '^[0-9]\.'` +CWD=`pwd` +RPMDIR=$CWD/../../dist/rpmbuild +PACK_PROJECT=cloudstack - if echo $VERSION | grep SNAPSHOT ; then - REALVER=`echo $VERSION | cut -d '-' -f 1` - DEFVER="-D_ver $REALVER" - DEFPRE="-D_prerelease 1" - DEFREL="-D_rel SNAPSHOT" - else - DEFVER="-D_ver $REALVER" - DEFPRE= - DEFREL= - fi - mkdir -p $RPMDIR/SPECS - mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION +VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep '^[0-9]\.'` +if echo $VERSION | grep SNAPSHOT ; then + REALVER=`echo $VERSION | cut -d '-' -f 1` + DEFVER="-D_ver $REALVER" + DEFPRE="-D_prerelease 1" + DEFREL="-D_rel SNAPSHOT" +else + DEFVER="-D_ver $REALVER" + DEFPRE= + DEFREL= +fi - (cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x) - (cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION) +mkdir -p $RPMDIR/SPECS +mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION - cp cloud.spec $RPMDIR/SPECS +(cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x ) +(cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION) - (cd $RPMDIR; rpmbuild -ba SPECS/cloud.spec "-D_topdir $RPMDIR" "$DEFVER" "$DEFREL" "$DEFPRE") +cp cloud.spec $RPMDIR/SPECS - exit +(cd $RPMDIR; rpmbuild -ba SPECS/cloud.spec "-D_topdir $RPMDIR" "$DEFVER" "$DEFREL" "$DEFPRE") + +exit } function packaging() { - CWD=`pwd` - RPMDIR=$CWD/../../dist/rpmbuild - PACK_PROJECT=cloudstack - DEFOSSNOSS="-D_ossnoss $packageval" - VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep '^[0-9]\.'` + +CWD=`pwd` +RPMDIR=$CWD/../../dist/rpmbuild +PACK_PROJECT=cloudstack +DEFOSSNOSS="-D_ossnoss $packageval" - if echo $VERSION | grep SNAPSHOT ; then - REALVER=`echo $VERSION | cut -d '-' -f 1` - DEFVER="-D_ver $REALVER" - DEFPRE="-D_prerelease 1" - DEFREL="-D_rel SNAPSHOT" - else - DEFVER="-D_ver $REALVER" - DEFPRE= - DEFREL= - fi - mkdir -p $RPMDIR/SPECS - mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION +VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep '^[0-9]\.'` +if echo $VERSION | grep SNAPSHOT ; then + REALVER=`echo $VERSION | cut -d '-' -f 1` + DEFVER="-D_ver $REALVER" + DEFPRE="-D_prerelease 1" + DEFREL="-D_rel SNAPSHOT" +else + DEFVER="-D_ver $REALVER" + DEFPRE= + DEFREL= +fi - (cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x ) - (cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION) +mkdir -p $RPMDIR/SPECS +mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION - cp cloud.spec $RPMDIR/SPECS - (cd $RPMDIR; rpmbuild -ba SPECS/cloud.spec "-D_topdir $RPMDIR" "$DEFVER" "$DEFREL" "$DEFPRE" "$DEFOSSNOSS") +(cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x ) +(cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION) - exit +cp cloud.spec $RPMDIR/SPECS + +(cd $RPMDIR; rpmbuild -ba SPECS/cloud.spec "-D_topdir $RPMDIR" "$DEFVER" "$DEFREL" "$DEFPRE" "$DEFOSSNOSS") + +exit } if [ $# -lt 1 ] ; then - defaultPackaging + + defaultPackaging + elif [ $# -gt 0 ] ; then - SHORTOPTS="hp:" - LONGOPTS="help,pack:" - ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@" ) - eval set -- "$ARGS" + SHORTOPTS="hp:" + LONGOPTS="help,pack:" + + ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@" ) + eval set -- "$ARGS" + + while [ $# -gt 0 ] ; do + case "$1" in + -h | --help) + usage + exit 0 + ;; + -p | --pack) + echo "Doing CloudStack Packaging ....." + packageval=$2 + if [ "$packageval" == "oss" -o "$packageval" == "OSS" ] ; then + defaultPackaging + elif [ "$packageval" == "nonoss" -o "$packageval" == "NONOSS" ] ; then + packaging + else + echo "Error: Incorrect value provided in package.sh script, Please see help ./package.sh --help|-h for more details." + exit 1 + fi + ;; + -) + echo "Unrecognized option..." + usage + exit 1 + ;; + --) + echo "Unrecognized option..." + usage + exit 1 + ;; + -*) + echo "Unrecognized option..." + usage + exit 1 + ;; + *) + shift + break + ;; + esac + done - while [ $# -gt 0 ] ; do - case "$1" in - -h | --help) - usage - exit 0 - ;; - -p | --pack) - echo "Packaging Apache CloudStack" - packageval=$2 - if [ "$packageval" == "oss" -o "$packageval" == "OSS" ] ; then - defaultPackaging - elif [ "$packageval" == "nonoss" -o "$packageval" == "NONOSS" ] ; then - packaging - else - echo "Error: Incorrect usage. See help ./package.sh --help|-h." - exit 1 - fi - ;; - -) - echo "Unrecognized option." - usage - exit 1 - ;; - --) - echo "Unrecognized option." - usage - exit 1 - ;; - -*) - echo "Unrecognized option." - usage - exit 1 - ;; - *) - shift - break - ;; - esac - done else - echo "Incorrect choice. Nothing to do." >&2 - echo "./package.sh --help for details" + echo "Incorrect choice. Nothing to do." >&2 + echo "Please, execute ./package.sh --help for more help" fi diff --git a/packaging/debian/init/cloud-management b/packaging/debian/init/cloud-management index 69a0428db21..1e008312e09 100755 --- a/packaging/debian/init/cloud-management +++ b/packaging/debian/init/cloud-management @@ -19,7 +19,7 @@ # specific language governing permissions and limitations # under the License. ### BEGIN INIT INFO -# Provides: tomcat-vmops +# Provides: cloudstack-management # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Should-Start: $named @@ -34,7 +34,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin NAME=cloudstack-management DESC="CloudStack-specific Tomcat servlet engine" DAEMON=/usr/bin/jsvc -CATALINA_HOME=/usr/share/cloudstack/management +CATALINA_HOME=/usr/share/cloudstack-management DEFAULT=/etc/cloudstack/management/tomcat6.conf JVM_TMP=/tmp/$NAME-temp @@ -65,7 +65,7 @@ TOMCAT6_USER=tomcat6 # The first existing directory is used for JAVA_HOME (if JAVA_HOME is not # defined in $DEFAULT) -JDK_DIRS="/usr/lib/jvm/java-1.6.0-openjdk-amd64/ /usr/lib/jvm/java-1.6.0-openjdk-i386/ /usr/lib/jvm/java-1.6.0-openjdk/ /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun" +JDK_DIRS="/usr/lib/jvm/java-7-openjdk-amd64 /usr/lib/jvm/java-7-openjdk-i386 /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64 /usr/lib/jvm/java-6-sun" # Look for the right JVM to use for jdir in $JDK_DIRS; do @@ -76,7 +76,7 @@ done export JAVA_HOME # Directory for per-instance configuration files and webapps -CATALINA_BASE=/usr/share/cloudstack/management +CATALINA_BASE=/usr/share/cloudstack-management # Use the Java security manager? (yes/no) TOMCAT6_SECURITY=no @@ -125,8 +125,7 @@ fi # Define other required variables CATALINA_PID="/var/run/$NAME.pid" BOOTSTRAP_CLASS=org.apache.catalina.startup.Bootstrap -JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar" -JSVC_CLASSPATH=$CLASSPATH:$JSVC_CLASSPATH +JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar:/etc/cloudstack/management" # Look for Java Secure Sockets Extension (JSSE) JARs if [ -z "${JSSE_HOME}" -a -r "${JAVA_HOME}/jre/lib/jsse.jar" ]; then diff --git a/packaging/debian/replace.properties b/packaging/debian/replace.properties index 8705c78a8f7..8c852060c02 100644 --- a/packaging/debian/replace.properties +++ b/packaging/debian/replace.properties @@ -34,7 +34,7 @@ AWSAPILOG=/var/log/cloudstack/awsapi/awsapi.log BINDIR=/usr/bin COMMONLIBDIR=/usr/share/cloudstack-common CONFIGUREVARS= -DEPSCLASSPATH= +DEPSCLASSPATH=/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar DOCDIR= IPALOCATORLOG=/var/log/cloudstack/management/ipallocator.log JAVADIR=/usr/share/cloudstack-management/webapps/client/WEB-INF/lib diff --git a/patches/systemvm/debian/config/root/edithosts.sh b/patches/systemvm/debian/config/root/edithosts.sh index 9f21f206172..1f98fbf96ae 100755 --- a/patches/systemvm/debian/config/root/edithosts.sh +++ b/patches/systemvm/debian/config/root/edithosts.sh @@ -200,7 +200,8 @@ fi pid=$(pidof dnsmasq) if [ "$pid" != "" ] then - service dnsmasq restart + #service dnsmasq restart + kill -HUP $pid else if [ $no_redundant -eq 1 ] then diff --git a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java index 77484f0f7e7..ce7eb498be9 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java @@ -47,6 +47,9 @@ public class ApiDiscoveryResponse extends BaseResponse { @SerializedName(ApiConstants.RESPONSE) @Param(description="api response fields", responseObject = ApiResponseResponse.class) private Set apiResponse; + @SerializedName(ApiConstants.TYPE) @Param(description="response field type") + private String type; + public ApiDiscoveryResponse(){ params = new HashSet(); apiResponse = new HashSet(); @@ -81,6 +84,7 @@ public class ApiDiscoveryResponse extends BaseResponse { this.isAsync = isAsync; } + public boolean getAsync() { return isAsync; } diff --git a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiResponseResponse.java b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiResponseResponse.java index b96295e1290..1433879a6ce 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiResponseResponse.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiResponseResponse.java @@ -16,11 +16,14 @@ // under the License. package org.apache.cloudstack.api.response; -import org.apache.cloudstack.api.ApiConstants; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; +import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; +import java.util.HashSet; +import java.util.Set; + public class ApiResponseResponse extends BaseResponse { @SerializedName(ApiConstants.NAME) @Param(description="the name of the api response field") private String name; @@ -31,6 +34,9 @@ public class ApiResponseResponse extends BaseResponse { @SerializedName(ApiConstants.TYPE) @Param(description="response field type") private String type; + @SerializedName(ApiConstants.RESPONSE) @Param(description="api response fields") + private Set apiResponse; + public void setName(String name) { this.name = name; } @@ -42,4 +48,11 @@ public class ApiResponseResponse extends BaseResponse { public void setType(String type) { this.type = type; } + + public void addApiResponse(ApiResponseResponse childApiResponse) { + if(this.apiResponse == null) { + this.apiResponse = new HashSet(); + } + this.apiResponse.add(childApiResponse); + } } diff --git a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java index b3714883964..2d7dbd18671 100755 --- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java @@ -16,25 +16,14 @@ // under the License. package org.apache.cloudstack.discovery; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.PostConstruct; -import javax.ejb.Local; -import javax.inject.Inject; - +import com.cloud.serializer.Param; +import com.cloud.user.User; +import com.cloud.utils.ReflectUtil; +import com.cloud.utils.StringUtils; +import com.cloud.utils.component.PluggableService; +import com.google.gson.annotations.SerializedName; import org.apache.cloudstack.acl.APIChecker; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.BaseAsyncCmd; -import org.apache.cloudstack.api.BaseAsyncCreateCmd; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.BaseResponse; -import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.*; import org.apache.cloudstack.api.command.user.discovery.ListApisCmd; import org.apache.cloudstack.api.response.ApiDiscoveryResponse; import org.apache.cloudstack.api.response.ApiParameterResponse; @@ -43,12 +32,11 @@ import org.apache.cloudstack.api.response.ListResponse; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; -import com.cloud.serializer.Param; -import com.cloud.user.User; -import com.cloud.utils.ReflectUtil; -import com.cloud.utils.StringUtils; -import com.cloud.utils.component.PluggableService; -import com.google.gson.annotations.SerializedName; +import javax.annotation.PostConstruct; +import javax.ejb.Local; +import javax.inject.Inject; +import java.lang.reflect.Field; +import java.util.*; @Component @Local(value = ApiDiscoveryService.class) @@ -69,9 +57,9 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { long startTime = System.nanoTime(); s_apiNameDiscoveryResponseMap = new HashMap(); Set> cmdClasses = new HashSet>(); - for(PluggableService service: _services) { + for(PluggableService service: _services) { s_logger.debug(String.format("getting api commands of service: %s", service.getClass().getName())); - cmdClasses.addAll(service.getCommands()); + cmdClasses.addAll(service.getCommands()); } cmdClasses.addAll(this.getCommands()); cacheResponseMap(cmdClasses); @@ -80,72 +68,39 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { } } - protected void cacheResponseMap(Set> cmdClasses) { + protected Map> cacheResponseMap(Set> cmdClasses) { Map> responseApiNameListMap = new HashMap>(); for(Class cmdClass: cmdClasses) { APICommand apiCmdAnnotation = cmdClass.getAnnotation(APICommand.class); - if (apiCmdAnnotation == null) + if (apiCmdAnnotation == null) { apiCmdAnnotation = cmdClass.getSuperclass().getAnnotation(APICommand.class); + } if (apiCmdAnnotation == null || !apiCmdAnnotation.includeInApiDoc() - || apiCmdAnnotation.name().isEmpty()) + || apiCmdAnnotation.name().isEmpty()) { continue; + } String apiName = apiCmdAnnotation.name(); + ApiDiscoveryResponse response = getCmdRequestMap(cmdClass, apiCmdAnnotation); + String responseName = apiCmdAnnotation.responseObject().getName(); if (!responseName.contains("SuccessResponse")) { - if (!responseApiNameListMap.containsKey(responseName)) + if (!responseApiNameListMap.containsKey(responseName)) { responseApiNameListMap.put(responseName, new ArrayList()); + } responseApiNameListMap.get(responseName).add(apiName); } - ApiDiscoveryResponse response = new ApiDiscoveryResponse(); - response.setName(apiName); - response.setDescription(apiCmdAnnotation.description()); - if (!apiCmdAnnotation.since().isEmpty()) - response.setSince(apiCmdAnnotation.since()); response.setRelated(responseName); + Field[] responseFields = apiCmdAnnotation.responseObject().getDeclaredFields(); for(Field responseField: responseFields) { - SerializedName serializedName = responseField.getAnnotation(SerializedName.class); - if(serializedName != null) { - ApiResponseResponse responseResponse = new ApiResponseResponse(); - responseResponse.setName(serializedName.value()); - Param param = responseField.getAnnotation(Param.class); - if (param != null) - responseResponse.setDescription(param.description()); - responseResponse.setType(responseField.getType().getSimpleName().toLowerCase()); - response.addApiResponse(responseResponse); - } + ApiResponseResponse responseResponse = getFieldResponseMap(responseField); + response.addApiResponse(responseResponse); } - Set fields = ReflectUtil.getAllFieldsForClass(cmdClass, - new Class[]{BaseCmd.class, BaseAsyncCmd.class, BaseAsyncCreateCmd.class}); - - boolean isAsync = ReflectUtil.isCmdClassAsync(cmdClass, - new Class[] {BaseAsyncCmd.class, BaseAsyncCreateCmd.class}); - - response.setAsync(isAsync); - - for(Field field: fields) { - Parameter parameterAnnotation = field.getAnnotation(Parameter.class); - if (parameterAnnotation != null - && parameterAnnotation.expose() - && parameterAnnotation.includeInApiDoc()) { - - ApiParameterResponse paramResponse = new ApiParameterResponse(); - paramResponse.setName(parameterAnnotation.name()); - paramResponse.setDescription(parameterAnnotation.description()); - paramResponse.setType(parameterAnnotation.type().toString().toLowerCase()); - paramResponse.setLength(parameterAnnotation.length()); - paramResponse.setRequired(parameterAnnotation.required()); - if (!parameterAnnotation.since().isEmpty()) - paramResponse.setSince(parameterAnnotation.since()); - paramResponse.setRelated(parameterAnnotation.entityType()[0].getName()); - response.addParam(paramResponse); - } - } response.setObjectName("api"); s_apiNameDiscoveryResponseMap.put(apiName, response); } @@ -173,6 +128,76 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { } s_apiNameDiscoveryResponseMap.put(apiName, response); } + return responseApiNameListMap; + } + + private ApiResponseResponse getFieldResponseMap(Field responseField) { + ApiResponseResponse responseResponse = new ApiResponseResponse(); + SerializedName serializedName = responseField.getAnnotation(SerializedName.class); + Param param = responseField.getAnnotation(Param.class); + if (serializedName != null && param != null) { + responseResponse.setName(serializedName.value()); + responseResponse.setDescription(param.description()); + responseResponse.setType(responseField.getType().getSimpleName().toLowerCase()); + //If response is not of primitive type - we have a nested entity + Class fieldClass = param.responseObject(); + if (fieldClass != null) { + Class superClass = fieldClass.getSuperclass(); + if (superClass != null) { + String superName = superClass.getName(); + if (superName.equals(BaseResponse.class.getName())) { + Field[] fields = fieldClass.getDeclaredFields(); + for (Field field : fields) { + ApiResponseResponse innerResponse = getFieldResponseMap(field); + if (innerResponse != null) { + responseResponse.addApiResponse(innerResponse); + } + } + } + } + } + } + return responseResponse; + } + + private ApiDiscoveryResponse getCmdRequestMap(Class cmdClass, APICommand apiCmdAnnotation) { + String apiName = apiCmdAnnotation.name(); + ApiDiscoveryResponse response = new ApiDiscoveryResponse(); + response.setName(apiName); + response.setDescription(apiCmdAnnotation.description()); + if (!apiCmdAnnotation.since().isEmpty()) { + response.setSince(apiCmdAnnotation.since()); + } + + + Set fields = ReflectUtil.getAllFieldsForClass(cmdClass, + new Class[]{BaseCmd.class, BaseAsyncCmd.class, BaseAsyncCreateCmd.class}); + + boolean isAsync = ReflectUtil.isCmdClassAsync(cmdClass, + new Class[]{BaseAsyncCmd.class, BaseAsyncCreateCmd.class}); + + response.setAsync(isAsync); + + for(Field field: fields) { + Parameter parameterAnnotation = field.getAnnotation(Parameter.class); + if (parameterAnnotation != null + && parameterAnnotation.expose() + && parameterAnnotation.includeInApiDoc()) { + + ApiParameterResponse paramResponse = new ApiParameterResponse(); + paramResponse.setName(parameterAnnotation.name()); + paramResponse.setDescription(parameterAnnotation.description()); + paramResponse.setType(parameterAnnotation.type().toString().toLowerCase()); + paramResponse.setLength(parameterAnnotation.length()); + paramResponse.setRequired(parameterAnnotation.required()); + if (!parameterAnnotation.since().isEmpty()) { + paramResponse.setSince(parameterAnnotation.since()); + } + paramResponse.setRelated(parameterAnnotation.entityType()[0].getName()); + response.addParam(paramResponse); + } + } + return response; } @Override diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java index f07b212173f..8d459028a17 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java @@ -14,35 +14,35 @@ // 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 01/29/2013 -package com.cloud.baremetal.manager; - +package com.cloud.baremetal.manager; + import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.command.admin.host.AddHostCmd; import org.apache.cloudstack.api.response.HostResponse; -@APICommand(name="addBaremetalHost", description="add a baremetal host", responseObject = HostResponse.class) +@APICommand(name="addBaremetalHost", description="add a baremetal host", responseObject = HostResponse.class) public class AddBaremetalHostCmd extends AddHostCmd { - - @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="ip address intentionally allocated to this host after provisioning") - private String vmIpAddress; - - public AddBaremetalHostCmd() { - } - + + @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="ip address intentionally allocated to this host after provisioning") + private String vmIpAddress; + + public AddBaremetalHostCmd() { + } + @Override - public void execute(){ - this.getFullUrlParams().put(ApiConstants.BAREMETAL_DISCOVER_NAME, BareMetalDiscoverer.class.getName()); - super.execute(); - } - - public String getVmIpAddress() { - return vmIpAddress; - } - - public void setVmIpAddress(String vmIpAddress) { - this.vmIpAddress = vmIpAddress; - } -} + public void execute(){ + this.getFullUrlParams().put(ApiConstants.BAREMETAL_DISCOVER_NAME, BareMetalDiscoverer.class.getName()); + super.execute(); + } + + public String getVmIpAddress() { + return vmIpAddress; + } + + public void setVmIpAddress(String vmIpAddress) { + this.vmIpAddress = vmIpAddress; + } +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java index 28c83753c09..edb5dea8ca5 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java @@ -202,7 +202,7 @@ public class BareMetalDiscoverer extends DiscovererBase implements Discoverer, R if (vmIp != null) { details.put(ApiConstants.IP_ADDRESS, vmIp); } - String isEchoScAgent = _configDao.getValue(Config.EnableBaremetalSecurityGroupAgentEcho.key()); + String isEchoScAgent = _configDao.getValue(Config.EnableBaremetalSecurityGroupAgentEcho.key()); details.put(BaremetalManager.EchoSecurityGroupAgent, isEchoScAgent); resources.put(resource, details); diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java index 6467c945795..60edde3c70d 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java @@ -22,7 +22,7 @@ import com.cloud.network.Network.Provider; import com.cloud.utils.component.Manager; import com.cloud.utils.component.PluggableService; -public interface BaremetalManager extends Manager, PluggableService { +public interface BaremetalManager extends Manager, PluggableService { public static final String EchoSecurityGroupAgent = "EchoSecurityGroupAgent"; public static final String ExternalBaremetalSystemUrl = "ExternalBaremetalSystemUrl"; public static final String DO_PXE = "doPxe"; diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java index 9daee3f3fe7..45fbeb782ab 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java @@ -1,39 +1,39 @@ -// 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.baremetal.manager; - -import java.util.Map; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; - -import com.cloud.deploy.AbstractDeployPlannerSelector; -import com.cloud.deploy.DeployPlannerSelector; -import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.vm.UserVmVO; -@Local(value = {DeployPlannerSelector.class}) -public class BaremetalPlannerSelector extends AbstractDeployPlannerSelector{ - - @Override - public String selectPlanner(UserVmVO vm) { - if (vm.getHypervisorType() == HypervisorType.BareMetal) { - return "BareMetalPlanner"; - } - return null; - } - -} +// 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.baremetal.manager; + +import java.util.Map; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; + +import com.cloud.deploy.AbstractDeployPlannerSelector; +import com.cloud.deploy.DeployPlannerSelector; +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.vm.UserVmVO; +@Local(value = {DeployPlannerSelector.class}) +public class BaremetalPlannerSelector extends AbstractDeployPlannerSelector{ + + @Override + public String selectPlanner(UserVmVO vm) { + if (vm.getHypervisorType() == HypervisorType.BareMetal) { + return "BareMetalPlanner"; + } + return null; + } + +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalKickStartPxeCmd.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalKickStartPxeCmd.java index 596a86dac8f..8bcc7c13f62 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalKickStartPxeCmd.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalKickStartPxeCmd.java @@ -14,24 +14,24 @@ // 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 01/29/2013 -package com.cloud.baremetal.networkservice; - +package com.cloud.baremetal.networkservice; + import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd.CommandType; import org.apache.cloudstack.api.Parameter; @APICommand(name="addBaremetalPxeKickStartServer", description="add a baremetal pxe server", responseObject = BaremetalPxeKickStartResponse.class) -public class AddBaremetalKickStartPxeCmd extends AddBaremetalPxeCmd { - @Parameter(name=ApiConstants.TFTP_DIR, type=CommandType.STRING, required = true, description="Tftp root directory of PXE server") - private String tftpDir; - - public String getTftpDir() { - return tftpDir; - } - - public void setTftpDir(String tftpDir) { - this.tftpDir = tftpDir; +public class AddBaremetalKickStartPxeCmd extends AddBaremetalPxeCmd { + @Parameter(name=ApiConstants.TFTP_DIR, type=CommandType.STRING, required = true, description="Tftp root directory of PXE server") + private String tftpDir; + + public String getTftpDir() { + return tftpDir; } -} + + public void setTftpDir(String tftpDir) { + this.tftpDir = tftpDir; + } +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java index 4c99f6bf544..86e41fea070 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java @@ -97,7 +97,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource protected String _mac; protected String _username; protected String _password; - protected String _ip; + protected String _ip; protected boolean _isEchoScAgent; protected IAgentControl _agentControl; protected Script2 _pingCommand; @@ -146,7 +146,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource _mac = (String) params.get(ApiConstants.HOST_MAC); _username = (String) params.get(ApiConstants.USERNAME); _password = (String) params.get(ApiConstants.PASSWORD); - _vmName = (String) params.get("vmName"); + _vmName = (String) params.get("vmName"); String echoScAgent = (String) params.get(BaremetalManager.EchoSecurityGroupAgent); if (_pod == null) { @@ -172,9 +172,9 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource if (_uuid == null) { throw new ConfigurationException("Unable to get the uuid"); - } - - if (echoScAgent != null) { + } + + if (echoScAgent != null) { _isEchoScAgent = Boolean.valueOf(echoScAgent); } @@ -416,9 +416,9 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) { return new CheckNetworkAnswer(cmd, true, "Success"); } - - protected Answer execute(SecurityGroupRulesCmd cmd) { - SecurityGroupHttpClient hc = new SecurityGroupHttpClient(); + + protected Answer execute(SecurityGroupRulesCmd cmd) { + SecurityGroupHttpClient hc = new SecurityGroupHttpClient(); return hc.call(cmd.getGuestIp(), cmd); } @@ -531,13 +531,13 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource if (!doScript(_powerOnCommand)) { return new StartAnswer(cmd, "IPMI power on failed"); } - } - - if (_isEchoScAgent) { - SecurityGroupHttpClient hc = new SecurityGroupHttpClient(); - boolean echoRet = hc.echo(vm.getNics()[0].getIp(), TimeUnit.MINUTES.toMillis(30), TimeUnit.MINUTES.toMillis(1)); + } + + if (_isEchoScAgent) { + SecurityGroupHttpClient hc = new SecurityGroupHttpClient(); + boolean echoRet = hc.echo(vm.getNics()[0].getIp(), TimeUnit.MINUTES.toMillis(30), TimeUnit.MINUTES.toMillis(1)); if (!echoRet) { - return new StartAnswer(cmd, String.format("Call security group agent on vm[%s] timeout", vm.getNics()[0].getIp())); + return new StartAnswer(cmd, String.format("Call security group agent on vm[%s] timeout", vm.getNics()[0].getIp())); } } diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetaNetworkGuru.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetaNetworkGuru.java index bec6e38b7c8..6d14e3f1a0c 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetaNetworkGuru.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetaNetworkGuru.java @@ -14,10 +14,10 @@ // 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 01/29/2013 -package com.cloud.baremetal.networkservice; - +package com.cloud.baremetal.networkservice; + import java.net.URI; import javax.ejb.Local; @@ -56,11 +56,11 @@ import com.cloud.vm.NicProfile; import com.cloud.vm.ReservationContext; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; - -@Local(value = { NetworkGuru.class }) -public class BaremetaNetworkGuru extends DirectPodBasedNetworkGuru { - private static final Logger s_logger = Logger.getLogger(BaremetaNetworkGuru.class); - @Inject + +@Local(value = { NetworkGuru.class }) +public class BaremetaNetworkGuru extends DirectPodBasedNetworkGuru { + private static final Logger s_logger = Logger.getLogger(BaremetaNetworkGuru.class); + @Inject private HostDao _hostDao; @Inject DataCenterDao _dcDao; @@ -73,101 +73,101 @@ public class BaremetaNetworkGuru extends DirectPodBasedNetworkGuru { @Inject NetworkOfferingDao _networkOfferingDao; @Inject - PodVlanMapDao _podVlanDao; - - @Override - public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) - throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException { - if (dest.getHost().getHypervisorType() != HypervisorType.BareMetal) { - super.reserve(nic, network, vm, dest, context); - return; - } - - HostVO host = _hostDao.findById(dest.getHost().getId()); - _hostDao.loadDetails(host); - String intentIp = host.getDetail(ApiConstants.IP_ADDRESS); - if (intentIp == null) { - super.reserve(nic, network, vm, dest, context); - return; - } - - String oldIp = nic.getIp4Address(); - boolean getNewIp = false; - if (oldIp == null) { - getNewIp = true; - } else { - // we need to get a new ip address if we try to deploy a vm in a - // different pod - IPAddressVO ipVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), oldIp); - if (ipVO != null) { - PodVlanMapVO mapVO = _podVlanDao.listPodVlanMapsByVlan(ipVO.getVlanId()); - if (mapVO.getPodId() != dest.getPod().getId()) { - Transaction txn = Transaction.currentTxn(); - txn.start(); - - // release the old ip here - _networkMgr.markIpAsUnavailable(ipVO.getId()); - _ipAddressDao.unassignIpAddress(ipVO.getId()); - - txn.commit(); - - nic.setIp4Address(null); - getNewIp = true; - } - } - } - - if (getNewIp) { - // we don't set reservationStrategy to Create because we need this - // method to be called again for the case when vm fails to deploy in - // Pod1, and we try to redeploy it in Pod2 - getBaremetalIp(nic, dest.getPod(), vm, network, intentIp); - } - - DataCenter dc = _dcDao.findById(network.getDataCenterId()); - nic.setDns1(dc.getDns1()); - nic.setDns2(dc.getDns2()); - - /* - * Pod pod = dest.getPod(); Pair ip = - * _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), - * dest.getPod().getId(), nic.getId(), context.getReservationId(), - * intentIp); if (ip == null) { throw new - * InsufficientAddressCapacityException - * ("Unable to get a management ip address", Pod.class, pod.getId()); } - * - * nic.setIp4Address(ip.first()); - * nic.setMacAddress(NetUtils.long2Mac(NetUtils - * .createSequenceBasedMacAddress(ip.second()))); - * nic.setGateway(pod.getGateway()); nic.setFormat(AddressFormat.Ip4); - * String netmask = NetUtils.getCidrNetmask(pod.getCidrSize()); - * nic.setNetmask(netmask); - * nic.setBroadcastType(BroadcastDomainType.Native); - * nic.setBroadcastUri(null); nic.setIsolationUri(null); - */ - - s_logger.debug("Allocated a nic " + nic + " for " + vm); - } + PodVlanMapDao _podVlanDao; - private void getBaremetalIp(NicProfile nic, Pod pod, VirtualMachineProfile vm, Network network, String requiredIp) - throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException { - DataCenter dc = _dcDao.findById(pod.getDataCenterId()); - if (nic.getIp4Address() == null) { - s_logger.debug(String.format("Requiring ip address: %s", nic.getIp4Address())); - PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), pod.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId(), requiredIp, false); - nic.setIp4Address(ip.getAddress().toString()); - nic.setFormat(AddressFormat.Ip4); - nic.setGateway(ip.getGateway()); - nic.setNetmask(ip.getNetmask()); - if (ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) { - nic.setIsolationUri(URI.create("ec2://" + Vlan.UNTAGGED)); - nic.setBroadcastUri(URI.create("vlan://" + Vlan.UNTAGGED)); - nic.setBroadcastType(BroadcastDomainType.Native); - } - nic.setReservationId(String.valueOf(ip.getVlanTag())); - nic.setMacAddress(ip.getMacAddress()); - } - nic.setDns1(dc.getDns1()); - nic.setDns2(dc.getDns2()); - } -} + @Override + public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) + throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException { + if (dest.getHost().getHypervisorType() != HypervisorType.BareMetal) { + super.reserve(nic, network, vm, dest, context); + return; + } + + HostVO host = _hostDao.findById(dest.getHost().getId()); + _hostDao.loadDetails(host); + String intentIp = host.getDetail(ApiConstants.IP_ADDRESS); + if (intentIp == null) { + super.reserve(nic, network, vm, dest, context); + return; + } + + String oldIp = nic.getIp4Address(); + boolean getNewIp = false; + if (oldIp == null) { + getNewIp = true; + } else { + // we need to get a new ip address if we try to deploy a vm in a + // different pod + IPAddressVO ipVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), oldIp); + if (ipVO != null) { + PodVlanMapVO mapVO = _podVlanDao.listPodVlanMapsByVlan(ipVO.getVlanId()); + if (mapVO.getPodId() != dest.getPod().getId()) { + Transaction txn = Transaction.currentTxn(); + txn.start(); + + // release the old ip here + _networkMgr.markIpAsUnavailable(ipVO.getId()); + _ipAddressDao.unassignIpAddress(ipVO.getId()); + + txn.commit(); + + nic.setIp4Address(null); + getNewIp = true; + } + } + } + + if (getNewIp) { + // we don't set reservationStrategy to Create because we need this + // method to be called again for the case when vm fails to deploy in + // Pod1, and we try to redeploy it in Pod2 + getBaremetalIp(nic, dest.getPod(), vm, network, intentIp); + } + + DataCenter dc = _dcDao.findById(network.getDataCenterId()); + nic.setDns1(dc.getDns1()); + nic.setDns2(dc.getDns2()); + + /* + * Pod pod = dest.getPod(); Pair ip = + * _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), + * dest.getPod().getId(), nic.getId(), context.getReservationId(), + * intentIp); if (ip == null) { throw new + * InsufficientAddressCapacityException + * ("Unable to get a management ip address", Pod.class, pod.getId()); } + * + * nic.setIp4Address(ip.first()); + * nic.setMacAddress(NetUtils.long2Mac(NetUtils + * .createSequenceBasedMacAddress(ip.second()))); + * nic.setGateway(pod.getGateway()); nic.setFormat(AddressFormat.Ip4); + * String netmask = NetUtils.getCidrNetmask(pod.getCidrSize()); + * nic.setNetmask(netmask); + * nic.setBroadcastType(BroadcastDomainType.Native); + * nic.setBroadcastUri(null); nic.setIsolationUri(null); + */ + + s_logger.debug("Allocated a nic " + nic + " for " + vm); + } + + private void getBaremetalIp(NicProfile nic, Pod pod, VirtualMachineProfile vm, Network network, String requiredIp) + throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException { + DataCenter dc = _dcDao.findById(pod.getDataCenterId()); + if (nic.getIp4Address() == null) { + s_logger.debug(String.format("Requiring ip address: %s", nic.getIp4Address())); + PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), pod.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId(), requiredIp, false); + nic.setIp4Address(ip.getAddress().toString()); + nic.setFormat(AddressFormat.Ip4); + nic.setGateway(ip.getGateway()); + nic.setNetmask(ip.getNetmask()); + if (ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) { + nic.setIsolationUri(URI.create("ec2://" + Vlan.UNTAGGED)); + nic.setBroadcastUri(URI.create("vlan://" + Vlan.UNTAGGED)); + nic.setBroadcastType(BroadcastDomainType.Native); + } + nic.setReservationId(String.valueOf(ip.getVlanTag())); + nic.setMacAddress(ip.getMacAddress()); + } + nic.setDns1(dc.getDns1()); + nic.setDns2(dc.getDns2()); + } +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java index 58c6e862d9f..7a7a5153e5c 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java @@ -14,10 +14,10 @@ // 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 01/29/2013 -package com.cloud.baremetal.networkservice; - +package com.cloud.baremetal.networkservice; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,166 +37,166 @@ import com.cloud.utils.script.Script; import com.cloud.utils.ssh.SSHCmdHelper; import com.cloud.vm.VirtualMachine.State; import com.trilead.ssh2.SCPClient; - -public class BaremetalKickStartPxeResource extends BaremetalPxeResourceBase { - private static final Logger s_logger = Logger.getLogger(BaremetalKickStartPxeResource.class); - private static final String _name = "BaremetalKickStartPxeResource"; - String _tftpDir; - - @Override - public boolean configure(String name, Map params) throws ConfigurationException { - super.configure(name, params); - _tftpDir = (String) params.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR); - if (_tftpDir == null) { - throw new ConfigurationException("No tftp directory specified"); - } - - com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); - - s_logger.debug(String.format("Trying to connect to kickstart PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, "******")); - try { - sshConnection.connect(null, 60000, 60000); - if (!sshConnection.authenticateWithPassword(_username, _password)) { - s_logger.debug("SSH Failed to authenticate"); - throw new ConfigurationException(String.format("Cannot connect to kickstart PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, - "******")); - } - - String cmd = String.format("[ -f /%1$s/pxelinux.0 ]", _tftpDir); - if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) { - throw new ConfigurationException("Miss files in TFTP directory at " + _tftpDir + " check if pxelinux.0 are here"); - } - - SCPClient scp = new SCPClient(sshConnection); - String prepareScript = "scripts/network/ping/prepare_kickstart_bootfile.py"; - String prepareScriptPath = Script.findScript("", prepareScript); - if (prepareScriptPath == null) { - throw new ConfigurationException("Can not find prepare_kickstart_bootfile.py at " + prepareScript); - } - scp.put(prepareScriptPath, "/usr/bin/", "0755"); - String cpScript = "scripts/network/ping/prepare_kickstart_kernel_initrd.py"; - String cpScriptPath = Script.findScript("", cpScript); - if (cpScriptPath == null) { - throw new ConfigurationException("Can not find prepare_kickstart_kernel_initrd.py at " + cpScript); - } - scp.put(cpScriptPath, "/usr/bin/", "0755"); - - String userDataScript = "scripts/network/ping/baremetal_user_data.py"; - String userDataScriptPath = Script.findScript("", userDataScript); - if (userDataScriptPath == null) { - throw new ConfigurationException("Can not find baremetal_user_data.py at " + userDataScript); - } - scp.put(userDataScriptPath, "/usr/bin/", "0755"); - - return true; - } catch (Exception e) { - throw new CloudRuntimeException(e); - } finally { - if (sshConnection != null) { - sshConnection.close(); - } - } - } - - @Override - public PingCommand getCurrentStatus(long id) { - com.trilead.ssh2.Connection sshConnection = SSHCmdHelper.acquireAuthorizedConnection(_ip, _username, _password); - if (sshConnection == null) { - return null; - } else { - SSHCmdHelper.releaseSshConnection(sshConnection); - return new PingRoutingCommand(getType(), id, new HashMap()); - } - } - - private Answer execute(VmDataCommand cmd) { - com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); - try { - List vmData = cmd.getVmData(); - StringBuilder sb = new StringBuilder(); - for (String[] data : vmData) { - String folder = data[0]; - String file = data[1]; - String contents = (data[2] == null) ? "none" : data[2]; - sb.append(cmd.getVmIpAddress()); - sb.append(","); - sb.append(folder); - sb.append(","); - sb.append(file); - sb.append(","); - sb.append(contents); - sb.append(";"); - } - String arg = StringUtils.stripEnd(sb.toString(), ";"); - - sshConnection.connect(null, 60000, 60000); - if (!sshConnection.authenticateWithPassword(_username, _password)) { - s_logger.debug("SSH Failed to authenticate"); - throw new ConfigurationException(String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, - _password)); - } - - String script = String.format("python /usr/bin/baremetal_user_data.py '%s'", arg); - if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { - return new Answer(cmd, false, "Failed to add user data, command:" + script); - } - - return new Answer(cmd, true, "Success"); - } catch (Exception e){ - s_logger.debug("Prepare for creating baremetal template failed", e); - return new Answer(cmd, false, e.getMessage()); - } finally { - if (sshConnection != null) { - sshConnection.close(); - } - } - } - - @Override - public Answer executeRequest(Command cmd) { - if (cmd instanceof PrepareKickstartPxeServerCommand) { - return execute((PrepareKickstartPxeServerCommand) cmd); - } else if (cmd instanceof VmDataCommand) { - return execute((VmDataCommand)cmd); - } else { - return super.executeRequest(cmd); - } - } - - private Answer execute(PrepareKickstartPxeServerCommand cmd) { - com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); - try { - sshConnection.connect(null, 60000, 60000); - if (!sshConnection.authenticateWithPassword(_username, _password)) { - s_logger.debug("SSH Failed to authenticate"); - throw new ConfigurationException(String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, - _password)); +public class BaremetalKickStartPxeResource extends BaremetalPxeResourceBase { + private static final Logger s_logger = Logger.getLogger(BaremetalKickStartPxeResource.class); + private static final String _name = "BaremetalKickStartPxeResource"; + String _tftpDir; + + @Override + public boolean configure(String name, Map params) throws ConfigurationException { + super.configure(name, params); + _tftpDir = (String) params.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR); + if (_tftpDir == null) { + throw new ConfigurationException("No tftp directory specified"); + } + + com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); + + s_logger.debug(String.format("Trying to connect to kickstart PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, "******")); + try { + sshConnection.connect(null, 60000, 60000); + if (!sshConnection.authenticateWithPassword(_username, _password)) { + s_logger.debug("SSH Failed to authenticate"); + throw new ConfigurationException(String.format("Cannot connect to kickstart PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, + "******")); } - + + String cmd = String.format("[ -f /%1$s/pxelinux.0 ]", _tftpDir); + if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) { + throw new ConfigurationException("Miss files in TFTP directory at " + _tftpDir + " check if pxelinux.0 are here"); + } + + SCPClient scp = new SCPClient(sshConnection); + String prepareScript = "scripts/network/ping/prepare_kickstart_bootfile.py"; + String prepareScriptPath = Script.findScript("", prepareScript); + if (prepareScriptPath == null) { + throw new ConfigurationException("Can not find prepare_kickstart_bootfile.py at " + prepareScript); + } + scp.put(prepareScriptPath, "/usr/bin/", "0755"); + + String cpScript = "scripts/network/ping/prepare_kickstart_kernel_initrd.py"; + String cpScriptPath = Script.findScript("", cpScript); + if (cpScriptPath == null) { + throw new ConfigurationException("Can not find prepare_kickstart_kernel_initrd.py at " + cpScript); + } + scp.put(cpScriptPath, "/usr/bin/", "0755"); + + String userDataScript = "scripts/network/ping/baremetal_user_data.py"; + String userDataScriptPath = Script.findScript("", userDataScript); + if (userDataScriptPath == null) { + throw new ConfigurationException("Can not find baremetal_user_data.py at " + userDataScript); + } + scp.put(userDataScriptPath, "/usr/bin/", "0755"); + + return true; + } catch (Exception e) { + throw new CloudRuntimeException(e); + } finally { + if (sshConnection != null) { + sshConnection.close(); + } + } + } + + @Override + public PingCommand getCurrentStatus(long id) { + com.trilead.ssh2.Connection sshConnection = SSHCmdHelper.acquireAuthorizedConnection(_ip, _username, _password); + if (sshConnection == null) { + return null; + } else { + SSHCmdHelper.releaseSshConnection(sshConnection); + return new PingRoutingCommand(getType(), id, new HashMap()); + } + } + + private Answer execute(VmDataCommand cmd) { + com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); + try { + List vmData = cmd.getVmData(); + StringBuilder sb = new StringBuilder(); + for (String[] data : vmData) { + String folder = data[0]; + String file = data[1]; + String contents = (data[2] == null) ? "none" : data[2]; + sb.append(cmd.getVmIpAddress()); + sb.append(","); + sb.append(folder); + sb.append(","); + sb.append(file); + sb.append(","); + sb.append(contents); + sb.append(";"); + } + String arg = StringUtils.stripEnd(sb.toString(), ";"); + + sshConnection.connect(null, 60000, 60000); + if (!sshConnection.authenticateWithPassword(_username, _password)) { + s_logger.debug("SSH Failed to authenticate"); + throw new ConfigurationException(String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, + _password)); + } + + String script = String.format("python /usr/bin/baremetal_user_data.py '%s'", arg); + if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { + return new Answer(cmd, false, "Failed to add user data, command:" + script); + } + + return new Answer(cmd, true, "Success"); + } catch (Exception e){ + s_logger.debug("Prepare for creating baremetal template failed", e); + return new Answer(cmd, false, e.getMessage()); + } finally { + if (sshConnection != null) { + sshConnection.close(); + } + } + } + + @Override + public Answer executeRequest(Command cmd) { + if (cmd instanceof PrepareKickstartPxeServerCommand) { + return execute((PrepareKickstartPxeServerCommand) cmd); + } else if (cmd instanceof VmDataCommand) { + return execute((VmDataCommand)cmd); + } else { + return super.executeRequest(cmd); + } + } + + private Answer execute(PrepareKickstartPxeServerCommand cmd) { + com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); + try { + sshConnection.connect(null, 60000, 60000); + if (!sshConnection.authenticateWithPassword(_username, _password)) { + s_logger.debug("SSH Failed to authenticate"); + throw new ConfigurationException(String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, + _password)); + } + String copyTo = String.format("%s/%s", _tftpDir, cmd.getTemplateUuid()); - String script = String.format("python /usr/bin/prepare_kickstart_kernel_initrd.py %s %s %s", cmd.getKernel(), cmd.getInitrd(), copyTo); - - if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { - return new Answer(cmd, false, "prepare kickstart at pxe server " + _ip + " failed, command:" + script); - } - - String kernelPath = String.format("%s/vmlinuz", cmd.getTemplateUuid()); - String initrdPath = String.format("%s/initrd.img", cmd.getTemplateUuid()); - script = String.format("python /usr/bin/prepare_kickstart_bootfile.py %s %s %s %s %s %s", _tftpDir, cmd.getMac(), kernelPath, initrdPath, cmd.getKsFile(), cmd.getMac()); - if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { - return new Answer(cmd, false, "prepare kickstart at pxe server " + _ip + " failed, command:" + script); - } - - s_logger.debug("Prepare kickstart PXE server successfully"); - return new Answer(cmd, true, "Success"); - } catch (Exception e){ - s_logger.debug("Prepare for kickstart server failed", e); - return new Answer(cmd, false, e.getMessage()); - } finally { - if (sshConnection != null) { - sshConnection.close(); - } - } - } -} + String script = String.format("python /usr/bin/prepare_kickstart_kernel_initrd.py %s %s %s", cmd.getKernel(), cmd.getInitrd(), copyTo); + + if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { + return new Answer(cmd, false, "prepare kickstart at pxe server " + _ip + " failed, command:" + script); + } + + String kernelPath = String.format("%s/vmlinuz", cmd.getTemplateUuid()); + String initrdPath = String.format("%s/initrd.img", cmd.getTemplateUuid()); + script = String.format("python /usr/bin/prepare_kickstart_bootfile.py %s %s %s %s %s %s", _tftpDir, cmd.getMac(), kernelPath, initrdPath, cmd.getKsFile(), cmd.getMac()); + if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { + return new Answer(cmd, false, "prepare kickstart at pxe server " + _ip + " failed, command:" + script); + } + + s_logger.debug("Prepare kickstart PXE server successfully"); + return new Answer(cmd, true, "Success"); + } catch (Exception e){ + s_logger.debug("Prepare for kickstart server failed", e); + return new Answer(cmd, false, e.getMessage()); + } finally { + if (sshConnection != null) { + sshConnection.close(); + } + } + } +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java index 8a5ac78729e..49582b07862 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java @@ -14,87 +14,87 @@ // 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 01/29/2013 -package com.cloud.baremetal.networkservice; - -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ejb.Local; +package com.cloud.baremetal.networkservice; + +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ejb.Local; import javax.inject.Inject; - -import org.apache.log4j.Logger; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.baremetal.IpmISetBootDevCommand; -import com.cloud.agent.api.baremetal.IpmISetBootDevCommand.BootDev; -import com.cloud.baremetal.database.BaremetalPxeDao; -import com.cloud.baremetal.database.BaremetalPxeVO; -import com.cloud.baremetal.networkservice.BaremetalPxeManager.BaremetalPxeType; -import com.cloud.deploy.DeployDestination; -import com.cloud.host.Host; -import com.cloud.host.HostVO; -import com.cloud.host.dao.HostDetailsDao; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.dao.NetworkDao; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.baremetal.IpmISetBootDevCommand; +import com.cloud.agent.api.baremetal.IpmISetBootDevCommand.BootDev; +import com.cloud.baremetal.database.BaremetalPxeDao; +import com.cloud.baremetal.database.BaremetalPxeVO; +import com.cloud.baremetal.networkservice.BaremetalPxeManager.BaremetalPxeType; +import com.cloud.deploy.DeployDestination; +import com.cloud.host.Host; +import com.cloud.host.HostVO; +import com.cloud.host.dao.HostDetailsDao; +import com.cloud.network.PhysicalNetworkServiceProvider; +import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; +import com.cloud.network.dao.PhysicalNetworkDao; +import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; +import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.resource.ResourceManager; -import com.cloud.resource.ServerResource; -import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.dao.VMTemplateDao; -import com.cloud.uservm.UserVm; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.SearchCriteria.Op; -import com.cloud.utils.db.SearchCriteria2; -import com.cloud.utils.db.SearchCriteriaService; -import com.cloud.utils.db.Transaction; -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.vm.NicProfile; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.UserVmVO; -import com.cloud.vm.VirtualMachineProfile; - -@Local(value = BaremetalPxeService.class) -public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase implements BaremetalPxeService { - private static final Logger s_logger = Logger.getLogger(BaremetalKickStartServiceImpl.class); - @Inject - ResourceManager _resourceMgr; - @Inject - PhysicalNetworkDao _physicalNetworkDao; - @Inject - PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao; - @Inject - HostDetailsDao _hostDetailsDao; - @Inject - BaremetalPxeDao _pxeDao; +import com.cloud.resource.ResourceManager; +import com.cloud.resource.ServerResource; +import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.dao.VMTemplateDao; +import com.cloud.uservm.UserVm; +import com.cloud.utils.db.DB; +import com.cloud.utils.db.SearchCriteria.Op; +import com.cloud.utils.db.SearchCriteria2; +import com.cloud.utils.db.SearchCriteriaService; +import com.cloud.utils.db.Transaction; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.NicProfile; +import com.cloud.vm.ReservationContext; +import com.cloud.vm.UserVmVO; +import com.cloud.vm.VirtualMachineProfile; + +@Local(value = BaremetalPxeService.class) +public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase implements BaremetalPxeService { + private static final Logger s_logger = Logger.getLogger(BaremetalKickStartServiceImpl.class); @Inject - NetworkDao _nwDao; + ResourceManager _resourceMgr; + @Inject + PhysicalNetworkDao _physicalNetworkDao; + @Inject + PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao; + @Inject + HostDetailsDao _hostDetailsDao; + @Inject + BaremetalPxeDao _pxeDao; + @Inject + NetworkDao _nwDao; @Inject VMTemplateDao _tmpDao; - - @Override + + @Override public boolean prepare(VirtualMachineProfile profile, NicProfile nic, DeployDestination dest, ReservationContext context) { NetworkVO nwVO = _nwDao.findById(nic.getNetworkId()); - SearchCriteriaService sc = SearchCriteria2.create(BaremetalPxeVO.class); + SearchCriteriaService sc = SearchCriteria2.create(BaremetalPxeVO.class); sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString()); - sc.addAnd(sc.getEntity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId()); - BaremetalPxeVO pxeVo = sc.find(); - if (pxeVo == null) { - throw new CloudRuntimeException("No kickstart PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM"); + sc.addAnd(sc.getEntity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId()); + BaremetalPxeVO pxeVo = sc.find(); + if (pxeVo == null) { + throw new CloudRuntimeException("No kickstart PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM"); } - VMTemplateVO template = _tmpDao.findById(profile.getTemplateId()); - - try { - String tpl = profile.getTemplate().getUrl(); - assert tpl != null : "How can a null template get here!!!"; + VMTemplateVO template = _tmpDao.findById(profile.getTemplateId()); + + try { + String tpl = profile.getTemplate().getUrl(); + assert tpl != null : "How can a null template get here!!!"; String[] tpls = tpl.split(";"); CloudRuntimeException err = new CloudRuntimeException(String.format("template url[%s] is not correctly encoded. it must be in format of ks=http_link_to_kickstartfile;kernel=nfs_path_to_pxe_kernel;initrd=nfs_path_to_pxe_initrd", tpl)); if (tpls.length != 3) { @@ -120,149 +120,149 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple throw err; } } - - PrepareKickstartPxeServerCommand cmd = new PrepareKickstartPxeServerCommand(); + + PrepareKickstartPxeServerCommand cmd = new PrepareKickstartPxeServerCommand(); cmd.setKsFile(ks); cmd.setInitrd(initrd); - cmd.setKernel(kernel); + cmd.setKernel(kernel); cmd.setMac(nic.getMacAddress()); - cmd.setTemplateUuid(template.getUuid()); - Answer aws = _agentMgr.send(pxeVo.getHostId(), cmd); - if (!aws.getResult()) { - s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails()); - return aws.getResult(); + cmd.setTemplateUuid(template.getUuid()); + Answer aws = _agentMgr.send(pxeVo.getHostId(), cmd); + if (!aws.getResult()) { + s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails()); + return aws.getResult(); } - - IpmISetBootDevCommand bootCmd = new IpmISetBootDevCommand(BootDev.pxe); - aws = _agentMgr.send(dest.getHost().getId(), bootCmd); - if (!aws.getResult()) { - s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails()); + + IpmISetBootDevCommand bootCmd = new IpmISetBootDevCommand(BootDev.pxe); + aws = _agentMgr.send(dest.getHost().getId(), bootCmd); + if (!aws.getResult()) { + s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails()); } - - return aws.getResult(); - } catch (Exception e) { - s_logger.warn("Cannot prepare PXE server", e); - return false; - } - } - - @Override - public boolean prepareCreateTemplate(Long pxeServerId, UserVm vm, String templateUrl) { - // TODO Auto-generated method stub - return false; - } - + + return aws.getResult(); + } catch (Exception e) { + s_logger.warn("Cannot prepare PXE server", e); + return false; + } + } + @Override - @DB - public BaremetalPxeVO addPxeServer(AddBaremetalPxeCmd cmd) { - AddBaremetalKickStartPxeCmd kcmd = (AddBaremetalKickStartPxeCmd)cmd; - PhysicalNetworkVO pNetwork = null; - long zoneId; - - if (cmd.getPhysicalNetworkId() == null || cmd.getUrl() == null || cmd.getUsername() == null || cmd.getPassword() == null) { - throw new IllegalArgumentException("At least one of the required parameters(physical network id, url, username, password) is null"); - } - - pNetwork = _physicalNetworkDao.findById(cmd.getPhysicalNetworkId()); - if (pNetwork == null) { - throw new IllegalArgumentException("Could not find phyical network with ID: " + cmd.getPhysicalNetworkId()); - } - zoneId = pNetwork.getDataCenterId(); - - PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(pNetwork.getId(), BaremetalPxeManager.BAREMETAL_PXE_SERVICE_PROVIDER.getName()); - if (ntwkSvcProvider == null) { - throw new CloudRuntimeException("Network Service Provider: " + BaremetalPxeManager.BAREMETAL_PXE_SERVICE_PROVIDER.getName() + - " is not enabled in the physical network: " + cmd.getPhysicalNetworkId() + "to add this device"); - } else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) { - throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() + - " is in shutdown state in the physical network: " + cmd.getPhysicalNetworkId() + "to add this device"); - } - - List pxes = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.BaremetalPxe, zoneId); - if (!pxes.isEmpty()) { + public boolean prepareCreateTemplate(Long pxeServerId, UserVm vm, String templateUrl) { + // TODO Auto-generated method stub + return false; + } + + @Override + @DB + public BaremetalPxeVO addPxeServer(AddBaremetalPxeCmd cmd) { + AddBaremetalKickStartPxeCmd kcmd = (AddBaremetalKickStartPxeCmd)cmd; + PhysicalNetworkVO pNetwork = null; + long zoneId; + + if (cmd.getPhysicalNetworkId() == null || cmd.getUrl() == null || cmd.getUsername() == null || cmd.getPassword() == null) { + throw new IllegalArgumentException("At least one of the required parameters(physical network id, url, username, password) is null"); + } + + pNetwork = _physicalNetworkDao.findById(cmd.getPhysicalNetworkId()); + if (pNetwork == null) { + throw new IllegalArgumentException("Could not find phyical network with ID: " + cmd.getPhysicalNetworkId()); + } + zoneId = pNetwork.getDataCenterId(); + + PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(pNetwork.getId(), BaremetalPxeManager.BAREMETAL_PXE_SERVICE_PROVIDER.getName()); + if (ntwkSvcProvider == null) { + throw new CloudRuntimeException("Network Service Provider: " + BaremetalPxeManager.BAREMETAL_PXE_SERVICE_PROVIDER.getName() + + " is not enabled in the physical network: " + cmd.getPhysicalNetworkId() + "to add this device"); + } else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) { + throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() + + " is in shutdown state in the physical network: " + cmd.getPhysicalNetworkId() + "to add this device"); + } + + List pxes = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.BaremetalPxe, zoneId); + if (!pxes.isEmpty()) { throw new IllegalArgumentException("Already had a PXE server zone: " + zoneId); - } - - String tftpDir = kcmd.getTftpDir(); - if (tftpDir == null) { - throw new IllegalArgumentException("No TFTP directory specified"); - } - - URI uri; - try { - uri = new URI(cmd.getUrl()); - } catch (Exception e) { - s_logger.debug(e); - throw new IllegalArgumentException(e.getMessage()); - } - String ipAddress = uri.getHost(); - - String guid = getPxeServerGuid(Long.toString(zoneId), BaremetalPxeType.KICK_START.toString(), ipAddress); - - ServerResource resource = null; - Map params = new HashMap(); - params.put(BaremetalPxeService.PXE_PARAM_ZONE, Long.toString(zoneId)); - params.put(BaremetalPxeService.PXE_PARAM_IP, ipAddress); - params.put(BaremetalPxeService.PXE_PARAM_USERNAME, cmd.getUsername()); - params.put(BaremetalPxeService.PXE_PARAM_PASSWORD, cmd.getPassword()); - params.put(BaremetalPxeService.PXE_PARAM_TFTP_DIR, tftpDir); + } + + String tftpDir = kcmd.getTftpDir(); + if (tftpDir == null) { + throw new IllegalArgumentException("No TFTP directory specified"); + } + + URI uri; + try { + uri = new URI(cmd.getUrl()); + } catch (Exception e) { + s_logger.debug(e); + throw new IllegalArgumentException(e.getMessage()); + } + String ipAddress = uri.getHost(); + + String guid = getPxeServerGuid(Long.toString(zoneId), BaremetalPxeType.KICK_START.toString(), ipAddress); + + ServerResource resource = null; + Map params = new HashMap(); + params.put(BaremetalPxeService.PXE_PARAM_ZONE, Long.toString(zoneId)); + params.put(BaremetalPxeService.PXE_PARAM_IP, ipAddress); + params.put(BaremetalPxeService.PXE_PARAM_USERNAME, cmd.getUsername()); + params.put(BaremetalPxeService.PXE_PARAM_PASSWORD, cmd.getPassword()); + params.put(BaremetalPxeService.PXE_PARAM_TFTP_DIR, tftpDir); params.put(BaremetalPxeService.PXE_PARAM_GUID, guid); resource = new BaremetalKickStartPxeResource(); try { - resource.configure("KickStart PXE resource", params); - } catch (Exception e) { - throw new CloudRuntimeException(e.getMessage(), e); + resource.configure("KickStart PXE resource", params); + } catch (Exception e) { + throw new CloudRuntimeException(e.getMessage(), e); } - - Host pxeServer = _resourceMgr.addHost(zoneId, resource, Host.Type.BaremetalPxe, params); - if (pxeServer == null) { - throw new CloudRuntimeException("Cannot add PXE server as a host"); + + Host pxeServer = _resourceMgr.addHost(zoneId, resource, Host.Type.BaremetalPxe, params); + if (pxeServer == null) { + throw new CloudRuntimeException("Cannot add PXE server as a host"); } - - BaremetalPxeVO vo = new BaremetalPxeVO(); - Transaction txn = Transaction.currentTxn(); - vo.setHostId(pxeServer.getId()); - vo.setNetworkServiceProviderId(ntwkSvcProvider.getId()); - vo.setPhysicalNetworkId(kcmd.getPhysicalNetworkId()); - vo.setDeviceType(BaremetalPxeType.KICK_START.toString()); - txn.start(); - _pxeDao.persist(vo); - txn.commit(); - return vo; - } - - @Override - public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) { - BaremetalPxeKickStartResponse response = new BaremetalPxeKickStartResponse(); - response.setId(String.valueOf(vo.getId())); - response.setPhysicalNetworkId(String.valueOf(vo.getPhysicalNetworkId())); - response.setPodId(String.valueOf(vo.getPodId())); - Map details = _hostDetailsDao.findDetails(vo.getHostId()); - response.setTftpDir(details.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR)); - return response; - } - - @Override - public List listPxeServers(ListBaremetalPxePingServersCmd cmd) { - SearchCriteriaService sc = SearchCriteria2.create(BaremetalPxeVO.class); - sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString()); - if (cmd.getPodId() != null) { - sc.addAnd(sc.getEntity().getPodId(), Op.EQ, cmd.getPodId()); - if (cmd.getId() != null) { - sc.addAnd(sc.getEntity().getId(), Op.EQ, cmd.getId()); - } - } - List vos = sc.list(); - List responses = new ArrayList(vos.size()); - for (BaremetalPxeVO vo : vos) { - responses.add(getApiResponse(vo)); - } - return responses; + + BaremetalPxeVO vo = new BaremetalPxeVO(); + Transaction txn = Transaction.currentTxn(); + vo.setHostId(pxeServer.getId()); + vo.setNetworkServiceProviderId(ntwkSvcProvider.getId()); + vo.setPhysicalNetworkId(kcmd.getPhysicalNetworkId()); + vo.setDeviceType(BaremetalPxeType.KICK_START.toString()); + txn.start(); + _pxeDao.persist(vo); + txn.commit(); + return vo; + } + + @Override + public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) { + BaremetalPxeKickStartResponse response = new BaremetalPxeKickStartResponse(); + response.setId(String.valueOf(vo.getId())); + response.setPhysicalNetworkId(String.valueOf(vo.getPhysicalNetworkId())); + response.setPodId(String.valueOf(vo.getPodId())); + Map details = _hostDetailsDao.findDetails(vo.getHostId()); + response.setTftpDir(details.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR)); + return response; + } + + @Override + public List listPxeServers(ListBaremetalPxePingServersCmd cmd) { + SearchCriteriaService sc = SearchCriteria2.create(BaremetalPxeVO.class); + sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString()); + if (cmd.getPodId() != null) { + sc.addAnd(sc.getEntity().getPodId(), Op.EQ, cmd.getPodId()); + if (cmd.getId() != null) { + sc.addAnd(sc.getEntity().getId(), Op.EQ, cmd.getId()); + } + } + List vos = sc.list(); + List responses = new ArrayList(vos.size()); + for (BaremetalPxeVO vo : vos) { + responses.add(getApiResponse(vo)); + } + return responses; } @Override public String getPxeServiceType() { return BaremetalPxeManager.BaremetalPxeType.KICK_START.toString(); - } - -} + } + +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeKickStartResponse.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeKickStartResponse.java index 64f22e0947e..116de440770 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeKickStartResponse.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeKickStartResponse.java @@ -14,10 +14,10 @@ // 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 01/29/2013 -package com.cloud.baremetal.networkservice; - +package com.cloud.baremetal.networkservice; + import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.EntityReference; @@ -25,16 +25,16 @@ import com.cloud.baremetal.database.BaremetalPxeVO; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; -@EntityReference(value=BaremetalPxeVO.class) -public class BaremetalPxeKickStartResponse extends BaremetalPxeResponse { - @SerializedName(ApiConstants.TFTP_DIR) @Param(description="Tftp root directory of PXE server") - private String tftpDir; - - public String getTftpDir() { - return tftpDir; - } - - public void setTftpDir(String tftpDir) { - this.tftpDir = tftpDir; - } -} +@EntityReference(value=BaremetalPxeVO.class) +public class BaremetalPxeKickStartResponse extends BaremetalPxeResponse { + @SerializedName(ApiConstants.TFTP_DIR) @Param(description="Tftp root directory of PXE server") + private String tftpDir; + + public String getTftpDir() { + return tftpDir; + } + + public void setTftpDir(String tftpDir) { + this.tftpDir = tftpDir; + } +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java index 6288f918567..59a28117cb5 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java @@ -110,11 +110,11 @@ public class BaremetalPxeManagerImpl extends ManagerBase implements BaremetalPxe if (service.getPxeServiceType().equals(type)) { return service; } - } - + } + throw new CloudRuntimeException("Cannot find PXE service for " + type); } - + @Override public boolean prepare(VirtualMachineProfile profile, NicProfile nic, DeployDestination dest, ReservationContext context) { //TODO: select type from template diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java index 3d9f5819582..49c6fd9b957 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java @@ -14,144 +14,144 @@ // 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 01/29/2013 -package com.cloud.baremetal.networkservice; - +package com.cloud.baremetal.networkservice; + import java.util.HashMap; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.Local; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.ejb.Local; import javax.inject.Inject; - -import com.cloud.baremetal.manager.BaremetalManager; -import com.cloud.dc.DataCenter.NetworkType; -import com.cloud.deploy.DeployDestination; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.network.Network; -import com.cloud.network.Network.Capability; -import com.cloud.network.Network.GuestType; -import com.cloud.network.Network.Provider; -import com.cloud.network.Network.Service; -import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.element.IpDeployer; -import com.cloud.network.element.NetworkElement; -import com.cloud.network.element.UserDataServiceProvider; -import com.cloud.offering.NetworkOffering; -import com.cloud.uservm.UserVm; -import com.cloud.utils.component.AdapterBase; -import com.cloud.vm.NicProfile; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.VirtualMachine; + +import com.cloud.baremetal.manager.BaremetalManager; +import com.cloud.dc.DataCenter.NetworkType; +import com.cloud.deploy.DeployDestination; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.network.Network; +import com.cloud.network.Network.Capability; +import com.cloud.network.Network.GuestType; +import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; +import com.cloud.network.Networks.TrafficType; +import com.cloud.network.PhysicalNetworkServiceProvider; +import com.cloud.network.element.IpDeployer; +import com.cloud.network.element.NetworkElement; +import com.cloud.network.element.UserDataServiceProvider; +import com.cloud.offering.NetworkOffering; +import com.cloud.uservm.UserVm; +import com.cloud.utils.component.AdapterBase; +import com.cloud.vm.NicProfile; +import com.cloud.vm.ReservationContext; +import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; - -@Local(value = NetworkElement.class) -public class BaremetalUserdataElement extends AdapterBase implements NetworkElement, UserDataServiceProvider { + +@Local(value = NetworkElement.class) +public class BaremetalUserdataElement extends AdapterBase implements NetworkElement, UserDataServiceProvider { private static Map> capabilities; - - @Inject + + @Inject private BaremetalPxeManager pxeMgr; - - static { + + static { capabilities = new HashMap>(); - capabilities.put(Service.UserData, null); + capabilities.put(Service.UserData, null); } - - private boolean canHandle(DeployDestination dest) { - if (dest.getDataCenter().getNetworkType() == NetworkType.Basic && dest.getHost().getHypervisorType() == HypervisorType.BareMetal) { - return true; + + private boolean canHandle(DeployDestination dest) { + if (dest.getDataCenter().getNetworkType() == NetworkType.Basic && dest.getHost().getHypervisorType() == HypervisorType.BareMetal) { + return true; } - return false; + return false; } - - @Override - public boolean addPasswordAndUserdata(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, + + @Override + public boolean addPasswordAndUserdata(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - if (!canHandle(dest)) { - return false; + if (!canHandle(dest)) { + return false; } - - if (vm.getType() != VirtualMachine.Type.User) { - return false; + + if (vm.getType() != VirtualMachine.Type.User) { + return false; } - - return pxeMgr.addUserData(nic, (VirtualMachineProfile) vm); - } - - @Override - public boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile vm) throws ResourceUnavailableException { - // TODO Auto-generated method stub - return false; - } - - @Override + + return pxeMgr.addUserData(nic, (VirtualMachineProfile) vm); + } + + @Override + public boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile vm) throws ResourceUnavailableException { + // TODO Auto-generated method stub + return false; + } + + @Override public boolean saveSSHKey(Network network, NicProfile nic, VirtualMachineProfile vm, String SSHPublicKey) throws ResourceUnavailableException { // TODO Auto-generated method stub return false; } @Override - public Map> getCapabilities() { - return capabilities; - } - - @Override - public Provider getProvider() { - return BaremetalPxeManager.BAREMETAL_USERDATA_PROVIDER; - } - - @Override - public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) - throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, - ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) - throws ConcurrentOperationException, ResourceUnavailableException { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isReady(PhysicalNetworkServiceProvider provider) { - return true; - } - - @Override - public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, - ResourceUnavailableException { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean canEnableIndividualServices() { - // TODO Auto-generated method stub - return true; - } - + public Map> getCapabilities() { + return capabilities; + } + + @Override + public Provider getProvider() { + return BaremetalPxeManager.BAREMETAL_USERDATA_PROVIDER; + } + + @Override + public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) + throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, + ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) + throws ConcurrentOperationException, ResourceUnavailableException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isReady(PhysicalNetworkServiceProvider provider) { + return true; + } + + @Override + public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, + ResourceUnavailableException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean canEnableIndividualServices() { + // TODO Auto-generated method stub + return true; + } + @Override public boolean saveUserData(Network network, NicProfile nic, VirtualMachineProfile vm) @@ -162,12 +162,12 @@ public class BaremetalUserdataElement extends AdapterBase implements NetworkElem @Override public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { - return true; - } - - @Override - public boolean verifyServicesCombination(Set services) { - return true; - } - -} + return true; + } + + @Override + public boolean verifyServicesCombination(Set services) { + return true; + } + +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java index 25dfeb70d30..a9899793885 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java @@ -14,32 +14,32 @@ // 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 01/29/2013 -package com.cloud.baremetal.networkservice; - -import com.cloud.agent.api.Command; - -public class PrepareKickstartPxeServerCommand extends Command { +package com.cloud.baremetal.networkservice; + +import com.cloud.agent.api.Command; + +public class PrepareKickstartPxeServerCommand extends Command { private String ksFile; - private String templateUuid; - private String mac; + private String templateUuid; + private String mac; private String ksDevice; private String kernel; - private String initrd; - - @Override - public boolean executeInSequence() { - return true; - } - - public String getKsFile() { - return ksFile; - } - - public void setKsFile(String ksFile) { - this.ksFile = ksFile; - } + private String initrd; + + @Override + public boolean executeInSequence() { + return true; + } + + public String getKsFile() { + return ksFile; + } + + public void setKsFile(String ksFile) { + this.ksFile = ksFile; + } public String getKernel() { return kernel; @@ -57,27 +57,27 @@ public class PrepareKickstartPxeServerCommand extends Command { this.initrd = initrd; } - public String getTemplateUuid() { - return templateUuid; - } - - public void setTemplateUuid(String templateUuid) { - this.templateUuid = templateUuid; - } - - public String getMac() { - return mac; - } - - public void setMac(String mac) { - this.mac = mac; - } - - public String getKsDevice() { - return ksDevice; - } - - public void setKsDevice(String ksDevice) { - this.ksDevice = ksDevice; - } -} + public String getTemplateUuid() { + return templateUuid; + } + + public void setTemplateUuid(String templateUuid) { + this.templateUuid = templateUuid; + } + + public String getMac() { + return mac; + } + + public void setMac(String mac) { + this.mac = mac; + } + + public String getKsDevice() { + return ksDevice; + } + + public void setKsDevice(String ksDevice) { + this.ksDevice = ksDevice; + } +} diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/SecurityGroupHttpClient.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/SecurityGroupHttpClient.java index 7ad351c2e33..b9c2e8484aa 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/SecurityGroupHttpClient.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/SecurityGroupHttpClient.java @@ -1,38 +1,38 @@ -// 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 01/29/2013 -// Apache License, Version 2.0 (the "License"); you may not use this -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -package com.cloud.baremetal.networkservice; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.SecurityGroupRulesCmd; - -public class SecurityGroupHttpClient { - - public Answer call(String guestIp, SecurityGroupRulesCmd cmd) { - // TODO Auto-generated method stub - return null; - } - - public boolean echo(String ip, long millis, long millis2) { - // TODO Auto-generated method stub - return false; - } - -} +// 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 01/29/2013 +// Apache License, Version 2.0 (the "License"); you may not use this +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +package com.cloud.baremetal.networkservice; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.SecurityGroupRulesCmd; + +public class SecurityGroupHttpClient { + + public Answer call(String guestIp, SecurityGroupRulesCmd cmd) { + // TODO Auto-generated method stub + return null; + } + + public boolean echo(String ip, long millis, long millis2) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml index 013a58d8b7c..613c817668e 100644 --- a/plugins/hypervisors/kvm/pom.xml +++ b/plugins/hypervisors/kvm/pom.xml @@ -1,22 +1,15 @@ - - + + 4.0.0 cloud-plugin-hypervisor-kvm Apache CloudStack Plugin - Hypervisor KVM @@ -45,28 +38,84 @@ - install - src - test - - - org.apache.maven.plugins - maven-dependency-plugin - 2.5.1 - - - copy-dependencies - package - - copy-dependencies - - - ${project.build.directory}/dependencies - runtime - - - - + install + src + test + + + org.apache.maven.plugins + maven-dependency-plugin + 2.5.1 + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/dependencies + runtime + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.14 + + + **/Qemu*.java + + + + + maven-assembly-plugin + 2.3 + + kvm-agent + false + + agent-descriptor.xml + + + + + make-agent + package + + single + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + + package + + copy-resources + + + dist + + + target + + kvm-agent.zip + + + + + + + + diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/DirectVifDriver.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/DirectVifDriver.java new file mode 100644 index 00000000000..1946d74a495 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/DirectVifDriver.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.cloud.hypervisor.kvm.resource; + +import com.cloud.agent.api.to.NicTO; +import com.cloud.exception.InternalErrorException; +import com.cloud.network.Networks; +import org.apache.log4j.Logger; +import org.libvirt.LibvirtException; + +import javax.naming.ConfigurationException; +import java.util.Map; + +public class DirectVifDriver extends VifDriverBase { + + private static final Logger s_logger = Logger.getLogger(DirectVifDriver.class); + + /** + * Experimental driver to configure direct networking in libvirt. This should only + * be used on an LXC cluster that does not run any system VMs. + * + * @param nic + * @param guestOsType + * @return + * @throws InternalErrorException + * @throws LibvirtException + */ + public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType) throws InternalErrorException, + LibvirtException { + LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef(); + + if (nic.getType() == Networks.TrafficType.Guest) { + intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType), + _libvirtComputingResource.getNetworkDirectSourceMode()); + + } else if (nic.getType() == Networks.TrafficType.Public) { + intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType), + _libvirtComputingResource.getNetworkDirectSourceMode()); + } + + return intf; + } + + public void unplug(LibvirtVMDef.InterfaceDef iface) { + // not needed, libvirt will cleanup + } + +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index f786f886bf1..362e0a53e53 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -57,6 +57,10 @@ import javax.ejb.Local; import javax.naming.ConfigurationException; import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; +import org.apache.cloudstack.utils.qemu.QemuImg; +import org.apache.cloudstack.utils.qemu.QemuImgFile; +import org.apache.cloudstack.utils.qemu.QemuImgException; import org.libvirt.Connect; import org.libvirt.Domain; import org.libvirt.DomainInfo; @@ -182,6 +186,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DevicesDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef.diskProtocol; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.FeaturesDef; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.FilesystemDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GraphicDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestResourceDef; @@ -192,7 +197,6 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; -import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.network.Networks.BroadcastDomainType; @@ -323,9 +327,11 @@ ServerResource { + " {1}" + " " + " "); - protected String _hypervisorType; + protected HypervisorType _hypervisorType; protected String _hypervisorURI; protected String _hypervisorPath; + protected String _networkDirectSourceMode; + protected String _networkDirectDevice; protected String _sysvmISOPath; protected String _privNwName; protected String _privBridgeName; @@ -392,6 +398,7 @@ ServerResource { private Map getDeveloperProperties() throws ConfigurationException { + final File file = PropertiesUtil.findConfigFile("developer.properties"); if (file == null) { throw new ConfigurationException( @@ -447,6 +454,14 @@ ServerResource { return "scripts/network/domr/kvm"; } + protected String getNetworkDirectSourceMode() { + return _networkDirectSourceMode; + } + + protected String getNetworkDirectDevice() { + return _networkDirectDevice; + } + @Override public boolean configure(String name, Map params) throws ConfigurationException { @@ -586,15 +601,19 @@ ServerResource { String instance = (String) params.get("instance"); - _hypervisorType = (String) params.get("hypervisor.type"); - if (_hypervisorType == null) { - _hypervisorType = "kvm"; + _hypervisorType = HypervisorType.getType((String) params.get("hypervisor.type")); + if (_hypervisorType == HypervisorType.None) { + _hypervisorType = HypervisorType.KVM; } _hypervisorURI = (String) params.get("hypervisor.uri"); if (_hypervisorURI == null) { - _hypervisorURI = "qemu:///system"; + _hypervisorURI = LibvirtConnection.getHypervisorURI(_hypervisorType.toString()); } + + _networkDirectSourceMode = (String) params.get("network.direct.source.mode"); + _networkDirectDevice = (String) params.get("network.direct.device"); + String startMac = (String) params.get("private.macaddr.start"); if (startMac == null) { startMac = "00:16:3e:77:e2:a0"; @@ -647,6 +666,9 @@ ServerResource { if (_localStoragePath == null) { _localStoragePath = "/var/lib/libvirt/images/"; } + + File storagePath = new File(_localStoragePath); + _localStoragePath = storagePath.getAbsolutePath(); _localStorageUUID = (String) params.get("local.storage.uuid"); if (_localStorageUUID == null) { @@ -680,12 +702,14 @@ ServerResource { throw new CloudRuntimeException(e.getMessage()); } - /* Does node support HVM guest? If not, exit */ - if (!IsHVMEnabled(conn)) { - throw new ConfigurationException( - "NO HVM support on this machine, please make sure: " - + "1. VT/SVM is supported by your CPU, or is enabled in BIOS. " - + "2. kvm modules are loaded (kvm, kvm_amd|kvm_intel)"); + if (HypervisorType.KVM == _hypervisorType) { + /* Does node support HVM guest? If not, exit */ + if (!IsHVMEnabled(conn)) { + throw new ConfigurationException( + "NO HVM support on this machine, please make sure: " + + "1. VT/SVM is supported by your CPU, or is enabled in BIOS. " + + "2. kvm modules are loaded (kvm, kvm_amd|kvm_intel)"); + } } _hypervisorPath = getHypervisorPath(conn); @@ -1218,10 +1242,23 @@ ServerResource { StorageFilerTO pool = cmd.getPool(); String secondaryStorageUrl = cmd.getSecondaryStorageURL(); KVMStoragePool secondaryStoragePool = null; + KVMStoragePool primaryPool = null; try { - KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool( - pool.getType(), - pool.getUuid()); + try { + primaryPool = _storagePoolMgr.getStoragePool( + pool.getType(), + pool.getUuid()); + } catch (CloudRuntimeException e) { + if (e.getMessage().contains("not found")) { + primaryPool = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), + cmd.getPool().getHost(), cmd.getPool().getPort(), + cmd.getPool().getPath(), cmd.getPool().getUserInfo(), + cmd.getPool().getType()); + } else { + return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null); + } + } + String volumeName = UUID.randomUUID().toString(); if (copyToSecondary) { @@ -1387,12 +1424,12 @@ ServerResource { StoragePoolType poolType = pool.getType(); PhysicalDiskFormat volFormat = vol.getFormat(); - if(pool.getType() == StoragePoolType.CLVM && volFormat == KVMPhysicalDisk.PhysicalDiskFormat.RAW) { + if(pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) { return "CLVM"; } else if ((poolType == StoragePoolType.NetworkFilesystem || poolType == StoragePoolType.SharedMountPoint || poolType == StoragePoolType.Filesystem) - && volFormat == KVMPhysicalDisk.PhysicalDiskFormat.QCOW2 ) { + && volFormat == PhysicalDiskFormat.QCOW2 ) { return "QCOW2"; } return null; @@ -1501,7 +1538,7 @@ ServerResource { NicTO nic = cmd.getNic(); String vmName = cmd.getVmName(); try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(vmName); Domain vm = getDomain(conn, vmName); List pluggedNics = getInterfaces(conn, vmName); Integer nicnum = 0; @@ -1530,7 +1567,7 @@ ServerResource { NicTO nic = cmd.getNic(); String vmName = cmd.getInstanceName(); try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(vmName); Domain vm = getDomain(conn, vmName); List pluggedNics = getInterfaces(conn, vmName); for (InterfaceDef pluggedNic : pluggedNics) { @@ -1568,7 +1605,7 @@ ServerResource { } try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(routerName); Domain vm = getDomain(conn, routerName); List pluggedNics = getInterfaces(conn, routerName); InterfaceDef routerNic = null; @@ -1609,7 +1646,7 @@ ServerResource { String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(routerName); Domain vm = getDomain(conn, routerName); String [][] rules = cmd.generateFwRules(); String[] aclRules = rules[0]; @@ -1648,7 +1685,7 @@ ServerResource { IpAddressTO pubIP = cmd.getIpAddress(); try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(routerName); Domain vm = getDomain(conn, routerName); Integer devNum = 0; String pubVlan = pubIP.getVlanId(); @@ -1694,7 +1731,7 @@ ServerResource { String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(routerName); IpAddressTO[] ips = cmd.getIpAddresses(); Domain vm = getDomain(conn, routerName); Integer devNum = 0; @@ -1742,7 +1779,7 @@ ServerResource { String[] results = new String[cmd.getIpAddresses().length]; Connect conn; try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(routerName); List nics = getInterfaces(conn, routerName); Map vlanAllocatedToVM = new HashMap(); Integer nicPos = 0; @@ -1799,7 +1836,7 @@ ServerResource { String snapshotPath = cmd.getSnapshotPath(); String vmName = cmd.getVmName(); try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(vmName); DomainInfo.DomainState state = null; Domain vm = null; if (vmName != null) { @@ -1888,7 +1925,7 @@ ServerResource { String vmName = cmd.getVmName(); KVMStoragePool secondaryStoragePool = null; try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(vmName); secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI( secondaryStoragePoolUrl); @@ -2155,8 +2192,9 @@ ServerResource { String secondaryStorageURL = cmd.getSecondaryStorageUrl(); KVMStoragePool secondaryStorage = null; + KVMStoragePool primary = null; try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); String templateFolder = cmd.getAccountId() + File.separator + cmd.getTemplateId() + File.separator; String templateInstallFolder = "/template/tmpl/" + templateFolder; @@ -2164,9 +2202,21 @@ ServerResource { secondaryStorage = _storagePoolMgr.getStoragePoolByURI( secondaryStorageURL); - KVMStoragePool primary = _storagePoolMgr.getStoragePool( + try { + primary = _storagePoolMgr.getStoragePool( cmd.getPool().getType(), cmd.getPrimaryStoragePoolNameLabel()); + } catch (CloudRuntimeException e) { + if (e.getMessage().contains("not found")) { + primary = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), + cmd.getPool().getHost(), cmd.getPool().getPort(), + cmd.getPool().getPath(), cmd.getPool().getUserInfo(), + cmd.getPool().getType()); + } else { + return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); + } + } + KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath()); String tmpltPath = secondaryStorage.getLocalPath() + File.separator + templateInstallFolder; @@ -2186,14 +2236,25 @@ ServerResource { } } else { s_logger.debug("Converting RBD disk " + disk.getPath() + " into template " + cmd.getUniqueName()); - Script.runSimpleBashScript("qemu-img convert" - + " -f raw -O qcow2 " - + KVMPhysicalDisk.RBDStringBuilder(primary.getSourceHost(), + + QemuImgFile srcFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(primary.getSourceHost(), primary.getSourcePort(), primary.getAuthUserName(), primary.getAuthSecret(), - disk.getPath()) - + " " + tmpltPath + "/" + cmd.getUniqueName() + ".qcow2"); + disk.getPath())); + srcFile.setFormat(PhysicalDiskFormat.RAW); + + QemuImgFile destFile = new QemuImgFile(tmpltPath + "/" + cmd.getUniqueName() + ".qcow2"); + destFile.setFormat(PhysicalDiskFormat.QCOW2); + + QemuImg q = new QemuImg(); + try { + q.convert(srcFile, destFile); + } catch (QemuImgException e) { + s_logger.error("Failed to create new template while converting " + + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage()); + } + File templateProp = new File(tmpltPath + "/template.properties"); if (!templateProp.exists()) { templateProp.createNewFile(); @@ -2331,7 +2392,7 @@ ServerResource { String vif = null; String brname = null; try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); List nics = getInterfaces(conn, cmd.getVmName()); vif = nics.get(0).getDevName(); brname = nics.get(0).getBrName(); @@ -2365,7 +2426,7 @@ ServerResource { protected GetVncPortAnswer execute(GetVncPortCommand cmd) { try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getName()); Integer vncPort = getVncPort(conn, cmd.getName()); return new GetVncPortAnswer(cmd, _privateIp, 5900 + vncPort); } catch (LibvirtException e) { @@ -2436,7 +2497,7 @@ ServerResource { private Answer execute(AttachIsoCommand cmd) { try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); attachOrDetachISO(conn, cmd.getVmName(), cmd.getIsoPath(), cmd.isAttach()); } catch (LibvirtException e) { @@ -2452,7 +2513,7 @@ ServerResource { private AttachVolumeAnswer execute(AttachVolumeCommand cmd) { try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); KVMStoragePool primary = _storagePoolMgr.getStoragePool( cmd.getPooltype(), cmd.getPoolUuid()); @@ -2504,7 +2565,7 @@ ServerResource { private Answer execute(CheckVirtualMachineCommand cmd) { try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); final State state = getVmState(conn, cmd.getVmName()); Integer vncPort = null; if (state == State.Running) { @@ -2573,7 +2634,7 @@ ServerResource { Domain destDomain = null; Connect conn = null; try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); ifaces = getInterfaces(conn, vmName); dm = conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName .getBytes())); @@ -2633,7 +2694,7 @@ ServerResource { NicTO[] nics = vm.getNics(); try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(vm.getName()); for (NicTO nic : nics) { getVifDriver(nic.getType()).plug(nic, null); } @@ -2828,7 +2889,7 @@ ServerResource { } try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); final String result = rebootVM(conn, cmd.getVmName()); if (result == null) { Integer vncPort = null; @@ -2866,8 +2927,8 @@ ServerResource { List vmNames = cmd.getVmNames(); try { HashMap vmStatsNameMap = new HashMap(); - Connect conn = LibvirtConnection.getConnection(); for (String vmName : vmNames) { + Connect conn = LibvirtConnection.getConnectionByVmName(vmName); VmStatsEntry statEntry = getVmStat(conn, vmName); if (statEntry == null) { continue; @@ -2891,7 +2952,7 @@ ServerResource { _vms.put(vmName, State.Stopping); } try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(vmName); List disks = getDisks(conn, vmName); List ifaces = getInterfaces(conn, vmName); @@ -3021,14 +3082,22 @@ ServerResource { protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) { LibvirtVMDef vm = new LibvirtVMDef(); - vm.setHvsType(_hypervisorType); vm.setDomainName(vmTO.getName()); vm.setDomUUID(UUID.nameUUIDFromBytes(vmTO.getName().getBytes()) .toString()); vm.setDomDescription(vmTO.getOs()); GuestDef guest = new GuestDef(); - guest.setGuestType(GuestDef.guestType.KVM); + + if (HypervisorType.LXC == _hypervisorType && + VirtualMachine.Type.User == vmTO.getType()) { + // LXC domain is only valid for user VMs. Use KVM for system VMs. + guest.setGuestType(GuestDef.guestType.LXC); + vm.setHvsType(HypervisorType.LXC.toString().toLowerCase()); + } else { + guest.setGuestType(GuestDef.guestType.KVM); + vm.setHvsType(HypervisorType.KVM.toString().toLowerCase()); + } guest.setGuestArch(vmTO.getArch()); guest.setMachineType("pc"); guest.setBootOrder(GuestDef.bootOrder.CDROM); @@ -3040,8 +3109,8 @@ ServerResource { if (vmTO.getMinRam() != vmTO.getMaxRam()){ grd.setMemBalloning(true); - grd.setCurrentMem((int)vmTO.getMinRam()/1024); - grd.setMemorySize((int)vmTO.getMaxRam()/1024); + grd.setCurrentMem((long)vmTO.getMinRam()/1024); + grd.setMemorySize((long)vmTO.getMaxRam()/1024); } else{ grd.setMemorySize(vmTO.getMaxRam() / 1024); @@ -3089,6 +3158,7 @@ ServerResource { DevicesDef devices = new DevicesDef(); devices.setEmulatorPath(_hypervisorPath); + devices.setGuestType(guest.getGuestType()); SerialDef serial = new SerialDef("pty", null, (short) 0); devices.addDevice(serial); @@ -3134,13 +3204,14 @@ ServerResource { State state = State.Stopped; Connect conn = null; try { - conn = LibvirtConnection.getConnection(); synchronized (_vms) { _vms.put(vmName, State.Starting); } vm = createVMFromSpec(vmSpec); + conn = LibvirtConnection.getConnectionByType(vm.getHvsType()); + createVbd(conn, vmSpec, vmName, vm); createVifs(vmSpec, vm); @@ -3305,6 +3376,22 @@ ServerResource { vm.getDevices().addDevice(iso); } } + + // For LXC, find and add the root filesystem + if (HypervisorType.LXC.toString().toLowerCase().equals(vm.getHvsType())) { + for (VolumeTO volume : disks) { + if (volume.getType() == Volume.Type.ROOT) { + KVMStoragePool pool = _storagePoolMgr.getStoragePool( + volume.getPoolType(), + volume.getPoolUuid()); + KVMPhysicalDisk physicalDisk = pool.getPhysicalDisk(volume.getPath()); + FilesystemDef rootFs = new FilesystemDef(physicalDisk.getPath(), "/"); + vm.getDevices().addDevice(rootFs); + break; + } + } + } + } private VolumeTO getVolume(VirtualMachineTO vmSpec, Volume.Type type) { @@ -3539,7 +3626,7 @@ ServerResource { final StartupRoutingCommand cmd = new StartupRoutingCommand( (Integer) info.get(0), (Long) info.get(1), (Long) info.get(2), - (Long) info.get(4), (String) info.get(3), HypervisorType.KVM, + (Long) info.get(4), (String) info.get(3), _hypervisorType, RouterPrivateIpStrategy.HostLocal); cmd.setStateChanges(changes); fillNetworkInformation(cmd); @@ -3695,7 +3782,7 @@ ServerResource { Domain dm = null; for (; i < 5; i++) { try { - Connect conn = LibvirtConnection.getConnection(); + Connect conn = LibvirtConnection.getConnectionByVmName(vm); dm = conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vm .getBytes())); DomainInfo.DomainState vps = dm.getInfo().state; @@ -3767,16 +3854,30 @@ ServerResource { private HashMap getAllVms() { final HashMap vmStates = new HashMap(); + Connect conn = null; + + try { + conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString()); + vmStates.putAll(getAllVms(conn)); + } catch (LibvirtException e) { + s_logger.debug("Failed to get connection: " + e.getMessage()); + } + + try { + conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString()); + vmStates.putAll(getAllVms(conn)); + } catch (LibvirtException e) { + s_logger.debug("Failed to get connection: " + e.getMessage()); + } + + return vmStates; + } + + private HashMap getAllVms(Connect conn) { + final HashMap vmStates = new HashMap(); String[] vms = null; int[] ids = null; - Connect conn = null; - try { - conn = LibvirtConnection.getConnection(); - } catch (LibvirtException e) { - s_logger.debug("Failed to get connection: " + e.getMessage()); - return vmStates; - } try { ids = conn.listDomains(); @@ -4227,9 +4328,11 @@ ServerResource { } private void cleanupVMNetworks(Connect conn, List nics) { - for (InterfaceDef nic : nics) { - if (nic.getHostNetType() == hostNicType.VNET) { - cleanupVnet(conn, getVnetIdFromBrName(nic.getBrName())); + if (nics != null) { + for (InterfaceDef nic : nics) { + if (nic.getHostNetType() == hostNicType.VNET) { + cleanupVnet(conn, getVnetIdFromBrName(nic.getBrName())); + } } } } @@ -4441,7 +4544,7 @@ ServerResource { } List intfs = getInterfaces(conn, vmName); - if (intfs.size() < nic.getDeviceId()) { + if (intfs.size() == 0 || intfs.size() < nic.getDeviceId()) { return false; } @@ -4539,7 +4642,7 @@ ServerResource { cmd.add("--vif", vif); cmd.add("--brname", brname); cmd.add("--nicsecips", secIps); - if (rules != null) { + if (newRules != null && !newRules.isEmpty()) { cmd.add("--rules", newRules); } String result = cmd.execute(); @@ -4647,7 +4750,7 @@ ServerResource { boolean success = false; Connect conn; try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); success = default_network_rules_for_systemvm(conn, cmd.getVmName()); } catch (LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); @@ -4660,7 +4763,7 @@ ServerResource { boolean success = false; Connect conn; try { - conn = LibvirtConnection.getConnection(); + conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); success = network_rules_vmSecondaryIp(conn, cmd.getVmName(), cmd.getVmSecIp(), cmd.getAction()); } catch (LibvirtException e) { // TODO Auto-generated catch block diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java index 981d343004d..2ad16166c42 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java @@ -16,33 +16,75 @@ // under the License. package com.cloud.hypervisor.kvm.resource; +import com.cloud.hypervisor.Hypervisor; +import com.cloud.hypervisor.Hypervisor.HypervisorType; import org.apache.log4j.Logger; import org.libvirt.Connect; import org.libvirt.LibvirtException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + public class LibvirtConnection { private static final Logger s_logger = Logger .getLogger(LibvirtConnection.class); + static private Map _connections = new HashMap(); + static private Connect _connection; static private String _hypervisorURI; static public Connect getConnection() throws LibvirtException { - if (_connection == null) { - _connection = new Connect(_hypervisorURI, false); + return getConnection(_hypervisorURI); + } + + static public Connect getConnection(String hypervisorURI) throws LibvirtException { + Connect conn = _connections.get(hypervisorURI); + + if (conn == null) { + conn = new Connect(hypervisorURI, false); + _connections.put(hypervisorURI, conn); } else { try { - _connection.getVersion(); + conn.getVersion(); } catch (LibvirtException e) { s_logger.debug("Connection with libvirtd is broken, due to " + e.getMessage()); - _connection = new Connect(_hypervisorURI, false); + conn = new Connect(hypervisorURI, false); + _connections.put(hypervisorURI, conn); } } - return _connection; + return conn; + } + + static public Connect getConnectionByVmName(String vmName) throws LibvirtException { + HypervisorType[] hypervisors = new HypervisorType[] {HypervisorType.KVM, Hypervisor.HypervisorType.LXC}; + + for (HypervisorType hypervisor : hypervisors) { + Connect conn = LibvirtConnection.getConnectionByType(hypervisor.toString()); + if (conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName.getBytes())) != null) { + return conn; + } + } + + // return the default connection + return getConnection(); + } + + static public Connect getConnectionByType(String hypervisorType) throws LibvirtException { + return getConnection(getHypervisorURI(hypervisorType)); } static void initialize(String hypervisorURI) { _hypervisorURI = hypervisorURI; } + + static String getHypervisorURI(String hypervisorType) { + if ("LXC".equalsIgnoreCase(hypervisorType)) { + return "lxc:///"; + } else { + return "qemu:///system"; + } + } } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java index b622b6d33cf..ac4baf122a9 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java @@ -25,6 +25,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -110,23 +111,29 @@ public class LibvirtDomainXMLParser { String bridge = getAttrValue("source", "bridge", nic); def.defBridgeNet(bridge, dev, mac, nicModel.valueOf(model.toUpperCase())); + } else if (type.equalsIgnoreCase("ethernet")) { + String scriptPath = getAttrValue("script", "path", nic); + def.defEthernet(dev, mac, nicModel.valueOf(model.toUpperCase()), scriptPath); } interfaces.add(def); } Element graphic = (Element) devices .getElementsByTagName("graphics").item(0); - String port = graphic.getAttribute("port"); - if (port != null) { - try { - vncPort = Integer.parseInt(port); - if (vncPort != -1) { - vncPort = vncPort - 5900; - } else { + + if (graphic != null) { + String port = graphic.getAttribute("port"); + if (port != null) { + try { + vncPort = Integer.parseInt(port); + if (vncPort != -1) { + vncPort = vncPort - 5900; + } else { + vncPort = null; + } + } catch (NumberFormatException nfe) { vncPort = null; } - } catch (NumberFormatException nfe) { - vncPort = null; } } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java index d5cd91a954c..7f9ceebe742 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java @@ -18,7 +18,7 @@ package com.cloud.hypervisor.kvm.resource; public class LibvirtStorageVolumeDef { public enum volFormat { - RAW("raw"), QCOW2("qcow2"), DIR("dir"); + RAW("raw"), QCOW2("qcow2"), DIR("dir"), TAR("tar"); private String _format; volFormat(String format) { @@ -38,6 +38,10 @@ public class LibvirtStorageVolumeDef { return RAW; } else if (format.equalsIgnoreCase("qcow2")) { return QCOW2; + } else if (format.equalsIgnoreCase("dir")) { + return DIR; + } else if (format.equalsIgnoreCase("tar")) { + return TAR; } return null; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index c93aeeb2dd6..9cddb2e4323 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -31,7 +31,7 @@ public class LibvirtVMDef { public static class GuestDef { enum guestType { - KVM, XEN, EXE + KVM, XEN, EXE, LXC } enum bootOrder { @@ -62,6 +62,10 @@ public class LibvirtVMDef { _type = type; } + public guestType getGuestType() { + return _type; + } + public void setGuestArch(String arch) { _arch = arch; } @@ -106,14 +110,22 @@ public class LibvirtVMDef { } guestDef.append("\n"); return guestDef.toString(); - } else + } else if (_type == guestType.LXC) { + StringBuilder guestDef = new StringBuilder(); + guestDef.append("\n"); + guestDef.append("exe\n"); + guestDef.append("/sbin/init\n"); + guestDef.append("\n"); + return guestDef.toString(); + } else { return null; + } } } public static class GuestResourceDef { private long _mem; - private int _currentMem = -1; + private long _currentMem = -1; private String _memBacking; private int _vcpu = -1; private boolean _memBalloning= false; @@ -122,7 +134,7 @@ public class LibvirtVMDef { _mem = mem; } - public void setCurrentMem(int currMem) { + public void setCurrentMem(long currMem) { _currentMem = currMem; } @@ -279,6 +291,7 @@ public class LibvirtVMDef { public static class DevicesDef { private String _emulator; + private GuestDef.guestType _guestType; private final Map> devices = new HashMap>(); public boolean addDevice(Object device) { @@ -298,6 +311,10 @@ public class LibvirtVMDef { _emulator = emulator; } + public void setGuestType(GuestDef.guestType guestType) { + _guestType = guestType; + } + @Override public String toString() { StringBuilder devicesBuilder = new StringBuilder(); @@ -309,6 +326,13 @@ public class LibvirtVMDef { for (List devs : devices.values()) { for (Object dev : devs) { + if (_guestType == GuestDef.guestType.LXC) { + if (dev instanceof GraphicDef || + dev instanceof InputDef || + dev instanceof DiskDef) { + continue; + } + } devicesBuilder.append(dev.toString()); } } @@ -610,7 +634,7 @@ public class LibvirtVMDef { public static class InterfaceDef { enum guestNetType { - BRIDGE("bridge"), NETWORK("network"), USER("user"), ETHERNET( + BRIDGE("bridge"), DIRECT("direct"), NETWORK("network"), USER("user"), ETHERNET( "ethernet"), INTERNAL("internal"); String _type; @@ -648,6 +672,7 @@ public class LibvirtVMDef { * internal */ private hostNicType _hostNetType; /* Only used by agent java code */ + private String _netSourceMode; private String _sourceName; private String _networkName; private String _macAddr; @@ -667,6 +692,16 @@ public class LibvirtVMDef { _model = model; } + public void defDirectNet(String sourceName, String targetName, + String macAddr, nicModel model, String sourceMode) { + _netType = guestNetType.DIRECT; + _netSourceMode = sourceMode; + _sourceName = sourceName; + _networkName = targetName; + _macAddr = macAddr; + _model = model; + } + public void defPrivateNet(String networkName, String targetName, String macAddr, nicModel model) { _netType = guestNetType.NETWORK; @@ -676,13 +711,19 @@ public class LibvirtVMDef { _model = model; } - public void defEthernet(String targetName, String macAddr, nicModel model) { + public void defEthernet(String targetName, String macAddr, nicModel model, String scriptPath) { _netType = guestNetType.ETHERNET; _networkName = targetName; + _sourceName = targetName; _macAddr = macAddr; _model = model; + _scriptPath = scriptPath; } + public void defEthernet(String targetName, String macAddr, nicModel model) { + defEthernet(targetName, macAddr, model, null); + } + public void setHostNetType(hostNicType hostNetType) { _hostNetType = hostNetType; } @@ -699,6 +740,10 @@ public class LibvirtVMDef { return _netType; } + public String getNetSourceMode() { + return _netSourceMode; + } + public String getDevName() { return _networkName; } @@ -739,6 +784,8 @@ public class LibvirtVMDef { netBuilder.append("\n"); } else if (_netType == guestNetType.NETWORK) { netBuilder.append("\n"); + } else if (_netType == guestNetType.DIRECT) { + netBuilder.append("\n"); } if (_networkName != null) { netBuilder.append("\n"); @@ -749,6 +796,9 @@ public class LibvirtVMDef { if (_model != null) { netBuilder.append("\n"); } + if (_scriptPath != null) { + netBuilder.append("