Merge master into disk_io_throttling

This commit is contained in:
Wei Zhou 2013-06-06 14:57:19 +02:00
commit 0beffe84d8
270 changed files with 13782 additions and 2943 deletions

View File

@ -1,54 +0,0 @@
<?xml version="1.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.
-->
<components-simulator.xml>
<management-server class="com.cloud.server.ManagementServerSimulatorImpl" library="com.cloud.configuration.SimulatorComponentLibrary" extends="components.xml:management-server">
<dao name="Configuration configuration server" class="com.cloud.configuration.dao.ConfigurationDaoImpl">
<param name="premium">true</param>
</dao>
<adapters key="com.cloud.ha.Investigator">
<adapter name="SimpleInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator"/>
<adapter name="PingInvestigator" class="com.cloud.ha.UserVmDomRInvestigator"/>
<adapter name="ManagementIPSysVMInvestigator" class="com.cloud.ha.ManagementIPSystemVMInvestigator"/>
</adapters>
<adapters key="com.cloud.resource.Discoverer">
<adapter name="Simulator Agent" class="com.cloud.resource.SimulatorDiscoverer"/>
<adapter name="XCP Agent" class="com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer"/>
<adapter name="SecondaryStorage" class="com.cloud.storage.secondary.SecondaryStorageDiscoverer"/>
<adapter name="KVM Agent" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer"/>
<adapter name="SecondaryStorage" class="com.cloud.resource.SimulatorSecondaryDiscoverer"/>
</adapters>
<adapters key="com.cloud.hypervisor.HypervisorGuru">
<adapter name="SimulatorGuru" class="com.cloud.simulator.SimulatorGuru"/>
<adapter name="XenServerGuru" class="com.cloud.hypervisor.XenServerGuru"/>
<adapter name="KVMGuru" class="com.cloud.hypervisor.KVMGuru"/>
</adapters>
<adapters key="com.cloud.agent.StartupCommandProcessor">
<adapter name="BasicAgentAuthorizer" class="com.cloud.agent.manager.authn.impl.BasicAgentAuthManager"/>
</adapters>
</management-server>
<configuration-server class="com.cloud.server.ConfigurationServerImpl" extends="components.xml:configuration-server">
<dao name="Configuration configuration server" class="com.cloud.configuration.dao.ConfigurationDaoImpl" singleton="false">
<param name="premium">true</param>
</dao>
</configuration-server>
</components-simulator.xml>

View File

@ -20,11 +20,14 @@ public class DnsmasqTO {
String routerIp;
String gateway;
String netmask;
String startIpOfSubnet;
public DnsmasqTO(String routerIp, String gateway, String netmask) {
public DnsmasqTO(String routerIp, String gateway, String netmask, String StartIpOfSubnet) {
this.routerIp = routerIp;
this.startIpOfSubnet = StartIpOfSubnet;
this.gateway = gateway;
this.netmask =netmask;
}
public void setRouterIp(String routerIp){
@ -39,6 +42,10 @@ public class DnsmasqTO {
this.netmask = netmask ;
}
public void setStartIpOfSubnet( String ipOfSubNet) {
startIpOfSubnet = ipOfSubNet;
}
public String getRouterIp() {
return routerIp;
}
@ -50,4 +57,8 @@ public class DnsmasqTO {
public String getNetmask() {
return netmask;
}
public String getStartIpOfSubnet() {
return startIpOfSubnet;
}
}

View File

@ -52,6 +52,7 @@ public class VirtualMachineTO {
boolean rebootOnCrash;
boolean enableHA;
boolean limitCpuUse;
boolean enableDynamicallyScaleVm;
String vncPassword;
String vncAddr;
Map<String, String> params;
@ -102,6 +103,14 @@ public class VirtualMachineTO {
this.id = id;
}
public boolean isEnableDynamicallyScaleVm() {
return enableDynamicallyScaleVm;
}
public void setEnableDynamicallyScaleVm(boolean enableDynamicallyScaleVm) {
this.enableDynamicallyScaleVm = enableDynamicallyScaleVm;
}
public String getName() {
return name;
}

View File

@ -0,0 +1,33 @@
// 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.dc;
import org.apache.cloudstack.acl.InfrastructureEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface DedicatedResources extends InfrastructureEntity, InternalIdentity, Identity{
long getId();
Long getDataCenterId();
Long getPodId();
Long getClusterId();
Long getHostId();
Long getDomainId();
Long getAccountId();
String getUuid();
}

View File

@ -18,6 +18,7 @@ package com.cloud.deploy;
import java.util.List;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
@ -40,6 +41,7 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner {
List<Long> orderClusters(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid)
throws InsufficientServerCapacityException;
PlannerResourceUsage getResourceUsage();
PlannerResourceUsage getResourceUsage(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
}

View File

@ -438,6 +438,10 @@ public class EventTypes {
public static final String EVENT_PORTABLE_IP_RANGE_DELETE = "PORTABLE.IP.RANGE.DELETE";
public static final String EVENT_PORTABLE_IP_TRANSFER = "PORTABLE.IP.TRANSFER";
// Dedicated Resources
public static final String EVENT_DEDICATE_RESOURCE = "DEDICATE.RESOURCE";
public static final String EVENT_DEDICATE_RESOURCE_RELEASE = "DEDICATE.RESOURCE.RELEASE";
static {
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking

View File

@ -33,6 +33,9 @@ public interface GlobalLoadBalancingRulesService {
GlobalLoadBalancerRule updateGlobalLoadBalancerRule(UpdateGlobalLoadBalancerRuleCmd updateGslbCmd);
boolean revokeAllGslbRulesForAccount(com.cloud.user.Account caller, long accountId)
throws com.cloud.exception.ResourceUnavailableException;
/*
* methods for managing sites participating in global load balancing
*/

View File

@ -16,22 +16,15 @@
// under the License.
package com.cloud.user;
import java.util.List;
import java.util.Map;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
import com.cloud.domain.Domain;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.utils.Pair;
public interface AccountService {
@ -83,13 +76,11 @@ public interface AccountService {
Account finalizeOwner(Account caller, String accountName, Long domainId, Long projectId);
Pair<List<Long>, Long> finalizeAccountDomainForList(Account caller, String accountName, Long domainId, Long projectId);
Account getActiveAccountByName(String accountName, Long domainId);
Account getActiveAccountById(Long accountId);
Account getActiveAccountById(long accountId);
Account getAccount(Long accountId);
Account getAccount(long accountId);
User getActiveUser(long userId);

View File

@ -18,7 +18,6 @@ package org.apache.cloudstack.affinity;
import java.util.List;
import com.cloud.exception.ResourceInUseException;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
@ -45,10 +44,8 @@ public interface AffinityGroupService {
* @param account
* @param domainId
* @param affinityGroupName
* @throws ResourceInUseException
*/
boolean deleteAffinityGroup(Long affinityGroupId, String account, Long domainId, String affinityGroupName)
throws ResourceInUseException;
boolean deleteAffinityGroup(Long affinityGroupId, String account, Long domainId, String affinityGroupName);
/** Lists Affinity Groups in your account
* @param account

View File

@ -206,6 +206,7 @@ public class ApiConstants {
public static final String STATE = "state";
public static final String STATUS = "status";
public static final String STORAGE_TYPE = "storagetype";
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
public static final String SYSTEM_VM_TYPE = "systemvmtype";
public static final String TAGS = "tags";
public static final String TARGET_IQN = "targetiqn";
@ -304,6 +305,8 @@ public class ApiConstants {
public static final String TEMPLATE_TAG = "templatetag";
public static final String HYPERVISOR_VERSION = "hypervisorversion";
public static final String MAX_GUESTS_LIMIT = "maxguestslimit";
public static final String MAX_DATA_VOLUMES_LIMIT = "maxdatavolumeslimit";
public static final String MAX_HOSTS_PER_CLUSTER = "maxhostspercluster";
public static final String PROJECT_ID = "projectid";
public static final String PROJECT_IDS = "projectids";
public static final String PROJECT = "project";
@ -402,6 +405,7 @@ public class ApiConstants {
public static final String VSM_CONFIG_MODE = "vsmconfigmode";
public static final String VSM_CONFIG_STATE = "vsmconfigstate";
public static final String VSM_DEVICE_STATE = "vsmdevicestate";
public static final String VCENTER = "vcenter";
public static final String ADD_VSM_FLAG = "addvsmflag";
public static final String END_POINT = "endpoint";
public static final String REGION_ID = "regionid";

View File

@ -16,113 +16,6 @@
// under the License.
package org.apache.cloudstack.api;
import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import com.cloud.vm.NicSecondaryIp;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import com.cloud.network.vpc.NetworkACL;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcOffering;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
import org.apache.cloudstack.api.response.AsyncJobResponse;
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
import org.apache.cloudstack.api.response.CapacityResponse;
import org.apache.cloudstack.api.response.ClusterResponse;
import org.apache.cloudstack.api.response.ConditionResponse;
import org.apache.cloudstack.api.response.ConfigurationResponse;
import org.apache.cloudstack.api.response.CounterResponse;
import org.apache.cloudstack.api.response.CreateCmdResponse;
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.DomainRouterResponse;
import org.apache.cloudstack.api.response.EventResponse;
import org.apache.cloudstack.api.response.ExtractResponse;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
import org.apache.cloudstack.api.response.HostForMigrationResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
import org.apache.cloudstack.api.response.LBStickinessResponse;
import org.apache.cloudstack.api.response.LDAPConfigResponse;
import org.apache.cloudstack.api.response.LoadBalancerResponse;
import org.apache.cloudstack.api.response.NetworkACLResponse;
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.NicResponse;
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
import org.apache.cloudstack.api.response.ProjectAccountResponse;
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ProviderResponse;
import org.apache.cloudstack.api.response.RegionResponse;
import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
import org.apache.cloudstack.api.response.ResourceCountResponse;
import org.apache.cloudstack.api.response.ResourceLimitResponse;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.api.response.S3Response;
import org.apache.cloudstack.api.response.SecurityGroupResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ServiceResponse;
import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
import org.apache.cloudstack.api.response.SnapshotResponse;
import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
import org.apache.cloudstack.api.response.StaticRouteResponse;
import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
import org.apache.cloudstack.api.response.StoragePoolForMigrationResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.api.response.SwiftResponse;
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
import org.apache.cloudstack.api.response.TrafficTypeResponse;
import org.apache.cloudstack.api.response.UsageRecordResponse;
import org.apache.cloudstack.api.response.UserResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VMSnapshotResponse;
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import org.apache.cloudstack.api.response.VpcOfferingResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.VpnUsersResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.api.response.*;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
import org.apache.cloudstack.region.Region;
import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
import org.apache.cloudstack.usage.Usage;
import com.cloud.async.AsyncJob;
import com.cloud.capacity.Capacity;
import com.cloud.configuration.Configuration;
@ -164,6 +57,12 @@ import com.cloud.network.rules.StaticNatRule;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityRule;
import com.cloud.network.vpc.NetworkACL;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
@ -192,6 +91,106 @@ import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.snapshot.VMSnapshot;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
import org.apache.cloudstack.api.response.AsyncJobResponse;
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
import org.apache.cloudstack.api.response.CapacityResponse;
import org.apache.cloudstack.api.response.ClusterResponse;
import org.apache.cloudstack.api.response.ConditionResponse;
import org.apache.cloudstack.api.response.ConfigurationResponse;
import org.apache.cloudstack.api.response.CounterResponse;
import org.apache.cloudstack.api.response.CreateCmdResponse;
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.DomainRouterResponse;
import org.apache.cloudstack.api.response.EventResponse;
import org.apache.cloudstack.api.response.ExtractResponse;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
import org.apache.cloudstack.api.response.HostForMigrationResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
import org.apache.cloudstack.api.response.LBStickinessResponse;
import org.apache.cloudstack.api.response.LDAPConfigResponse;
import org.apache.cloudstack.api.response.LoadBalancerResponse;
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
import org.apache.cloudstack.api.response.NetworkACLResponse;
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.NicResponse;
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.PortableIpRangeResponse;
import org.apache.cloudstack.api.response.PortableIpResponse;
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
import org.apache.cloudstack.api.response.ProjectAccountResponse;
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ProviderResponse;
import org.apache.cloudstack.api.response.RegionResponse;
import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
import org.apache.cloudstack.api.response.ResourceCountResponse;
import org.apache.cloudstack.api.response.ResourceLimitResponse;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.api.response.S3Response;
import org.apache.cloudstack.api.response.SecurityGroupResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ServiceResponse;
import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
import org.apache.cloudstack.api.response.SnapshotResponse;
import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
import org.apache.cloudstack.api.response.StaticRouteResponse;
import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.api.response.SwiftResponse;
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
import org.apache.cloudstack.api.response.TrafficTypeResponse;
import org.apache.cloudstack.api.response.UsageRecordResponse;
import org.apache.cloudstack.api.response.UserResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VMSnapshotResponse;
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import org.apache.cloudstack.api.response.VpcOfferingResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.VpnUsersResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
import org.apache.cloudstack.region.Region;
import org.apache.cloudstack.usage.Usage;
import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
public interface ResponseGenerator {
UserResponse createUserResponse(UserAccount user);
@ -259,7 +258,7 @@ public interface ResponseGenerator {
StoragePoolResponse createStoragePoolResponse(StoragePool pool);
StoragePoolForMigrationResponse createStoragePoolForMigrationResponse(StoragePool pool);
StoragePoolResponse createStoragePoolForMigrationResponse(StoragePool pool);
ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapacities);

View File

@ -17,10 +17,13 @@
package org.apache.cloudstack.api.command.admin.internallb;
import java.util.List;
import javax.inject.Inject;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.VirtualRouterProvider;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
@ -31,13 +34,8 @@ import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.VirtualRouterProvider;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import javax.inject.Inject;
import java.util.List;
@APICommand(name = "configureInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class,
description="Configures an Internal Load Balancer element.", since="4.2.0")
@ -98,11 +96,8 @@ public class ConfigureInternalLoadBalancerElementCmd extends BaseAsyncCmd {
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
s_logger.debug("hello alena");
UserContext.current().setEventDetails("Internal load balancer element: " + id);
s_logger.debug("hello alena");
VirtualRouterProvider result = _service.get(0).configureInternalLoadBalancerElement(getId(), getEnabled());
s_logger.debug("hello alena");
if (result != null){
InternalLoadBalancerElementResponse routerResponse = _responseGenerator.createInternalLbElementResponse(result);
routerResponse.setResponseName(getCommandName());

View File

@ -71,15 +71,19 @@ public class CreateStoragePoolCmd extends BaseCmd {
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
required=true, description="the Zone ID for the storage pool")
private Long zoneId;
@Parameter(name=ApiConstants.PROVIDER, type=CommandType.STRING,
required=false, description="the storage provider name")
private String storageProviderName;
@Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING,
required=false, description="the scope of the storage: cluster or zone")
private String scope;
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=false,
description="hypervisor type of the hosts in zone that will be attached to this storage pool. KVM, VMware supported as of now.")
private String hypervisor;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -111,18 +115,18 @@ public class CreateStoragePoolCmd extends BaseCmd {
public Long getZoneId() {
return zoneId;
}
public String getStorageProviderName() {
return this.storageProviderName;
}
public String getScope() {
return this.scope;
return this.scope;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
public String getHypervisor() {
return hypervisor;
}
@Override
public String getCommandName() {

View File

@ -16,24 +16,23 @@
// under the License.
package org.apache.cloudstack.api.command.admin.storage;
import java.util.ArrayList;
import java.util.List;
import com.cloud.async.AsyncJob;
import com.cloud.storage.StoragePool;
import com.cloud.utils.Pair;
import org.apache.cloudstack.api.APICommand;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.StoragePoolForMigrationResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import com.cloud.async.AsyncJob;
import com.cloud.storage.StoragePool;
import com.cloud.utils.Pair;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@APICommand(name = "findStoragePoolsForMigration", description="Lists storage pools available for migration of a volume.",
responseObject=StoragePoolForMigrationResponse.class)
responseObject=StoragePoolResponse.class)
public class FindStoragePoolsForMigrationCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(FindStoragePoolsForMigrationCmd.class.getName());
@ -72,13 +71,13 @@ public class FindStoragePoolsForMigrationCmd extends BaseListCmd {
public void execute() {
Pair<List<? extends StoragePool>, List<? extends StoragePool>> pools =
_mgr.listStoragePoolsForMigrationOfVolume(getId());
ListResponse<StoragePoolForMigrationResponse> response = new ListResponse<StoragePoolForMigrationResponse>();
List<StoragePoolForMigrationResponse> poolResponses = new ArrayList<StoragePoolForMigrationResponse>();
ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
List<StoragePoolResponse> poolResponses = new ArrayList<StoragePoolResponse>();
List<? extends StoragePool> allPools = pools.first();
List<? extends StoragePool> suitablePoolList = pools.second();
for (StoragePool pool : allPools) {
StoragePoolForMigrationResponse poolResponse = _responseGenerator.createStoragePoolForMigrationResponse(pool);
StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolForMigrationResponse(pool);
Boolean suitableForMigration = false;
for (StoragePool suitablePool : suitablePoolList) {
if (suitablePool.getId() == pool.getId()) {

View File

@ -38,7 +38,7 @@ public class UpdateVPCOfferingCmd extends BaseAsyncCmd{
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = VpcOfferingResponse.class,
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = VpcOfferingResponse.class, required=true,
description="the id of the VPC offering")
private Long id;

View File

@ -30,7 +30,6 @@ import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@ -123,17 +122,12 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
@Override
public void execute(){
try{
boolean result = _affinityGroupService.deleteAffinityGroup(id, accountName, domainId, name);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete affinity group");
}
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex.getMessage());
boolean result = _affinityGroupService.deleteAffinityGroup(id, accountName, domainId, name);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete affinity group");
}
}

View File

@ -87,13 +87,19 @@ public class DeleteGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
@Override
public void execute(){
_gslbService.deleteGlobalLoadBalancerRule(this);
UserContext.current().setEventDetails("Deleting global Load balancer Id: " + getGlobalLoadBalancerId());
UserContext.current().setEventDetails("Deleting global Load balancer rule Id: " + getGlobalLoadBalancerId());
boolean result = _gslbService.deleteGlobalLoadBalancerRule(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Global Load Balancer rule.");
}
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
return BaseAsyncCmd.gslbSyncObject;
}
@Override

View File

@ -42,7 +42,7 @@ public class RestartVPCCmd extends BaseAsyncCmd{
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcResponse.class,
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcResponse.class, required=true,
description="the id of the VPC")
private Long id;

View File

@ -38,11 +38,11 @@ public class UpdateVPCCmd extends BaseAsyncCmd{
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcResponse.class,
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcResponse.class, required=true,
description="the id of the VPC")
private Long id;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the VPC")
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the VPC", required=true)
private String vpcName;
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the VPC")

View File

@ -42,6 +42,14 @@ public class HypervisorCapabilitiesResponse extends BaseResponse {
@SerializedName(ApiConstants.SECURITY_GROUP_EANBLED) @Param(description="true if security group is supported")
private boolean isSecurityGroupEnabled;
@SerializedName(ApiConstants.MAX_DATA_VOLUMES_LIMIT) @Param(description="the maximum number of Data Volumes that can be attached for this hypervisor")
private Integer maxDataVolumesLimit;
@SerializedName(ApiConstants.MAX_HOSTS_PER_CLUSTER) @Param(description="the maximum number of Hosts per cluster for this hypervisor")
private Integer maxHostsPerCluster;
@SerializedName(ApiConstants.STORAGE_MOTION_ENABLED) @Param(description="true if storage motion is supported")
private boolean isStorageMotionSupported;
public String getId() {
return id;
@ -83,4 +91,28 @@ public class HypervisorCapabilitiesResponse extends BaseResponse {
public void setIsSecurityGroupEnabled(Boolean sgEnabled) {
this.isSecurityGroupEnabled = sgEnabled;
}
public Boolean getIsStorageMotionSupported() {
return this.isStorageMotionSupported;
}
public void setIsStorageMotionSupported(Boolean smSupported) {
this.isStorageMotionSupported = smSupported;
}
public Integer getMaxDataVolumesLimit() {
return maxDataVolumesLimit;
}
public void setMaxDataVolumesLimit(Integer maxDataVolumesLimit) {
this.maxDataVolumesLimit = maxDataVolumesLimit;
}
public Integer getMaxHostsPerCluster() {
return maxHostsPerCluster;
}
public void setMaxHostsPerCluster(Integer maxHostsPerCluster) {
this.maxHostsPerCluster = maxHostsPerCluster;
}
}

View File

@ -166,6 +166,10 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
@SerializedName(ApiConstants.DISPLAY_NETWORK) @Param(description="an optional field, whether to the display the network to the end user or not.")
private Boolean displayNetwork;
@SerializedName(ApiConstants.ACL_ID) @Param(description="ACL Id associated with the VPC network")
private String aclId;
public Boolean getDisplayNetwork() {
return displayNetwork;
}
@ -352,4 +356,12 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
public void setIp6Cidr(String ip6Cidr) {
this.ip6Cidr = ip6Cidr;
}
public String getAclId() {
return aclId;
}
public void setAclId(String aclId) {
this.aclId = aclId;
}
}

View File

@ -1,248 +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.
package org.apache.cloudstack.api.response;
import java.util.Date;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import com.cloud.serializer.Param;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
import com.google.gson.annotations.SerializedName;
@EntityReference(value=StoragePool.class)
public class StoragePoolForMigrationResponse extends BaseResponse {
@SerializedName("id") @Param(description="the ID of the storage pool")
private String id;
@SerializedName("zoneid") @Param(description="the Zone ID of the storage pool")
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the storage pool")
private String zoneName;
@SerializedName("podid") @Param(description="the Pod ID of the storage pool")
private String podId;
@SerializedName("podname") @Param(description="the Pod name of the storage pool")
private String podName;
@SerializedName("name") @Param(description="the name of the storage pool")
private String name;
@SerializedName("ipaddress") @Param(description="the IP address of the storage pool")
private String ipAddress;
@SerializedName("path") @Param(description="the storage pool path")
private String path;
@SerializedName("created") @Param(description="the date and time the storage pool was created")
private Date created;
@SerializedName("type") @Param(description="the storage pool type")
private String type;
@SerializedName("clusterid") @Param(description="the ID of the cluster for the storage pool")
private String clusterId;
@SerializedName("clustername") @Param(description="the name of the cluster for the storage pool")
private String clusterName;
@SerializedName("disksizetotal") @Param(description="the total disk size of the storage pool")
private Long diskSizeTotal;
@SerializedName("disksizeallocated") @Param(description="the host's currently allocated disk size")
private Long diskSizeAllocated;
@SerializedName("disksizeused") @Param(description="the host's currently used disk size")
private Long diskSizeUsed;
@SerializedName("tags") @Param(description="the tags for the storage pool")
private String tags;
@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;
@SerializedName("suitableformigration") @Param(description="true if this pool is suitable to migrate a volume," +
" false otherwise")
private Boolean suitableForMigration;
/**
* @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();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getZoneId() {
return zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getPodId() {
return podId;
}
public void setPodId(String podId) {
this.podId = podId;
}
public String getPodName() {
return podName;
}
public void setPodName(String podName) {
this.podName = podName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getClusterId() {
return clusterId;
}
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}
public String getClusterName() {
return clusterName;
}
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
public Long getDiskSizeTotal() {
return diskSizeTotal;
}
public void setDiskSizeTotal(Long diskSizeTotal) {
this.diskSizeTotal = diskSizeTotal;
}
public Long getDiskSizeAllocated() {
return diskSizeAllocated;
}
public void setDiskSizeAllocated(Long diskSizeAllocated) {
this.diskSizeAllocated = diskSizeAllocated;
}
public Long getDiskSizeUsed() {
return diskSizeUsed;
}
public void setDiskSizeUsed(Long diskSizeUsed) {
this.diskSizeUsed = diskSizeUsed;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
public StoragePoolStatus getState() {
return state;
}
public void setState(StoragePoolStatus state) {
this.state = state;
}
public void setSuitableForMigration(Boolean suitableForMigration) {
this.suitableForMigration = suitableForMigration;
}
}

View File

@ -16,16 +16,15 @@
// under the License.
package org.apache.cloudstack.api.response;
import java.util.Date;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import com.cloud.serializer.Param;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import java.util.Date;
@EntityReference(value=StoragePool.class)
public class StoragePoolResponse extends BaseResponse {
@ -40,13 +39,13 @@ public class StoragePoolResponse extends BaseResponse {
@SerializedName(ApiConstants.ZONE_TYPE) @Param(description = "network type of the availability zone")
private String zoneType;
@SerializedName("podid") @Param(description="the Pod ID of the storage pool")
private String podId;
@SerializedName("podname") @Param(description="the Pod name of the storage pool")
private String podName;
@SerializedName("name") @Param(description="the name of the storage pool")
private String name;
@ -82,10 +81,17 @@ 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;
@SerializedName(ApiConstants.HYPERVISOR) @Param(description="the hypervisor type of the storage pool")
private String hypervisor;
@SerializedName("suitableformigration") @Param(description="true if this pool is suitable to migrate a volume," +
" false otherwise")
private Boolean suitableForMigration;
/**
* @return the scope
*/
@ -100,6 +106,14 @@ public class StoragePoolResponse extends BaseResponse {
this.scope = scope;
}
public String getHypervisor() {
return hypervisor;
}
public void setHypervisor(String hypervisor) {
this.hypervisor = hypervisor;
}
@Override
public String getObjectId() {
return this.getId();
@ -132,11 +146,11 @@ public class StoragePoolResponse extends BaseResponse {
public String getZoneType() {
return zoneType;
}
public void setZoneType(String zoneType) {
this.zoneType = zoneType;
}
public String getPodId() {
return podId;
}
@ -248,4 +262,8 @@ public class StoragePoolResponse extends BaseResponse {
public void setState(StoragePoolStatus state) {
this.state = state;
}
public void setSuitableForMigration(Boolean suitableForMigration) {
this.suitableForMigration = suitableForMigration;
}
}

View File

@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
label.view.secondary.ips=View secondary IPs
message.acquire.ip.nic=Please confirm that you would like to acquire a new secondary IP for this NIC.<br/>NOTE: You need to manually configure the newly-acquired secondary IP inside the virtual machine.
message.select.affinity.groups=Please select any affinity groups you want this VM to belong to:
message.no.affinity.groups=You do not have any affinity groups. Please continue to the next step.
label.action.delete.nic=Remove NIC
@ -53,6 +55,7 @@ label.account.specific=Account-Specific
label.account=Account
label.accounts=Accounts
label.acquire.new.ip=Acquire New IP
label.acquire.new.secondary.ip=Acquire new secondary IP
label.action.attach.disk.processing=Attaching Disk....
label.action.attach.disk=Attach Disk
label.action.attach.iso.processing=Attaching ISO....

View File

@ -29,6 +29,11 @@
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-acl-static-role-based</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-dedicated-resources</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
@ -136,6 +141,11 @@
<artifactId>cloud-plugin-planner-implicit-dedication</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-explicit-dedication</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-host-allocator-random</artifactId>

View File

@ -93,7 +93,7 @@
<entry key="cache.size" value="50" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl">
@ -156,9 +156,17 @@
<entry key="cache.size" value="100" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl">
<property name="configParams">
<map>
<entry key="cache.size" value="30" />
<entry key="cache.time.to.live" value="3600" />
</map>
</property>
</bean>
<!--
DAOs with default configuration
-->
@ -673,7 +681,6 @@
<bean id="ipv6AddressManagerImpl" class="com.cloud.network.Ipv6AddressManagerImpl" />
<bean id="apiRateLimitServiceImpl" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl"/>
<bean id="alertManagerImpl" class="com.cloud.alert.AlertManagerImpl" />
<bean id="asyncJobExecutorContextImpl" class="com.cloud.async.AsyncJobExecutorContextImpl" />
<bean id="asyncJobManagerImpl" class="com.cloud.async.AsyncJobManagerImpl" />
@ -796,6 +803,7 @@
<bean id="mockAgentManagerImpl" class="com.cloud.agent.manager.MockAgentManagerImpl" />
<bean id="mockStorageManagerImpl" class="com.cloud.agent.manager.MockStorageManagerImpl" />
<bean id="mockVmManagerImpl" class="com.cloud.agent.manager.MockVmManagerImpl" />
<bean id="mockNetworkManagerImpl" class="com.cloud.agent.manager.MockNetworkManagerImpl" />
<bean id="simulatorManagerImpl" class="com.cloud.agent.manager.SimulatorManagerImpl" />
<bean id="vMSnapshotManagerImpl" class="com.cloud.vm.snapshot.VMSnapshotManagerImpl" />
<bean id="volumeManagerImpl" class="com.cloud.storage.VolumeManagerImpl" />

View File

@ -265,6 +265,10 @@ addSecondaryStorage=1
updateHostPassword=1
releaseHostReservation=1
#### VmWare DC
addVmwareDc=1
removeVmwareDc=1
#### volume commands
attachVolume=15
uploadVolume=15
@ -276,10 +280,6 @@ extractVolume=15
migrateVolume=15
resizeVolume=15
updateVolume=1
addVolumeDetail=1
updateVolumeDetail=1
removeVolumeDetail=1
listVolumeDetails=1
#### registration command: FIXME -- this really should be something in management server that
#### generates a new key for the user and they just have to
@ -350,10 +350,6 @@ updateNetwork=15
addNicToVirtualMachine=15
removeNicFromVirtualMachine=15
updateDefaultNicForVirtualMachine=15
addNicDetail=1
updateNicDetail=1
removeNicDetail=1
listNicDetails=1
####
addIpToNic=15
@ -641,3 +637,16 @@ listInternalLoadBalancerVMs=1
### Network Isolation methods listing
listNetworkIsolationMethods=1
#### Dedicated Resource commands
dedicateZone=1
dedicatePod=1
dedicateCluster=1
dedicateHost=1
releaseDedicatedZone=1
releaseDedicatedPod=1
releaseDedicatedCluster=1
releaseDedicatedHost=1
listDedicatedZones=1
listDedicatedPods=1
listDedicatedClusters=1
listDedicatedHosts=1

View File

@ -24,28 +24,27 @@
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!--
OSS deployment configuration
OSS/non-OSS counter-exclusive components and related configurations should be put here
for example, configurationDaoImpl component, it has exclusive configuration settings in OSS and non-OSS deployment,
its component declaration should be put in both componentContext.xml.in and nonossComponentContext.xml.in, each with
independent configuration
-->
<bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl" />
<bean id="GlobalLoadBalancingRulesServiceImpl" class ="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" />
<!--
@ -70,13 +69,13 @@
<bean id="MidoNetElement" class="com.cloud.network.element.MidoNetElement">
<property name="name" value="MidoNetElement"/>
</bean>
<!--
Deployment configurations of various adapters
It determines whether or not a adapter is activated or how it is loaded in order in its managing provider,
-->
<!-- Security adapters -->
@ -171,7 +170,7 @@
</list>
</property>
</bean>
<bean id="hostAllocators" class="com.cloud.utils.component.AdapterList">
<property name="Adapters">
<list>
@ -260,13 +259,22 @@
<property name="name" value="HostAntiAffinityProcessor"/>
<property name="type" value="host anti-affinity"/>
</bean>
<bean id="affinityProcessors" class="com.cloud.utils.component.AdapterList">
<property name="Adapters">
<list>
<ref bean="HostAntiAffinityProcessor" />
<ref bean="ExplicitDedicationProcessor"/>
</list>
</property>
</bean>
<!--
Dedicated Resources components
-->
<bean id="DedicatedResourceManagerImpl" class="org.apache.cloudstack.dedicated.DedicatedResourceManagerImpl"/>
<bean id="ExplicitDedicationProcessor" class="org.apache.cloudstack.affinity.ExplicitDedicationProcessor">
<property name="name" value="ExplicitDedicationProcessor"/>
<property name="type" value="ExplicitDedication"/>
</bean>
</beans>

View File

@ -77,6 +77,10 @@
</bean>
<bean id="VmwareManager" class="com.cloud.hypervisor.vmware.manager.VmwareManagerImpl"/>
<bean id="vmwareContextFactory" class="com.cloud.hypervisor.vmware.resource.VmwareContextFactory" />
<bean id="VmwareDatacenterDaoImpl" class="com.cloud.hypervisor.vmware.dao.VmwareDatacenterDaoImpl" />
<bean id="VmwareDatacenterZoneMapDaoImpl" class="com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDaoImpl" />
<bean id="LegacyZoneDaoImpl" class="com.cloud.hypervisor.vmware.dao.LegacyZoneDaoImpl" />
<bean id="vmwareStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.VmwareStorageMotionStrategy"/>
<!--
Nicira support components
@ -370,4 +374,14 @@
</property>
</bean>
<!--
Dedicated Resources components
-->
<bean id="DedicatedResourceManagerImpl" class="org.apache.cloudstack.dedicated.DedicatedResourceManagerImpl"/>
<bean id="ExplicitDedicationProcessor" class="org.apache.cloudstack.affinity.ExplicitDedicationProcessor">
<property name="name" value="ExplicitDedicationProcessor"/>
<property name="type" value="ExplicitDedication"/>
</bean>
</beans>

View File

@ -234,4 +234,10 @@
</property>
</bean>
<bean id="DedicatedResourceManagerImpl" class="org.apache.cloudstack.dedicated.DedicatedResourceManagerImpl"/>
<bean id="ExplicitDedicationProcessor" class="org.apache.cloudstack.affinity.ExplicitDedicationProcessor">
<property name="name" value="ExplicitDedicationProcessor"/>
<property name="type" value="ExplicitDedication"/>
</bean>
</beans>

View File

@ -24,10 +24,18 @@ import com.cloud.agent.api.to.StorageFilerTO;
public class MigrateWithStorageCommand extends Command {
VirtualMachineTO vm;
Map<VolumeTO, StorageFilerTO> volumeToFiler;
String tgtHost;
public MigrateWithStorageCommand(VirtualMachineTO vm, Map<VolumeTO, StorageFilerTO> volumeToFiler) {
this.vm = vm;
this.volumeToFiler = volumeToFiler;
this.tgtHost = null;
}
public MigrateWithStorageCommand(VirtualMachineTO vm, Map<VolumeTO, StorageFilerTO> volumeToFiler, String tgtHost) {
this.vm = vm;
this.volumeToFiler = volumeToFiler;
this.tgtHost = tgtHost;
}
public VirtualMachineTO getVirtualMachine() {
@ -38,6 +46,10 @@ public class MigrateWithStorageCommand extends Command {
return volumeToFiler;
}
public String getTargetHost() {
return tgtHost;
}
@Override
public boolean executeInSequence() {
return true;

View File

@ -39,7 +39,7 @@ public class UnPlugNicCommand extends Command{
this.instanceName = instanceName;
}
public String getInstanceName() {
public String getVmName() {
return instanceName;
}
}

View File

@ -642,7 +642,7 @@ public class VirtualRoutingResource implements Manager {
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
args = args + ipAliasTO.getAlias_count()+":"+ipAliasTO.getRouterip()+":"+ipAliasTO.getNetmask()+"-";
}
args = args + " " ;
args = args + "- " ;
List<IpAliasTO> activeIpAliasTOs = cmd.getCreateIpAliasTos();
for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
args = args + ipAliasTO.getAlias_count()+":"+ipAliasTO.getRouterip()+":"+ipAliasTO.getNetmask()+"-";

View File

@ -71,7 +71,7 @@ import java.util.List;
"conf-dir=/etc/dnsmasq.d\n",
"dhcp-option=tag:net1,3,ipaddress\n",
"dhcp-option=tag:net1,1,netmask\n",
"dhcp-option=6,10.147.28.149,8.8.8.8\n",
"dhcp-option=6,router_ip,external_dns\n",
"dhcp-optsfile=/etc/dhcpopts.txt\n",
@ -85,11 +85,21 @@ import java.util.List;
String netmask="";
String domain= dnsMasqconfigcmd.getDomain();
String dnsServers="";
String dns_external="";
if (dnsMasqconfigcmd.getDns1()!= null) {
dns_external = dnsMasqconfigcmd.getDns1()+",";
}
if (dnsMasqconfigcmd.getDns2() != null) {
dns_external = dns_external+dnsMasqconfigcmd.getDns2()+",";
}
dns_external = dns_external + "*";
dns_external = dns_external.replace(",*","");
int i=0;
for (; i< dnsmasqTOs.size(); i++) {
range=range + "dhcp-range=set:range"+i+","+dnsmasqTOs.get(i).getRouterIp()+",static\n";
range=range + "dhcp-range=set:range"+i+","+dnsmasqTOs.get(i).getStartIpOfSubnet()+",static\n";
gateway=gateway +"dhcp-option=tag:range"+i+",3,"+dnsmasqTOs.get(i).getGateway()+"\n";
netmask=netmask +"dhcp-option=tag:range"+i+",1,"+dnsmasqTOs.get(i).getNetmask()+"\n";
dnsServers=dnsServers+"dhcp-option=tag:range"+i+",6,"+dnsmasqTOs.get(i).getRouterIp()+","+dns_external+"\n";
}
dnsMasqconf.set(12, "domain="+domain+"\n");
dnsMasqconf.set(14, "domain="+domain+"\n");
@ -97,21 +107,7 @@ import java.util.List;
dnsMasqconf.set(18, range);
dnsMasqconf.set(22, gateway);
dnsMasqconf.set(23, netmask);
if (dnsMasqconfigcmd.getInternal_dns1() != null) {
dnsServers = dnsServers+dnsMasqconfigcmd.getInternal_dns1()+",";
}
if (dnsMasqconfigcmd.getInternal_dns2() != null) {
dnsServers = dnsServers+dnsMasqconfigcmd.getInternal_dns2()+",";
}
if (dnsMasqconfigcmd.getDns1() != null) {
dnsServers = dnsServers+dnsMasqconfigcmd.getDns1()+",";
}
if (dnsMasqconfigcmd.getDns2() != null) {
dnsServers = dnsServers+dnsMasqconfigcmd.getDns2()+",";
}
dnsServers = dnsServers +"*";
dnsServers = dnsServers.replace(",*", "");
dnsMasqconf.set(24,"dhcp-option=6,"+dnsServers);
dnsMasqconf.set(24,dnsServers);
return dnsMasqconf.toArray( new String[dnsMasqconf.size()]);
}

View File

@ -250,6 +250,13 @@ public class HttpTemplateDownloader implements TemplateDownloader {
}
} else {
remoteSize2 = Long.parseLong(contentLengthHeader.getValue());
if ( remoteSize2 == 0 ) {
status = TemplateDownloader.Status.DOWNLOAD_FINISHED;
String downloaded = "(download complete remote=" + remoteSize + "bytes)";
errorString = "Downloaded " + totalBytes + " bytes " + downloaded;
downloadTime = 0;
return 0;
}
}
if (remoteSize == 0) {

View File

@ -13,7 +13,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-developer</artifactId>
<name>Apache CloudStack Developer Tools</name>
<name>Apache CloudStack Developer Mode</name>
<packaging>pom</packaging>
<parent>
<groupId>org.apache.cloudstack</groupId>

View File

@ -0,0 +1,22 @@
<!-- 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.
-->
<!ENTITY PRODUCT "CloudStack">
<!ENTITY BOOKID "Technical Documentation">
<!ENTITY YEAR "2013">
<!ENTITY HOLDER "Apache Software Foundation">

View File

@ -0,0 +1,52 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "CloudStack_GSoC_Guide.ent">
%BOOK_ENTITIES;
<!ENTITY % xinclude SYSTEM "http://www.docbook.org/xml/4.4/xinclude.mod">
%xinclude;
]>
<!-- 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.
-->
<book>
<bookinfo id="cloudstack_gsoc_2013">
<title>&PRODUCT; Guide for the 2013 Google Summer of Code</title>
<productname>Apache CloudStack</productname>
<productnumber>4.3.0</productnumber>
<edition>1</edition>
<pubsnumber></pubsnumber>
<abstract>
<para>
Guide for 2013 Google Summer of Code Projects.
</para>
</abstract>
<corpauthor>
<inlinemediaobject>
<imageobject>
<imagedata fileref="Common_Content/images/title_logo.svg" format="SVG" />
</imageobject>
</inlinemediaobject>
</corpauthor>
<xi:include href="Common_Content/Legal_Notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Author_Group.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</bookinfo>
<xi:include href="gsoc-tuna.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>

View File

@ -39,28 +39,43 @@
<para>Click the Configure button of the VPC to which you want to deploy the VMs.</para>
<para>The VPC page is displayed where all the tiers you created are listed in a
diagram.</para>
</listitem>
<listitem>
<para>Click the Settings icon.</para>
<para>The following options are displayed.</para>
<itemizedlist>
<listitem>
<para>IP Addresses</para>
<para>Internal LB</para>
</listitem>
<listitem>
<para>Gateways</para>
<para>Public LB IP</para>
</listitem>
<listitem>
<para>Site-to-Site VPN</para>
<para>Static NAT</para>
</listitem>
<listitem>
<para>Network ACLs</para>
<para>Virtual Machines</para>
</listitem>
<listitem>
<para>CIDR</para>
</listitem>
</itemizedlist>
<para>The following router information is displayed:</para>
<itemizedlist>
<listitem>
<para>Private Gateways</para>
</listitem>
<listitem>
<para>Public IP Addresses</para>
</listitem>
<listitem>
<para>Site-to-Site VPNs</para>
</listitem>
<listitem>
<para>Network ACL Lists</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Select IP Addresses.</para>
<para>The IP Addresses page is displayed.</para>
<para>The Public IP Addresses page is displayed.</para>
</listitem>
<listitem>
<para>Click Acquire New IP, and click Yes in the confirmation dialog.</para>
@ -70,4 +85,4 @@
rules.</para>
</listitem>
</orderedlist>
</section>
</section>

View File

@ -21,8 +21,8 @@
<section id="add-gateway-vpc">
<title>Adding a Private Gateway to a VPC</title>
<para>A private gateway can be added by the root admin only. The VPC private network has 1:1
relationship with the NIC of the physical network. No gateways with duplicated VLAN and IP are
allowed in the same data center.</para>
relationship with the NIC of the physical network. You can configure multiple private gateways
to a single VPC. No gateways with duplicated VLAN and IP are allowed in the same data center.</para>
<orderedlist>
<listitem>
<para>Log in to the &PRODUCT; UI as an administrator or end user.</para>
@ -45,16 +45,34 @@
<para>The following options are displayed.</para>
<itemizedlist>
<listitem>
<para>IP Addresses</para>
<para>Internal LB</para>
</listitem>
<listitem>
<para>Public LB IP</para>
</listitem>
<listitem>
<para>Static NAT</para>
</listitem>
<listitem>
<para>Virtual Machines</para>
</listitem>
<listitem>
<para>CIDR</para>
</listitem>
</itemizedlist>
<para>The following router information is displayed:</para>
<itemizedlist>
<listitem>
<para>Private Gateways</para>
</listitem>
<listitem>
<para>Site-to-Site VPN</para>
<para>Public IP Addresses</para>
</listitem>
<listitem>
<para>Network ACLs</para>
<para>Site-to-Site VPNs</para>
</listitem>
<listitem>
<para>Network ACL Lists</para>
</listitem>
</itemizedlist>
</listitem>
@ -96,9 +114,38 @@
<para><emphasis role="bold">VLAN</emphasis>: The VLAN associated with the VPC
gateway.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Source NAT</emphasis>: Select this option to enable the source
NAT service on the VPC private gateway.</para>
<para>See <xref linkend="sourcenat-private-gateway"/>.</para>
</listitem>
<listitem>
<para><emphasis role="bold">ACL</emphasis>: Controls both ingress and egress traffic on a
VPC private gateway. By default, all the traffic is blocked.</para>
<para>See <xref linkend="acl-private-gateway"/>.</para>
</listitem>
</itemizedlist>
<para>The new gateway appears in the list. You can repeat these steps to add more gateway for
this VPC.</para>
</listitem>
</orderedlist>
<section id="sourcenat-private-gateway">
<title>Source NAT on Private Gateway</title>
<para>You might want to deploy multiple VPCs with the same super CIDR and guest tier CIDR.
Therefore, multiple guest VMs from different VPCs can have the same IPs to reach a enterprise
data center through the private gateway. In such cases, a NAT service need to be configured on
the private gateway. If Source NAT is enabled, the guest VMs in VPC reaches the enterprise
network via private gateway IP address by using the NAT service. </para>
<para>The Source NAT service on a private gateway can be enabled while adding the private
gateway. On deletion of a private gateway, source NAT rules specific to the private gateway
are deleted.</para>
</section>
<section id="acl-private-gateway">
<title>ACL on Private Gateway</title>
<para>The traffic on the VPC private gateway is controlled by creating both ingress and egress
network ACL rules. The ACLs contains both allow and deny rules. As per the rule, all the
ingress traffic to the private gateway interface and all the egress traffic out from the
private gateway interface are blocked. You can change this default behaviour while creating a
private gateway.</para>
</section>
</section>

View File

@ -21,103 +21,310 @@
-->
<section id="add-loadbalancer-rule-vpc">
<title>Adding Load Balancing Rules on a VPC</title>
<para>A &PRODUCT; user or administrator may create load balancing rules that balance traffic
received at a public IP to one or more VMs that belong to a network tier that provides load
balancing service in a VPC. A user creates a rule, specifies an algorithm, and assigns the rule
to a set of VMs within a VPC.</para>
<orderedlist>
<listitem>
<para>Log in to the &PRODUCT; UI as an administrator or end user.</para>
</listitem>
<listitem>
<para>In the left navigation, choose Network.</para>
</listitem>
<listitem>
<para>In the Select view, select VPC.</para>
<para>All the VPCs that you have created for the account is listed in the page.</para>
</listitem>
<listitem>
<para>Click the Configure button of the VPC to which you want to configure load balancing
rules.</para>
<para>The VPC page is displayed where all the tiers you created are listed in a
diagram.</para>
</listitem>
<listitem>
<para>Click the Settings icon.</para>
<para>The following options are displayed.</para>
<itemizedlist>
<para>In a VPC, you can configure two types of load balancing&mdash;external LB and internal LB.
External LB is nothing but a LB rule created to redirect the traffic received at a public IP of
the VPC virtual router. The traffic is load balanced within a tier based on your configuration.
Citrix NetScaler and VPC virtual router are supported for external LB. When you use internal LB
service, traffic received at a tier is load balanced across different tiers within the VPC. For
example, traffic reached at Web tier is redirected to Application tier. External load balancing
devices are not supported for internal LB. The service is provided by a internal LB VM
configured on the target tier.</para>
<section id="curent-lb-vpc">
<title>Load Balancing Within a Tier (External LB)</title>
<para>A &PRODUCT; user or administrator may create load balancing rules that balance traffic
received at a public IP to one or more VMs that belong to a network tier that provides load
balancing service in a VPC. A user creates a rule, specifies an algorithm, and assigns the
rule to a set of VMs within a VPC.</para>
<orderedlist>
<listitem>
<para>Log in to the &PRODUCT; UI as an administrator or end user.</para>
</listitem>
<listitem>
<para>In the left navigation, choose Network.</para>
</listitem>
<listitem>
<para>In the Select view, select VPC.</para>
<para>All the VPCs that you have created for the account is listed in the page.</para>
</listitem>
<listitem>
<para>Click the Configure button of the VPC, for which you want to configure load balancing
rules.</para>
<para>The VPC page is displayed where all the tiers you created listed in a diagram.</para>
<para>For each tier, the following options are displayed:</para>
<itemizedlist>
<listitem>
<para>Internal LB</para>
</listitem>
<listitem>
<para>Public LB IP</para>
</listitem>
<listitem>
<para>Static NAT</para>
</listitem>
<listitem>
<para>Virtual Machines</para>
</listitem>
<listitem>
<para>CIDR</para>
</listitem>
</itemizedlist>
<para>The following router information is displayed:</para>
<itemizedlist>
<listitem>
<para>Private Gateways</para>
</listitem>
<listitem>
<para>Public IP Addresses</para>
</listitem>
<listitem>
<para>Site-to-Site VPNs</para>
</listitem>
<listitem>
<para>Network ACL Lists</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>In the Router node, select Public IP Addresses.</para>
<para>The IP Addresses page is displayed.</para>
</listitem>
<listitem>
<para>Click the IP address for which you want to create the rule, then click the
Configuration tab.</para>
</listitem>
<listitem>
<para>In the Load Balancing node of the diagram, click View All.</para>
</listitem>
<listitem>
<para>Select the tier to which you want to apply the rule.</para>
</listitem>
<listitem>
<para>Specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">Name</emphasis>: A name for the load balancer rule.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Public Port</emphasis>: The port that receives the incoming
traffic to be balanced.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Private Port</emphasis>: The port that the VMs will use to
receive the traffic.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Algorithm</emphasis>. Choose the load balancing algorithm
you want &PRODUCT; to use. &PRODUCT; supports the following well-known
algorithms:</para>
<itemizedlist>
<listitem>
<para>Round-robin</para>
</listitem>
<listitem>
<para>Least connections</para>
</listitem>
<listitem>
<para>Source</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><emphasis role="bold">Stickiness</emphasis>. (Optional) Click Configure and choose
the algorithm for the stickiness policy. See Sticky Session Policies for Load Balancer
Rules.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Add VMs</emphasis>: Click Add VMs, then select two or more
VMs that will divide the load of incoming traffic, and click Apply.</para>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
<para>The new load balancing rule appears in the list. You can repeat these steps to add more
load balancing rules for this IP address.</para>
</section>
<section id="acros-tiers-lb">
<title>Load Balancing Across Tiers</title>
<para>&PRODUCT; supports sharing workload across different tiers within your VPC. Assume that
multiple tiers are set up in your environment, such as Web tier and Application tier. Traffic
to each tier is balanced on the VPC virtual router on the public side, as explained in <xref
linkend="add-loadbalancer-rule-vpc"/>. If you want the traffic coming from the Web tier to
the Application tier to be balanced, use the internal load balancing feature offered by
&PRODUCT;.</para>
<section id="vpc-pic">
<title>How Does Internal LB Work in VPC?</title>
<para>In this figure, a public LB rule is created for the public IP 72.52.125.10 with public
port 80 and private port 81. The LB rule, created on the VPC virtual router, is applied on
the traffic coming from the Internet to the VMs on the Web tier. On the Application tier two
internal load balancing rules are created. An internal LB rule for the guest IP 10.10.10.4
with load balancer port 23 and instance port 25 is configured on the VM, InternalLBVM1.
Another internal LB rule for the guest IP 10.10.10.4 with load balancer port 45 and instance
port 46 is configured on the VM, InternalLBVM1. Another internal LB rule for the guest IP
10.10.10.6, with load balancer port 23 and instance port 25 is configured on the VM,
InternalLBVM2.</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/vpc-lb.png"/>
</imageobject>
<textobject>
<phrase>vpc-lb.png: Configuring internal LB for VPC</phrase>
</textobject>
</mediaobject>
</section>
<section id="enable-vpc-lb">
<title>Enabling Internal LB on a VPC Tier</title>
<orderedlist>
<listitem>
<para>IP Addresses</para>
<para>Create a network offering, as given in <xref linkend="int-lb-vpc"/>.</para>
</listitem>
<listitem>
<para>Gateways</para>
<para>Create an internal load balancing rule and apply, as given in <xref
linkend="int-lb-vpc"/>.</para>
</listitem>
</orderedlist>
</section>
<section id="int-lb-offering">
<title>Creating a Network Offering for Internal LB</title>
<para>To have internal LB support on VPC, create a network offering as follows: </para>
<orderedlist>
<listitem>
<para>Log in to the &PRODUCT; UI as a user or admin.</para>
</listitem>
<listitem>
<para>Site-to-Site VPN</para>
<para>From the Select Offering drop-down, choose Network Offering.</para>
</listitem>
<listitem>
<para>Network ACLs</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Select IP Addresses.</para>
<para>The IP Addresses page is displayed.</para>
</listitem>
<listitem>
<para>Click the IP address for which you want to create the rule, then click the Configuration
tab.</para>
</listitem>
<listitem>
<para>In the Load Balancing node of the diagram, click View All.</para>
</listitem>
<listitem>
<para>Select the tier to which you want to apply the rule.</para>
<note>
<para>In a VPC, the load balancing service is supported only on a single tier.</para>
</note>
</listitem>
<listitem>
<para>Specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">Name</emphasis>: A name for the load balancer rule.</para>
<para>Click Add Network Offering.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Public Port</emphasis>: The port that receives the incoming
traffic to be balanced.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Private Port</emphasis>: The port that the VMs will use to
receive the traffic.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Algorithm</emphasis>. Choose the load balancing algorithm you
want &PRODUCT; to use. &PRODUCT; supports the following well-known algorithms:</para>
<para>In the dialog, make the following choices:</para>
<itemizedlist>
<listitem>
<para>Round-robin</para>
<para><emphasis role="bold">Name</emphasis>: Any desired name for the network
offering.</para>
</listitem>
<listitem>
<para>Least connections</para>
<para><emphasis role="bold">Description</emphasis>: A short description of the
offering that can be displayed to users.</para>
</listitem>
<listitem>
<para>Source</para>
<para><emphasis role="bold">Network Rate</emphasis>: Allowed data transfer rate in MB
per second.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Traffic Type</emphasis>: The type of network traffic that
will be carried on the network.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Guest Type</emphasis>: Choose whether the guest network is
isolated or shared.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Persistent</emphasis>: Indicate whether the guest network
is persistent or not. The network that you can provision without having to deploy a
VM on it is termed persistent network. </para>
</listitem>
<listitem>
<para><emphasis role="bold">VPC</emphasis>: This option indicate whether the guest
network is Virtual Private Cloud-enabled. A Virtual Private Cloud (VPC) is a
private, isolated part of &PRODUCT;. A VPC can have its own virtual network topology
that resembles a traditional physical network. For more information on VPCs, see
<xref linkend="vpc"/>.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Specify VLAN</emphasis>: (Isolated guest networks only)
Indicate whether a VLAN should be specified when this offering is used.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Supported Services</emphasis>: Select Load Balancer.
Select <code>InternalLbVM</code> from the provider list.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Load Balancer Type</emphasis>: Select Internal LB from the
drop-down.</para>
</listitem>
<listitem>
<para><emphasis role="bold">System Offering</emphasis>: Choose the system service
offering that you want virtual routers to use in this network.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Conserve mode</emphasis>: Indicate whether to use conserve
mode. In this mode, network resources are allocated only when the first virtual
machine starts in the network.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><emphasis role="bold">Stickiness</emphasis>. (Optional) Click Configure and choose
the algorithm for the stickiness policy. See Sticky Session Policies for Load Balancer
Rules.</para>
<para>Click OK and the network offering is created.</para>
</listitem>
</orderedlist>
</section>
<section id="int-lb-vpc">
<title>Creating an Internal LB Rule</title>
<orderedlist>
<listitem>
<para>Log in to the &PRODUCT; UI as an administrator or end user.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Add VMs</emphasis>: Click Add VMs, then select two or more VMs
that will divide the load of incoming traffic, and click Apply.</para>
<para>In the left navigation, choose Network.</para>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
<para>The new load balancing rule appears in the list. You can repeat these steps to add more load
balancing rules for this IP address.</para>
</section>
<listitem>
<para>In the Select view, select VPC.</para>
<para>All the VPCs that you have created for the account is listed in the page.</para>
</listitem>
<listitem>
<para>Locate the VPC for which you want to configure internal LB, then click
Configure.</para>
<para>The VPC page is displayed where all the tiers you created listed in a
diagram.</para>
</listitem>
<listitem>
<para>Locate the Tier for which you want to configure an internal LB rule, click Internal
LB.</para>
<para>In the Internal LB page, click Add Internal LB.</para>
</listitem>
<listitem>
<para>In the dialog, specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">Name</emphasis>: A name for the load balancer rule.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Description</emphasis>: A short description of the rule
that can be displayed to users.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Source IP Address</emphasis>: The source IP from which
traffic originates. Typically, this is the IP of an instance on another tier within
your VPC.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Source Port</emphasis>: The port associated with the
source IP. Traffic on this port is load balanced. </para>
</listitem>
<listitem>
<para><emphasis role="bold">Instance Port</emphasis>: The port of the internal LB
VM.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Algorithm</emphasis>. Choose the load balancing algorithm
you want &PRODUCT; to use. &PRODUCT; supports the following well-known
algorithms:</para>
<itemizedlist>
<listitem>
<para>Round-robin</para>
</listitem>
<listitem>
<para>Least connections</para>
</listitem>
<listitem>
<para>Source</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
</section>
</section>
</section>

View File

@ -35,28 +35,42 @@
<para>Click the Configure button of the VPC to which you want to deploy the VMs.</para>
<para>The VPC page is displayed where all the tiers you created are listed in a
diagram.</para>
</listitem>
<listitem>
<para>Click the Settings icon.</para>
<para>The following options are displayed.</para>
<para>For each tier, the following options are displayed:</para>
<itemizedlist>
<listitem>
<para>IP Addresses</para>
<para>Internal LB</para>
</listitem>
<listitem>
<para>Gateways</para>
<para>Public LB IP</para>
</listitem>
<listitem>
<para>Site-to-Site VPN</para>
<para>Static NAT</para>
</listitem>
<listitem>
<para>Network ACLs</para>
<para>Virtual Machines</para>
</listitem>
<listitem>
<para>CIDR</para>
</listitem>
</itemizedlist>
<para>The following router information is displayed:</para>
<itemizedlist>
<listitem>
<para>Private Gateways</para>
</listitem>
<listitem>
<para>Public IP Addresses</para>
</listitem>
<listitem>
<para>Site-to-Site VPNs</para>
</listitem>
<listitem>
<para>Network ACL Lists</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Choose an existing IP address or acquire a new IP address. Click the name of the IP
address in the list.</para>
<para>In the Router node, select Public IP Addresses.</para>
<para>The IP Addresses page is displayed.</para>
</listitem>
<listitem>
@ -95,7 +109,7 @@
<listitem>
<para><emphasis role="bold">Add VM</emphasis>: Click Add VM. Select the name of the
instance to which this rule applies, and click Apply.</para>
<para>You can test the rule by opening an ssh session to the instance.</para>
<para>You can test the rule by opening an SSH session to the instance.</para>
</listitem>
</itemizedlist>
</listitem>

View File

@ -41,6 +41,9 @@
</listitem>
<listitem>
<para>Click the Configure button of the VPC for which you want to set up tiers.</para>
</listitem>
<listitem>
<para>Click Create network.</para>
<para>The Add new tier dialog is displayed, as follows:</para>
<mediaobject>
<imageobject>
@ -62,7 +65,7 @@
</listitem>
<listitem>
<para><emphasis role="bold">Network Offering</emphasis>: The following default network
offerings are listed: DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
offerings are listed: Internal LB, DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
DefaultIsolatedNetworkOfferingForVpcNetworks</para>
<para>In a VPC, only one tier can be created by using LB-enabled network offering.</para>
</listitem>

View File

@ -33,13 +33,21 @@
</listitem>
<listitem>
<para>Click the Configure button of the VPC to which you want to deploy the VMs.</para>
<para>The VPC page is displayed where all the tiers you created are listed.</para>
<para>The VPC page is displayed where all the tiers you have created are listed.</para>
</listitem>
<listitem>
<para>Click the Add VM button of the tier for which you want to add a VM.</para>
<para>Click Virtual Machines tab of the tier to which you want to add a VM.</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/add-vm-vpc.png"/>
</imageobject>
<textobject>
<phrase>add-vm-vpc.png: adding a VM to a vpc.</phrase>
</textobject>
</mediaobject>
<para>The Add Instance page is displayed.</para>
<para>Follow the on-screen instruction to add an instance. For information on adding an
instance, see Adding Instances section in the Installation Guide.</para>
instance, see the Installation Guide.</para>
</listitem>
</orderedlist>
</section>

View File

@ -37,31 +37,66 @@
<para>All the VPCs that you have created for the account is listed in the page.</para>
</listitem>
<listitem>
<para>Click the Settings icon.</para>
<para>The following options are displayed.</para>
<para>Click the Configure button of the VPC, for which you want to configure load balancing
rules.</para>
<para>For each tier, the following options are displayed:</para>
<itemizedlist>
<listitem>
<para>IP Addresses</para>
<para>Internal LB</para>
</listitem>
<listitem>
<para>Gateways</para>
<para>Public LB IP</para>
</listitem>
<listitem>
<para>Site-to-Site VPN</para>
<para>Static NAT</para>
</listitem>
<listitem>
<para>Network ACLs</para>
<para>Virtual Machines</para>
</listitem>
<listitem>
<para>CIDR</para>
</listitem>
</itemizedlist>
<para>The following router information is displayed:</para>
<itemizedlist>
<listitem>
<para>Private Gateways</para>
</listitem>
<listitem>
<para>Public IP Addresses</para>
</listitem>
<listitem>
<para>Site-to-Site VPNs</para>
</listitem>
<listitem>
<para>Network ACL Lists</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Select Network ACLs.</para>
<para>The Network ACLs page is displayed.</para>
<para>Select Network ACL Lists.</para>
<para>The following default rules are displayed in the Network ACLs page: default_allow,
default_deny.</para>
</listitem>
<listitem>
<para>Click Add Network ACLs.</para>
<para>Click Add ACL Lists, and specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">ACL List Name</emphasis>: A name for the ACL list.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Description</emphasis>: A short description of the ACL list
that can be displayed to users.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Select the ACL list.</para>
</listitem>
<listitem>
<para>Select the ACL List Rules tab.</para>
<para>To add an ACL rule, fill in the following fields to specify what kind of network traffic
is allowed in this tier. </para>
is allowed in the VPC. </para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">CIDR</emphasis>: The CIDR acts as the Source CIDR for the
@ -74,7 +109,8 @@
<para><emphasis role="bold">Protocol</emphasis>: The networking protocol that sources use
to send traffic to the tier. The TCP and UDP protocols are typically used for data
exchange and end-user communications. The ICMP protocol is typically used to send error
messages or network monitoring data.</para>
messages or network monitoring data. All supports all the traffic. Other option is
Protocol Number.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Start Port</emphasis>, <emphasis role="bold">End
@ -83,8 +119,10 @@
fields.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Select Tier</emphasis>: Select the tier for which you want to
add this ACL rule.</para>
<para><emphasis role="bold">Protocol Number</emphasis>: The protocol number associated
with IPv4 or IPv6. For more information, see <ulink
url="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml">Protocol
Numbers</ulink>.</para>
</listitem>
<listitem>
<para><emphasis role="bold">ICMP Type</emphasis>, <emphasis role="bold">ICMP
@ -92,48 +130,14 @@
sent.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Traffic Type</emphasis>: Select the traffic type you want to
apply. </para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">Egress</emphasis>: To add an egress rule, select Egress
from the Traffic type drop-down box and click Add. This specifies what type of
traffic is allowed to be sent out of VM instances in this tier. If no egress rules
are specified, all traffic from the tier is allowed out at the VPC virtual router.
Once egress rules are specified, only the traffic specified in egress rules and the
responses to any traffic that has been allowed in through an ingress rule are
allowed out. No egress rule is required for the VMs in a tier to communicate with
each other.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Ingress</emphasis>: To add an ingress rule, select Ingress
from the Traffic type drop-down box and click Add. This specifies what network
traffic is allowed into the VM instances in this tier. If no ingress rules are
specified, then no traffic will be allowed in, except for responses to any traffic
that has been allowed out through an egress rule.</para>
</listitem>
</itemizedlist>
<note>
<para>By default, all incoming and outgoing traffic to the guest networks is blocked. To
open the ports, create a new network ACL.</para>
</note>
<para><emphasis role="bold">Action</emphasis>: What action to be taken. </para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Click Add. The ACL rule is added.</para>
<para>To view the list of ACL rules you have added, click the desired tier from the Network
ACLs page, then select the Network ACL tab.</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/network-acl.png"/>
</imageobject>
<textobject>
<phrase>network-acl.png: adding, editing, deleting an ACL rule.</phrase>
</textobject>
</mediaobject>
<para>You can edit the tags assigned to the ACL rules and delete the ACL rules you have
created. Click the appropriate button in the Actions column.</para>
created. Click the appropriate button in the Details tab.</para>
</listitem>
</orderedlist>
</section>

View File

@ -42,27 +42,42 @@
<para>Click the Configure button of the VPC to which you want to deploy the VMs.</para>
<para>The VPC page is displayed where all the tiers you created are listed in a
diagram.</para>
</listitem>
<listitem>
<para>Click the Settings icon.</para>
<para>The following options are displayed.</para>
<para>For each tier, the following options are displayed.</para>
<itemizedlist>
<listitem>
<para>IP Addresses</para>
<para>Internal LB</para>
</listitem>
<listitem>
<para>Gateways</para>
<para>Public LB IP</para>
</listitem>
<listitem>
<para>Site-to-Site VPN</para>
<para>Static NAT</para>
</listitem>
<listitem>
<para>Network ACLs</para>
<para>Virtual Machines</para>
</listitem>
<listitem>
<para>CIDR</para>
</listitem>
</itemizedlist>
<para>The following router information is displayed:</para>
<itemizedlist>
<listitem>
<para>Private Gateways</para>
</listitem>
<listitem>
<para>Public IP Addresses</para>
</listitem>
<listitem>
<para>Site-to-Site VPNs</para>
</listitem>
<listitem>
<para>Network ACL Lists</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Select IP Addresses.</para>
<para>In the Router node, select Public IP Addresses.</para>
<para>The IP Addresses page is displayed.</para>
</listitem>
<listitem>
@ -74,7 +89,7 @@
<imagedata fileref="./images/enable-disable.png"/>
</imageobject>
<textobject>
<phrase>enable-disable.png: button to enable Statid NAT.</phrase>
<phrase>enable-disable.png: button to enable Static NAT.</phrase>
</textobject>
</inlinemediaobject>The button toggles between Enable and Disable, depending on whether
static NAT is currently enabled for the IP address.</para>

28
docs/en-US/gsoc-tuna.xml Normal file
View File

@ -0,0 +1,28 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "CloudStack_GSoC_Guide.ent">
%BOOK_ENTITIES;
]>
<!-- 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.
-->
<chapter id="gsoc-tuna">
<title>Nguyen's 2013 GSoC Proposal</title>
<para>This chapter describes Nguyen 2013 Google Summer of Code project within the &PRODUCT; ASF project. It is a copy paste of the submitted proposal.</para>
</chapter>

View File

@ -28,5 +28,5 @@
their guest network and their clients.</para>
<para>In shared networks in Basic zone and Security Group-enabled Advanced networks, you will have
the flexibility to add multiple guest IP ranges from different subnets. You can add or remove
one IP range at a time.</para>
one IP range at a time. For more information, see <xref linkend="multiple-ip-range"/>.</para>
</section>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

View File

@ -0,0 +1,205 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
%BOOK_ENTITIES;
]>
<!-- 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.
-->
<section id="ip-vlan-tenant">
<title>Dedicated Resources: Public IP Addresses and VLANs Per Account</title>
<para>&PRODUCT; provides you the ability to reserve a set of public IP addresses and VLANs
exclusively for an account. During zone creation, you can continue to define a set of VLANs and
multiple public IP ranges. This feature extends the functionality to enable you to dedicate a
fixed set of VLANs and guest IP addresses for a tenant.</para>
<para>This feature provides you the following capabilities:</para>
<itemizedlist>
<listitem>
<para>Reserve a VLAN range and public IP address range from an Advanced zone and assign it to
a domain or account</para>
</listitem>
<listitem>
<para>Disassociate a VLAN and public IP address range from an domain or account</para>
</listitem>
<listitem>
<para>View the number of public IP addresses allocated to an account</para>
</listitem>
<listitem>
<para>Check whether the required range is available and is conforms to account limits.</para>
<para>The maximum IPs per account limit cannot be superseded.</para>
</listitem>
</itemizedlist>
<section id="howto-dedicate-ip">
<title>Dedicating IP Address Ranges to an Account</title>
<orderedlist>
<listitem>
<para>Log in to the &PRODUCT; UI as administrator.</para>
</listitem>
<listitem>
<para>In the left navigation bar, click Infrastructure.</para>
</listitem>
<listitem>
<para>In Zones, click View All.</para>
</listitem>
<listitem>
<para>Choose the zone you want to work with.</para>
</listitem>
<listitem>
<para>Click the Physical Network tab.</para>
</listitem>
<listitem>
<para>In the Public node of the diagram, click Configure.</para>
</listitem>
<listitem>
<para>Click the IP Ranges tab.</para>
<para>You can either assign an existing IP range to an account, or create a new IP range and
assign to an account.</para>
</listitem>
<listitem>
<para>To assign an existing IP range to an account, perform the following:</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>Locate the IP range you want to work with.</para>
</listitem>
<listitem>
<para>Click Add Account <inlinemediaobject>
<imageobject>
<imagedata fileref="./images/addAccount-icon.png"/>
</imageobject>
<textobject>
<phrase>addAccount-icon.png: button to assign an IP range to an account.</phrase>
</textobject>
</inlinemediaobject>button.</para>
<para>The Add Account dialog is displayed.</para>
</listitem>
<listitem>
<para>Specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">Account</emphasis>: The account to which you want to
assign the IP address range.</para>
</listitem>
<listitem>
<para><emphasis role="bold">Domain</emphasis>: The domain associated with the
account.</para>
</listitem>
</itemizedlist>
<para>To create a new IP range and assign an account, perform the following:</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>Specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">Gateway</emphasis></para>
</listitem>
<listitem>
<para><emphasis role="bold">Netmask</emphasis></para>
</listitem>
<listitem>
<para><emphasis role="bold">VLAN</emphasis></para>
</listitem>
<listitem>
<para><emphasis role="bold">Start IP</emphasis></para>
</listitem>
<listitem>
<para><emphasis role="bold">End IP</emphasis></para>
</listitem>
<listitem>
<para><emphasis role="bold">Account</emphasis>: Perform the following:</para>
<orderedlist numeration="lowerroman">
<listitem>
<para>Click Account.</para>
<para>The Add Account page is displayed.</para>
</listitem>
<listitem>
<para>Specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold"><emphasis role="bold"
>Account</emphasis></emphasis>: The account to which you want to
assign an IP address range.</para>
</listitem>
<listitem>
<para><emphasis role="bold"><emphasis role="bold"
>Domain</emphasis></emphasis>: The domain associated with the
account.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Click OK.</para>
</listitem>
</orderedlist>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Click Add.</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
</section>
<section id="howto-dedicate-vlan">
<title>Dedicating VLAN Ranges to an Account</title>
<orderedlist>
<listitem>
<para>After the &PRODUCT; Management Server is installed, log in to the &PRODUCT; UI as
administrator.</para>
</listitem>
<listitem>
<para>In the left navigation bar, click Infrastructure.</para>
</listitem>
<listitem>
<para>In Zones, click View All.</para>
</listitem>
<listitem>
<para>Choose the zone you want to work with.</para>
</listitem>
<listitem>
<para>Click the Physical Network tab.</para>
</listitem>
<listitem>
<para>In the Guest node of the diagram, click Configure.</para>
</listitem>
<listitem>
<para>Select the Dedicated VLAN Ranges tab.</para>
</listitem>
<listitem>
<para>Click Dedicate VLAN Range.</para>
<para>The Dedicate VLAN Range dialog is displayed.</para>
</listitem>
<listitem>
<para>Specify the following:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold"><emphasis role="bold">VLAN Range</emphasis></emphasis>: The
VLAN range that you want to assign to an account.</para>
</listitem>
<listitem>
<para><emphasis role="bold"><emphasis role="bold">Account</emphasis></emphasis>: The
account to which you want to assign the selected VLAN range.</para>
</listitem>
<listitem>
<para><emphasis role="bold"><emphasis role="bold">Domain</emphasis></emphasis>: The
domain associated with the account.</para>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
</section>
</section>

View File

@ -0,0 +1,42 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
%BOOK_ENTITIES;
]>
<!-- 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.
-->
<section id="multiple-ip-range">
<title>About Multiple IP Ranges</title>
<note>
<para>The feature can only be implemented on IPv4 addresses.</para>
</note>
<para>&PRODUCT; provides you with the flexibility to add guest IP ranges from different subnets in
Basic zones and security groups-enabled Advanced zones. For security groups-enabled Advanced
zones, it implies multiple subnets can be added to the same VLAN. With the addition of this
feature, you will be able to add IP address ranges from the same subnet or from a different one
when IP address are exhausted. This would in turn allows you to employ higher number of subnets
and thus reduce the address management overhead. To support this feature, the capability of
<code>createVlanIpRange</code> API is extended to add IP ranges also from a different
subnet.</para>
<para>Ensure that you manually configure the gateway of the new subnet before adding the IP range.
Note that &PRODUCT; supports only one gateway for a subnet; overlapping subnets are not
currently supported.</para>
<para>Use the <code>deleteVlanRange</code> API to delete IP ranges. This operation fails if an IP
from the remove range is in use. If the remove range contains the IP address on which the DHCP
server is running, &PRODUCT; acquires a new IP from the same subnet. If no IP is available in
the subnet, the remove operation fails.</para>
<para>This feature is supported on KVM, xenServer, and VMware hypervisors.</para>
</section>

View File

@ -33,6 +33,7 @@
<xi:include href="using-multiple-guest-networks.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="reserved-ip-addresses-non-csvms.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="multiple-ip-nic.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="multiple-ip-range.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="security-groups.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="external-firewalls-and-load-balancers.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>

57
docs/en-US/pvlan.xml Normal file
View File

@ -0,0 +1,57 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
%BOOK_ENTITIES;
]>
<!-- 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.
-->
<section id="pvlan">
<title>Isolation in Advanced Zone Using Private VLAN</title>
<para/>
<section id="about-pvlan">
<title>About Private VLAN</title>
<para>In an Ethernet switch, a VLAN is a broadcast domain in which hosts can establish direct
communication with each another at Layer 2. Private VLAN is designed as an extension of VLAN
standard to add further segmentation of the logical broadcast domain. A regular VLAN is a
single broadcast domain, whereas a private VLAN partitions a larger VLAN broadcast domain into
smaller sub-domains. A sub-domain is represented by a pair of VLANs: a Primary VLAN and a
Secondary VLAN. The original VLAN that is being divided into smaller groups is called
Primary, That implies all VLAN pairs in a private VLAN share the same Primary VLAN. All the
secondary VLANs exist only inside the Primary. Each Secondary VLAN has a specific VLAN ID
associated to it, which differentiates one sub-domain from another.</para>
<para>For further reading:</para>
<itemizedlist>
<listitem>
<para><ulink
url="http://www.cisco.com/en/US/docs/switches/lan/catalyst3750/software/release/12.2_25_see/configuration/guide/swpvlan.html#wp1038379"
>Understanding Private VLANs</ulink></para>
</listitem>
<listitem>
<para><ulink url="http://tools.ietf.org/html/rfc5517">Cisco Systems' Private VLANs: Scalable
Security in a Multi-Client Environment</ulink></para>
</listitem>
<listitem>
<para><ulink url="http://kb.vmware.com">Private VLAN (PVLAN) on vNetwork Distributed Switch
- Concept Overview (1010691)</ulink></para>
</listitem>
</itemizedlist>
</section>
<section id="prereq-pvlan">
<title>Prerequisites</title>
<para>Ensure that you configure private VLAN on your physical switches out-of-band.</para>
</section>
</section>

View File

@ -40,27 +40,42 @@
<para>Click the Configure button of the VPC whose IP you want to release.</para>
<para>The VPC page is displayed where all the tiers you created are listed in a
diagram.</para>
</listitem>
<listitem>
<para>Click the Settings icon.</para>
<para>The following options are displayed.</para>
<itemizedlist>
<listitem>
<para>IP Addresses</para>
<para>Internal LB</para>
</listitem>
<listitem>
<para>Gateways</para>
<para>Public LB IP</para>
</listitem>
<listitem>
<para>Site-to-Site VPN</para>
<para>Static NAT</para>
</listitem>
<listitem>
<para>Network ACLs</para>
<para>Virtual Machines</para>
</listitem>
<listitem>
<para>CIDR</para>
</listitem>
</itemizedlist>
<para>The following router information is displayed:</para>
<itemizedlist>
<listitem>
<para>Private Gateways</para>
</listitem>
<listitem>
<para>Public IP Addresses</para>
</listitem>
<listitem>
<para>Site-to-Site VPNs</para>
</listitem>
<listitem>
<para>Network ACL Lists</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Select IP Addresses.</para>
<para>Select Public IP Addresses.</para>
<para>The IP Addresses page is displayed.</para>
</listitem>
<listitem>

View File

@ -40,16 +40,18 @@
<para>The Configure VPC page is displayed. Locate the tier you want to work with.</para>
</listitem>
<listitem>
<para>Click the Remove VPC button:</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/remove-tier.png"/>
</imageobject>
<textobject>
<phrase>remove-tier.png: removing a tier from a vpc.</phrase>
</textobject>
</mediaobject>
<para>Wait for some time for the tier to be removed.</para>
<para>Select the tier you want to remove.</para>
</listitem>
<listitem>
<para>In the Network Details tab, click the Delete Network button.
<inlinemediaobject><imageobject>
<imagedata fileref="./images/del-tier.png"/>
</imageobject>
<textobject>
<phrase>del-tier.png: button to remove a tier</phrase>
</textobject>
</inlinemediaobject></para>
<para>Click Yes to confirm. Wait for some time for the tier to be removed.</para>
</listitem>
</orderedlist>
</section>

View File

@ -38,14 +38,15 @@
<para>Select the VPC you want to work with.</para>
</listitem>
<listitem>
<para>To remove, click the Remove VPC button<inlinemediaobject>
<para>In the Details tab, click the Remove VPC button<inlinemediaobject>
<imageobject>
<imagedata fileref="./images/remove-vpc.png"/>
</imageobject>
<textobject>
<phrase>remove-vpc.png: button to remove a VPC</phrase>
</textobject>
</inlinemediaobject></para>
</inlinemediaobject></para>
<para>You can remove the VPC by also using the remove button in the Quick View.</para>
<para>You can edit the name and description of a VPC. To do that, select the VPC, then click
the Edit button. <inlinemediaobject>
<imageobject>

View File

@ -151,8 +151,8 @@
cannot be used for StaticNAT or port forwarding.</para>
</listitem>
<listitem>
<para>The instances only have a private IP address that you provision. To communicate with the
Internet, enable NAT to an instance that you launch in your VPC.</para>
<para>The instances can only have a private IP address that you provision. To communicate with
the Internet, enable NAT to an instance that you launch in your VPC.</para>
</listitem>
<listitem>
<para>Only new networks can be added to a VPC. The maximum number of networks per VPC is

View File

@ -0,0 +1,27 @@
# Publican configuration file for CloudStack Complete Documentation Set
# Contains all technical docs except release notes
# Config::Simple 4.58
# Tue May 29 00:57:27 2012
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information#
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
xml_lang: en-US
type: Book
docname: CloudStack_GSoC_Guide
brand: cloudstack
chunk_first: 1
chunk_section_depth: 1

View File

@ -21,6 +21,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import java.util.Map;
import com.cloud.agent.api.StoragePoolInfo;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
public interface DataStoreLifeCycle {
@ -28,8 +29,8 @@ public interface DataStoreLifeCycle {
public boolean attachCluster(DataStore store, ClusterScope scope);
public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo);
boolean attachZone(DataStore dataStore, ZoneScope scope);
boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType);
public boolean dettach();
public boolean unmanaged();

View File

@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePoolStatus;
import com.cloud.utils.db.GenericDao;
/**
@ -109,4 +110,6 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
Long clusterId, String[] tags);
List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType);
}

View File

@ -32,6 +32,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
import org.springframework.stereotype.Component;
import com.cloud.host.Status;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePoolStatus;
@ -427,4 +428,14 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
return listBy(sc);
}
@Override
public List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType) {
SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dataCenterId);
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
sc.addAnd(sc.getEntity().getHypervisor(), Op.EQ, hypervisorType);
return sc.list();
}
}

View File

@ -31,6 +31,7 @@ import javax.persistence.TemporalType;
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
@ -102,6 +103,10 @@ public class StoragePoolVO implements StoragePool{
@Enumerated(value = EnumType.STRING)
private ScopeType scope;
@Column(name = "hypervisor")
@Enumerated(value = EnumType.STRING)
private HypervisorType hypervisor;
public long getId() {
return id;
}
@ -276,6 +281,14 @@ public class StoragePoolVO implements StoragePool{
return this.scope;
}
public HypervisorType getHypervisor() {
return hypervisor;
}
public void setHypervisor(HypervisorType hypervisor) {
this.hypervisor = hypervisor;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof StoragePoolVO) || obj == null) {

View File

@ -89,10 +89,9 @@ public class CloudOrchestrator implements OrchestrationService {
public CloudOrchestrator() {
}
public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String hypervisor, String hostName, int cpu, int speed, long memory, List<String> networks, List<String> computeTags,
Map<String, String> details, String owner) {
// TODO Auto-generated method stub
return null;
}

View File

@ -156,7 +156,7 @@ public class AlertDaoImpl extends GenericDaoBase<AlertVO, Long> implements Alert
public List<AlertVO> listOlderAlerts(Date oldTime) {
if (oldTime == null) return null;
SearchCriteria<AlertVO> sc = createSearchCriteria();
sc.addAnd("createDate", SearchCriteria.Op.LT, oldTime);
sc.addAnd("createdDate", SearchCriteria.Op.LT, oldTime);
sc.addAnd("archived", SearchCriteria.Op.EQ, false);
return listIncludingRemovedBy(sc, null);
}

View File

@ -34,4 +34,5 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long> {
Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);
List<Long> listDisabledClusters(long zoneId, Long podId);
List<Long> listClustersWithDisabledPods(long zoneId);
List<ClusterVO> listClustersByDcId(long zoneId);
}

View File

@ -52,6 +52,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
protected final SearchBuilder<ClusterVO> AvailHyperSearch;
protected final SearchBuilder<ClusterVO> ZoneSearch;
protected final SearchBuilder<ClusterVO> ZoneHyTypeSearch;
protected final SearchBuilder<ClusterVO> ZoneClusterSearch;
private static final String GET_POD_CLUSTER_MAP_PREFIX = "SELECT pod_id, id FROM cloud.cluster WHERE cluster.id IN( ";
private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )";
@ -85,12 +86,16 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
AvailHyperSearch.and("zoneId", AvailHyperSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
AvailHyperSearch.select(null, Func.DISTINCT, AvailHyperSearch.entity().getHypervisorType());
AvailHyperSearch.done();
ZoneClusterSearch = createSearchBuilder();
ZoneClusterSearch.and("dataCenterId", ZoneClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
ZoneClusterSearch.done();
}
@Override
public List<ClusterVO> listByZoneId(long zoneId) {
SearchCriteria<ClusterVO> sc = ZoneSearch.create();
sc.setParameters("dataCenterId", zoneId);
sc.setParameters("dataCenterId", zoneId);
return listBy(sc);
}
@ -223,6 +228,13 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
return customSearch(sc, null);
}
@Override
public List<ClusterVO> listClustersByDcId(long zoneId) {
SearchCriteria<ClusterVO> sc = ZoneClusterSearch.create();
sc.setParameters("dataCenterId", zoneId);
return listBy(sc);
}
@Override
public boolean remove(Long id) {
Transaction txn = Transaction.currentTxn();

View File

@ -288,5 +288,5 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
return parentDomains;
}
}

View File

@ -80,4 +80,10 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
* @return
*/
List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
List<HostVO> findByPodId(Long podId);
List<HostVO> findByClusterId(Long clusterId);
List<HostVO> listByDataCenterId(long id);
}

View File

@ -37,6 +37,7 @@ import com.cloud.cluster.agentlb.HostTransferMapVO;
import com.cloud.cluster.agentlb.dao.HostTransferMapDao;
import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.ClusterDaoImpl;
import com.cloud.host.Host;
@ -86,6 +87,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
protected SearchBuilder<HostVO> GuidSearch;
protected SearchBuilder<HostVO> DcSearch;
protected SearchBuilder<HostVO> PodSearch;
protected SearchBuilder<HostVO> ClusterSearch;
protected SearchBuilder<HostVO> TypeSearch;
protected SearchBuilder<HostVO> StatusSearch;
protected SearchBuilder<HostVO> ResourceStateSearch;
@ -201,6 +203,9 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
DcSearch = createSearchBuilder();
DcSearch.and("dc", DcSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
DcSearch.and("type", DcSearch.entity().getType(), Op.EQ);
DcSearch.and("status", DcSearch.entity().getStatus(), Op.EQ);
DcSearch.and("resourceState", DcSearch.entity().getResourceState(), Op.EQ);
DcSearch.done();
ClusterStatusSearch = createSearchBuilder();
@ -215,9 +220,13 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
TypeNameZoneSearch.done();
PodSearch = createSearchBuilder();
PodSearch.and("pod", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
PodSearch.and("podId", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
PodSearch.done();
ClusterSearch = createSearchBuilder();
ClusterSearch.and("clusterId", ClusterSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
ClusterSearch.done();
TypeSearch = createSearchBuilder();
TypeSearch.and("type", TypeSearch.entity().getType(), SearchCriteria.Op.EQ);
TypeSearch.done();
@ -373,7 +382,17 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
List<HostVO> hosts = listBy(sc);
return hosts.size();
}
@Override
public List<HostVO> listByDataCenterId(long id) {
SearchCriteria<HostVO> sc = DcSearch.create();
sc.setParameters("dcId", id);
sc.setParameters("status", Status.Up);
sc.setParameters("type", Host.Type.Routing);
sc.setParameters("resourceState", ResourceState.Enabled);
return listBy(sc);
}
@Override
public HostVO findByGuid(String guid) {
@ -906,6 +925,20 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
return findOneBy(sc);
}
@Override
public List<HostVO> findByPodId(Long podId) {
SearchCriteria<HostVO> sc = PodSearch.create();
sc.setParameters("podId", podId);
return listBy(sc);
}
@Override
public List<HostVO> findByClusterId(Long clusterId) {
SearchCriteria<HostVO> sc = ClusterSearch.create();
sc.setParameters("clusterId", clusterId);
return listBy(sc);
}
@Override
public List<HostVO> findHypervisorHostInCluster(long clusterId) {
SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();

View File

@ -18,9 +18,6 @@ package com.cloud.upgrade;
import javax.ejb.Local;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import com.cloud.upgrade.dao.DbUpgrade;
import com.cloud.upgrade.dao.Upgrade217to218;
import com.cloud.upgrade.dao.Upgrade218to224DomainVlans;
@ -43,7 +40,6 @@ import com.cloud.upgrade.dao.Upgrade30to301;
import com.cloud.upgrade.dao.Upgrade40to41;
import com.cloud.upgrade.dao.UpgradeSnapshot217to224;
import com.cloud.upgrade.dao.UpgradeSnapshot223to224;
import com.cloud.upgrade.dao.VersionDaoImpl;
import com.cloud.utils.component.SystemIntegrityChecker;

View File

@ -18,6 +18,7 @@
package com.cloud.upgrade.dao;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import org.apache.log4j.Logger;
@ -64,6 +65,7 @@ public class Upgrade410to420 implements DbUpgrade {
@Override
public void performDataMigration(Connection conn) {
upgradeVmwareLabels(conn);
persistLegacyZones(conn);
createPlaceHolderNics(conn);
updateRemoteAccessVpn(conn);
updateSystemVmTemplates(conn);
@ -77,6 +79,7 @@ public class Upgrade410to420 implements DbUpgrade {
updateNetworkACLs(conn);
addHostDetailsIndex(conn);
updateNetworksForPrivateGateways(conn);
correctExternalNetworkDevicesSetup(conn);
removeFirewallServiceFromSharedNetworkOfferingWithSGService(conn);
fix22xKVMSnapshots(conn);
addIndexForAlert(conn);
@ -110,16 +113,215 @@ public class Upgrade410to420 implements DbUpgrade {
}
private void updateSystemVmTemplates(Connection conn) {
PreparedStatement sql = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
boolean xenserver = false;
boolean kvm = false;
boolean VMware = false;
boolean Hyperv = false;
boolean LXC = false;
s_logger.debug("Updating System Vm template IDs");
try{
//Get all hypervisors in use
try {
pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null");
rs = pstmt.executeQuery();
while(rs.next()){
if("XenServer".equals(rs.getString(1))){
xenserver = true;
} else if("KVM".equals(rs.getString(1))){
kvm = true;
} else if("VMware".equals(rs.getString(1))){
VMware = true;
} else if("Hyperv".equals(rs.getString(1))) {
Hyperv = true;
} else if("LXC".equals(rs.getString(1))) {
LXC = true;
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Error while listing hypervisors in use", e);
}
s_logger.debug("Updating XenSever System Vms");
//XenServer
try {
//Get 4.2.0 xenserer system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-xenserver-4.2' and removed is null order by id desc limit 1");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
rs.close();
pstmt.close();
// change template type to SYSTEM
pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
// update templete ID of system Vms
pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'XenServer'");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
} else {
if (xenserver){
throw new CloudRuntimeException("4.2.0 XenServer SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("4.2.0 XenServer SystemVm template not found. XenServer hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Error while updating XenServer systemVm template", e);
}
//KVM
s_logger.debug("Updating KVM System Vms");
try {
//Get 4.2.0 KVM system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-kvm-4.2' and removed is null order by id desc limit 1");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
rs.close();
pstmt.close();
// change template type to SYSTEM
pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
// update templete ID of system Vms
pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'KVM'");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
} else {
if (kvm){
throw new CloudRuntimeException("4.2.0 KVM SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("4.2.0 KVM SystemVm template not found. KVM hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Error while updating KVM systemVm template", e);
}
//VMware
s_logger.debug("Updating VMware System Vms");
try {
//Get 4.2.0 VMware system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-vmware-4.2' and removed is null order by id desc limit 1");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
rs.close();
pstmt.close();
// change template type to SYSTEM
pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
// update templete ID of system Vms
pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'VMware'");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
} else {
if (VMware){
throw new CloudRuntimeException("4.2.0 VMware SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("4.2.0 VMware SystemVm template not found. VMware hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Error while updating VMware systemVm template", e);
}
//Hyperv
s_logger.debug("Updating Hyperv System Vms");
try {
//Get 4.2.0 Hyperv system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-hyperv-4.2' and removed is null order by id desc limit 1");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
rs.close();
pstmt.close();
// change template type to SYSTEM
pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
// update templete ID of system Vms
pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'Hyperv'");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
} else {
if (Hyperv){
throw new CloudRuntimeException("4.2.0 HyperV SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("4.2.0 Hyperv SystemVm template not found. Hyperv hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Error while updating Hyperv systemVm template", e);
}
//LXC
s_logger.debug("Updating LXC System Vms");
try {
//Get 4.2.0 LXC system Vm template Id
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-lxc-4.2' and removed is null order by id desc limit 1");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
rs.close();
pstmt.close();
// change template type to SYSTEM
pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
// update templete ID of system Vms
pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'LXC'");
pstmt.setLong(1, templateId);
pstmt.executeUpdate();
pstmt.close();
} else {
if (LXC){
throw new CloudRuntimeException("4.2.0 LXC SystemVm template not found. Cannot upgrade system Vms");
} else {
s_logger.warn("4.2.0 LXC SystemVm template not found. LXC hypervisor is not used, so not failing upgrade");
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Error while updating LXC systemVm template", e);
}
s_logger.debug("Updating System Vm Template IDs Complete");
}
finally {
try {
if (rs != null) {
rs.close();
}
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
pstmt = null;
try {
sql = conn.prepareStatement("update vm_template set image_data_store_id = 1 where type = 'SYSTEM' or type = 'BUILTIN'");
sql.executeUpdate();
pstmt = conn.prepareStatement("update vm_template set image_data_store_id = 1 where type = 'SYSTEM' or type = 'BUILTIN'");
pstmt.executeUpdate();
} catch (SQLException e) {
throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
} finally {
if (sql != null) {
if (pstmt != null) {
try {
sql.close();
pstmt.close();
} catch (SQLException e) {
}
}
@ -277,6 +479,180 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
private void persistLegacyZones(Connection conn) {
List<Long> listOfLegacyZones = new ArrayList<Long>();
PreparedStatement pstmt = null;
PreparedStatement clustersQuery = null;
PreparedStatement clusterDetailsQuery = null;
ResultSet rs = null;
ResultSet clusters = null;
ResultSet clusterDetails = null;
ResultSet dcInfo = null;
Long vmwareDcId = 1L;
Long zoneId;
Long clusterId;
String clusterHypervisorType;
boolean legacyZone;
boolean ignoreZone;
Long count;
String dcOfPreviousCluster = null;
String dcOfCurrentCluster = null;
String[] tokens;
String url;
String user = "";
String password = "";
String vc = "";
String dcName = "";
String guid;
String key;
String value;
try {
clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL");
pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where removed is NULL");
rs = pstmt.executeQuery();
while (rs.next()) {
zoneId = rs.getLong("id");
legacyZone = false;
ignoreZone = true;
count = 0L;
// Legacy zone term is meant only for VMware
// Legacy zone is a zone with atleast 2 clusters & with multiple DCs or VCs
clusters = clustersQuery.executeQuery();
if (!clusters.next()) {
continue; // Ignore the zone without any clusters
} else {
dcOfPreviousCluster = null;
dcOfCurrentCluster = null;
do {
clusterHypervisorType = clusters.getString("hypervisor_type");
clusterId = clusters.getLong("id");
if (clusterHypervisorType.equalsIgnoreCase("VMware")) {
ignoreZone = false;
clusterDetailsQuery = conn.prepareStatement("select value from `cloud`.`cluster_details` where name='url' and cluster_id=?");
clusterDetailsQuery.setLong(1, clusterId);
clusterDetails = clusterDetailsQuery.executeQuery();
clusterDetails.next();
url = clusterDetails.getString("value");
tokens = url.split("/"); // url format - http://vcenter/dc/cluster
vc = tokens[2];
dcName = tokens[3];
if (count > 0) {
dcOfPreviousCluster = dcOfCurrentCluster;
dcOfCurrentCluster = dcName + "@" + vc;
if (!dcOfPreviousCluster.equals(dcOfCurrentCluster)) {
legacyZone = true;
s_logger.debug("Marking the zone " + zoneId + " as legacy zone.");
}
}
} else {
s_logger.debug("Ignoring zone " + zoneId + " with hypervisor type " + clusterHypervisorType);
break;
}
count++;
} while (clusters.next());
if (ignoreZone) {
continue; // Ignore the zone with hypervisors other than VMware
}
}
if (legacyZone) {
listOfLegacyZones.add(zoneId);
} else {
assert(clusterDetails != null) : "Couldn't retrieve details of cluster!";
s_logger.debug("Discovered non-legacy zone " + zoneId + ". Processing the zone to associate with VMware datacenter.");
clusterDetailsQuery = conn.prepareStatement("select name, value from `cloud`.`cluster_details` where cluster_id=?");
clusterDetailsQuery.setLong(1, clusterId);
clusterDetails = clusterDetailsQuery.executeQuery();
while (clusterDetails.next()) {
key = clusterDetails.getString(1);
value = clusterDetails.getString(2);
if (key.equalsIgnoreCase("username")) {
user = value;
} else if (key.equalsIgnoreCase("password")) {
password = value;
}
}
guid = dcName + "@" + vc;
pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vmware_data_center` (uuid, name, guid, vcenter_host, username, password) values(?, ?, ?, ?, ?, ?)");
pstmt.setString(1, UUID.randomUUID().toString());
pstmt.setString(2, dcName);
pstmt.setString(3, guid);
pstmt.setString(4, vc);
pstmt.setString(5, user);
pstmt.setString(6, password);
pstmt.executeUpdate();
pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`vmware_data_center` where guid=?");
pstmt.setString(1, guid);
dcInfo = pstmt.executeQuery();
if(dcInfo.next()) {
vmwareDcId = dcInfo.getLong("id");
}
pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vmware_data_center_zone_map` (zone_id, vmware_data_center_id) values(?, ?)");
pstmt.setLong(1, zoneId);
pstmt.setLong(2, vmwareDcId);
pstmt.executeUpdate();
}
}
updateLegacyZones(conn, listOfLegacyZones);
} catch (SQLException e) {
String msg = "Unable to discover legacy zones." + e.getMessage();
s_logger.error(msg);
throw new CloudRuntimeException(msg, e);
} finally {
try {
if (rs != null) {
rs.close();
}
if (pstmt != null) {
pstmt.close();
}
if (dcInfo != null) {
dcInfo.close();
}
if (clusters != null) {
clusters.close();
}
if (clusterDetails != null) {
clusterDetails.close();
}
if (clustersQuery != null) {
clustersQuery.close();
}
if (clusterDetailsQuery != null) {
clusterDetailsQuery.close();
}
} catch (SQLException e) {
}
}
}
private void updateLegacyZones(Connection conn, List<Long> zones) {
PreparedStatement legacyZonesQuery = null;
//Insert legacy zones into table for legacy zones.
try {
legacyZonesQuery = conn.prepareStatement("INSERT INTO `cloud`.`legacy_zones` (zone_id) VALUES (?)");
for(Long zoneId : zones) {
legacyZonesQuery.setLong(1, zoneId);
legacyZonesQuery.executeUpdate();
s_logger.debug("Inserted zone " + zoneId + " into cloud.legacyzones table");
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable add zones to cloud.legacyzones table.", e);
} finally {
try {
if (legacyZonesQuery != null) {
legacyZonesQuery.close();
}
} catch (SQLException e) {
}
}
}
private void createPlaceHolderNics(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -849,4 +1225,363 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
// Corrects upgrade for deployment with F5 and SRX devices (pre 3.0) to network offering &
// network service provider paradigm
private void correctExternalNetworkDevicesSetup(Connection conn) {
PreparedStatement zoneSearchStmt = null, pNetworkStmt = null, f5DevicesStmt = null, srxDevicesStmt = null;
ResultSet zoneResults = null, pNetworksResults = null, f5DevicesResult = null, srxDevicesResult = null;
try {
zoneSearchStmt = conn.prepareStatement("SELECT id, networktype FROM `cloud`.`data_center`");
zoneResults = zoneSearchStmt.executeQuery();
while (zoneResults.next()) {
long zoneId = zoneResults.getLong(1);
String networkType = zoneResults.getString(2);
if (!com.cloud.dc.DataCenter.NetworkType.Advanced.toString().equalsIgnoreCase(networkType)) {
continue;
}
pNetworkStmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where data_center_id=?");
pNetworkStmt.setLong(1, zoneId);
pNetworksResults = pNetworkStmt.executeQuery();
while (pNetworksResults.next()) {
long physicalNetworkId = pNetworksResults.getLong(1);
PreparedStatement fetchF5NspStmt = conn.prepareStatement("SELECT id from `cloud`.`physical_network_service_providers` where physical_network_id=" + physicalNetworkId
+ " and provider_name = 'F5BigIp'");
ResultSet rsF5NSP = fetchF5NspStmt.executeQuery();
boolean hasF5Nsp = rsF5NSP.next();
fetchF5NspStmt.close();
// if there is no 'F5BigIP' physical network service provider added into physical network then
// add 'F5BigIP' as network service provider and add the entry in 'external_load_balancer_devices'
if (!hasF5Nsp) {
f5DevicesStmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalLoadBalancer' AND removed IS NULL");
f5DevicesStmt.setLong(1, zoneId);
f5DevicesResult = f5DevicesStmt.executeQuery();
// add F5BigIP provider and provider instance to physical network if there are any external load
// balancers added in the zone
while (f5DevicesResult.next()) {
long f5HostId = f5DevicesResult.getLong(1);;
addF5ServiceProvider(conn, physicalNetworkId, zoneId);
addF5LoadBalancer(conn, f5HostId, physicalNetworkId);
}
}
PreparedStatement fetchSRXNspStmt = conn.prepareStatement("SELECT id from `cloud`.`physical_network_service_providers` where physical_network_id=" + physicalNetworkId
+ " and provider_name = 'JuniperSRX'");
ResultSet rsSRXNSP = fetchSRXNspStmt.executeQuery();
boolean hasSrxNsp = rsSRXNSP.next();
fetchSRXNspStmt.close();
// if there is no 'JuniperSRX' physical network service provider added into physical network then
// add 'JuniperSRX' as network service provider and add the entry in 'external_firewall_devices'
if (!hasSrxNsp) {
srxDevicesStmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalFirewall' AND removed IS NULL");
srxDevicesStmt.setLong(1, zoneId);
srxDevicesResult = srxDevicesStmt.executeQuery();
// add JuniperSRX provider and provider instance to physical network if there are any external
// firewall instances added in to the zone
while (srxDevicesResult.next()) {
long srxHostId = srxDevicesResult.getLong(1);
// add SRX provider and provider instance to physical network
addSrxServiceProvider(conn, physicalNetworkId, zoneId);
addSrxFirewall(conn, srxHostId, physicalNetworkId);
}
}
}
}
// not the network service provider has been provisioned in to physical network, mark all guest network
// to be using network offering 'Isolated with external providers'
fixZoneUsingExternalDevices(conn);
if (zoneResults != null) {
try {
zoneResults.close();
} catch (SQLException e) {
}
}
if (zoneSearchStmt != null) {
try {
zoneSearchStmt.close();
} catch (SQLException e) {
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e);
} finally {
}
}
private void addF5LoadBalancer(Connection conn, long hostId, long physicalNetworkId){
PreparedStatement pstmtUpdate = null;
try{
s_logger.debug("Adding F5 Big IP load balancer with host id " + hostId + " in to physical network" + physicalNetworkId);
String insertF5 = "INSERT INTO `cloud`.`external_load_balancer_devices` (physical_network_id, host_id, provider_name, " +
"device_name, capacity, is_dedicated, device_state, allocation_state, is_inline, is_managed, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmtUpdate = conn.prepareStatement(insertF5);
pstmtUpdate.setLong(1, physicalNetworkId);
pstmtUpdate.setLong(2, hostId);
pstmtUpdate.setString(3, "F5BigIp");
pstmtUpdate.setString(4, "F5BigIpLoadBalancer");
pstmtUpdate.setLong(5, 0);
pstmtUpdate.setBoolean(6, false);
pstmtUpdate.setString(7, "Enabled");
pstmtUpdate.setString(8, "Shared");
pstmtUpdate.setBoolean(9, false);
pstmtUpdate.setBoolean(10, false);
pstmtUpdate.setString(11, UUID.randomUUID().toString());
pstmtUpdate.executeUpdate();
}catch (SQLException e) {
throw new CloudRuntimeException("Exception while adding F5 load balancer device" , e);
} finally {
if (pstmtUpdate != null) {
try {
pstmtUpdate.close();
} catch (SQLException e) {
}
}
}
}
private void addSrxFirewall(Connection conn, long hostId, long physicalNetworkId){
PreparedStatement pstmtUpdate = null;
try{
s_logger.debug("Adding SRX firewall device with host id " + hostId + " in to physical network" + physicalNetworkId);
String insertSrx = "INSERT INTO `cloud`.`external_firewall_devices` (physical_network_id, host_id, provider_name, " +
"device_name, capacity, is_dedicated, device_state, allocation_state, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmtUpdate = conn.prepareStatement(insertSrx);
pstmtUpdate.setLong(1, physicalNetworkId);
pstmtUpdate.setLong(2, hostId);
pstmtUpdate.setString(3, "JuniperSRX");
pstmtUpdate.setString(4, "JuniperSRXFirewall");
pstmtUpdate.setLong(5, 0);
pstmtUpdate.setBoolean(6, false);
pstmtUpdate.setString(7, "Enabled");
pstmtUpdate.setString(8, "Shared");
pstmtUpdate.setString(9, UUID.randomUUID().toString());
pstmtUpdate.executeUpdate();
}catch (SQLException e) {
throw new CloudRuntimeException("Exception while adding SRX firewall device ", e);
} finally {
if (pstmtUpdate != null) {
try {
pstmtUpdate.close();
} catch (SQLException e) {
}
}
}
}
private void addF5ServiceProvider(Connection conn, long physicalNetworkId, long zoneId){
PreparedStatement pstmtUpdate = null;
try{
// add physical network service provider - F5BigIp
s_logger.debug("Adding PhysicalNetworkServiceProvider F5BigIp" + " in to physical network" + physicalNetworkId);
String insertPNSP = "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," +
"`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," +
"`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," +
"`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,0,0,0,1,0,0,0,0)";
pstmtUpdate = conn.prepareStatement(insertPNSP);
pstmtUpdate.setString(1, UUID.randomUUID().toString());
pstmtUpdate.setLong(2, physicalNetworkId);
pstmtUpdate.setString(3, "F5BigIp");
pstmtUpdate.setString(4, "Enabled");
pstmtUpdate.executeUpdate();
}catch (SQLException e) {
throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider F5BigIp", e);
} finally {
if (pstmtUpdate != null) {
try {
pstmtUpdate.close();
} catch (SQLException e) {
}
}
}
}
private void addSrxServiceProvider(Connection conn, long physicalNetworkId, long zoneId){
PreparedStatement pstmtUpdate = null;
try{
// add physical network service provider - JuniperSRX
s_logger.debug("Adding PhysicalNetworkServiceProvider JuniperSRX");
String insertPNSP = "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," +
"`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," +
"`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," +
"`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,1,1,1,0,1,1,0,0)";
pstmtUpdate = conn.prepareStatement(insertPNSP);
pstmtUpdate.setString(1, UUID.randomUUID().toString());
pstmtUpdate.setLong(2, physicalNetworkId);
pstmtUpdate.setString(3, "JuniperSRX");
pstmtUpdate.setString(4, "Enabled");
pstmtUpdate.executeUpdate();
}catch (SQLException e) {
throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider JuniperSRX" , e);
} finally {
if (pstmtUpdate != null) {
try {
pstmtUpdate.close();
} catch (SQLException e) {
}
}
}
}
// This method does two things
//
// 1) ensure that networks using external load balancer/firewall in deployments prior to release 3.0
// has entry in network_external_lb_device_map and network_external_firewall_device_map
//
// 2) Some keys of host details for F5 and SRX devices were stored in Camel Case in 2.x releases. From 3.0
// they are made in lowercase. On upgrade change the host details name to lower case
private void fixZoneUsingExternalDevices(Connection conn) {
//Get zones to upgrade
List<Long> zoneIds = new ArrayList<Long>();
PreparedStatement pstmt = null;
PreparedStatement pstmtUpdate = null;
ResultSet rs = null;
long networkOfferingId, networkId;
long f5DeviceId, f5HostId;
long srxDevivceId, srxHostId;
try {
pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where lb_provider='F5BigIp' or firewall_provider='JuniperSRX' or gateway_provider='JuniperSRX'");
rs = pstmt.executeQuery();
while (rs.next()) {
zoneIds.add(rs.getLong(1));
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to create network to LB & firewall device mapping for networks that use them", e);
}
if (zoneIds.size() == 0) {
return; // no zones using F5 and SRX devices so return
}
// find the default network offering created for external devices during upgrade from 2.2.14
try {
pstmt = conn.prepareStatement("select id from `cloud`.`network_offerings` where unique_name='Isolated with external providers' ");
rs = pstmt.executeQuery();
if (rs.first()) {
networkOfferingId = rs.getLong(1);
} else {
throw new CloudRuntimeException("Cannot upgrade as there is no 'Isolated with external providers' network offering crearted .");
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to create network to LB & firewalla device mapping for networks that use them", e);
}
for (Long zoneId : zoneIds) {
try {
// find the F5 device id in the zone
pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalLoadBalancer' AND removed IS NULL");
pstmt.setLong(1, zoneId);
rs = pstmt.executeQuery();
if (rs.first()) {
f5HostId = rs.getLong(1);
} else {
throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device found in data center " + zoneId);
}
pstmt = conn.prepareStatement("SELECT id FROM external_load_balancer_devices WHERE host_id=?");
pstmt.setLong(1, f5HostId);
rs = pstmt.executeQuery();
if (rs.first()) {
f5DeviceId = rs.getLong(1);
} else {
throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device with host ID " + f5HostId + " found in external_load_balancer_device");
}
// find the SRX device id in the zone
pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalFirewall' AND removed IS NULL");
pstmt.setLong(1, zoneId);
rs = pstmt.executeQuery();
if (rs.first()) {
srxHostId = rs.getLong(1);
} else {
throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found in data center " + zoneId);
}
pstmt = conn.prepareStatement("SELECT id FROM external_firewall_devices WHERE host_id=?");
pstmt.setLong(1, srxHostId);
rs = pstmt.executeQuery();
if (rs.first()) {
srxDevivceId = rs.getLong(1);
} else {
throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found with host ID " + srxHostId + " found in external_firewall_devices");
}
// check if network any uses F5 or SRX devices in the zone
pstmt = conn.prepareStatement("select id from `cloud`.`networks` where guest_type='Virtual' and data_center_id=? and network_offering_id=? and removed IS NULL");
pstmt.setLong(1, zoneId);
pstmt.setLong(2, networkOfferingId);
rs = pstmt.executeQuery();
while (rs.next()) {
// get the network Id
networkId = rs.getLong(1);
// add mapping for the network in network_external_lb_device_map
String insertLbMapping = "INSERT INTO `cloud`.`network_external_lb_device_map` (uuid, network_id, external_load_balancer_device_id, created) VALUES ( ?, ?, ?, now())";
pstmtUpdate = conn.prepareStatement(insertLbMapping);
pstmtUpdate.setString(1, UUID.randomUUID().toString());
pstmtUpdate.setLong(2, networkId);
pstmtUpdate.setLong(3, f5DeviceId);
pstmtUpdate.executeUpdate();
s_logger.debug("Successfully added entry in network_external_lb_device_map for network " + networkId + " and F5 device ID " + f5DeviceId);
// add mapping for the network in network_external_firewall_device_map
String insertFwMapping = "INSERT INTO `cloud`.`network_external_firewall_device_map` (uuid, network_id, external_firewall_device_id, created) VALUES ( ?, ?, ?, now())";
pstmtUpdate = conn.prepareStatement(insertFwMapping);
pstmtUpdate.setString(1, UUID.randomUUID().toString());
pstmtUpdate.setLong(2, networkId);
pstmtUpdate.setLong(3, srxDevivceId);
pstmtUpdate.executeUpdate();
s_logger.debug("Successfully added entry in network_external_firewall_device_map for network " + networkId + " and SRX device ID " + srxDevivceId);
}
// update host details for F5 and SRX devices
s_logger.debug("Updating the host details for F5 and SRX devices");
pstmt = conn.prepareStatement("SELECT host_id, name FROM `cloud`.`host_details` WHERE host_id=? OR host_id=?");
pstmt.setLong(1, f5HostId);
pstmt.setLong(2, srxHostId);
rs = pstmt.executeQuery();
while (rs.next()) {
long hostId = rs.getLong(1);
String camlCaseName = rs.getString(2);
if (!(camlCaseName.equalsIgnoreCase("numRetries") ||
camlCaseName.equalsIgnoreCase("publicZone") ||
camlCaseName.equalsIgnoreCase("privateZone") ||
camlCaseName.equalsIgnoreCase("publicInterface") ||
camlCaseName.equalsIgnoreCase("privateInterface") ||
camlCaseName.equalsIgnoreCase("usageInterface") )) {
continue;
}
String lowerCaseName = camlCaseName.toLowerCase();
pstmt = conn.prepareStatement("update `cloud`.`host_details` set name=? where host_id=? AND name=?");
pstmt.setString(1, lowerCaseName);
pstmt.setLong(2, hostId);
pstmt.setString(3, camlCaseName);
pstmt.executeUpdate();
}
s_logger.debug("Successfully updated host details for F5 and SRX devices");
} catch (SQLException e) {
throw new CloudRuntimeException("Unable create a mapping for the networks in network_external_lb_device_map and network_external_firewall_device_map", e);
} finally {
try {
if (rs != null) {
rs.close();
}
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
s_logger.info("Successfully upgraded network using F5 and SRX devices to have a entry in the network_external_lb_device_map and network_external_firewall_device_map");
}
}
}

View File

@ -54,10 +54,9 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long> {
/**
* List user vm instances with virtualized networking (i.e. not direct attached networking) for the given account and datacenter
* @param accountId will search for vm instances belonging to this account
* @param dcId will search for vm instances in this zone
* @return the list of vm instances owned by the account in the given data center that have virtualized networking (not direct attached networking)
*/
List<UserVmVO> listVirtualNetworkInstancesByAcctAndZone(long accountId, long dcId, long networkId);
List<UserVmVO> listVirtualNetworkInstancesByAcctAndNetwork(long accountId, long networkId);
List<UserVmVO> listByNetworkIdAndStates(long networkId, State... states);

View File

@ -283,11 +283,10 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
}
@Override
public List<UserVmVO> listVirtualNetworkInstancesByAcctAndZone(long accountId, long dcId, long networkId) {
public List<UserVmVO> listVirtualNetworkInstancesByAcctAndNetwork(long accountId, long networkId) {
SearchCriteria<UserVmVO> sc = AccountDataCenterVirtualSearch.create();
sc.setParameters("account", accountId);
sc.setParameters("dc", dcId);
sc.setJoinParameters("nicSearch", "networkId", networkId);
return listBy(sc);

View File

@ -31,5 +31,6 @@ public interface ApplicationLoadBalancerRuleDao extends GenericDao<ApplicationLo
long countBySourceIp(Ip sourceIp, long sourceIpNetworkId);
List<ApplicationLoadBalancerRuleVO> listBySourceIpAndNotRevoked(Ip sourceIp, long sourceNetworkId);
List<String> listLbIpsBySourceIpNetworkIdAndScheme(long sourceIpNetworkId, Scheme scheme);
long countBySourceIpAndNotRevoked(Ip sourceIp, long sourceIpNetworkId);
}

View File

@ -25,6 +25,7 @@ import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
import org.springframework.stereotype.Component;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.FirewallRule.State;
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.GenericSearchBuilder;
@ -41,8 +42,8 @@ public class ApplicationLoadBalancerRuleDaoImpl extends GenericDaoBase<Applicati
final GenericSearchBuilder<ApplicationLoadBalancerRuleVO, String> listIps;
final GenericSearchBuilder<ApplicationLoadBalancerRuleVO, Long> CountBy;
protected final SearchBuilder<ApplicationLoadBalancerRuleVO> NotRevokedSearch;
final GenericSearchBuilder<ApplicationLoadBalancerRuleVO, Long> CountNotRevoked;
protected ApplicationLoadBalancerRuleDaoImpl() {
AllFieldsSearch = createSearchBuilder();
@ -69,6 +70,13 @@ public class ApplicationLoadBalancerRuleDaoImpl extends GenericDaoBase<Applicati
NotRevokedSearch.and("sourceIpNetworkId", NotRevokedSearch.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), SearchCriteria.Op.NEQ);
NotRevokedSearch.done();
CountNotRevoked = createSearchBuilder(Long.class);
CountNotRevoked.select(null, Func.COUNT, CountNotRevoked.entity().getId());
CountNotRevoked.and("sourceIp", CountNotRevoked.entity().getSourceIp(), Op.EQ);
CountNotRevoked.and("state", CountNotRevoked.entity().getState(), Op.NEQ);
CountNotRevoked.and("sourceIpNetworkId", CountNotRevoked.entity().getSourceIpNetworkId(), Op.EQ);
CountNotRevoked.done();
}
@Override
@ -112,4 +120,14 @@ public class ApplicationLoadBalancerRuleDaoImpl extends GenericDaoBase<Applicati
return customSearch(sc, null);
}
@Override
public long countBySourceIpAndNotRevoked(Ip sourceIp, long sourceIpNetworkId) {
SearchCriteria<Long> sc = CountNotRevoked.create();
sc.setParameters("sourceIp", sourceIp);
sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
sc.setParameters("state", State.Revoke);
List<Long> results = customSearch(sc, null);
return results.get(0);
}
}

View File

@ -31,12 +31,17 @@ public class GlobalLoadBalancerDaoImpl extends GenericDaoBase<GlobalLoadBalancer
private final SearchBuilder<GlobalLoadBalancerRuleVO> listByDomainSearch;
private final SearchBuilder<GlobalLoadBalancerRuleVO> listByRegionIDSearch;
private final SearchBuilder<GlobalLoadBalancerRuleVO> AccountIdSearch;
public GlobalLoadBalancerDaoImpl() {
listByDomainSearch = createSearchBuilder();
listByDomainSearch.and("gslbDomain", listByDomainSearch.entity().getGslbDomain(), SearchCriteria.Op.EQ);
listByDomainSearch.done();
AccountIdSearch = createSearchBuilder();
AccountIdSearch.and("account", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
AccountIdSearch.done();
listByRegionIDSearch = createSearchBuilder();
listByRegionIDSearch.and("region", listByRegionIDSearch.entity().getRegion(), SearchCriteria.Op.EQ);
listByRegionIDSearch.done();
@ -49,6 +54,13 @@ public class GlobalLoadBalancerDaoImpl extends GenericDaoBase<GlobalLoadBalancer
return listBy(sc);
}
@Override
public List<GlobalLoadBalancerRuleVO> listByAccount(long accountId) {
SearchCriteria<GlobalLoadBalancerRuleVO> sc = AccountIdSearch.create();
sc.setParameters("account", accountId);
return listBy(sc, null);
}
@Override
public GlobalLoadBalancerRuleVO findByDomainName(String domainName) {
SearchCriteria<GlobalLoadBalancerRuleVO> sc = listByDomainSearch.create();

View File

@ -24,5 +24,8 @@ import java.util.List;
public interface GlobalLoadBalancerRuleDao extends GenericDao<GlobalLoadBalancerRuleVO, Long> {
List<GlobalLoadBalancerRuleVO> listByRegionId(int regionId);
List<GlobalLoadBalancerRuleVO> listByAccount(long accountId);
GlobalLoadBalancerRuleVO findByDomainName(String domainName);
}

View File

@ -30,6 +30,7 @@ import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
import com.cloud.agent.api.StoragePoolInfo;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
@Inject
@ -65,7 +66,7 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
@Override
public boolean attachZone(DataStore dataStore, ZoneScope scope) {
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisor) {
// TODO Auto-generated method stub
return false;
}

View File

@ -38,34 +38,36 @@ import com.cloud.vm.VirtualMachineProfile;
@Component
public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator {
private static final Logger s_logger = Logger.getLogger(ZoneWideStoragePoolAllocator.class);
@Inject PrimaryDataStoreDao _storagePoolDao;
@Inject DataStoreManager dataStoreMgr;
private static final Logger s_logger = Logger.getLogger(ZoneWideStoragePoolAllocator.class);
@Inject PrimaryDataStoreDao _storagePoolDao;
@Inject DataStoreManager dataStoreMgr;
@Override
protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
DeploymentPlan plan) {
@Override
protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
DeploymentPlan plan) {
Volume volume = _volumeDao.findById(dskCh.getVolumeId());
List<Volume> requestVolumes = new ArrayList<Volume>();
requestVolumes.add(volume);
return storageMgr.storagePoolHasEnoughSpace(requestVolumes, pool);
}
}
@Override
protected List<StoragePool> select(DiskProfile dskCh,
VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool");
List<StoragePool> suitablePools = new ArrayList<StoragePool>();
HypervisorType hypervisor = dskCh.getHypervisorType();
if (hypervisor != null) {
if (hypervisor != HypervisorType.KVM) {
s_logger.debug("Only kvm supports zone wide storage");
return suitablePools;
}
}
@Override
protected List<StoragePool> select(DiskProfile dskCh,
VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool");
List<StoragePool> suitablePools = new ArrayList<StoragePool>();
HypervisorType hypervisor = dskCh.getHypervisorType();
if (hypervisor != null) {
if (hypervisor != HypervisorType.KVM && hypervisor != HypervisorType.VMware) {
s_logger.debug("Only kvm, VMware hypervisors are enabled to support zone wide storage");
return suitablePools;
}
}
List<StoragePoolVO> storagePools = _storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(), dskCh.getTags());
List<StoragePoolVO> storagePools = _storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(), dskCh.getTags());
List<StoragePoolVO> storagePoolsByHypervisor = _storagePoolDao.findZoneWideStoragePoolsByHypervisor(plan.getDataCenterId(), dskCh.getHypervisorType());
storagePools.retainAll(storagePoolsByHypervisor);
// add remaining pools in zone, that did not match tags, to avoid set
List<StoragePoolVO> allPools = _storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(), null);
@ -74,17 +76,17 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator {
avoid.addPool(pool.getId());
}
for (StoragePoolVO storage : storagePools) {
if (suitablePools.size() == returnUpTo) {
break;
}
StoragePool pol = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(storage.getId());
if (filter(avoid, pol, dskCh, plan)) {
suitablePools.add(pol);
for (StoragePoolVO storage : storagePools) {
if (suitablePools.size() == returnUpTo) {
break;
}
StoragePool pol = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(storage.getId());
if (filter(avoid, pol, dskCh, plan)) {
suitablePools.add(pol);
} else {
avoid.addPool(pol.getId());
}
}
return suitablePools;
}
}
return suitablePools;
}
}

View File

@ -29,25 +29,20 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreParameters;
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.DeleteStoragePoolCommand;
import com.cloud.agent.api.StoragePoolInfo;
import com.cloud.alert.AlertManager;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.StoragePoolStatus;
import com.cloud.storage.dao.StoragePoolHostDao;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
@ -70,7 +65,7 @@ public class PrimaryDataStoreHelper {
if (dataStoreVO != null) {
throw new CloudRuntimeException("duplicate uuid: " + params.getUuid());
}
dataStoreVO = new StoragePoolVO();
dataStoreVO.setStorageProviderName(params.getProviderName());
dataStoreVO.setHostAddress(params.getHost());
@ -84,7 +79,7 @@ public class PrimaryDataStoreHelper {
dataStoreVO.setClusterId(params.getClusterId());
dataStoreVO.setStatus(StoragePoolStatus.Initialized);
dataStoreVO.setUserInfo(params.getUserInfo());
Map<String, String> details = params.getDetails();
String tags = params.getTags();
if (tags != null) {
@ -98,19 +93,19 @@ public class PrimaryDataStoreHelper {
details.put(tag, "true");
}
}
dataStoreVO = dataStoreDao.persist(dataStoreVO, details);
return dataStoreMgr.getDataStore(dataStoreVO.getId(), DataStoreRole.Primary);
}
public DataStore attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
StoragePoolHostVO poolHost = storagePoolHostDao.findByPoolHost(store.getId(), scope.getScopeId());
if (poolHost == null) {
poolHost = new StoragePoolHostVO(store.getId(), scope.getScopeId(), existingInfo.getLocalPath());
storagePoolHostDao.persist(poolHost);
}
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
pool.setScope(scope.getScopeType());
pool.setAvailableBytes(existingInfo.getAvailableBytes());
@ -120,18 +115,18 @@ public class PrimaryDataStoreHelper {
this.storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, pool.getCapacityBytes() - pool.getAvailableBytes());
return dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
}
public DataStore attachCluster(DataStore store) {
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
storageMgr.createCapacityEntry(pool.getId());
pool.setScope(ScopeType.CLUSTER);
pool.setStatus(StoragePoolStatus.Up);
this.dataStoreDao.update(pool.getId(), pool);
return dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
}
public DataStore attachZone(DataStore store) {
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
pool.setScope(ScopeType.ZONE);
@ -139,21 +134,30 @@ public class PrimaryDataStoreHelper {
this.dataStoreDao.update(pool.getId(), pool);
return dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
}
public DataStore attachZone(DataStore store, HypervisorType hypervisor) {
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
pool.setScope(ScopeType.ZONE);
pool.setHypervisor(hypervisor);
pool.setStatus(StoragePoolStatus.Up);
this.dataStoreDao.update(pool.getId(), pool);
return dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
}
public boolean maintain(DataStore store) {
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
pool.setStatus(StoragePoolStatus.Maintenance);
this.dataStoreDao.update(pool.getId(), pool);
return true;
}
public boolean cancelMaintain(DataStore store) {
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
pool.setStatus(StoragePoolStatus.Up);
dataStoreDao.update(store.getId(), pool);
return true;
}
protected boolean deletePoolStats(Long poolId) {
CapacityVO capacity1 = _capacityDao.findByHostIdType(poolId,
@ -167,10 +171,10 @@ public class PrimaryDataStoreHelper {
if (capacity2 != null) {
_capacityDao.remove(capacity2.getId());
}
return true;
}
public boolean deletePrimaryDataStore(DataStore store) {
List<StoragePoolHostVO> hostPoolRecords = this.storagePoolHostDao
.listByPoolId(store.getId());

View File

@ -114,7 +114,7 @@ public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLif
}
@Override
public boolean attachZone(DataStore dataStore, ZoneScope scope) {
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
// TODO Auto-generated method stub
return false;
}

View File

@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# under the License.
#
# cloud-management This shell script takes care of starting and stopping Tomcat
# cloudstack-management This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
@ -56,13 +56,13 @@ stop() {
let count="${count}+1"
done
if [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ]; then
log_success_msg "Stopping cloud-management:"
log_success_msg "Stopping ${NAME}:"
else
log_failure_msg "Stopping cloud-management:"
log_failure_msg "Stopping ${NAME}:"
fi
else
echo "Cannot find PID file of Cloud-management"
log_failure_msg "Stopping cloud-management:"
echo "Cannot find PID file of ${NAME}"
log_failure_msg "Stopping ${NAME}:"
fi
}

View File

@ -165,11 +165,11 @@ echo VERSION=%{_maventag} >> build/replace.properties
echo PACKAGE=%{name} >> build/replace.properties
if [ "%{_ossnoss}" == "NONOSS" -o "%{_ossnoss}" == "nonoss" ] ; then
echo "Executing mvn packaging for NONOSS ..."
mvn -Pawsapi,systemvm -Dnonoss package
echo "Executing mvn packaging for NONOSS ..."
mvn -Pawsapi,systemvm -Dnonoss package clean install
else
echo "Executing mvn packaging for OSS ..."
mvn -Pawsapi package -Dsystemvm
echo "Executing mvn packaging for OSS ..."
mvn -Pawsapi package -Dsystemvm clean install
fi
%install
@ -216,6 +216,8 @@ ln -sf /var/log/%{name}/management ${RPM_BUILD_ROOT}%{_datadir}/%{name}-manageme
ln -sf /var/cache/%{name}/management/temp ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/temp
ln -sf /var/cache/%{name}/management/work ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/work
/bin/touch ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management/catalina.out
install -D client/target/utilities/bin/cloud-migrate-databases ${RPM_BUILD_ROOT}%{_bindir}/%{name}-migrate-databases
install -D client/target/utilities/bin/cloud-set-guest-password ${RPM_BUILD_ROOT}%{_bindir}/%{name}-set-guest-password
install -D client/target/utilities/bin/cloud-set-guest-sshkey ${RPM_BUILD_ROOT}%{_bindir}/%{name}-set-guest-sshkey
@ -519,6 +521,7 @@ fi
%dir %attr(0770,root,root) %{_localstatedir}/log/%{name}-management
%{_defaultdocdir}/%{name}-management-%{version}/LICENSE
%{_defaultdocdir}/%{name}-management-%{version}/NOTICE
%attr(0644,cloud,cloud) %{_localstatedir}/log/%{name}/management/catalina.out
%files agent
%attr(0755,root,root) %{_bindir}/%{name}-setup-agent

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
### BEGIN INIT INFO
# Provides: cloud-early-config
# Required-Start: mountkernfs $local_fs
@ -87,14 +87,13 @@ EOF
hypervisor() {
[ -d /proc/xen ] && mount -t xenfs none /proc/xen
[ -d /proc/xen ] && echo "xen-domU" && return 0
local try=$([ -x /usr/sbin/virt-what ] && virt-what | tail -1)
[ "$try" != "" ] && echo $try && return 0
vmware-checkvm &> /dev/null && echo "vmware" && return 0
[ -d /proc/xen ] && echo "xen-domU" && return 0
grep -q QEMU /proc/cpuinfo && echo "kvm" && return 0
grep -q QEMU /var/log/messages && echo "kvm" && return 0
@ -343,6 +342,22 @@ enable_svc() {
[ -f $cfg ] && sed -i "s/ENABLED=.*$/ENABLED=$enabled/" $cfg && return
}
enable_irqbalance() {
local enabled=$1
local proc=0
proc=$(cat /proc/cpuinfo | grep "processor" | wc -l)
if [ $proc -le 1 ] && [ $enabled -eq 1 ]
then
enabled=0
fi
log_it "Processors = $proc Enable service ${svc} = $enabled"
local cfg=/etc/default/irqbalance
[ -f $cfg ] && sed -i "s/ENABLED=.*$/ENABLED=$enabled/" $cfg && return
}
disable_hvc() {
[ ! -d /proc/xen ] && sed -i 's/^vc/#vc/' /etc/inittab && telinit q
[ -d /proc/xen ] && sed -i 's/^#vc/vc/' /etc/inittab && telinit q
@ -699,6 +714,7 @@ setup_router() {
enable_svc dnsmasq 1
enable_svc haproxy 1
enable_irqbalance 1
enable_svc cloud-passwd-srvr 1
enable_svc cloud 0
disable_rpfilter_domR
@ -778,6 +794,7 @@ EOF
enable_svc dnsmasq 1
enable_svc haproxy 1
enable_irqbalance 1
enable_svc cloud 0
disable_rpfilter
enable_fwding 1
@ -804,6 +821,7 @@ setup_dhcpsrvr() {
enable_svc dnsmasq 1
enable_svc haproxy 0
enable_irqbalance 0
enable_svc cloud-passwd-srvr 1
enable_svc cloud 0
enable_fwding 0
@ -856,6 +874,7 @@ setup_secstorage() {
disable_rpfilter
enable_fwding 0
enable_svc haproxy 0
enable_irqbalance 0
enable_svc dnsmasq 0
enable_svc cloud-passwd-srvr 0
enable_svc cloud 1
@ -880,6 +899,7 @@ setup_console_proxy() {
disable_rpfilter
enable_fwding 0
enable_svc haproxy 0
enable_irqbalance 0
enable_svc dnsmasq 0
enable_svc cloud-passwd-srvr 0
enable_svc cloud 1
@ -906,6 +926,7 @@ setup_elbvm() {
enable_fwding 0
enable_svc haproxy 0
enable_irqbalance 0
enable_svc dnsmasq 0
enable_svc cloud-passwd-srvr 0
enable_svc cloud 0
@ -928,6 +949,7 @@ setup_ilbvm() {
enable_fwding 0
enable_svc haproxy 1
enable_irqbalance 1
enable_svc dnsmasq 0
enable_svc cloud-passwd-srvr 0
enable_svc cloud 0

View File

@ -227,7 +227,8 @@ add_first_ip() {
if [ $if_keep_state -ne 1 -o $old_state -ne 0 ]
then
sudo ip link set $ethDev up
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
fi
add_routing $1
@ -273,7 +274,8 @@ add_an_ip () {
if [ $if_keep_state -ne 1 -o $old_state -ne 0 ]
then
sudo ip link set $ethDev up
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
fi
add_routing $1
return $?

View File

@ -22,7 +22,7 @@ getEthByIp (){
local ip=$1
for dev in `ls -1 /sys/class/net | grep eth`
do
sudo ip addr show dev $dev | grep $ip > /dev/null
sudo ip addr show dev $dev | grep $ip\/ > /dev/null
if [ $? -eq 0 ]
then
echo $dev

View File

@ -24,7 +24,7 @@ set -x
var="$1"
cert="/root/.ssh/id_rsa.cloud"
while [ -n "$var" ]
while [[ !( "$var" == "-" ) ]]
do
var1=$(echo $var | cut -f1 -d "-")
alias_count=$( echo $var1 | cut -f1 -d ":" )

View File

@ -0,0 +1,33 @@
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-explicit-dedication</artifactId>
<name>Apache CloudStack Plugin - Explicit Dedication Processor</name>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
</build>
</project>

View File

@ -0,0 +1,383 @@
// 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.affinity;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.log4j.Logger;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.DedicatedResourceVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.DedicatedResourceDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao;
import com.cloud.exception.AffinityConflictException;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
@Local(value = AffinityGroupProcessor.class)
public class ExplicitDedicationProcessor extends AffinityProcessorBase implements AffinityGroupProcessor {
private static final Logger s_logger = Logger.getLogger(ExplicitDedicationProcessor.class);
@Inject
protected UserVmDao _vmDao;
@Inject
protected VMInstanceDao _vmInstanceDao;
@Inject
protected DataCenterDao _dcDao;
@Inject
protected DedicatedResourceDao _dedicatedDao;
@Inject
protected HostPodDao _podDao;
@Inject
protected ClusterDao _clusterDao;
@Inject
protected HostDao _hostDao;
@Inject
protected DomainDao _domainDao;
@Inject
protected AffinityGroupDao _affinityGroupDao;
@Inject
protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
/**
* This method will process the affinity group of type 'Explicit Dedication' for a deployment of a VM that demands dedicated resources.
* For ExplicitDedicationProcessor we need to add dedicated resources into the IncludeList based on the level we have dedicated resources available.
* For eg. if admin dedicates a pod to a domain, then all the user in that domain can use the resources of that pod.
* We need to take care of the situation when dedicated resources further have resources dedicated to sub-domain/account.
* This IncludeList is then used to update the avoid list for a given data center.
*/
@Override
public void process(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan,
ExcludeList avoid) throws AffinityConflictException {
VirtualMachine vm = vmProfile.getVirtualMachine();
List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(), getType());
DataCenter dc = _dcDao.findById(vm.getDataCenterId());
long domainId = vm.getDomainId();
long accountId = vm.getAccountId();
for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
if (vmGroupMapping != null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Processing affinity group of type 'ExplicitDedication' for VM Id: " + vm.getId());
}
List<DedicatedResourceVO> dr = _dedicatedDao.listByAccountId(accountId);
List<DedicatedResourceVO> drOfDomain = searchInDomainResources(domainId);
List<DedicatedResourceVO> drOfParentDomain = searchInParentDomainResources(domainId);
List<DedicatedResourceVO> resourceList = new ArrayList<DedicatedResourceVO>();
resourceList.addAll(dr);
resourceList.addAll(drOfDomain);
resourceList.addAll(drOfParentDomain);
boolean canUse = false;
if (plan.getHostId() != null) {
HostVO host = _hostDao.findById(plan.getHostId());
ClusterVO clusterofHost = _clusterDao.findById(host.getClusterId());
HostPodVO podOfHost = _podDao.findById(host.getPodId());
DataCenterVO zoneOfHost = _dcDao.findById(host.getDataCenterId());
if (resourceList != null && resourceList.size() != 0) {
for(DedicatedResourceVO resource : resourceList){
if ((resource.getHostId() != null && resource.getHostId() == plan.getHostId()) ||
(resource.getClusterId() != null && resource.getClusterId() == clusterofHost.getId()) ||
(resource.getPodId() != null && resource.getPodId() == podOfHost.getId()) ||
(resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfHost.getId())){
canUse = true;
}
}
}
if (!canUse) {
throw new CloudRuntimeException("Cannot use this host " + host.getName() + " for explicit dedication");
}
} else if (plan.getClusterId() != null) {
ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
HostPodVO podOfCluster = _podDao.findById(cluster.getPodId());
DataCenterVO zoneOfCluster = _dcDao.findById(cluster.getDataCenterId());
List<HostVO> hostToUse = new ArrayList<HostVO>();
// check whether this cluster or its pod is dedicated
if (resourceList != null && resourceList.size() != 0) {
for(DedicatedResourceVO resource : resourceList){
if ((resource.getClusterId() != null && resource.getClusterId() == cluster.getId()) ||
(resource.getPodId() != null && resource.getPodId() == podOfCluster.getId()) ||
(resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfCluster.getId())){
canUse = true;
}
// check for all dedicated host; if it belongs to this cluster
if (!canUse){
if (resource.getHostId() != null) {
HostVO dHost = _hostDao.findById(resource.getHostId());
if (dHost.getClusterId() == cluster.getId()) {
hostToUse.add(dHost);
}
}
}
}
}
if (hostToUse.isEmpty() && !canUse) {
throw new CloudRuntimeException("Cannot use this cluster " + cluster.getName() + " for explicit dedication");
}
if (hostToUse != null && hostToUse.size() != 0) {
// add other non-dedicated hosts to avoid list
List<HostVO> hostList = _hostDao.findByClusterId(cluster.getId());
for (HostVO host : hostList){
if (!hostToUse.contains(host)) {
avoid.addHost(host.getId());
}
}
}
} else if (plan.getPodId() != null) {
HostPodVO pod = _podDao.findById(plan.getPodId());
DataCenterVO zoneOfPod = _dcDao.findById(pod.getDataCenterId());
List<ClusterVO> clustersToUse = new ArrayList<ClusterVO>();
List<HostVO> hostsToUse = new ArrayList<HostVO>();
// check whether this cluster or its pod is dedicated
if (resourceList != null && resourceList.size() != 0) {
for(DedicatedResourceVO resource : resourceList){
if ((resource.getPodId() != null && resource.getPodId() == pod.getId()) ||
(resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfPod.getId())){
canUse = true;
}
// check for all dedicated cluster/host; if it belongs to this pod
if (!canUse){
if (resource.getClusterId() != null) {
ClusterVO dCluster = _clusterDao.findById(resource.getClusterId());
if (dCluster.getPodId() == pod.getId()) {
clustersToUse.add(dCluster);
}
}
if (resource.getHostId() != null) {
HostVO dHost = _hostDao.findById(resource.getHostId());
if (dHost.getPodId() == pod.getId()) {
hostsToUse.add(dHost);
}
}
}
}
}
if (hostsToUse.isEmpty() && clustersToUse.isEmpty() && !canUse) {
throw new CloudRuntimeException("Cannot use this pod " + pod.getName() + " for explicit dedication");
}
if (clustersToUse != null && clustersToUse.size() != 0) {
// add other non-dedicated clusters to avoid list
List<ClusterVO> clusterList = _clusterDao.listByPodId(pod.getId());
for (ClusterVO cluster : clusterList){
if (!clustersToUse.contains(cluster)) {
avoid.addCluster(cluster.getId());
}
}
}
if (hostsToUse != null && hostsToUse.size() != 0) {
// add other non-dedicated hosts to avoid list
List<HostVO> hostList = _hostDao.findByPodId(pod.getId());
for (HostVO host : hostList){
if (!hostsToUse.contains(host)) {
avoid.addHost(host.getId());
}
}
}
} else {
//check all resources under this zone
if (dr != null && dr.size() != 0) {
avoid = updateAvoidList(dr, avoid, dc);
} else if(drOfDomain != null && drOfDomain.size() != 0){
avoid = updateAvoidList(drOfDomain, avoid, dc);
} else if(drOfParentDomain != null && drOfParentDomain.size() != 0){
avoid = updateAvoidList(drOfParentDomain, avoid, dc);
} else {
avoid.addDataCenter(dc.getId());
if (s_logger.isDebugEnabled()) {
s_logger.debug("No dedicated resources available for this domain or account");
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("ExplicitDedicationProcessor returns Avoid List as: Deploy avoids pods: " + avoid.getPodsToAvoid() + ", clusters: "
+ avoid.getClustersToAvoid() + ", hosts: " + avoid.getHostsToAvoid());
}
}
}
}
}
private ExcludeList updateAvoidList(List<DedicatedResourceVO> dedicatedResources, ExcludeList avoidList, DataCenter dc) {
ExcludeList includeList = new ExcludeList();
for (DedicatedResourceVO dr : dedicatedResources) {
if (dr.getHostId() != null){
includeList.addHost(dr.getHostId());
HostVO dedicatedHost = _hostDao.findById(dr.getHostId());
includeList.addCluster(dedicatedHost.getClusterId());
includeList.addPod(dedicatedHost.getPodId());
}
if (dr.getClusterId() != null) {
includeList.addCluster(dr.getClusterId());
//add all hosts inside this in includeList
List<HostVO> hostList = _hostDao.findByClusterId(dr.getClusterId());
for (HostVO host : hostList) {
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
if (dHost != null) {
avoidList.addHost(host.getId());
} else {
includeList.addHost(host.getId());
}
}
ClusterVO dedicatedCluster = _clusterDao.findById(dr.getClusterId());
includeList.addPod(dedicatedCluster.getPodId());
}
if (dr.getPodId() != null) {
includeList.addPod(dr.getPodId());
//add all cluster under this pod in includeList
List<ClusterVO> clusterList = _clusterDao.listByPodId(dr.getPodId());
for (ClusterVO cluster : clusterList) {
if (_dedicatedDao.findByClusterId(cluster.getId()) != null) {
avoidList.addCluster(cluster.getId());
} else {
includeList.addCluster(cluster.getId());
}
}
//add all hosts inside this pod in includeList
List<HostVO> hostList = _hostDao.findByPodId(dr.getPodId());
for (HostVO host : hostList) {
if (_dedicatedDao.findByHostId(host.getId()) != null) {
avoidList.addHost(host.getId());
} else {
includeList.addHost(host.getId());
}
}
}
if (dr.getDataCenterId() != null) {
includeList.addDataCenter(dr.getDataCenterId());
//add all Pod under this data center in includeList
List<HostPodVO> podList = _podDao.listByDataCenterId(dr.getDataCenterId());
for (HostPodVO pod : podList) {
if (_dedicatedDao.findByPodId(pod.getId()) != null) {
avoidList.addPod(pod.getId());
} else {
includeList.addPod(pod.getId());
}
}
List<ClusterVO> clusterList = _clusterDao.listClustersByDcId(dr.getDataCenterId());
for (ClusterVO cluster : clusterList) {
if (_dedicatedDao.findByClusterId(cluster.getId()) != null) {
avoidList.addCluster(cluster.getId());
} else {
includeList.addCluster(cluster.getId());
}
}
//add all hosts inside this in includeList
List<HostVO> hostList = _hostDao.listByDataCenterId(dr.getDataCenterId());
for (HostVO host : hostList) {
if (_dedicatedDao.findByHostId(host.getId()) != null) {
avoidList.addHost(host.getId());
} else {
includeList.addHost(host.getId());
}
}
}
}
//Update avoid list using includeList.
//add resources in avoid list which are not in include list.
List<HostPodVO> pods = _podDao.listByDataCenterId(dc.getId());
List<ClusterVO> clusters = _clusterDao.listClustersByDcId(dc.getId());
List<HostVO> hosts = _hostDao.listByDataCenterId(dc.getId());
Set<Long> podsInIncludeList = includeList.getPodsToAvoid();
Set<Long> clustersInIncludeList = includeList.getClustersToAvoid();
Set<Long> hostsInIncludeList = includeList.getHostsToAvoid();
for (HostPodVO pod : pods){
if (podsInIncludeList != null && !podsInIncludeList.contains(pod.getId())) {
avoidList.addPod(pod.getId());
}
}
for (ClusterVO cluster : clusters) {
if (clustersInIncludeList != null && !clustersInIncludeList.contains(cluster.getId())) {
avoidList.addCluster(cluster.getId());
}
}
for (HostVO host : hosts) {
if (hostsInIncludeList != null && !hostsInIncludeList.contains(host.getId())) {
avoidList.addHost(host.getId());
}
}
return avoidList;
}
private List<DedicatedResourceVO> searchInParentDomainResources(long domainId) {
List<Long> domainIds = getDomainParentIds(domainId);
List<DedicatedResourceVO> dr = new ArrayList<DedicatedResourceVO>();
for (Long id : domainIds) {
List<DedicatedResourceVO> resource = _dedicatedDao.listByDomainId(id);
if(resource != null) {
dr.addAll(resource);
}
}
return dr;
}
private List<DedicatedResourceVO> searchInDomainResources(long domainId) {
List<DedicatedResourceVO> dr = _dedicatedDao.listByDomainId(domainId);
return dr;
}
private List<Long> getDomainParentIds(long domainId) {
DomainVO domainRecord = _domainDao.findById(domainId);
List<Long> domainIds = new ArrayList<Long>();
domainIds.add(domainRecord.getId());
while (domainRecord.getParent() != null ){
domainRecord = _domainDao.findById(domainRecord.getParent());
domainIds.add(domainRecord.getId());
}
return domainIds;
}
}

View File

@ -0,0 +1,29 @@
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-dedicated-resources</artifactId>
<name>Apache CloudStack Plugin - Dedicated Resources</name>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>

View File

@ -0,0 +1,115 @@
// 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.api.commands;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ClusterResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.DedicateClusterResponse;
import org.apache.cloudstack.dedicated.DedicatedService;
import org.apache.log4j.Logger;
import com.cloud.dc.DedicatedResources;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
@APICommand(name = "dedicateCluster", description= "Dedicate an existing cluster", responseObject = DedicateClusterResponse.class )
public class DedicateClusterCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DedicateClusterCmd.class.getName());
private static final String s_name = "dedicateclusterresponse";
@Inject DedicatedService dedicatedService;
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType=ClusterResponse.class,
required=true, description="the ID of the Cluster")
private Long clusterId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
private Long domainId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
private String accountName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getClusterId() {
return clusterId;
}
public Long getDomainId() {
return domainId;
}
public String getAccountName() {
return accountName;
}
@Override
public String getEventType() {
return EventTypes.EVENT_DEDICATE_RESOURCE;
}
@Override
public String getEventDescription() {
return "dedicating a cluster";
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
List<? extends DedicatedResources> result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName());
ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
List<DedicateClusterResponse> clusterResponseList = new ArrayList<DedicateClusterResponse>();
if (result != null) {
for (DedicatedResources resource : result) {
DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
clusterResponseList.add(clusterResponse);
}
response.setResponses(clusterResponseList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster");
}
}
}

View File

@ -0,0 +1,118 @@
// 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.api.commands;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.DedicateHostResponse;
import org.apache.cloudstack.dedicated.DedicatedService;
import org.apache.log4j.Logger;
import com.cloud.dc.DedicatedResources;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
@APICommand(name = "dedicateHost", description = "Dedicates a host.", responseObject = DedicateHostResponse.class)
public class DedicateHostCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DedicateHostCmd.class.getName());
private static final String s_name = "dedicatehostresponse";
@Inject DedicatedService dedicatedService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType = HostResponse.class,
required=true, description="the ID of the host to update")
private Long hostId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
private Long domainId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
private String accountName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getHostId() {
return hostId;
}
public Long getDomainId() {
return domainId;
}
public String getAccountName() {
return accountName;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
List<? extends DedicatedResources> result = dedicatedService.dedicateHost(getHostId(), getDomainId(), getAccountName());
ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
List<DedicateHostResponse> hostResponseList = new ArrayList<DedicateHostResponse>();
if (result != null) {
for (DedicatedResources resource : result) {
DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
hostResponseList.add(hostResponse);
}
response.setResponses(hostResponseList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate host");
}
}
@Override
public String getEventType() {
return EventTypes.EVENT_DEDICATE_RESOURCE;
}
@Override
public String getEventDescription() {
return "dedicating a host";
}
}

View File

@ -0,0 +1,120 @@
// 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.api.commands;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.DedicatePodResponse;
import org.apache.cloudstack.dedicated.DedicatedService;
import org.apache.log4j.Logger;
import com.cloud.dc.DedicatedResources;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
@APICommand(name = "dedicatePod", description ="Dedicates a Pod.", responseObject = DedicatePodResponse.class)
public class DedicatePodCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DedicatePodCmd.class.getName());
private static final String s_name = "dedicatepodresponse";
@Inject public DedicatedService dedicatedService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
required=true, description="the ID of the Pod")
private Long podId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
private Long domainId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
private String accountName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getPodId() {
return podId;
}
public Long getDomainId() {
return domainId;
}
public String getAccountName() {
return accountName;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
List<? extends DedicatedResources> result = dedicatedService.dedicatePod(getPodId(), getDomainId(), getAccountName());
ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
List<DedicatePodResponse> podResponseList = new ArrayList<DedicatePodResponse>();
if (result != null) {
for (DedicatedResources resource : result) {
DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
podResponseList.add(podresponse);
}
response.setResponses(podResponseList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate pod");
}
}
@Override
public String getEventType() {
return EventTypes.EVENT_DEDICATE_RESOURCE;
}
@Override
public String getEventDescription() {
return "dedicating a pod";
}
}

View File

@ -0,0 +1,120 @@
// 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.api.commands;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.api.response.DedicateZoneResponse;
import org.apache.cloudstack.dedicated.DedicatedService;
import org.apache.log4j.Logger;
import com.cloud.dc.DedicatedResources;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
@APICommand(name = "dedicateZone", description ="Dedicates a zones.", responseObject = DedicateZoneResponse.class)
public class DedicateZoneCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DedicateZoneCmd.class.getName());
private static final String s_name = "dedicatezoneresponse";
@Inject public DedicatedService dedicatedService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
required=true, description="the ID of the zone")
private Long zoneId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
private Long domainId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
private String accountName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getZoneId() {
return zoneId;
}
public Long getDomainId() {
return domainId;
}
public String getAccountName() {
return accountName;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
List<? extends DedicatedResources> result = dedicatedService.dedicateZone(getZoneId(), getDomainId(), getAccountName());
ListResponse<DedicateZoneResponse> response = new ListResponse<DedicateZoneResponse>();
List<DedicateZoneResponse> zoneResponseList = new ArrayList<DedicateZoneResponse>();
if (result != null) {
for (DedicatedResources resource : result) {
DedicateZoneResponse zoneresponse = dedicatedService.createDedicateZoneResponse(resource);
zoneResponseList.add(zoneresponse);
}
response.setResponses(zoneResponseList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate zone");
}
}
@Override
public String getEventType() {
return EventTypes.EVENT_DEDICATE_RESOURCE;
}
@Override
public String getEventDescription() {
return "dedicating a zone";
}
}

View File

@ -0,0 +1,105 @@
// 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.api.commands;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ClusterResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.DedicateClusterResponse;
import org.apache.cloudstack.dedicated.DedicatedService;
import org.apache.log4j.Logger;
import com.cloud.dc.DedicatedResourceVO;
import com.cloud.dc.DedicatedResources;
import com.cloud.utils.Pair;
@APICommand(name = "listDedicatedClusters", description = "Lists dedicated clusters.", responseObject = DedicateClusterResponse.class)
public class ListDedicatedClustersCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDedicatedClustersCmd.class.getName());
private static final String s_name = "listdedicatedclustersresponse";
@Inject DedicatedService dedicatedService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType=ClusterResponse.class,
description="the ID of the cluster")
private Long clusterId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
description="the ID of the domain associated with the cluster")
private Long domainId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING,
description = "the name of the account associated with the cluster. Must be used with domainId.")
private String accountName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getClusterId() {
return clusterId;
}
public Long getDomainId(){
return domainId;
}
public String getAccountName(){
return accountName;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute(){
Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedClusters(this);
ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
List<DedicateClusterResponse> Responses = new ArrayList<DedicateClusterResponse>();
if (result != null) {
for (DedicatedResources resource : result.first()) {
DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
Responses.add(clusterResponse);
}
response.setResponses(Responses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated clusters");
}
}
}

View File

@ -0,0 +1,105 @@
// 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.api.commands;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.DedicateHostResponse;
import org.apache.cloudstack.dedicated.DedicatedService;
import org.apache.log4j.Logger;
import com.cloud.dc.DedicatedResourceVO;
import com.cloud.dc.DedicatedResources;
import com.cloud.utils.Pair;
@APICommand(name = "listDedicatedHosts", description = "Lists dedicated hosts.", responseObject = DedicateHostResponse.class)
public class ListDedicatedHostsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDedicatedHostsCmd.class.getName());
private static final String s_name = "listdedicatedhostsresponse";
@Inject DedicatedService dedicatedService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
description="the ID of the host")
private Long hostId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
description="the ID of the domain associated with the host")
private Long domainId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING,
description = "the name of the account associated with the host. Must be used with domainId.")
private String accountName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getHostId() {
return hostId;
}
public Long getDomainId(){
return domainId;
}
public String getAccountName(){
return accountName;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////l
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute(){
Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedHosts(this);
ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
List<DedicateHostResponse> Responses = new ArrayList<DedicateHostResponse>();
if (result != null) {
for (DedicatedResources resource : result.first()) {
DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
Responses.add(hostResponse);
}
response.setResponses(Responses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated hosts");
}
}
}

View File

@ -0,0 +1,105 @@
// 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.api.commands;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.DedicatePodResponse;
import org.apache.cloudstack.dedicated.DedicatedService;
import org.apache.log4j.Logger;
import com.cloud.dc.DedicatedResourceVO;
import com.cloud.dc.DedicatedResources;
import com.cloud.utils.Pair;
@APICommand(name = "listDedicatedPods", description = "Lists dedicated pods.", responseObject = DedicatePodResponse.class)
public class ListDedicatedPodsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDedicatedPodsCmd.class.getName());
private static final String s_name = "listdedicatedpodsresponse";
@Inject DedicatedService dedicatedService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
description="the ID of the pod")
private Long podId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
description="the ID of the domain associated with the pod")
private Long domainId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING,
description = "the name of the account associated with the pod. Must be used with domainId.")
private String accountName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getPodId() {
return podId;
}
public Long getDomainId(){
return domainId;
}
public String getAccountName(){
return accountName;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute(){
Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedPods(this);
ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
List<DedicatePodResponse> Responses = new ArrayList<DedicatePodResponse>();
if (result != null) {
for (DedicatedResources resource : result.first()) {
DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
Responses.add(podresponse);
}
response.setResponses(Responses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated pods");
}
}
}

Some files were not shown because too many files have changed in this diff Show More