mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' into rbac
Conflicts: api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java server/src/com/cloud/api/ApiServer.java server/src/com/cloud/api/query/QueryManagerImpl.java server/src/com/cloud/template/TemplateAdapterBase.java setup/db/db/schema-430to440.sql tools/apidoc/gen_toc.py
This commit is contained in:
commit
f84375442e
|
|
@ -114,3 +114,7 @@ domr.scripts.dir=scripts/network/domr/kvm
|
|||
# for examples:"Conroe" "Penryn", "Nehalem", "Westmere", "pentiumpro" and so
|
||||
# on,run virsh capabilities for more details.
|
||||
# guest.cpu.model=
|
||||
#
|
||||
# vm.memballoon.disable=true
|
||||
# Disable memory ballooning on vm guests for overcommit, by default overcommit
|
||||
# feature enables balloon and sets currentMemory to a minimum value.
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public class IpAddressTO {
|
|||
private Integer networkRate;
|
||||
private TrafficType trafficType;
|
||||
private String networkName;
|
||||
private Integer nicDevId;
|
||||
private boolean newNic;
|
||||
|
||||
public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String broadcastUri, String vlanGateway, String vlanNetmask,
|
||||
String vifMacAddress, Integer networkRate, boolean isOneToOneNat) {
|
||||
|
|
@ -116,4 +118,19 @@ public class IpAddressTO {
|
|||
return networkRate;
|
||||
}
|
||||
|
||||
public Integer getNicDevId() {
|
||||
return nicDevId;
|
||||
}
|
||||
|
||||
public void setNicDevId(Integer nicDevId) {
|
||||
this.nicDevId = nicDevId;
|
||||
}
|
||||
|
||||
public boolean isNewNic() {
|
||||
return newNic;
|
||||
}
|
||||
|
||||
public void setNewNic(boolean newNic) {
|
||||
this.newNic = newNic;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||
|
||||
public static final Provider VirtualRouter = new Provider("VirtualRouter", false);
|
||||
public static final Provider JuniperContrailRouter = new Provider("JuniperContrailRouter", false);
|
||||
public static final Provider JuniperContrailVpcRouter = new Provider("JuniperContrailVpcRouter", false);
|
||||
public static final Provider JuniperSRX = new Provider("JuniperSRX", true);
|
||||
public static final Provider PaloAlto = new Provider("PaloAlto", true);
|
||||
public static final Provider F5BigIp = new Provider("F5BigIp", true);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public interface NetworkService {
|
|||
|
||||
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
|
||||
|
||||
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel,
|
||||
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String isolationMethod, String xenLabel, String kvmLabel, String vmwareLabel,
|
||||
String simulatorLabel, String vlan, String hypervLabel);
|
||||
|
||||
PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,22 @@ public class Networks {
|
|||
return uri.getSchemeSpecificPart();
|
||||
}
|
||||
},
|
||||
Mido("mido", String.class), Pvlan("pvlan", String.class), Vxlan("vxlan", Long.class), UnDecided(null, null), OpenDaylight("opendaylight", String.class);
|
||||
Mido("mido", String.class), Pvlan("pvlan", String.class),
|
||||
Vxlan("vxlan", Long.class) {
|
||||
@Override
|
||||
public <T> URI toUri(T value) {
|
||||
try {
|
||||
if (value.toString().contains("://"))
|
||||
return new URI(value.toString());
|
||||
else
|
||||
return new URI("vxlan://" + value.toString());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new CloudRuntimeException(
|
||||
"Unable to convert to broadcast URI: " + value);
|
||||
}
|
||||
}
|
||||
},
|
||||
UnDecided(null, null), OpenDaylight("opendaylight", String.class);
|
||||
|
||||
private final String scheme;
|
||||
private final Class<?> type;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ public interface FirewallRule extends ControlledEntity, Identity, InternalIdenti
|
|||
Staged, // Rule been created but has never got through network rule conflict detection. Rules in this state can not be sent to network elements.
|
||||
Add, // Add means the rule has been created and has gone through network rule conflict detection.
|
||||
Active, // Rule has been sent to the network elements and reported to be active.
|
||||
Revoke // Revoke means this rule has been revoked. If this rule has been sent to the network elements, the rule will be deleted from database.
|
||||
Revoke, // Revoke means this rule has been revoked. If this rule has been sent to the network elements, the rule will be deleted from database.
|
||||
Deleting // rule has been revoked and is scheduled for deletion
|
||||
}
|
||||
|
||||
enum TrafficType {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ public interface StaticRoute extends ControlledEntity, Identity, InternalIdentit
|
|||
Staged, // route been created but has never got through network rule conflict detection. Routes in this state can not be sent to VPC virtual router.
|
||||
Add, // Add means the route has been created and has gone through network rule conflict detection.
|
||||
Active, // Route has been sent to the VPC router and reported to be active.
|
||||
Revoke // Revoke means this route has been revoked. If this route has been sent to the VPC router, the route will be deleted from database.
|
||||
Revoke, // Revoke means this route has been revoked. If this route has been sent to the VPC router, the route will be deleted from database.
|
||||
Deleting // rule has been revoked and is scheduled for deletion
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
|
|||
CustomerGateway(false, true),
|
||||
VpnConnection(false, true),
|
||||
User(true, true),
|
||||
DiskOffering(false, true);
|
||||
DiskOffering(false, true),
|
||||
AutoScaleVmProfile(false, true),
|
||||
AutoScaleVmGroup(false, true);
|
||||
|
||||
ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
|
||||
this.resourceTagsSupport = resourceTagsSupport;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
|||
s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.ExpungingRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged);
|
||||
s_fsm.addTransition(Expunging, Event.OperationFailed, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.OperationFailed, Destroy);
|
||||
s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);
|
||||
s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready);
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ public class ApiConstants {
|
|||
public static final String CAPACITY_IOPS = "capacityiops";
|
||||
public static final String NETWORK_SPEED = "networkspeed";
|
||||
public static final String BROADCAST_DOMAIN_RANGE = "broadcastdomainrange";
|
||||
public static final String ISOLATION_METHOD = "isolationmethod";
|
||||
public static final String ISOLATION_METHODS = "isolationmethods";
|
||||
public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid";
|
||||
public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class GenerateAlertCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name of the alert", required = true)
|
||||
private String name;
|
||||
|
||||
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Alert description", required = true)
|
||||
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Alert description", required = true, length = 999)
|
||||
private String description;
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "Zone id for which alert is generated")
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name = ApiConstants.VLAN, type = CommandType.STRING, description = "The VLAN id to be used for Management traffic by VMware host")
|
||||
private String vlan;
|
||||
|
||||
@Parameter(name=ApiConstants.ISOLATION_METHOD, type=CommandType.STRING, description="Used if physical network has multiple isolation types and traffic type is public."
|
||||
+ " Choose which isolation method. Valid options currently 'vlan' or 'vxlan', defaults to 'vlan'.")
|
||||
private String isolationMethod;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -118,6 +122,14 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
|
|||
return vlan;
|
||||
}
|
||||
|
||||
public String getIsolationMethod() {
|
||||
if (isolationMethod != null && !isolationMethod.isEmpty()) {
|
||||
return isolationMethod;
|
||||
} else {
|
||||
return "vlan";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -148,7 +160,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
|
|||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
PhysicalNetworkTrafficType result =
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getXenLabel(), getKvmLabel(), getVmwareLabel(),
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getIsolationMethod(), getXenLabel(), getKvmLabel(), getVmwareLabel(),
|
||||
getSimulatorLabel(), getVlan(), getHypervLabel());
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@ package org.apache.cloudstack.api.command.user.autoscale;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.AclEntityType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -28,7 +25,10 @@ import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.as.AutoScaleVmProfile;
|
||||
|
||||
|
|
@ -48,9 +48,15 @@ public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourc
|
|||
@Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "the templateid of the autoscale vm profile")
|
||||
private Long templateId;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, description = "list profiles by service offering id")
|
||||
private Long serviceOffId;
|
||||
|
||||
@Parameter(name = ApiConstants.OTHER_DEPLOY_PARAMS, type = CommandType.STRING, description = "the otherdeployparameters of the autoscale vm profile")
|
||||
private String otherDeployParams;
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, since = "4.4", description = "availability zone for the auto deployed virtual machine")
|
||||
private Long zoneId;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
@ -67,10 +73,18 @@ public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourc
|
|||
return otherDeployParams;
|
||||
}
|
||||
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOffId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
// 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
|
||||
|
|
@ -42,7 +43,7 @@ public class AssignCertToLoadBalancerCmd extends BaseAsyncCmd {
|
|||
|
||||
public static final Logger s_logger = Logger.getLogger(AssignCertToLoadBalancerCmd.class.getName());
|
||||
|
||||
private static final String s_name = "assignCertToLoadBalancer";
|
||||
private static final String s_name = "assigncerttoloadbalancerresponse";
|
||||
|
||||
@Parameter(name = ApiConstants.LBID,
|
||||
type = CommandType.UUID,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class RemoveCertFromLoadBalancerCmd extends BaseAsyncCmd {
|
|||
|
||||
public static final Logger s_logger = Logger.getLogger(RemoveCertFromLoadBalancerCmd.class.getName());
|
||||
|
||||
private static final String s_name = "removeCertFromLoadBalancer";
|
||||
private static final String s_name = "removecertfromloadbalancerresponse";
|
||||
|
||||
@Parameter(name = ApiConstants.LBID,
|
||||
type = CommandType.UUID,
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd {
|
|||
try {
|
||||
result = _networkService.allocateSecondaryGuestIP(getNicId(), getIpaddress());
|
||||
} catch (InsufficientAddressCapacityException e) {
|
||||
throw new InvalidParameterValueException("Allocating guest ip for nic failed");
|
||||
throw new InvalidParameterValueException("Allocating guest ip for nic failed : " + e.getMessage());
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.volume;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.AclEntityType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
|
|
@ -31,7 +30,6 @@ import org.apache.cloudstack.api.ServerApiException;
|
|||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
|
|
@ -52,7 +50,7 @@ public class ResizeVolumeCmd extends BaseAsyncCmd {
|
|||
/////////////////////////////////////////////////////
|
||||
|
||||
@ACL(accessType = AccessType.OperateEntry)
|
||||
@Parameter(name=ApiConstants.ID, entityType=VolumeResponse.class, type=CommandType.UUID, description="the ID of the disk volume")
|
||||
@Parameter(name = ApiConstants.ID, entityType = VolumeResponse.class, required = true, type = CommandType.UUID, description = "the ID of the disk volume")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.SIZE, type = CommandType.LONG, required = false, description = "New volume size in G")
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.cloudstack.framework.config.Configurable;
|
|||
@Local(value = {ApiServiceConfiguration.class})
|
||||
public class ApiServiceConfiguration implements Configurable {
|
||||
public static final ConfigKey<String> ManagementHostIPAdr = new ConfigKey<String>("Advanced", String.class, "host", "localhost", "The ip address of management server", true);
|
||||
public static final ConfigKey<String> ApiServletPath = new ConfigKey<String>("Advanced", String.class, "api.servlet.endpoint", "http://localhost:8080/client/api?",
|
||||
public static final ConfigKey<String> ApiServletPath = new ConfigKey<String>("Advanced", String.class, "endpointe.url", "http://localhost:8080/client/api",
|
||||
"API end point. Can be used by CS components/services deployed remotely, for sending CS API requests", true);
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
<artifactId>opensaml1</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
|
@ -162,7 +162,7 @@
|
|||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
<artifactId>opensaml1</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
|
@ -178,7 +178,7 @@
|
|||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
<artifactId>opensaml1</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
|
@ -194,7 +194,7 @@
|
|||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
<artifactId>opensaml1</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
|
@ -210,7 +210,7 @@
|
|||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.opensaml</groupId>
|
||||
<artifactId>opensaml</artifactId>
|
||||
<artifactId>opensaml1</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
|
|
|||
|
|
@ -354,13 +354,19 @@ public class DimeDelimitedInputStream extends FilterInputStream {
|
|||
}
|
||||
|
||||
//OPTIONS_LENGTH
|
||||
int optionsLength = ((((int)header[2]) << 8) & 0xff00) | ((int)header[3]);
|
||||
int oneButLastByte = (((int)header[2]) << 8) & 0xff00;
|
||||
int lastByte = (int)header[3] & 0xff;
|
||||
int optionsLength = oneButLastByte | lastByte;
|
||||
|
||||
//ID_LENGTH
|
||||
int idLength = ((((int)header[4]) << 8) & 0xff00) | ((int)header[5]);
|
||||
oneButLastByte = ((((int)header[4]) << 8) & 0xff00);
|
||||
lastByte = ((int)header[5]) & 0xff;
|
||||
int idLength = oneButLastByte | lastByte;
|
||||
|
||||
//TYPE_LENGTH
|
||||
int typeLength = ((((int)header[6]) << 8) & 0xff00) | ((int)header[7]);
|
||||
oneButLastByte = ((((int)header[6]) << 8) & 0xff00);
|
||||
lastByte = ((int)header[7]) & 0xff;
|
||||
int typeLength = oneButLastByte | lastByte;
|
||||
|
||||
//DATA_LENGTH
|
||||
recordLength =
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ public class SObjectItemVO {
|
|||
}
|
||||
|
||||
if (theObject.getId() != null) {
|
||||
if (!theObject.getId().equals(((SObjectItemVO)other).getTheObject()))
|
||||
if (!theObject.getId().equals(((SObjectItemVO)other).getTheObject().getId()))
|
||||
return false;
|
||||
} else {
|
||||
if (((SObjectItemVO)other).getTheObject() != null)
|
||||
|
|
|
|||
|
|
@ -1977,6 +1977,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
|||
DescribeAddressesResponseItemType item = new DescribeAddressesResponseItemType();
|
||||
item.setPublicIp(addr.getIpAddress());
|
||||
item.setInstanceId(addr.getAssociatedInstanceId());
|
||||
item.setDomain("standard"); // Since VPC is not supported by AWSAPI default to 'standard'
|
||||
items.add(item);
|
||||
}
|
||||
DescribeAddressesResponseInfoType descAddrRespInfoType = new DescribeAddressesResponseInfoType();
|
||||
|
|
|
|||
|
|
@ -593,6 +593,11 @@ addBigSwitchVnsDevice=1
|
|||
deleteBigSwitchVnsDevice=1
|
||||
listBigSwitchVnsDevices=1
|
||||
|
||||
#### stratosphere ssp commands
|
||||
|
||||
addStratosphereSsp=1
|
||||
deleteStratoshereSsp=1
|
||||
|
||||
#### host simulator commands
|
||||
|
||||
configureSimulator=1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
// 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.agent.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GetVmConfigAnswer extends Answer {
|
||||
|
||||
String vmName;
|
||||
List<NicDetails> nics;
|
||||
|
||||
protected GetVmConfigAnswer() {
|
||||
}
|
||||
|
||||
public GetVmConfigAnswer(String vmName, List<NicDetails> nics) {
|
||||
this.vmName = vmName;
|
||||
this.nics = nics;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public List<NicDetails> getNics() {
|
||||
return nics;
|
||||
}
|
||||
|
||||
public class NicDetails {
|
||||
String macAddress;
|
||||
int vlanid;
|
||||
|
||||
public NicDetails() {
|
||||
}
|
||||
|
||||
public NicDetails(String macAddress, int vlanid) {
|
||||
this.macAddress = macAddress;
|
||||
this.vlanid = vlanid;
|
||||
}
|
||||
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public int getVlanid() {
|
||||
return vlanid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.agent.api;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
|
||||
public class GetVmConfigCommand extends Command {
|
||||
String vmName;
|
||||
List<NicTO> nics;
|
||||
protected GetVmConfigCommand() {
|
||||
}
|
||||
|
||||
public GetVmConfigCommand(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public void setNics(List<NicTO> nics){
|
||||
this.nics = nics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// 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.agent.api;
|
||||
|
||||
public class ModifyVmNicConfigAnswer extends Answer {
|
||||
String vmName;
|
||||
protected ModifyVmNicConfigAnswer() {
|
||||
}
|
||||
|
||||
public ModifyVmNicConfigAnswer(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// 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.agent.api;
|
||||
|
||||
|
||||
public class ModifyVmNicConfigCommand extends Command {
|
||||
String vmName;
|
||||
int vlan;
|
||||
String macAddress;
|
||||
protected ModifyVmNicConfigCommand() {
|
||||
}
|
||||
|
||||
public ModifyVmNicConfigCommand(String vmName, int vlan, String macAddress) {
|
||||
this.vmName = vmName;
|
||||
this.vlan = vlan;
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,10 +16,10 @@
|
|||
// under the License.
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class NetworkElementCommand extends Command {
|
||||
HashMap<String, String> accessDetails = new HashMap<String, String>(0);
|
||||
|
||||
|
|
@ -35,6 +35,8 @@ public abstract class NetworkElementCommand extends Command {
|
|||
public static final String VPC_PRIVATE_GATEWAY = "vpc.gateway.private";
|
||||
public static final String FIREWALL_EGRESS_DEFAULT = "firewall.egress.default";
|
||||
|
||||
private String routerAccessIp;
|
||||
|
||||
protected NetworkElementCommand() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -52,4 +54,11 @@ public abstract class NetworkElementCommand extends Command {
|
|||
return false;
|
||||
}
|
||||
|
||||
public String getRouterAccessIp() {
|
||||
return routerAccessIp;
|
||||
}
|
||||
|
||||
public void setRouterAccessIp(String routerAccessIp) {
|
||||
this.routerAccessIp = routerAccessIp;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.agent.resource.virtualnetwork;
|
||||
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.utils.ExecutionResult;
|
||||
|
||||
public interface VirtualRouterDeployer {
|
||||
ExecutionResult executeInVR(String routerIp, String script, String args);
|
||||
ExecutionResult createFileInVR(String routerIp, String path, String filename, String content);
|
||||
ExecutionResult prepareCommand(NetworkElementCommand cmd);
|
||||
ExecutionResult cleanupCommand(NetworkElementCommand cmd);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,7 @@ Source: cloudstack
|
|||
Section: libs
|
||||
Priority: extra
|
||||
Maintainer: Wido den Hollander <wido@widodh.nl>
|
||||
Build-Depends: debhelper (>= 7), openjdk-6-jdk | openjdk-7-jdk, tomcat6, genisoimage,
|
||||
Build-Depends: debhelper (>= 7), openjdk-7-jdk, tomcat6, genisoimage,
|
||||
python-mysqldb, maven3 | maven (>= 3), python (>= 2.6.6-3~)
|
||||
Standards-Version: 3.8.1
|
||||
Homepage: http://www.cloudstack.org/
|
||||
|
|
@ -22,7 +22,7 @@ Description: CloudStack server library
|
|||
|
||||
Package: cloudstack-agent
|
||||
Architecture: all
|
||||
Depends: openjdk-6-jre | openjdk-7-jre, cloudstack-common (= ${source:Version}), lsb-base (>= 3.2), libcommons-daemon-java, openssh-client, libvirt0, sysvinit-utils, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, perl-base, perl-modules, ebtables, vlan, wget, jsvc, ipset, python-libvirt, ethtool, iptables
|
||||
Depends: openjdk-7-jre, cloudstack-common (= ${source:Version}), lsb-base (>= 3.2), libcommons-daemon-java, openssh-client, libvirt0, sysvinit-utils, qemu-kvm, libvirt-bin, uuid-runtime, rsync, grep, iproute, perl-base, perl-modules, ebtables, vlan, wget, jsvc, ipset, python-libvirt, ethtool, iptables
|
||||
Conflicts: cloud-agent, cloud-agent-libs, cloud-agent-deps, cloud-agent-scripts
|
||||
Description: CloudStack agent
|
||||
The CloudStack agent is in charge of managing shared computing resources in
|
||||
|
|
@ -31,7 +31,7 @@ Description: CloudStack agent
|
|||
|
||||
Package: cloudstack-usage
|
||||
Architecture: all
|
||||
Depends: openjdk-6-jre | openjdk-7-jre, cloudstack-common (= ${source:Version}), jsvc
|
||||
Depends: openjdk-7-jre, cloudstack-common (= ${source:Version}), jsvc
|
||||
Description: CloudStack usage monitor
|
||||
The CloudStack usage monitor provides usage accounting across the entire cloud for
|
||||
cloud operators to charge based on usage parameters.
|
||||
|
|
|
|||
|
|
@ -1525,6 +1525,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
|
||||
protected boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId, String reservationId) throws NoTransitionException {
|
||||
// if there are active vm snapshots task, state change is not allowed
|
||||
if (_vmSnapshotMgr.hasActiveVMSnapshotTasks(vm.getId())) {
|
||||
s_logger.error("State transit with event: " + e + " failed due to: " + vm.getInstanceName() + " has active VM snapshots tasks");
|
||||
return false;
|
||||
}
|
||||
vm.setReservationId(reservationId);
|
||||
return _stateMachine.transitTo(vm, e, new Pair<Long, Long>(vm.getHostId(), hostId), _vmDao);
|
||||
}
|
||||
|
|
@ -4317,7 +4322,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4368,7 +4373,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4421,7 +4426,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4470,7 +4475,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4525,7 +4530,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4578,7 +4583,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4630,7 +4635,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4679,7 +4684,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4728,7 +4733,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4777,7 +4782,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4828,7 +4833,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
return new Object[] {workJob, new Long(workJob.getId())};
|
||||
return new Object[] {workJob, workJob.getId()};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4918,7 +4923,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
NicProfile nic = orchestrateAddVmToNetwork(vm, network,
|
||||
work.getRequestedNicProfile());
|
||||
|
||||
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(new Long(nic.getId())));
|
||||
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(nic.getId()));
|
||||
}
|
||||
|
||||
private Pair<JobInfo.Status, String> orchestrateRemoveNicFromVm(VmWorkRemoveNicFromVm work) throws Exception {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,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">
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
<entry key="cache.size" value="50" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl">
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
<entry key="cache.size" value="50" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl">
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
<entry key="cache.size" value="50" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl">
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
<entry key="cache.size" value="30" />
|
||||
<entry key="cache.time.to.live" value="3600" />
|
||||
</map>
|
||||
</property>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl">
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
<entry key="cache.size" value="5000" />
|
||||
<entry key="cache.time.to.live" value="300" />
|
||||
</map>
|
||||
</property>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl">
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
<entry key="cache.size" value="100" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl">
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
<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">
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<!--
|
||||
DAOs with default configuration
|
||||
-->
|
||||
|
|
@ -172,12 +172,12 @@
|
|||
<bean id="hostTransferMapDaoImpl" class="com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl" />
|
||||
<bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
|
||||
<bean id="imageStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDaoImpl" />
|
||||
<bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" />
|
||||
<bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />
|
||||
<bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" />
|
||||
<bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" />
|
||||
<bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" />
|
||||
<bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />
|
||||
<bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" />
|
||||
<bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" />
|
||||
<bean id="templateJoinDaoImpl" class="com.cloud.api.query.dao.TemplateJoinDaoImpl" />
|
||||
<bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />
|
||||
<bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />
|
||||
<bean id="inlineLoadBalancerNicMapDaoImpl" class="com.cloud.network.dao.InlineLoadBalancerNicMapDaoImpl" />
|
||||
<bean id="instanceGroupDaoImpl" class="com.cloud.vm.dao.InstanceGroupDaoImpl" />
|
||||
<bean id="instanceGroupJoinDaoImpl" class="com.cloud.api.query.dao.InstanceGroupJoinDaoImpl" />
|
||||
|
|
@ -331,6 +331,8 @@
|
|||
<bean id="Site2SiteVpnConnectionDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.Site2SiteVpnConnectionDetailsDaoImpl" />
|
||||
<bean id="DiskOfferingDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDaoImpl" />
|
||||
<bean id="UserDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.UserDetailsDaoImpl" />
|
||||
<bean id="AutoScaleVmProfileDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.AutoScaleVmProfileDetailsDaoImpl" />
|
||||
<bean id="AutoScaleVmGroupDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.AutoScaleVmGroupDetailsDaoImpl" />
|
||||
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -147,7 +148,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
sb.and("format", sb.entity().getFormat(), SearchCriteria.Op.EQ);
|
||||
sb.and("type", sb.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||
sb.and("bootable", sb.entity().isBootable(), SearchCriteria.Op.EQ);
|
||||
sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
|
||||
SearchBuilder<ResourceTagVO> tagSearch = _tagsDao.createSearchBuilder();
|
||||
for (int count = 0; count < tags.size(); count++) {
|
||||
|
|
@ -170,7 +171,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
}
|
||||
|
||||
if (!listRemoved) {
|
||||
sc.setParameters("removed", (Object)null);
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active);
|
||||
}
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
|
|
@ -197,7 +198,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
sc.setParameters("type", TemplateType.USER.toString());
|
||||
|
||||
if (!listRemoved) {
|
||||
sc.setParameters("removed", (Object)null);
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active);
|
||||
}
|
||||
|
||||
return listBy(sc);
|
||||
|
|
@ -217,7 +218,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
|
||||
String sql =
|
||||
"select * from template_host_ref as thr INNER JOIN vm_template as t ON t.id=thr.template_id "
|
||||
+ "where thr.host_id=? and t.public=0 and t.featured=0 and t.type='USER' and t.removed is NULL";
|
||||
+ "where thr.host_id=? and t.public=0 and t.featured=0 and t.type='USER' and t.state='Active'";
|
||||
|
||||
List<Long> l = new ArrayList<Long>();
|
||||
|
||||
|
|
@ -265,6 +266,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
public List<VMTemplateVO> listByAccountId(long accountId) {
|
||||
SearchCriteria<VMTemplateVO> sc = AccountIdSearch.create();
|
||||
sc.setParameters("accountId", accountId);
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
|
@ -312,12 +314,12 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
PublicIsoSearch.and("format", PublicIsoSearch.entity().getFormat(), SearchCriteria.Op.EQ);
|
||||
PublicIsoSearch.and("type", PublicIsoSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||
PublicIsoSearch.and("bootable", PublicIsoSearch.entity().isBootable(), SearchCriteria.Op.EQ);
|
||||
PublicIsoSearch.and("removed", PublicIsoSearch.entity().getRemoved(), SearchCriteria.Op.EQ);
|
||||
PublicIsoSearch.and("state", PublicIsoSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
|
||||
UserIsoSearch = createSearchBuilder();
|
||||
UserIsoSearch.and("format", UserIsoSearch.entity().getFormat(), SearchCriteria.Op.EQ);
|
||||
UserIsoSearch.and("type", UserIsoSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||
UserIsoSearch.and("removed", UserIsoSearch.entity().getRemoved(), SearchCriteria.Op.EQ);
|
||||
UserIsoSearch.and("state", UserIsoSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
|
||||
tmpltTypeHyperSearch = createSearchBuilder();
|
||||
tmpltTypeHyperSearch.and("templateType", tmpltTypeHyperSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -332,7 +334,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
tmpltTypeHyperSearch.done();
|
||||
|
||||
readySystemTemplateSearch = createSearchBuilder();
|
||||
readySystemTemplateSearch.and("removed", readySystemTemplateSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
readySystemTemplateSearch.and("state", readySystemTemplateSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
readySystemTemplateSearch.and("templateType", readySystemTemplateSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||
SearchBuilder<TemplateDataStoreVO> templateDownloadSearch = _templateDataStoreDao.createSearchBuilder();
|
||||
templateDownloadSearch.and("downloadState", templateDownloadSearch.entity().getDownloadState(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -355,13 +357,13 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
tmpltTypeHyperSearch2.and("templateName", tmpltTypeHyperSearch2.entity().getName(), SearchCriteria.Op.EQ);
|
||||
|
||||
tmpltTypeSearch = createSearchBuilder();
|
||||
tmpltTypeSearch.and("removed", tmpltTypeSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
tmpltTypeSearch.and("state", tmpltTypeSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
tmpltTypeSearch.and("templateType", tmpltTypeSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||
|
||||
AccountIdSearch = createSearchBuilder();
|
||||
AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountIdSearch.and("publicTemplate", AccountIdSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
|
||||
AccountIdSearch.and("removed", AccountIdSearch.entity().getRemoved(), SearchCriteria.Op.NULL); // only list not removed templates for this account
|
||||
AccountIdSearch.and("state", AccountIdSearch.entity().getState(), SearchCriteria.Op.EQ); // only list not removed templates for this account
|
||||
AccountIdSearch.done();
|
||||
|
||||
SearchBuilder<VMTemplateZoneVO> tmpltZoneSearch = _templateZoneDao.createSearchBuilder();
|
||||
|
|
@ -369,7 +371,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
tmpltZoneSearch.and("zoneId", tmpltZoneSearch.entity().getZoneId(), SearchCriteria.Op.EQ);
|
||||
|
||||
TmpltsInZoneSearch = createSearchBuilder();
|
||||
TmpltsInZoneSearch.and("removed", TmpltsInZoneSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
TmpltsInZoneSearch.and("state", TmpltsInZoneSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
TmpltsInZoneSearch.and().op("avoidtype", TmpltsInZoneSearch.entity().getTemplateType(), SearchCriteria.Op.NEQ);
|
||||
TmpltsInZoneSearch.or("templateType", TmpltsInZoneSearch.entity().getTemplateType(), SearchCriteria.Op.NULL);
|
||||
TmpltsInZoneSearch.cp();
|
||||
|
|
@ -378,12 +380,12 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
TmpltsInZoneSearch.done();
|
||||
|
||||
ActiveTmpltSearch = createSearchBuilder();
|
||||
ActiveTmpltSearch.and("removed", ActiveTmpltSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
ActiveTmpltSearch.and("state", ActiveTmpltSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
|
||||
CountTemplatesByAccount = createSearchBuilder(Long.class);
|
||||
CountTemplatesByAccount.select(null, Func.COUNT, null);
|
||||
CountTemplatesByAccount.and("account", CountTemplatesByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
CountTemplatesByAccount.and("state", CountTemplatesByAccount.entity().getState(), SearchCriteria.Op.EQ);
|
||||
CountTemplatesByAccount.done();
|
||||
|
||||
// updateStateSearch = this.createSearchBuilder();
|
||||
|
|
@ -774,6 +776,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
public List<VMTemplateVO> listAllInZone(long dataCenterId) {
|
||||
SearchCriteria<VMTemplateVO> sc = TmpltsInZoneSearch.create();
|
||||
sc.setParameters("avoidtype", TemplateType.PERHOST.toString());
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active);
|
||||
sc.setJoinParameters("tmpltzone", "zoneId", dataCenterId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
|
@ -781,6 +784,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
@Override
|
||||
public List<VMTemplateVO> listAllActive() {
|
||||
SearchCriteria<VMTemplateVO> sc = ActiveTmpltSearch.create();
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active.toString());
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
|
@ -788,6 +792,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
public List<VMTemplateVO> listDefaultBuiltinTemplates() {
|
||||
SearchCriteria<VMTemplateVO> sc = tmpltTypeSearch.create();
|
||||
sc.setParameters("templateType", Storage.TemplateType.BUILTIN);
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
|
@ -813,6 +818,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
public VMTemplateVO findSystemVMReadyTemplate(long zoneId, HypervisorType hypervisorType) {
|
||||
SearchCriteria<VMTemplateVO> sc = readySystemTemplateSearch.create();
|
||||
sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active);
|
||||
sc.setJoinParameters("tmplHyper", "type", Host.Type.Routing);
|
||||
sc.setJoinParameters("tmplHyper", "zoneId", zoneId);
|
||||
sc.setJoinParameters("vmTemplateJoinTemplateStoreRef", "downloadState", VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
|
||||
|
|
@ -873,6 +879,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
public Long countTemplatesForAccount(long accountId) {
|
||||
SearchCriteria<Long> sc = CountTemplatesByAccount.create();
|
||||
sc.setParameters("account", accountId);
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active.toString());
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,43 +172,17 @@ public class Upgrade430to440 implements DbUpgrade {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (networkRs != null) {
|
||||
try {
|
||||
networkRs.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pstmtNw != null) {
|
||||
try {
|
||||
networkRs = null;
|
||||
pstmtNw.close();
|
||||
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
pstmtNw = null;
|
||||
}
|
||||
} //if
|
||||
|
||||
|
||||
if (vmRs != null) {
|
||||
try {
|
||||
pstmtVm.close();
|
||||
pstmtVm = null;
|
||||
vmRs.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (networkRs != null) {
|
||||
try {
|
||||
networkRs.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vmRs = null;
|
||||
} // while
|
||||
|
||||
|
||||
|
|
@ -225,22 +199,6 @@ public class Upgrade430to440 implements DbUpgrade {
|
|||
}
|
||||
|
||||
|
||||
if (pstmtVm != null) {
|
||||
try {
|
||||
pstmtVm.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pstmtNw != null) {
|
||||
try {
|
||||
pstmtNw.close();
|
||||
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (rs1 != null) {
|
||||
try {
|
||||
rs1.close();
|
||||
|
|
@ -248,6 +206,15 @@ public class Upgrade430to440 implements DbUpgrade {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (pstmtVm != null) {
|
||||
try {
|
||||
pstmtVm.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (vmRs != null) {
|
||||
try {
|
||||
vmRs.close();
|
||||
|
|
@ -255,6 +222,17 @@ public class Upgrade430to440 implements DbUpgrade {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (pstmtNw != null) {
|
||||
try {
|
||||
pstmtNw.close();
|
||||
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (networkRs != null) {
|
||||
try {
|
||||
networkRs.close();
|
||||
|
|
|
|||
|
|
@ -51,4 +51,6 @@ public interface NicSecondaryIpDao extends GenericDao<NicSecondaryIpVO, Long> {
|
|||
NicSecondaryIpVO findByIp4AddressAndNetworkIdAndInstanceId(long networkId, Long vmId, String vmIp);
|
||||
|
||||
List<String> getSecondaryIpAddressesForNic(long nicId);
|
||||
|
||||
Long countByNicId(long nicId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
|||
public class NicSecondaryIpDaoImpl extends GenericDaoBase<NicSecondaryIpVO, Long> implements NicSecondaryIpDao {
|
||||
private final SearchBuilder<NicSecondaryIpVO> AllFieldsSearch;
|
||||
private final GenericSearchBuilder<NicSecondaryIpVO, String> IpSearch;
|
||||
protected GenericSearchBuilder<NicSecondaryIpVO, Long> CountByNicId;
|
||||
|
||||
protected NicSecondaryIpDaoImpl() {
|
||||
super();
|
||||
|
|
@ -50,6 +51,11 @@ public class NicSecondaryIpDaoImpl extends GenericDaoBase<NicSecondaryIpVO, Long
|
|||
IpSearch.and("network", IpSearch.entity().getNetworkId(), Op.EQ);
|
||||
IpSearch.and("address", IpSearch.entity().getIp4Address(), Op.NNULL);
|
||||
IpSearch.done();
|
||||
|
||||
CountByNicId = createSearchBuilder(Long.class);
|
||||
CountByNicId.select(null, Func.COUNT, null);
|
||||
CountByNicId.and("nic", CountByNicId.entity().getNicId(), SearchCriteria.Op.EQ);
|
||||
CountByNicId.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -135,4 +141,11 @@ public class NicSecondaryIpDaoImpl extends GenericDaoBase<NicSecondaryIpVO, Long
|
|||
sc.setParameters("address", vmIp);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countByNicId(long nicId) {
|
||||
SearchCriteria<Long> sc = CountByNicId.create();
|
||||
sc.setParameters("nic", nicId);
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
// 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.resourcedetail;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
@Entity
|
||||
@Table(name = "autoscale_vmgroup_details")
|
||||
public class AutoScaleVmGroupDetailVO implements ResourceDetail {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "autoscale_vmgroup_id")
|
||||
private long resourceId;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "value", length = 1024)
|
||||
private String value;
|
||||
|
||||
@Column(name = "display")
|
||||
private boolean display;
|
||||
|
||||
public AutoScaleVmGroupDetailVO() {
|
||||
}
|
||||
|
||||
public AutoScaleVmGroupDetailVO(long id, String name, String value) {
|
||||
this.resourceId = id;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
// 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.resourcedetail;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
@Entity
|
||||
@Table(name = "autoscale_vmprofile_details")
|
||||
public class AutoScaleVmProfileDetailVO implements ResourceDetail {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "autoscale_vmprofile_id")
|
||||
private long resourceId;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "value", length = 1024)
|
||||
private String value;
|
||||
|
||||
@Column(name = "display")
|
||||
private boolean display;
|
||||
|
||||
public AutoScaleVmProfileDetailVO() {
|
||||
}
|
||||
|
||||
public AutoScaleVmProfileDetailVO(long id, String name, String value) {
|
||||
this.resourceId = id;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// 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.resourcedetail.dao;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.AutoScaleVmGroupDetailVO;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface AutoScaleVmGroupDetailsDao extends GenericDao<AutoScaleVmGroupDetailVO, Long>, ResourceDetailsDao<AutoScaleVmGroupDetailVO> {
|
||||
|
||||
}
|
||||
|
|
@ -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 org.apache.cloudstack.resourcedetail.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.AutoScaleVmGroupDetailVO;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Local(value = {AutoScaleVmGroupDetailsDao.class})
|
||||
public class AutoScaleVmGroupDetailsDaoImpl extends ResourceDetailsDaoBase<AutoScaleVmGroupDetailVO> implements AutoScaleVmGroupDetailsDao {
|
||||
|
||||
@Override
|
||||
public void addDetail(long resourceId, String key, String value) {
|
||||
super.addDetail(new AutoScaleVmGroupDetailVO(resourceId, key, value));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// 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.resourcedetail.dao;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.AutoScaleVmProfileDetailVO;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface AutoScaleVmProfileDetailsDao extends GenericDao<AutoScaleVmProfileDetailVO, Long>, ResourceDetailsDao<AutoScaleVmProfileDetailVO> {
|
||||
|
||||
}
|
||||
|
|
@ -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 org.apache.cloudstack.resourcedetail.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.AutoScaleVmProfileDetailVO;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Local(value = {AutoScaleVmProfileDetailsDao.class})
|
||||
public class AutoScaleVmProfileDetailsDaoImpl extends ResourceDetailsDaoBase<AutoScaleVmProfileDetailVO> implements AutoScaleVmProfileDetailsDao {
|
||||
|
||||
@Override
|
||||
public void addDetail(long resourceId, String key, String value) {
|
||||
super.addDetail(new AutoScaleVmProfileDetailVO(resourceId, key, value));
|
||||
}
|
||||
}
|
||||
|
|
@ -75,6 +75,7 @@ import com.cloud.dc.dao.DataCenterDao;
|
|||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
|
|
@ -721,6 +722,13 @@ public class TemplateServiceImpl implements TemplateService {
|
|||
|
||||
@Override
|
||||
public AsyncCallFuture<TemplateApiResult> copyTemplate(TemplateInfo srcTemplate, DataStore destStore) {
|
||||
// for vmware template, we need to check if ova packing is needed, since template created from snapshot does not have .ova file
|
||||
// we invoke createEntityExtractURL to trigger ova packing. Ideally, we can directly use extractURL to pass to following createTemplate.
|
||||
// Need to understand what is the background to use two different urls for copy and extract.
|
||||
if (srcTemplate.getFormat() == ImageFormat.OVA){
|
||||
ImageStoreEntity tmpltStore = (ImageStoreEntity)srcTemplate.getDataStore();
|
||||
tmpltStore.createEntityExtractUrl(srcTemplate.getInstallPath(), srcTemplate.getFormat(), srcTemplate);
|
||||
}
|
||||
// generate a URL from source template ssvm to download to destination data store
|
||||
String url = generateCopyUrl(srcTemplate);
|
||||
if (url == null) {
|
||||
|
|
|
|||
|
|
@ -420,12 +420,12 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found template " + template.getUniqueName() + " in storage pool " + dataStore.getId() + " with VMTemplateStoragePool id: " +
|
||||
templatePoolRef.getId());
|
||||
templatePoolRef.getId());
|
||||
}
|
||||
}
|
||||
long templatePoolRefId = templatePoolRef.getId();
|
||||
CreateBaseImageContext<CreateCmdResult> context =
|
||||
new CreateBaseImageContext<CreateCmdResult>(null, volume, dataStore, template, future, templateOnPrimaryStoreObj, templatePoolRefId);
|
||||
new CreateBaseImageContext<CreateCmdResult>(null, volume, dataStore, template, future, templateOnPrimaryStoreObj, templatePoolRefId);
|
||||
AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().copyBaseImageCallback(null, null)).setContext(context);
|
||||
|
||||
|
|
@ -440,9 +440,9 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
s_logger.info("Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId);
|
||||
}
|
||||
templatePoolRef = _tmpltPoolDao.findByPoolTemplate(dataStore.getId(), template.getId());
|
||||
if (templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) {
|
||||
if (templatePoolRef != null && templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) {
|
||||
s_logger.info("Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId + ", But Template " + template.getUniqueName() +
|
||||
" is already copied to primary storage, skip copying");
|
||||
" is already copied to primary storage, skip copying");
|
||||
createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, dataStore, future);
|
||||
return;
|
||||
}
|
||||
|
|
@ -523,7 +523,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
volumeOnPrimaryStorage.processEvent(Event.CreateOnlyRequested);
|
||||
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context =
|
||||
new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null);
|
||||
new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null);
|
||||
AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(null, null));
|
||||
caller.setContext(context);
|
||||
|
|
@ -534,7 +534,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
|
||||
@DB
|
||||
protected Void createVolumeFromBaseImageCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback,
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
|
||||
DataObject vo = context.vo;
|
||||
DataObject tmplOnPrimary = context.templateOnStore;
|
||||
CopyCommandResult result = callback.getResult();
|
||||
|
|
@ -615,7 +615,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
volumeOnStore.processEvent(Event.CreateOnlyRequested);
|
||||
snapshot.processEvent(Event.CopyingRequested);
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context =
|
||||
new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volume, store, volumeOnStore, future, snapshot);
|
||||
new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volume, store, volumeOnStore, future, snapshot);
|
||||
AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().createVolumeFromSnapshotCallback(null, null)).setContext(context);
|
||||
motionSrv.copyAsync(snapshot, volumeOnStore, caller);
|
||||
|
|
@ -630,7 +630,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
}
|
||||
|
||||
protected Void createVolumeFromSnapshotCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback,
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
|
||||
CopyCommandResult result = callback.getResult();
|
||||
VolumeInfo volume = (VolumeInfo)context.templateOnStore;
|
||||
SnapshotInfo snapshot = context.snapshot;
|
||||
|
|
@ -716,7 +716,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
}
|
||||
|
||||
protected Void
|
||||
copyVolumeFromImageToPrimaryCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
|
||||
copyVolumeFromImageToPrimaryCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
|
||||
VolumeInfo srcVolume = context.srcVolume;
|
||||
VolumeInfo destVolume = context.destVolume;
|
||||
CopyCommandResult result = callback.getResult();
|
||||
|
|
@ -770,7 +770,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
}
|
||||
|
||||
protected Void
|
||||
copyVolumeFromPrimaryToImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
|
||||
copyVolumeFromPrimaryToImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
|
||||
VolumeInfo srcVolume = context.srcVolume;
|
||||
VolumeInfo destVolume = context.destVolume;
|
||||
CopyCommandResult result = callback.getResult();
|
||||
|
|
@ -988,7 +988,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
}
|
||||
|
||||
protected Void
|
||||
migrateVmWithVolumesCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, MigrateVmWithVolumesContext<CommandResult> context) {
|
||||
migrateVmWithVolumesCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, MigrateVmWithVolumesContext<CommandResult> context) {
|
||||
Map<VolumeInfo, DataStore> volumeToPool = context.volumeToPool;
|
||||
CopyCommandResult result = callback.getResult();
|
||||
AsyncCallFuture<CommandResult> future = context.future;
|
||||
|
|
@ -1065,20 +1065,20 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
physicalSize = volStore.getPhysicalSize();
|
||||
} else {
|
||||
s_logger.warn("No entry found in volume_store_ref for volume id: " + vo.getId() + " and image store id: " + ds.getId() +
|
||||
" at the end of uploading volume!");
|
||||
" at the end of uploading volume!");
|
||||
}
|
||||
Scope dsScope = ds.getScope();
|
||||
if (dsScope.getScopeType() == ScopeType.ZONE) {
|
||||
if (dsScope.getScopeId() != null) {
|
||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, vo.getAccountId(), dsScope.getScopeId(), vo.getId(), vo.getName(), null,
|
||||
null, physicalSize, vo.getSize(), Volume.class.getName(), vo.getUuid());
|
||||
null, physicalSize, vo.getSize(), Volume.class.getName(), vo.getUuid());
|
||||
} else {
|
||||
s_logger.warn("Zone scope image store " + ds.getId() + " has a null scope id");
|
||||
}
|
||||
} else if (dsScope.getScopeType() == ScopeType.REGION) {
|
||||
// publish usage event for region-wide image store using a -1 zoneId for 4.2, need to revisit post-4.2
|
||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, vo.getAccountId(), -1, vo.getId(), vo.getName(), null, null, physicalSize,
|
||||
vo.getSize(), Volume.class.getName(), vo.getUuid());
|
||||
vo.getSize(), Volume.class.getName(), vo.getUuid());
|
||||
|
||||
_resourceLimitMgr.incrementResourceCount(vo.getAccountId(), ResourceType.secondary_storage, vo.getSize());
|
||||
}
|
||||
|
|
@ -1173,7 +1173,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
VolumeVO volume = _volumeDao.findById(volumeStore.getVolumeId());
|
||||
if (volume == null) {
|
||||
s_logger.warn("Volume_store_ref shows that volume " + volumeStore.getVolumeId() + " is on image store " + storeId +
|
||||
", but the volume is not found in volumes table, potentially some bugs in deleteVolume, so we just treat this volume to be deleted and mark it as destroyed");
|
||||
", but the volume is not found in volumes table, potentially some bugs in deleteVolume, so we just treat this volume to be deleted and mark it as destroyed");
|
||||
volumeStore.setDestroyed(true);
|
||||
_volumeStoreDao.update(volumeStore.getId(), volumeStore);
|
||||
continue;
|
||||
|
|
@ -1193,7 +1193,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
s_logger.info("msg");
|
||||
if (volumeStore.getDownloadUrl() == null) {
|
||||
msg =
|
||||
"Volume (" + volume.getUuid() + ") with install path " + volInfo.getInstallPath() +
|
||||
"Volume (" + volume.getUuid() + ") with install path " + volInfo.getInstallPath() +
|
||||
"is corrupted, please check in image store: " + volumeStore.getDataStoreId();
|
||||
s_logger.warn(msg);
|
||||
} else {
|
||||
|
|
@ -1221,15 +1221,15 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
if (volInfo.getSize() > 0) {
|
||||
try {
|
||||
_resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()),
|
||||
com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize());
|
||||
com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize());
|
||||
} catch (ResourceAllocationException e) {
|
||||
s_logger.warn(e.getMessage());
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED, volume.getDataCenterId(), volume.getPodId(),
|
||||
e.getMessage(),
|
||||
e.getMessage());
|
||||
e.getMessage(),
|
||||
e.getMessage());
|
||||
} finally {
|
||||
_resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(),
|
||||
com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal());
|
||||
com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1238,7 +1238,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
// Volume is not on secondary but we should download.
|
||||
if (volumeStore.getDownloadState() != Status.DOWNLOADED) {
|
||||
s_logger.info("Volume Sync did not find " + volume.getName() + " ready on image store " + storeId +
|
||||
", will request download to start/resume shortly");
|
||||
", will request download to start/resume shortly");
|
||||
toBeDownloaded.add(volumeStore);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -658,9 +658,21 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a result set.
|
||||
*
|
||||
* @param type
|
||||
* the expected type of the result
|
||||
* @param rs
|
||||
* the result set
|
||||
* @param index
|
||||
* the index of the column
|
||||
* @return the result in the requested type
|
||||
* @throws SQLException
|
||||
*/
|
||||
@DB()
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <M> M getObject(Class<M> type, ResultSet rs, int index) throws SQLException {
|
||||
protected static <M> M getObject(Class<M> type, ResultSet rs, int index) throws SQLException {
|
||||
if (type == String.class) {
|
||||
byte[] bytes = rs.getBytes(index);
|
||||
if (bytes != null) {
|
||||
|
|
@ -681,12 +693,12 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
|
|||
return (M)new Integer(rs.getInt(index));
|
||||
}
|
||||
} else if (type == long.class) {
|
||||
return (M)new Long(rs.getLong(index));
|
||||
return (M) (Long) rs.getLong(index);
|
||||
} else if (type == Long.class) {
|
||||
if (rs.getObject(index) == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (M)new Long(rs.getLong(index));
|
||||
return (M) (Long) rs.getLong(index);
|
||||
}
|
||||
} else if (type == Date.class) {
|
||||
final Object data = rs.getDate(index);
|
||||
|
|
@ -696,44 +708,44 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
|
|||
return (M)DateUtil.parseDateString(s_gmtTimeZone, rs.getString(index));
|
||||
}
|
||||
} else if (type == short.class) {
|
||||
return (M)new Short(rs.getShort(index));
|
||||
return (M) (Short) rs.getShort(index);
|
||||
} else if (type == Short.class) {
|
||||
if (rs.getObject(index) == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (M)new Short(rs.getShort(index));
|
||||
return (M) (Short) rs.getShort(index);
|
||||
}
|
||||
} else if (type == boolean.class) {
|
||||
return (M)new Boolean(rs.getBoolean(index));
|
||||
return (M) (Boolean) rs.getBoolean(index);
|
||||
} else if (type == Boolean.class) {
|
||||
if (rs.getObject(index) == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (M)new Boolean(rs.getBoolean(index));
|
||||
return (M) (Boolean) rs.getBoolean(index);
|
||||
}
|
||||
} else if (type == float.class) {
|
||||
return (M)new Float(rs.getFloat(index));
|
||||
return (M) (Float) rs.getFloat(index);
|
||||
} else if (type == Float.class) {
|
||||
if (rs.getObject(index) == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (M)new Float(rs.getFloat(index));
|
||||
return (M) (Float) rs.getFloat(index);
|
||||
}
|
||||
} else if (type == double.class) {
|
||||
return (M)new Double(rs.getDouble(index));
|
||||
return (M) (Double) rs.getDouble(index);
|
||||
} else if (type == Double.class) {
|
||||
if (rs.getObject(index) == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (M)new Double(rs.getDouble(index));
|
||||
return (M) (Double) rs.getDouble(index);
|
||||
}
|
||||
} else if (type == byte.class) {
|
||||
return (M)new Byte(rs.getByte(index));
|
||||
return (M) (Byte) rs.getByte(index);
|
||||
} else if (type == Byte.class) {
|
||||
if (rs.getObject(index) == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (M)new Byte(rs.getByte(index));
|
||||
return (M) (Byte) rs.getByte(index);
|
||||
}
|
||||
} else if (type == Calendar.class) {
|
||||
final Object data = rs.getDate(index);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
// 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.utils.db;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GenericDaoBaseTest {
|
||||
@Mock
|
||||
ResultSet resultSet;
|
||||
|
||||
@Test
|
||||
public void getObjectBoolean() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(false);
|
||||
Mockito.when(resultSet.getBoolean(1)).thenReturn(false);
|
||||
Assert.assertFalse(GenericDaoBase
|
||||
.getObject(Boolean.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getBoolean(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectPrimitiveBoolean() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(false);
|
||||
Mockito.when(resultSet.getBoolean(1)).thenReturn(false);
|
||||
Assert.assertFalse(GenericDaoBase
|
||||
.getObject(boolean.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getBoolean(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectPrimitiveShort() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn((short) 1);
|
||||
Mockito.when(resultSet.getShort(1)).thenReturn((short) 1);
|
||||
Assert.assertEquals(Short.valueOf((short) 1),
|
||||
GenericDaoBase.getObject(short.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getShort(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectShort() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn((short) 1);
|
||||
Mockito.when(resultSet.getShort(1)).thenReturn((short) 1);
|
||||
Assert.assertEquals(Short.valueOf((short) 1),
|
||||
GenericDaoBase.getObject(Short.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getShort(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectFloat() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(0.1f);
|
||||
Mockito.when(resultSet.getFloat(1)).thenReturn(0.1f);
|
||||
Assert.assertEquals(0.1f,
|
||||
GenericDaoBase.getObject(Float.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getFloat(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectPrimitiveFloat() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(0.1f);
|
||||
Mockito.when(resultSet.getFloat(1)).thenReturn(0.1f);
|
||||
Assert.assertEquals(0.1f,
|
||||
GenericDaoBase.getObject(float.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getFloat(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectPrimitiveDouble() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(0.1d);
|
||||
Mockito.when(resultSet.getDouble(1)).thenReturn(0.1d);
|
||||
Assert.assertEquals(0.1d,
|
||||
GenericDaoBase.getObject(double.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getDouble(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectDouble() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(0.1d);
|
||||
Mockito.when(resultSet.getDouble(1)).thenReturn(0.1d);
|
||||
Assert.assertEquals(0.1d,
|
||||
GenericDaoBase.getObject(Double.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getDouble(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectLong() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(1l);
|
||||
Mockito.when(resultSet.getLong(1)).thenReturn(1l);
|
||||
Assert.assertEquals((Long) 1l,
|
||||
GenericDaoBase.getObject(Long.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getLong(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectPrimitiveLong() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn(1l);
|
||||
Mockito.when(resultSet.getLong(1)).thenReturn(1l);
|
||||
Assert.assertEquals((Long) 1l,
|
||||
GenericDaoBase.getObject(long.class, resultSet, 1));
|
||||
Mockito.verify(resultSet).getLong(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectPrimitiveByte() throws SQLException {
|
||||
Mockito.when(resultSet.getObject(1)).thenReturn((byte) 1);
|
||||
Mockito.when(resultSet.getByte(1)).thenReturn((byte) 1);
|
||||
Assert.assertTrue((byte) 1 == GenericDaoBase.getObject(byte.class,
|
||||
resultSet, 1));
|
||||
Mockito.verify(resultSet).getByte(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ Group: System Environment/Libraries
|
|||
Source0: %{name}-%{_maventag}.tgz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{_maventag}-%{release}-build
|
||||
|
||||
BuildRequires: java-1.6.0-openjdk-devel
|
||||
BuildRequires: java-1.7.0-openjdk-devel
|
||||
BuildRequires: tomcat6
|
||||
BuildRequires: ws-commons-util
|
||||
BuildRequires: jpackage-utils
|
||||
|
|
@ -60,7 +60,7 @@ intelligent IaaS cloud implementation.
|
|||
%package management
|
||||
Summary: CloudStack management server UI
|
||||
Requires: tomcat6
|
||||
Requires: java >= 1.6.0
|
||||
Requires: java >= 1.7.0
|
||||
Requires: python
|
||||
Requires: bash
|
||||
Requires: bzip2
|
||||
|
|
@ -112,7 +112,7 @@ The Apache CloudStack files shared between agent and management server
|
|||
%package agent
|
||||
Summary: CloudStack Agent for KVM hypervisors
|
||||
Requires: openssh-clients
|
||||
Requires: java >= 1.6.0
|
||||
Requires: java >= 1.7.0
|
||||
Requires: %{name}-common = %{_ver}
|
||||
Requires: libvirt
|
||||
Requires: bridge-utils
|
||||
|
|
@ -138,7 +138,7 @@ The CloudStack agent for KVM hypervisors
|
|||
|
||||
%package usage
|
||||
Summary: CloudStack Usage calculation server
|
||||
Requires: java >= 1.6.0
|
||||
Requires: java >= 1.7.0
|
||||
Requires: jsvc
|
||||
Requires: jakarta-commons-daemon
|
||||
Requires: jakarta-commons-daemon-jsvc
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace CloudStack.Plugin.AgentShell
|
|||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.ServiceName = "CloudStack ServerResource";
|
||||
this.ServiceName = Program.serviceName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<startup>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</startup>
|
||||
|
||||
<log4net>
|
||||
<appender name="FileAppender" type="log4net.Appender.FileAppender">
|
||||
|
|
@ -25,13 +25,14 @@
|
|||
</appender>
|
||||
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
|
||||
<appendToFile value="true" />
|
||||
<param name="ApplicationName" value="CloudStack Hyper-V Agent" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="ALL"/>
|
||||
<appender-ref ref="FileAppender"/>
|
||||
<appender-ref ref="EventLogAppender"/>
|
||||
</root>
|
||||
</log4net>
|
||||
|
||||
|
|
@ -95,7 +96,7 @@
|
|||
<value>2048</value>
|
||||
</setting>
|
||||
<setting name="private_ip_address" serializeAs="String">
|
||||
<value>10.102.192.150</value>
|
||||
<value>0.0.0.0</value>
|
||||
</setting>
|
||||
</CloudStack.Plugin.AgentShell.AgentSettings>
|
||||
</applicationSettings>
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ namespace HypervResource
|
|||
// Assert
|
||||
if (result.dataStore == null || (result.primaryDataStore == null && result.nfsDataStore == null))
|
||||
{
|
||||
String errMsg = "VolumeObjectTO missing dataStore in spec " + volumeObjectTOJson.ToString();
|
||||
String errMsg = "VolumeObjectTO missing dataStore in spec " + Utils.CleanString(volumeObjectTOJson.ToString());
|
||||
logger.Error(errMsg);
|
||||
throw new ArgumentNullException(errMsg);
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ namespace HypervResource
|
|||
}
|
||||
else
|
||||
{
|
||||
String errMsg = "VolumeObjectTO missing dataStore in spec " + volInfo.ToString();
|
||||
String errMsg = "VolumeObjectTO missing dataStore in spec " + Utils.CleanString(volInfo.ToString());
|
||||
logger.Error(errMsg);
|
||||
throw new ArgumentNullException(errMsg);
|
||||
}
|
||||
|
|
@ -690,6 +690,20 @@ namespace HypervResource
|
|||
public String entityType;
|
||||
}
|
||||
|
||||
public class NicDetails
|
||||
{
|
||||
[JsonProperty("macAddress")]
|
||||
public string macaddress;
|
||||
[JsonProperty("vlanid")]
|
||||
public int vlanid;
|
||||
public NicDetails() { }
|
||||
public NicDetails(String macaddress, int vlanid)
|
||||
{
|
||||
this.macaddress = macaddress;
|
||||
this.vlanid = vlanid;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fully qualified named for a number of types used in CloudStack. Used to specify the intended type for JSON serialised objects.
|
||||
/// </summary>
|
||||
|
|
@ -738,6 +752,10 @@ namespace HypervResource
|
|||
public const string GetVmDiskStatsCommand = "com.cloud.agent.api.GetVmDiskStatsCommand";
|
||||
public const string GetVmStatsAnswer = "com.cloud.agent.api.GetVmStatsAnswer";
|
||||
public const string GetVmStatsCommand = "com.cloud.agent.api.GetVmStatsCommand";
|
||||
public const string GetVmConfigCommand = "com.cloud.agent.api.GetVmConfigCommand";
|
||||
public const string GetVmConfigAnswer = "com.cloud.agent.api.GetVmConfigAnswer";
|
||||
public const string ModifyVmNicConfigCommand = "com.cloud.agent.api.ModifyVmNicConfigCommand";
|
||||
public const string ModifyVmNicConfigAnswer = "com.cloud.agent.api.ModifyVmNicConfigAnswer";
|
||||
public const string GetVncPortAnswer = "com.cloud.agent.api.GetVncPortAnswer";
|
||||
public const string GetVncPortCommand = "com.cloud.agent.api.GetVncPortCommand";
|
||||
public const string HostStatsEntry = "com.cloud.agent.api.HostStatsEntry";
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.AttachCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.AttachCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -268,7 +268,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.DettachCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.DettachCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -485,7 +485,7 @@ namespace HypervResource
|
|||
{
|
||||
JObject ansObj = Utils.CreateCloudStackObject(ansType, ansContent);
|
||||
JArray answer = new JArray(ansObj);
|
||||
logger.Info(ansObj.ToString());
|
||||
logger.Info(Utils.CleanString(ansObj.ToString()));
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
|
@ -496,7 +496,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CreateCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CreateCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
|
@ -603,7 +603,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.PrimaryStorageDownloadCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.PrimaryStorageDownloadCommand + Utils.CleanString(cmd.ToString()));
|
||||
string details = null;
|
||||
bool result = false;
|
||||
long size = 0;
|
||||
|
|
@ -871,7 +871,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CreateStoragePoolCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CreateStoragePoolCommand + Utils.CleanString(cmd.ToString()));
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
|
|
@ -889,7 +889,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.ModifyStoragePoolCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.ModifyStoragePoolCommand + Utils.CleanString(cmd.ToString()));
|
||||
string details = null;
|
||||
string localPath;
|
||||
StoragePoolType poolType;
|
||||
|
|
@ -982,6 +982,24 @@ namespace HypervResource
|
|||
return true;
|
||||
}
|
||||
|
||||
// POST api/HypervResource/PlugNicCommand
|
||||
[HttpPost]
|
||||
[ActionName(CloudStackTypes.PlugNicCommand)]
|
||||
public JContainer PlugNicCommand([FromBody]dynamic cmd)
|
||||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.PlugNicCommand + cmd.ToString());
|
||||
object ansContent = new
|
||||
{
|
||||
result = true,
|
||||
details = "instead of plug, change he network settings",
|
||||
contextMap = contextMap
|
||||
};
|
||||
return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.PlugNicAnswer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// POST api/HypervResource/CleanupNetworkRulesCmd
|
||||
[HttpPost]
|
||||
|
|
@ -1045,7 +1063,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.StartCommand + cmd.ToString()); // TODO: Security hole? VM data printed to log
|
||||
logger.Info(CloudStackTypes.StartCommand + Utils.CleanString(cmd.ToString()));
|
||||
string details = null;
|
||||
bool result = false;
|
||||
|
||||
|
|
@ -1144,7 +1162,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.CreateObjectCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CreateObjectCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
bool result = false;
|
||||
string details = null;
|
||||
|
|
@ -1264,6 +1282,88 @@ namespace HypervResource
|
|||
}
|
||||
}
|
||||
|
||||
// POST api/HypervResource/ModifyVmVnicVlanCommand
|
||||
[HttpPost]
|
||||
[ActionName(CloudStackTypes.ModifyVmNicConfigCommand)]
|
||||
public JContainer ModifyVmNicConfigCommand([FromBody]dynamic cmd)
|
||||
{
|
||||
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.ModifyVmNicConfigCommand + cmd.ToString());
|
||||
bool result = false;
|
||||
String vmName = cmd.vmName;
|
||||
uint vlan = (uint)cmd.vlan;
|
||||
string macAddress = cmd.macAddress;
|
||||
wmiCallsV2.ModifyVmVLan(vmName, vlan, macAddress);
|
||||
|
||||
result = true;
|
||||
|
||||
object ansContent = new
|
||||
{
|
||||
vmName = vmName,
|
||||
result = result,
|
||||
contextMap = contextMap
|
||||
};
|
||||
return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.ModifyVmNicConfigAnswer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// POST api/HypervResource/GetVmConfigCommand
|
||||
[HttpPost]
|
||||
[ActionName(CloudStackTypes.GetVmConfigCommand)]
|
||||
public JContainer GetVmConfigCommand([FromBody]dynamic cmd)
|
||||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.GetVmConfigCommand + cmd.ToString());
|
||||
bool result = false;
|
||||
String vmName = cmd.vmName;
|
||||
ComputerSystem vm = wmiCallsV2.GetComputerSystem(vmName);
|
||||
List<NicDetails> nicDetails = new List<NicDetails>();
|
||||
var nicSettingsViaVm = wmiCallsV2.GetEthernetPortSettings(vm);
|
||||
NicDetails nic = null;
|
||||
String[] macAddress = new String[nicSettingsViaVm.Length];
|
||||
int index = 0;
|
||||
foreach (SyntheticEthernetPortSettingData item in nicSettingsViaVm)
|
||||
{
|
||||
macAddress[index++] = item.Address;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
var ethernetConnections = wmiCallsV2.GetEthernetConnections(vm);
|
||||
int vlanid = 1;
|
||||
foreach (EthernetPortAllocationSettingData item in ethernetConnections)
|
||||
{
|
||||
EthernetSwitchPortVlanSettingData vlanSettings = wmiCallsV2.GetVlanSettings(item);
|
||||
if (vlanSettings == null)
|
||||
{
|
||||
vlanid = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
vlanid = vlanSettings.AccessVlanId;
|
||||
}
|
||||
nic = new NicDetails(macAddress[index++], vlanid);
|
||||
nicDetails.Add(nic);
|
||||
}
|
||||
|
||||
result = true;
|
||||
|
||||
object ansContent = new
|
||||
{
|
||||
vmName = vmName,
|
||||
nics = nicDetails,
|
||||
result = result,
|
||||
contextMap = contextMap
|
||||
};
|
||||
return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.GetVmConfigAnswer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// POST api/HypervResource/GetVmStatsCommand
|
||||
[HttpPost]
|
||||
[ActionName(CloudStackTypes.GetVmStatsCommand)]
|
||||
|
|
@ -1315,7 +1415,7 @@ namespace HypervResource
|
|||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
// Log command *after* we've removed security details from the command.
|
||||
logger.Info(CloudStackTypes.CopyCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.CopyCommand + Utils.CleanString(cmd.ToString()));
|
||||
|
||||
bool result = false;
|
||||
string details = null;
|
||||
|
|
@ -1691,7 +1791,7 @@ namespace HypervResource
|
|||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.GetStorageStatsCommand + cmd.ToString());
|
||||
logger.Info(CloudStackTypes.GetStorageStatsCommand + Utils.CleanString(cmd.ToString()));
|
||||
bool result = false;
|
||||
string details = null;
|
||||
long capacity = 0;
|
||||
|
|
@ -1921,6 +2021,7 @@ namespace HypervResource
|
|||
string productVersion = System.Environment.OSVersion.Version.Major.ToString() + "." +
|
||||
System.Environment.OSVersion.Version.Minor.ToString();
|
||||
details.Add("product_version", productVersion);
|
||||
details.Add("rdp.server.port", 2179);
|
||||
}
|
||||
|
||||
// Detect CPUs, speed, memory
|
||||
|
|
@ -2000,6 +2101,45 @@ namespace HypervResource
|
|||
}
|
||||
}
|
||||
|
||||
// POST api/HypervResource/GetVncPortCommand
|
||||
[HttpPost]
|
||||
[ActionName(CloudStackTypes.GetVncPortCommand)]
|
||||
public JContainer GetVncPortCommand([FromBody]dynamic cmd)
|
||||
{
|
||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||
{
|
||||
logger.Info(CloudStackTypes.GetVncPortCommand + cmd.ToString());
|
||||
|
||||
string details = null;
|
||||
bool result = false;
|
||||
string address = null;
|
||||
int port = -9;
|
||||
|
||||
try
|
||||
{
|
||||
string vmName = (string)cmd.name;
|
||||
var sys = wmiCallsV2.GetComputerSystem(vmName);
|
||||
address = "instanceId=" + sys.Name ;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception sysEx)
|
||||
{
|
||||
details = CloudStackTypes.GetVncPortAnswer + " failed due to " + sysEx.Message;
|
||||
logger.Error(details, sysEx);
|
||||
}
|
||||
|
||||
object ansContent = new
|
||||
{
|
||||
result = result,
|
||||
details = details,
|
||||
address = address,
|
||||
port = port
|
||||
};
|
||||
|
||||
return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.GetVncPortAnswer);
|
||||
}
|
||||
}
|
||||
|
||||
public static System.Net.NetworkInformation.NetworkInterface GetNicInfoFromIpAddress(string ipAddress, out string subnet)
|
||||
{
|
||||
System.Net.NetworkInformation.NetworkInterface[] nics = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
|
||||
|
|
|
|||
|
|
@ -66,5 +66,6 @@ namespace HypervResource
|
|||
void patchSystemVmIso(string vmName, string systemVmIso);
|
||||
void SetState(ComputerSystem vm, ushort requiredState);
|
||||
Dictionary<String, VmState> GetVmSync(String privateIpAddress);
|
||||
void ModifyVmVLan(string vmName, uint vlanid, string mac);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,6 +164,16 @@ namespace HypervResource
|
|||
capacity = totalNumberOfBytes > 0 ? (long)totalNumberOfBytes : 0;
|
||||
}
|
||||
|
||||
public static string CleanString(string stringToClean)
|
||||
{
|
||||
string cleanString = null;
|
||||
string regexQueryString = "(&|%26)?(password|accesskey|secretkey)(=|%3D).*?(?=(%26|[&'\"]))";
|
||||
string regexJson = "\"(password|accesskey|secretkey)\":\".*?\",?";
|
||||
cleanString = System.Text.RegularExpressions.Regex.Replace(stringToClean, regexQueryString, "");
|
||||
cleanString = System.Text.RegularExpressions.Regex.Replace(cleanString, regexJson, "");
|
||||
return cleanString;
|
||||
}
|
||||
|
||||
// from http://stackoverflow.com/a/2541569/939250
|
||||
#region imports
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
|
|
|
|||
|
|
@ -443,6 +443,7 @@ namespace HypervResource
|
|||
nicCount++;
|
||||
}
|
||||
|
||||
|
||||
// pass the boot args for the VM using KVP component.
|
||||
// We need to pass the boot args to system vm's to get them configured with cloudstack configuration.
|
||||
// Add new user data
|
||||
|
|
@ -909,6 +910,37 @@ namespace HypervResource
|
|||
return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
|
||||
}
|
||||
|
||||
|
||||
// Modify the systemvm nic's VLAN id
|
||||
public void ModifyVmVLan(string vmName, uint vlanid, String mac)
|
||||
{
|
||||
ComputerSystem vm = GetComputerSystem(vmName);
|
||||
SyntheticEthernetPortSettingData[] nicSettingsViaVm = GetEthernetPortSettings(vm);
|
||||
// Obtain controller for Hyper-V virtualisation subsystem
|
||||
VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
|
||||
string normalisedMAC = string.Join("", (mac.Split(new char[] { ':' })));
|
||||
int index = 0;
|
||||
foreach (SyntheticEthernetPortSettingData item in nicSettingsViaVm)
|
||||
{
|
||||
if (normalisedMAC.ToLower().Equals(item.Address.ToLower()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
//TODO: make sure the index wont be out of range.
|
||||
|
||||
EthernetPortAllocationSettingData[] ethernetConnections = GetEthernetConnections(vm);
|
||||
EthernetSwitchPortVlanSettingData vlanSettings = GetVlanSettings(ethernetConnections[index]);
|
||||
|
||||
//Assign configuration to new NIC
|
||||
vlanSettings.LateBoundObject["AccessVlanId"] = vlanid;
|
||||
vlanSettings.LateBoundObject["OperationMode"] = 1;
|
||||
ModifyFeatureVmResources(vmMgmtSvc, vm, new String[] {
|
||||
vlanSettings.LateBoundObject.GetText(TextFormat.CimDtd20)});
|
||||
}
|
||||
|
||||
public void AttachIso(string displayName, string iso)
|
||||
{
|
||||
logger.DebugFormat("Got request to attach iso {0} to vm {1}", iso, displayName);
|
||||
|
|
@ -1420,6 +1452,36 @@ namespace HypervResource
|
|||
return vSwitch;
|
||||
}
|
||||
|
||||
|
||||
private static void ModifyFeatureVmResources(VirtualSystemManagementService vmMgmtSvc, ComputerSystem vm, string[] resourceSettings)
|
||||
{
|
||||
// Resource settings are changed through the management service
|
||||
System.Management.ManagementPath jobPath;
|
||||
System.Management.ManagementPath[] results;
|
||||
|
||||
var ret_val = vmMgmtSvc.ModifyFeatureSettings(
|
||||
resourceSettings,
|
||||
out jobPath,
|
||||
out results);
|
||||
|
||||
// If the Job is done asynchronously
|
||||
if (ret_val == ReturnCode.Started)
|
||||
{
|
||||
JobCompleted(jobPath);
|
||||
}
|
||||
else if (ret_val != ReturnCode.Completed)
|
||||
{
|
||||
var errMsg = string.Format(
|
||||
"Failed to update VM {0} (GUID {1}) due to {2} (ModifyVirtualSystem call), existing VM not deleted",
|
||||
vm.ElementName,
|
||||
vm.Name,
|
||||
ReturnCode.ToString(ret_val));
|
||||
var ex = new WmiException(errMsg);
|
||||
logger.Error(errMsg, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ModifyVmResources(VirtualSystemManagementService vmMgmtSvc, ComputerSystem vm, string[] resourceSettings)
|
||||
{
|
||||
// Resource settings are changed through the management service
|
||||
|
|
|
|||
|
|
@ -16,15 +16,30 @@
|
|||
// under the License.
|
||||
package com.cloud.hypervisor.hyperv.guru;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.hypervisor.HypervisorGuruBase;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.hypervisor.hyperv.manager.HypervManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
/**
|
||||
|
|
@ -35,6 +50,9 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
|
||||
@Inject
|
||||
private GuestOSDao _guestOsDao;
|
||||
@Inject HypervManager _hypervMgr;
|
||||
@Inject NetworkDao _networkDao;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
||||
@Override
|
||||
public final HypervisorType getHypervisorType() {
|
||||
|
|
@ -51,6 +69,78 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
@Override
|
||||
public final VirtualMachineTO implement(VirtualMachineProfile vm) {
|
||||
VirtualMachineTO to = toVirtualMachineTO(vm);
|
||||
List<NicProfile> nicProfiles = vm.getNics();
|
||||
|
||||
if(vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
|
||||
|
||||
NicProfile publicNicProfile = null;
|
||||
for(NicProfile nicProfile : nicProfiles) {
|
||||
if(nicProfile.getTrafficType() == TrafficType.Public) {
|
||||
publicNicProfile = nicProfile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(publicNicProfile != null) {
|
||||
NicTO[] nics = to.getNics();
|
||||
|
||||
// reserve extra NICs
|
||||
NicTO[] expandedNics = new NicTO[nics.length + _hypervMgr.getRouterExtraPublicNics()];
|
||||
int i = 0;
|
||||
int deviceId = -1;
|
||||
for(i = 0; i < nics.length; i++) {
|
||||
expandedNics[i] = nics[i];
|
||||
if(nics[i].getDeviceId() > deviceId)
|
||||
deviceId = nics[i].getDeviceId();
|
||||
}
|
||||
deviceId++;
|
||||
|
||||
long networkId = publicNicProfile.getNetworkId();
|
||||
NetworkVO network = _networkDao.findById(networkId);
|
||||
|
||||
for(; i < nics.length + _hypervMgr.getRouterExtraPublicNics(); i++) {
|
||||
NicTO nicTo = new NicTO();
|
||||
nicTo.setDeviceId(deviceId++);
|
||||
nicTo.setBroadcastType(publicNicProfile.getBroadcastType());
|
||||
nicTo.setType(publicNicProfile.getTrafficType());
|
||||
nicTo.setIp("0.0.0.0");
|
||||
nicTo.setNetmask("255.255.255.255");
|
||||
nicTo.setName(publicNicProfile.getName());
|
||||
|
||||
try {
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(networkId);
|
||||
nicTo.setMac(mac);
|
||||
} catch (InsufficientAddressCapacityException e) {
|
||||
throw new CloudRuntimeException("unable to allocate mac address on network: " + networkId);
|
||||
}
|
||||
nicTo.setDns1(publicNicProfile.getDns1());
|
||||
nicTo.setDns2(publicNicProfile.getDns2());
|
||||
if (publicNicProfile.getGateway() != null) {
|
||||
nicTo.setGateway(publicNicProfile.getGateway());
|
||||
} else {
|
||||
nicTo.setGateway(network.getGateway());
|
||||
}
|
||||
nicTo.setDefaultNic(false);
|
||||
nicTo.setBroadcastUri(publicNicProfile.getBroadCastUri());
|
||||
nicTo.setIsolationuri(publicNicProfile.getIsolationUri());
|
||||
|
||||
Integer networkRate = _networkMgr.getNetworkRate(network.getId(), null);
|
||||
nicTo.setNetworkRateMbps(networkRate);
|
||||
|
||||
expandedNics[i] = nicTo;
|
||||
}
|
||||
to.setNics(expandedNics);
|
||||
}
|
||||
|
||||
StringBuffer sbMacSequence = new StringBuffer();
|
||||
for(NicTO nicTo : sortNicsByDeviceId(to.getNics())) {
|
||||
sbMacSequence.append(nicTo.getMac()).append("|");
|
||||
}
|
||||
sbMacSequence.deleteCharAt(sbMacSequence.length() - 1);
|
||||
String bootArgs = to.getBootArgs();
|
||||
to.setBootArgs(bootArgs + " nic_macs=" + sbMacSequence.toString());
|
||||
|
||||
}
|
||||
|
||||
// Determine the VM's OS description
|
||||
GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
|
||||
|
|
@ -59,6 +149,29 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
return to;
|
||||
}
|
||||
|
||||
private NicTO[] sortNicsByDeviceId(NicTO[] nics) {
|
||||
|
||||
List<NicTO> listForSort = new ArrayList<NicTO>();
|
||||
for (NicTO nic : nics) {
|
||||
listForSort.add(nic);
|
||||
}
|
||||
Collections.sort(listForSort, new Comparator<NicTO>() {
|
||||
|
||||
@Override
|
||||
public int compare(NicTO arg0, NicTO arg1) {
|
||||
if (arg0.getDeviceId() < arg1.getDeviceId()) {
|
||||
return -1;
|
||||
} else if (arg0.getDeviceId() == arg1.getDeviceId()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
return listForSort.toArray(new NicTO[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean trackVmHostChange() {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -21,4 +21,5 @@ import com.cloud.utils.component.Manager;
|
|||
|
||||
public interface HypervManager extends Manager {
|
||||
public String prepareSecondaryStorageStore(long zoneId);
|
||||
int getRouterExtraPublicNics();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ import com.cloud.utils.NumbersUtil;
|
|||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Local(value = {HypervManager.class})
|
||||
public class HypervManagerImpl implements HypervManager {
|
||||
|
|
@ -60,10 +62,11 @@ public class HypervManagerImpl implements HypervManager {
|
|||
Map<String, String> _storageMounts = new HashMap<String, String>();
|
||||
StorageLayer _storage;
|
||||
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
DataStoreManager _dataStoreMgr;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject DataStoreManager _dataStoreMgr;
|
||||
@Inject VMInstanceDao _vminstanceDao;
|
||||
@Inject NicDao _nicDao;
|
||||
int _routerExtraPublicNics = 2;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
|
|
@ -77,7 +80,7 @@ public class HypervManagerImpl implements HypervManager {
|
|||
_storage = new JavaStorageLayer();
|
||||
_storage.configure("StorageLayer", params);
|
||||
}
|
||||
|
||||
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -373,4 +376,9 @@ public class HypervManagerImpl implements HypervManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRouterExtraPublicNics() {
|
||||
return _routerExtraPublicNics;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,13 +36,13 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
|
@ -71,7 +71,12 @@ import com.cloud.agent.api.CheckS2SVpnConnectionsCommand;
|
|||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetDomRVersionAnswer;
|
||||
import com.cloud.agent.api.GetDomRVersionCmd;
|
||||
import com.cloud.agent.api.GetVmConfigAnswer;
|
||||
import com.cloud.agent.api.GetVmConfigAnswer.NicDetails;
|
||||
import com.cloud.agent.api.GetVmConfigCommand;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.ModifyVmNicConfigAnswer;
|
||||
import com.cloud.agent.api.ModifyVmNicConfigCommand;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
|
|
@ -117,11 +122,13 @@ import com.cloud.agent.api.to.PortForwardingRuleTO;
|
|||
import com.cloud.agent.api.to.StaticNatRuleTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.hyperv.manager.HypervManager;
|
||||
import com.cloud.network.HAProxyConfigurator;
|
||||
import com.cloud.network.LoadBalancerConfigurator;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.RouterPrivateIpStrategy;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.resource.ServerResource;
|
||||
|
|
@ -133,6 +140,8 @@ import com.cloud.utils.net.NetUtils;
|
|||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of dummy resource to be returned from discoverer.
|
||||
**/
|
||||
|
|
@ -706,65 +715,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// find mac address of a specified ethx device
|
||||
// ip address show ethx | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2
|
||||
// returns
|
||||
// eth0:xx.xx.xx.xx
|
||||
|
||||
//
|
||||
// list IP with eth devices
|
||||
// ifconfig ethx |grep -B1 "inet addr" | awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }'
|
||||
// | awk -F: '{ print $1 ": " $3 }'
|
||||
//
|
||||
// returns
|
||||
// eth0:xx.xx.xx.xx
|
||||
//
|
||||
//
|
||||
|
||||
private int findRouterEthDeviceIndex(String domrName, String routerIp, String mac) throws Exception {
|
||||
|
||||
s_logger.info("findRouterEthDeviceIndex. mac: " + mac);
|
||||
|
||||
// TODO : this is a temporary very inefficient solution, will refactor it later
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "ls /proc/sys/net/ipv4/conf");
|
||||
|
||||
// when we dynamically plug in a new NIC into virtual router, it may take time to show up in guest OS
|
||||
// we use a waiting loop here as a workaround to synchronize activities in systems
|
||||
long startTick = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - startTick < 15000) {
|
||||
if (result.first()) {
|
||||
String[] tokens = result.second().split("\\s+");
|
||||
for (String token : tokens) {
|
||||
if (!("all".equalsIgnoreCase(token) || "default".equalsIgnoreCase(token) || "lo".equalsIgnoreCase(token))) {
|
||||
String cmd = String.format("ip address show %s | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2", token);
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Run domr script " + cmd);
|
||||
Pair<Boolean, String> result2 = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
|
||||
// TODO need to find the dev index inside router based on IP address
|
||||
cmd);
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("result: " + result2.first() + ", output: " + result2.second());
|
||||
|
||||
if (result2.first() && result2.second().trim().equalsIgnoreCase(mac.trim()))
|
||||
return Integer.parseInt(token.substring(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.warn("can not find intereface associated with mac: " + mac + ", guest OS may still at loading state, retry...");
|
||||
|
||||
try {
|
||||
Thread.currentThread();
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected Answer execute(SetPortForwardingRulesCommand cmd) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Executing resource SetPortForwardingRulesCommand: " + s_gson.toJson(cmd));
|
||||
|
|
@ -1170,74 +1120,35 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Executing resource VmDataCommand: " + s_gson.toJson(cmd));
|
||||
}
|
||||
|
||||
String routerPrivateIpAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String controlIp = getRouterSshControlIp(cmd);
|
||||
Map<String, List<String[]>> data = new HashMap<String, List<String[]>>();
|
||||
data.put(cmd.getVmIpAddress(), cmd.getVmData());
|
||||
|
||||
String vmIpAddress = cmd.getVmIpAddress();
|
||||
List<String[]> vmData = cmd.getVmData();
|
||||
String[] vmDataArgs = new String[vmData.size() * 2 + 4];
|
||||
vmDataArgs[0] = "routerIP";
|
||||
vmDataArgs[1] = routerPrivateIpAddress;
|
||||
vmDataArgs[2] = "vmIP";
|
||||
vmDataArgs[3] = vmIpAddress;
|
||||
int i = 4;
|
||||
for (String[] vmDataEntry : vmData) {
|
||||
String folder = vmDataEntry[0];
|
||||
String file = vmDataEntry[1];
|
||||
String contents = (vmDataEntry[2] != null) ? vmDataEntry[2] : "none";
|
||||
String json = new Gson().toJson(data);
|
||||
s_logger.debug("VM data JSON IS:" + json);
|
||||
|
||||
vmDataArgs[i] = folder + "," + file;
|
||||
vmDataArgs[i + 1] = contents;
|
||||
i += 2;
|
||||
}
|
||||
json = Base64.encodeBase64String(json.getBytes());
|
||||
|
||||
String content = encodeDataArgs(vmDataArgs);
|
||||
String tmpFileName = UUID.randomUUID().toString();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Run vm_data command on domain router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", data: " + content);
|
||||
}
|
||||
String args = "-d " + json;
|
||||
|
||||
try {
|
||||
SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/tmp", content.getBytes(), tmpFileName, null);
|
||||
|
||||
try {
|
||||
Pair<Boolean, String> result =
|
||||
SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/userdata.py " + tmpFileName);
|
||||
|
||||
if (!result.first()) {
|
||||
s_logger.error("vm_data command on domain router " + controlIp + " failed. messge: " + result.second());
|
||||
return new Answer(cmd, false, "VmDataCommand failed due to " + result.second());
|
||||
}
|
||||
} finally {
|
||||
|
||||
SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "rm /tmp/" + tmpFileName);
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/vmdata.py " + args);
|
||||
if (!result.first()) {
|
||||
s_logger.error("vm_data command on domain router " + controlIp + " failed. messge: " + result.second());
|
||||
return new Answer(cmd, false, "VmDataCommand failed due to " + result.second());
|
||||
}
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("vm_data command on domain router " + controlIp + " completed");
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
String msg = "VmDataCommand failed due to " + e;
|
||||
String msg = "VmDataCommand failed due to " + e.getMessage();
|
||||
s_logger.error(msg, e);
|
||||
return new Answer(cmd, false, msg);
|
||||
}
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
private String encodeDataArgs(String[] dataArgs) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (String arg : dataArgs) {
|
||||
sb.append(arg);
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected Answer execute(DhcpEntryCommand cmd) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Executing resource DhcpEntryCommand: " + s_gson.toJson(cmd));
|
||||
|
|
@ -1386,6 +1297,102 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
//
|
||||
// find mac address of a specified ethx device
|
||||
// ip address show ethx | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2
|
||||
// returns
|
||||
// eth0:xx.xx.xx.xx
|
||||
|
||||
//
|
||||
// list IP with eth devices
|
||||
// ifconfig ethx |grep -B1 "inet addr" | awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }'
|
||||
// | awk -F: '{ print $1 ": " $3 }'
|
||||
//
|
||||
// returns
|
||||
// eth0:xx.xx.xx.xx
|
||||
//
|
||||
//
|
||||
|
||||
private int findRouterEthDeviceIndex(String domrName, String routerIp, String mac) throws Exception {
|
||||
|
||||
s_logger.info("findRouterEthDeviceIndex. mac: " + mac);
|
||||
|
||||
// TODO : this is a temporary very inefficient solution, will refactor it later
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
|
||||
"ls /proc/sys/net/ipv4/conf");
|
||||
|
||||
// when we dynamically plug in a new NIC into virtual router, it may take time to show up in guest OS
|
||||
// we use a waiting loop here as a workaround to synchronize activities in systems
|
||||
long startTick = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - startTick < 15000) {
|
||||
if (result.first()) {
|
||||
String[] tokens = result.second().split("\\s+");
|
||||
for (String token : tokens) {
|
||||
if (!("all".equalsIgnoreCase(token) || "default".equalsIgnoreCase(token) || "lo".equalsIgnoreCase(token))) {
|
||||
String cmd = String.format("ip address show %s | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2", token);
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Run domr script " + cmd);
|
||||
Pair<Boolean, String> result2 = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
|
||||
// TODO need to find the dev index inside router based on IP address
|
||||
cmd);
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("result: " + result2.first() + ", output: " + result2.second());
|
||||
|
||||
if (result2.first() && result2.second().trim().equalsIgnoreCase(mac.trim()))
|
||||
return Integer.parseInt(token.substring(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.warn("can not find intereface associated with mac: " + mac + ", guest OS may still at loading state, retry...");
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private Pair<Integer, String> findRouterFreeEthDeviceIndex(String routerIp) throws Exception {
|
||||
|
||||
s_logger.info("findRouterFreeEthDeviceIndex. mac: ");
|
||||
|
||||
// TODO : this is a temporary very inefficient solution, will refactor it later
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
|
||||
"ip address | grep DOWN| cut -f2 -d :");
|
||||
|
||||
// when we dynamically plug in a new NIC into virtual router, it may take time to show up in guest OS
|
||||
// we use a waiting loop here as a workaround to synchronize activities in systems
|
||||
long startTick = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - startTick < 15000) {
|
||||
if (result.first() && !result.second().isEmpty()) {
|
||||
String[] tokens = result.second().split("\\n");
|
||||
for (String token : tokens) {
|
||||
if (!("all".equalsIgnoreCase(token) || "default".equalsIgnoreCase(token) || "lo".equalsIgnoreCase(token))) {
|
||||
//String cmd = String.format("ip address show %s | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2", token);
|
||||
//TODO: don't check for eth0,1,2, as they will be empty by default.
|
||||
//String cmd = String.format("ip address show %s ", token);
|
||||
String cmd = String.format("ip address show %s | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2", token);
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Run domr script " + cmd);
|
||||
Pair<Boolean, String> result2 = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
|
||||
// TODO need to find the dev index inside router based on IP address
|
||||
cmd);
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("result: " + result2.first() + ", output: " + result2.second());
|
||||
|
||||
if (result2.first() && result2.second().trim().length() > 0)
|
||||
return new Pair<Integer, String>(Integer.parseInt(token.trim().substring(3)), result2.second().trim()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//s_logger.warn("can not find intereface associated with mac: , guest OS may still at loading state, retry...");
|
||||
|
||||
}
|
||||
|
||||
return new Pair<Integer, String>(-1, "");
|
||||
}
|
||||
|
||||
protected Answer execute(IpAssocCommand cmd) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Executing resource IPAssocCommand: " + s_gson.toJson(cmd));
|
||||
|
|
@ -1401,7 +1408,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
String controlIp = getRouterSshControlIp(cmd);
|
||||
for (IpAddressTO ip : ips) {
|
||||
assignPublicIpAddress(routerName, controlIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(), ip.getVlanGateway(),
|
||||
ip.getVlanNetmask(), ip.getVifMacAddress());
|
||||
ip.getVlanNetmask(), ip.getVifMacAddress());
|
||||
results[i++] = ip.getPublicIp() + " - success";
|
||||
}
|
||||
|
||||
|
|
@ -1419,16 +1426,97 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
return new IpAssocAnswer(cmd, results);
|
||||
}
|
||||
|
||||
protected int getVmNics(String vmName, int vlanid) {
|
||||
GetVmConfigCommand vmConfig = new GetVmConfigCommand(vmName);
|
||||
URI agentUri = null;
|
||||
int nicposition = -1;
|
||||
try {
|
||||
String cmdName = GetVmConfigCommand.class.getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (URISyntaxException e) {
|
||||
String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
s_logger.error(errMsg, e);
|
||||
}
|
||||
String ansStr = postHttpRequest(s_gson.toJson(vmConfig), agentUri);
|
||||
Answer[] result = s_gson.fromJson(ansStr, Answer[].class);
|
||||
s_logger.debug("executeRequest received response "
|
||||
+ s_gson.toJson(result));
|
||||
if (result.length > 0) {
|
||||
GetVmConfigAnswer ans = ((GetVmConfigAnswer)result[0]);
|
||||
List<NicDetails> nics = ans.getNics();
|
||||
for (NicDetails nic : nics) {
|
||||
if (nic.getVlanid() == vlanid) {
|
||||
nicposition = nics.indexOf(nic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nicposition;
|
||||
}
|
||||
|
||||
protected void modifyNicVlan(String vmName, int vlanId, String macAddress) {
|
||||
ModifyVmNicConfigCommand modifynic = new ModifyVmNicConfigCommand(vmName, vlanId, macAddress);
|
||||
URI agentUri = null;
|
||||
try {
|
||||
String cmdName = ModifyVmNicConfigCommand.class.getName();
|
||||
agentUri =
|
||||
new URI("https", null, _agentIp, _port,
|
||||
"/api/HypervResource/" + cmdName, null, null);
|
||||
} catch (URISyntaxException e) {
|
||||
String errMsg = "Could not generate URI for Hyper-V agent";
|
||||
s_logger.error(errMsg, e);
|
||||
}
|
||||
String ansStr = postHttpRequest(s_gson.toJson(modifynic), agentUri);
|
||||
Answer[] result = s_gson.fromJson(ansStr, Answer[].class);
|
||||
s_logger.debug("executeRequest received response "
|
||||
+ s_gson.toJson(result));
|
||||
if (result.length > 0) {
|
||||
ModifyVmNicConfigAnswer ans = ((ModifyVmNicConfigAnswer)result[0]);
|
||||
}
|
||||
}
|
||||
|
||||
protected void assignPublicIpAddress(final String vmName, final String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP,
|
||||
final boolean sourceNat, final String vlanId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {
|
||||
final boolean sourceNat, final String broadcastId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {
|
||||
|
||||
URI broadcastUri = BroadcastDomainType.fromString(broadcastId);
|
||||
if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
|
||||
throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + broadcastId);
|
||||
}
|
||||
int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
|
||||
|
||||
int publicNicInfo = -1;
|
||||
publicNicInfo = getVmNics(vmName, vlanId);
|
||||
|
||||
boolean addVif = false;
|
||||
if (add) {
|
||||
if (add && publicNicInfo == -1) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Plug new NIC to associate" + privateIpAddress + " to " + publicIpAddress);
|
||||
}
|
||||
addVif = true;
|
||||
} else if (!add && firstIP) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unplug NIC " + publicNicInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (addVif) {
|
||||
Pair<Integer, String> nicdevice = findRouterFreeEthDeviceIndex(privateIpAddress);
|
||||
publicNicInfo = nicdevice.first();
|
||||
if (publicNicInfo > 0) {
|
||||
modifyNicVlan(vmName, vlanId, nicdevice.second());
|
||||
// After modifying the vnic on VR, check the VR VNics config in the host and get the device position
|
||||
publicNicInfo = getVmNics(vmName, vlanId);
|
||||
// As a new nic got activated in the VR. add the entry in the NIC's table.
|
||||
networkUsage(privateIpAddress, "addVif", "eth" + publicNicInfo);
|
||||
}
|
||||
else {
|
||||
// we didn't find any eth device available in VR to configure the ip range with new VLAN
|
||||
String msg = "No Nic is available on DomR VIF to associate/disassociate IP with.";
|
||||
s_logger.error(msg);
|
||||
throw new InternalErrorException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
String args = null;
|
||||
|
|
@ -1450,8 +1538,8 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
args += publicIpAddress + "/" + cidrSize;
|
||||
|
||||
args += " -c ";
|
||||
args += "eth" + "2"; // currently hardcoding to eth 2 (which is default public ipd)//publicNicInfo.first();
|
||||
|
||||
args += "eth" + publicNicInfo;
|
||||
args += " -g ";
|
||||
args += vlanGateway;
|
||||
|
||||
|
|
@ -1464,7 +1552,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
}
|
||||
|
||||
Pair<Boolean, String> result =
|
||||
SshHelper.sshExecute(privateIpAddress, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/ipassoc.sh " + args);
|
||||
SshHelper.sshExecute(privateIpAddress, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/ipassoc.sh " + args);
|
||||
|
||||
if (!result.first()) {
|
||||
s_logger.error("ipassoc command on domain router " + privateIpAddress + " failed. message: " + result.second());
|
||||
|
|
@ -1840,7 +1928,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
sch.connect(addr);
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
s_logger.info("Could not connect to " + ipAddress + " due to " + e.toString());
|
||||
s_logger.info("Could] not connect to " + ipAddress + " due to " + e.toString());
|
||||
if (e instanceof ConnectException) {
|
||||
// if connection is refused because of VM is being started,
|
||||
// we give it more sleep time
|
||||
|
|
|
|||
|
|
@ -16,73 +16,12 @@
|
|||
// under the License.
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.Connect;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.DomainBlockStats;
|
||||
import org.libvirt.DomainInfo;
|
||||
import org.libvirt.DomainInterfaceStats;
|
||||
import org.libvirt.DomainSnapshot;
|
||||
import org.libvirt.LibvirtException;
|
||||
import org.libvirt.NodeInfo;
|
||||
|
||||
import com.ceph.rados.IoCTX;
|
||||
import com.ceph.rados.Rados;
|
||||
import com.ceph.rados.RadosException;
|
||||
import com.ceph.rbd.Rbd;
|
||||
import com.ceph.rbd.RbdException;
|
||||
import com.ceph.rbd.RbdImage;
|
||||
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImg;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImgException;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImgFile;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
import com.cloud.agent.api.AttachVolumeAnswer;
|
||||
|
|
@ -155,7 +94,6 @@ import com.cloud.agent.api.RebootCommand;
|
|||
import com.cloud.agent.api.RebootRouterCommand;
|
||||
import com.cloud.agent.api.SecurityGroupRuleAnswer;
|
||||
import com.cloud.agent.api.SecurityGroupRulesCmd;
|
||||
import com.cloud.agent.api.SetupGuestNetworkAnswer;
|
||||
import com.cloud.agent.api.SetupGuestNetworkCommand;
|
||||
import com.cloud.agent.api.StartAnswer;
|
||||
import com.cloud.agent.api.StartCommand;
|
||||
|
|
@ -174,13 +112,9 @@ import com.cloud.agent.api.check.CheckSshCommand;
|
|||
import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
|
||||
import com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer;
|
||||
import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocAnswer;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocVpcCommand;
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.agent.api.routing.SetNetworkACLAnswer;
|
||||
import com.cloud.agent.api.routing.SetNetworkACLCommand;
|
||||
import com.cloud.agent.api.routing.SetSourceNatAnswer;
|
||||
import com.cloud.agent.api.routing.SetSourceNatCommand;
|
||||
import com.cloud.agent.api.storage.CopyVolumeAnswer;
|
||||
import com.cloud.agent.api.storage.CopyVolumeCommand;
|
||||
|
|
@ -201,6 +135,7 @@ import com.cloud.agent.api.to.NicTO;
|
|||
import com.cloud.agent.api.to.StorageFilerTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.agent.resource.virtualnetwork.VirtualRouterDeployer;
|
||||
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
|
|
@ -250,17 +185,77 @@ import com.cloud.storage.template.Processor.FormatInfo;
|
|||
import com.cloud.storage.template.QCOW2Processor;
|
||||
import com.cloud.storage.template.TemplateLocation;
|
||||
import com.cloud.storage.template.TemplateProp;
|
||||
import com.cloud.utils.ExecutionResult;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.utils.script.OutputInterpreter;
|
||||
import com.cloud.utils.script.OutputInterpreter.AllLinesParser;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImg;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImgException;
|
||||
import org.apache.cloudstack.utils.qemu.QemuImgFile;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.Connect;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.DomainBlockStats;
|
||||
import org.libvirt.DomainInfo;
|
||||
import org.libvirt.DomainInterfaceStats;
|
||||
import org.libvirt.DomainSnapshot;
|
||||
import org.libvirt.LibvirtException;
|
||||
import org.libvirt.NodeInfo;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* LibvirtComputingResource execute requests on the computing/routing host using
|
||||
|
|
@ -285,7 +280,7 @@ import com.cloud.vm.VirtualMachine.State;
|
|||
* pool | the parent of the storage pool hierarchy * }
|
||||
**/
|
||||
@Local(value = {ServerResource.class})
|
||||
public class LibvirtComputingResource extends ServerResourceBase implements ServerResource {
|
||||
public class LibvirtComputingResource extends ServerResourceBase implements ServerResource, VirtualRouterDeployer {
|
||||
private static final Logger s_logger = Logger.getLogger(LibvirtComputingResource.class);
|
||||
|
||||
private String _modifyVlanPath;
|
||||
|
|
@ -322,6 +317,59 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
protected static final String DEFAULT_OVS_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.OvsVifDriver";
|
||||
protected static final String DEFAULT_BRIDGE_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver";
|
||||
|
||||
@Override
|
||||
public ExecutionResult executeInVR(String routerIp, String script, String args) {
|
||||
final Script command = new Script(_routerProxyPath, _timeout, s_logger);
|
||||
final AllLinesParser parser = new AllLinesParser();
|
||||
command.add(script);
|
||||
command.add(routerIp);
|
||||
if (args != null) {
|
||||
command.add(args);
|
||||
}
|
||||
String details = command.execute(parser);
|
||||
if (details == null) {
|
||||
details = parser.getLines();
|
||||
}
|
||||
return new ExecutionResult(command.getExitValue() == 0, details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
|
||||
File permKey = new File("/root/.ssh/id_rsa.cloud");
|
||||
String error = null;
|
||||
|
||||
try {
|
||||
SshHelper.scpTo(routerIp, 3922, "root", permKey, null, path, content.getBytes(), filename, null);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Fail to create file " + path + filename + " in VR " + routerIp, e);
|
||||
error = e.getMessage();
|
||||
}
|
||||
return new ExecutionResult(error == null, error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult prepareCommand(NetworkElementCommand cmd) {
|
||||
//Update IP used to access router
|
||||
cmd.setRouterAccessIp(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
||||
assert cmd.getRouterAccessIp() != null;
|
||||
|
||||
if (cmd instanceof IpAssocVpcCommand) {
|
||||
return prepareNetworkElementCommand((IpAssocVpcCommand)cmd);
|
||||
} else if (cmd instanceof IpAssocCommand) {
|
||||
return prepareNetworkElementCommand((IpAssocCommand)cmd);
|
||||
} else if (cmd instanceof SetupGuestNetworkCommand) {
|
||||
return prepareNetworkElementCommand((SetupGuestNetworkCommand)cmd);
|
||||
} else if (cmd instanceof SetSourceNatCommand) {
|
||||
return prepareNetworkElementCommand((SetSourceNatCommand)cmd);
|
||||
}
|
||||
return new ExecutionResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult cleanupCommand(NetworkElementCommand cmd) {
|
||||
return new ExecutionResult(true, null);
|
||||
}
|
||||
|
||||
private static final class KeyValueInterpreter extends OutputInterpreter {
|
||||
private final Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
|
|
@ -376,6 +424,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
private boolean _canBridgeFirewall;
|
||||
protected String _localStoragePath;
|
||||
protected String _localStorageUUID;
|
||||
protected boolean _noMemBalloon = false;
|
||||
protected String _guestCpuMode;
|
||||
protected String _guestCpuModel;
|
||||
private final Map<String, String> _pifs = new HashMap<String, String>();
|
||||
|
|
@ -537,7 +586,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
params.put("domr.scripts.dir", domrScriptsDir);
|
||||
|
||||
_virtRouterResource = new VirtualRoutingResource();
|
||||
_virtRouterResource = new VirtualRoutingResource(this);
|
||||
success = _virtRouterResource.configure(name, params);
|
||||
|
||||
if (!success) {
|
||||
|
|
@ -723,6 +772,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
value = (String)params.get("cmds.timeout");
|
||||
_cmdsTimeout = NumbersUtil.parseInt(value, 7200) * 1000;
|
||||
|
||||
value = (String) params.get("vm.memballoon.disable");
|
||||
if (Boolean.parseBoolean(value)) {
|
||||
_noMemBalloon = true;
|
||||
}
|
||||
|
||||
value = (String)params.get("host.reserved.mem.mb");
|
||||
_dom0MinMem = NumbersUtil.parseInt(value, 0) * 1024 * 1024;
|
||||
|
||||
|
|
@ -1258,16 +1312,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
return execute((PlugNicCommand)cmd);
|
||||
} else if (cmd instanceof UnPlugNicCommand) {
|
||||
return execute((UnPlugNicCommand)cmd);
|
||||
} else if (cmd instanceof SetupGuestNetworkCommand) {
|
||||
return execute((SetupGuestNetworkCommand)cmd);
|
||||
} else if (cmd instanceof SetNetworkACLCommand) {
|
||||
return execute((SetNetworkACLCommand)cmd);
|
||||
} else if (cmd instanceof SetSourceNatCommand) {
|
||||
return execute((SetSourceNatCommand)cmd);
|
||||
} else if (cmd instanceof IpAssocVpcCommand) {
|
||||
return execute((IpAssocVpcCommand)cmd);
|
||||
} else if (cmd instanceof IpAssocCommand) {
|
||||
return execute((IpAssocCommand)cmd);
|
||||
} else if (cmd instanceof NetworkElementCommand) {
|
||||
return _virtRouterResource.executeRequest(cmd);
|
||||
} else if (cmd instanceof CheckSshCommand) {
|
||||
|
|
@ -1977,25 +2021,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
}
|
||||
}
|
||||
|
||||
private SetupGuestNetworkAnswer execute(SetupGuestNetworkCommand cmd) {
|
||||
private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) {
|
||||
Connect conn;
|
||||
NicTO nic = cmd.getNic();
|
||||
String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String routerGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
|
||||
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
|
||||
String gateway = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
|
||||
String cidr = Long.toString(NetUtils.getCidrSize(nic.getNetmask()));
|
||||
String domainName = cmd.getNetworkDomain();
|
||||
String dns = cmd.getDefaultDns1();
|
||||
|
||||
if (dns == null || dns.isEmpty()) {
|
||||
dns = cmd.getDefaultDns2();
|
||||
} else {
|
||||
String dns2 = cmd.getDefaultDns2();
|
||||
if (dns2 != null && !dns2.isEmpty()) {
|
||||
dns += "," + dns2;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
conn = LibvirtConnection.getConnectionByVmName(routerName);
|
||||
|
|
@ -2010,62 +2039,18 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
}
|
||||
|
||||
if (routerNic == null) {
|
||||
return new SetupGuestNetworkAnswer(cmd, false, "Can not find nic with mac " + nic.getMac() + " for VM " + routerName);
|
||||
return new ExecutionResult(false, "Can not find nic with mac " + nic.getMac() + " for VM " + routerName);
|
||||
}
|
||||
|
||||
String dev = "eth" + nic.getDeviceId();
|
||||
String netmask = NetUtils.getSubNet(routerGIP, nic.getNetmask());
|
||||
String result = _virtRouterResource.assignGuestNetwork(dev, routerIP, routerGIP, gateway, cidr, netmask, dns, domainName);
|
||||
|
||||
if (result != null) {
|
||||
return new SetupGuestNetworkAnswer(cmd, false, "Creating guest network failed due to " + result);
|
||||
}
|
||||
return new SetupGuestNetworkAnswer(cmd, true, "success");
|
||||
return new ExecutionResult(true, null);
|
||||
} catch (LibvirtException e) {
|
||||
String msg = "Creating guest network failed due to " + e.toString();
|
||||
s_logger.warn(msg, e);
|
||||
return new SetupGuestNetworkAnswer(cmd, false, msg);
|
||||
return new ExecutionResult(false, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private SetNetworkACLAnswer execute(SetNetworkACLCommand cmd) {
|
||||
String[] results = new String[cmd.getRules().length];
|
||||
|
||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String privateGw = cmd.getAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY);
|
||||
|
||||
try {
|
||||
String[][] rules = cmd.generateFwRules();
|
||||
String[] aclRules = rules[0];
|
||||
NicTO nic = cmd.getNic();
|
||||
String dev = "eth" + nic.getDeviceId();
|
||||
String netmask = Long.toString(NetUtils.getCidrSize(nic.getNetmask()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < aclRules.length; i++) {
|
||||
sb.append(aclRules[i]).append(',');
|
||||
}
|
||||
|
||||
String rule = sb.toString();
|
||||
String result = _virtRouterResource.assignNetworkACL(routerIp, dev, nic.getIp(), netmask, rule, privateGw);
|
||||
|
||||
if (result != null) {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
results[i] = "Failed";
|
||||
}
|
||||
return new SetNetworkACLAnswer(cmd, false, results);
|
||||
}
|
||||
|
||||
return new SetNetworkACLAnswer(cmd, true, results);
|
||||
} catch (Exception e) {
|
||||
String msg = "SetNetworkACL failed due to " + e.toString();
|
||||
s_logger.error(msg, e);
|
||||
return new SetNetworkACLAnswer(cmd, false, results);
|
||||
}
|
||||
}
|
||||
|
||||
protected SetSourceNatAnswer execute(SetSourceNatCommand cmd) {
|
||||
protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) {
|
||||
Connect conn;
|
||||
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
|
||||
String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
|
|
@ -2086,7 +2071,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
/*skip over, no physical bridge device exists*/
|
||||
} else if (pluggedVlanId == null) {
|
||||
/*this should only be true in the case of link local bridge*/
|
||||
return new SetSourceNatAnswer(cmd, false, "unable to find the vlan id for bridge " + pluggedVlanBr + " when attempting to set up" + pubVlan +
|
||||
return new ExecutionResult(false, "unable to find the vlan id for bridge " + pluggedVlanBr + " when attempting to set up" + pubVlan +
|
||||
" on router " + routerName);
|
||||
} else if (pluggedVlanId.equals(pubVlan)) {
|
||||
break;
|
||||
|
|
@ -2094,26 +2079,20 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
devNum++;
|
||||
}
|
||||
|
||||
String dev = "eth" + devNum;
|
||||
String result = _virtRouterResource.assignSourceNat(routerIP, pubIP.getPublicIp(), dev);
|
||||
pubIP.setNicDevId(devNum);
|
||||
|
||||
if (result != null) {
|
||||
return new SetSourceNatAnswer(cmd, false, "KVM plugin \"vpc_snat\" failed:" + result);
|
||||
}
|
||||
return new SetSourceNatAnswer(cmd, true, "success");
|
||||
return new ExecutionResult(true, "success");
|
||||
} catch (LibvirtException e) {
|
||||
String msg = "Ip SNAT failure due to " + e.toString();
|
||||
s_logger.error(msg, e);
|
||||
return new SetSourceNatAnswer(cmd, false, msg);
|
||||
return new ExecutionResult(false, msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected IpAssocAnswer execute(IpAssocVpcCommand cmd) {
|
||||
protected ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) {
|
||||
Connect conn;
|
||||
String[] results = new String[cmd.getIpAddresses().length];
|
||||
int i = 0;
|
||||
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
|
||||
String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
|
||||
try {
|
||||
conn = LibvirtConnection.getConnectionByVmName(routerName);
|
||||
|
|
@ -2136,31 +2115,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
}
|
||||
|
||||
for (IpAddressTO ip : ips) {
|
||||
String nicName = "eth" + broadcastUriToNicNum.get(ip.getBroadcastUri());
|
||||
String netmask = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
|
||||
String subnet = NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
|
||||
_virtRouterResource.assignVpcIpToRouter(routerIP, ip.isAdd(), ip.getPublicIp(), nicName, ip.getVlanGateway(), netmask, subnet, ip.isSourceNat());
|
||||
results[i++] = ip.getPublicIp() + " - success";
|
||||
ip.setNicDevId(broadcastUriToNicNum.get(ip.getBroadcastUri()));
|
||||
}
|
||||
|
||||
return new ExecutionResult(true, null);
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.error("Ip Assoc failure on applying one ip due to exception: ", e);
|
||||
results[i++] = IpAssocAnswer.errorResult;
|
||||
} catch (InternalErrorException e) {
|
||||
s_logger.error("Ip Assoc failure on applying one ip due to exception: ", e);
|
||||
results[i++] = IpAssocAnswer.errorResult;
|
||||
return new ExecutionResult(false, e.getMessage());
|
||||
}
|
||||
|
||||
return new IpAssocAnswer(cmd, results);
|
||||
}
|
||||
|
||||
public Answer execute(IpAssocCommand cmd) {
|
||||
public ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) {
|
||||
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
|
||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String[] results = new String[cmd.getIpAddresses().length];
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
results[i] = IpAssocAnswer.errorResult;
|
||||
}
|
||||
Connect conn;
|
||||
try {
|
||||
conn = LibvirtConnection.getConnectionByVmName(routerName);
|
||||
|
|
@ -2182,11 +2149,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
nicPos++;
|
||||
}
|
||||
IpAddressTO[] ips = cmd.getIpAddresses();
|
||||
int i = 0;
|
||||
String result = null;
|
||||
int nicNum = 0;
|
||||
boolean newNic = false;
|
||||
for (IpAddressTO ip : ips) {
|
||||
boolean newNic = false;
|
||||
if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) {
|
||||
/* plug a vif into router */
|
||||
VifHotPlug(conn, routerName, ip.getBroadcastUri(), ip.getVifMacAddress());
|
||||
|
|
@ -2195,21 +2160,17 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
}
|
||||
nicNum = broadcastUriAllocatedToVM.get(ip.getBroadcastUri());
|
||||
networkUsage(routerIp, "addVif", "eth" + nicNum);
|
||||
result =
|
||||
_virtRouterResource.assignPublicIpAddress(routerName, routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(),
|
||||
ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(), nicNum, newNic);
|
||||
|
||||
if (result == null) {
|
||||
results[i++] = ip.getPublicIp() + " - success";
|
||||
}
|
||||
ip.setNicDevId(nicNum);
|
||||
ip.setNewNic(newNic);
|
||||
}
|
||||
return new IpAssocAnswer(cmd, results);
|
||||
return new ExecutionResult(true, null);
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.error("ipassoccmd failed", e);
|
||||
return new IpAssocAnswer(cmd, results);
|
||||
return new ExecutionResult(false, e.getMessage());
|
||||
} catch (InternalErrorException e) {
|
||||
s_logger.error("ipassoccmd failed", e);
|
||||
return new IpAssocAnswer(cmd, results);
|
||||
return new ExecutionResult(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2972,10 +2933,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
dconn = new Connect("qemu+tcp://" + cmd.getDestinationIp() + "/system");
|
||||
/*
|
||||
* Hard code lm flags: VIR_MIGRATE_LIVE(1<<0) and
|
||||
* VIR_MIGRATE_PERSIST_DEST(1<<3)
|
||||
* Hard code lm flag: VIR_MIGRATE_LIVE(1<<0)
|
||||
*/
|
||||
destDomain = dm.migrate(dconn, (1 << 0) | (1 << 3), xmlDesc, vmName, "tcp:" + cmd.getDestinationIp(), _migrateSpeed);
|
||||
destDomain = dm.migrate(dconn, (1 << 0), xmlDesc, vmName, "tcp:" + cmd.getDestinationIp(), _migrateSpeed);
|
||||
|
||||
_storagePoolMgr.disconnectPhysicalDisksViaVmSpec(cmd.getVirtualMachine());
|
||||
} catch (LibvirtException e) {
|
||||
|
|
@ -3143,8 +3103,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
String[] splitResult = result.split(":");
|
||||
int i = 0;
|
||||
while (i < splitResult.length - 1) {
|
||||
stats[0] += (new Long(splitResult[i++])).longValue();
|
||||
stats[1] += (new Long(splitResult[i++])).longValue();
|
||||
stats[0] += Long.parseLong(splitResult[i++]);
|
||||
stats[1] += Long.parseLong(splitResult[i++]);
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
|
|
@ -3185,8 +3145,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
String[] splitResult = result.split(":");
|
||||
int i = 0;
|
||||
while (i < splitResult.length - 1) {
|
||||
stats[0] += (new Long(splitResult[i++])).longValue();
|
||||
stats[1] += (new Long(splitResult[i++])).longValue();
|
||||
stats[0] += Long.parseLong(splitResult[i++]);
|
||||
stats[1] += Long.parseLong(splitResult[i++]);
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
|
|
@ -3472,7 +3432,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
GuestResourceDef grd = new GuestResourceDef();
|
||||
|
||||
if (vmTO.getMinRam() != vmTO.getMaxRam()) {
|
||||
if (vmTO.getMinRam() != vmTO.getMaxRam() && !_noMemBalloon) {
|
||||
grd.setMemBalloning(true);
|
||||
grd.setCurrentMem(vmTO.getMinRam() / 1024);
|
||||
grd.setMemorySize(vmTO.getMaxRam() / 1024);
|
||||
|
|
|
|||
|
|
@ -162,6 +162,8 @@ public class LibvirtVMDef {
|
|||
}
|
||||
if (_memBalloning) {
|
||||
resBuidler.append("<devices>\n" + "<memballoon model='virtio'/>\n" + "</devices>\n");
|
||||
} else {
|
||||
resBuidler.append("<devices>\n" + "<memballoon model='none'/>\n" + "</devices>\n");
|
||||
}
|
||||
if (_vcpu != -1) {
|
||||
resBuidler.append("<vcpu>" + _vcpu + "</vcpu>\n");
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
LibvirtStoragePool libvirtPool = (LibvirtStoragePool)pool;
|
||||
|
||||
try {
|
||||
StorageVol vol = this.getVolume(libvirtPool.getPool(), volumeUuid);
|
||||
StorageVol vol = getVolume(libvirtPool.getPool(), volumeUuid);
|
||||
KVMPhysicalDisk disk;
|
||||
LibvirtStorageVolumeDef voldef = getStorageVolumeDef(libvirtPool.getPool().getConnect(), vol);
|
||||
disk = new KVMPhysicalDisk(vol.getPath(), vol.getName(), pool);
|
||||
|
|
@ -471,7 +471,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
String targetPath = pdef.getTargetPath();
|
||||
if (targetPath != null && targetPath.equals(path)) {
|
||||
s_logger.debug("Storage pool utilizing path '" + path + "' already exists as pool " + poolname +
|
||||
", undefining so we can re-define with correct name " + name);
|
||||
", undefining so we can re-define with correct name " + name);
|
||||
if (p.isPersistent() == 1) {
|
||||
p.destroy();
|
||||
p.undefine();
|
||||
|
|
@ -527,8 +527,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
String error = e.toString();
|
||||
if (error.contains("Storage source conflict")) {
|
||||
throw new CloudRuntimeException("A pool matching this location already exists in libvirt, " +
|
||||
" but has a different UUID/Name. Cannot create new pool without first " + " removing it. Check for inactive pools via 'virsh pool-list --all'. " +
|
||||
error);
|
||||
" but has a different UUID/Name. Cannot create new pool without first " + " removing it. Check for inactive pools via 'virsh pool-list --all'. " +
|
||||
error);
|
||||
} else {
|
||||
throw new CloudRuntimeException(error);
|
||||
}
|
||||
|
|
@ -556,7 +556,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
/*
|
||||
* Some storage pools, like RBD also have 'secret' information stored in libvirt
|
||||
* Destroy them if they exist
|
||||
*/
|
||||
*/
|
||||
try {
|
||||
s = conn.secretLookupByUUIDString(uuid);
|
||||
} catch (LibvirtException e) {
|
||||
|
|
@ -580,7 +580,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
if (e.toString().contains("exit status 16")) {
|
||||
String targetPath = _mountPoint + File.separator + uuid;
|
||||
s_logger.error("deleteStoragePool removed pool from libvirt, but libvirt had trouble" + "unmounting the pool. Trying umount location " + targetPath +
|
||||
"again in a few seconds");
|
||||
"again in a few seconds");
|
||||
String result = Script.runSimpleBashScript("sleep 5 && umount " + targetPath);
|
||||
if (result == null) {
|
||||
s_logger.error("Succeeded in unmounting " + targetPath);
|
||||
|
|
@ -624,7 +624,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
|
||||
IoCTX io = r.ioCtxCreate(pool.getSourceDir());
|
||||
Rbd rbd = new Rbd(io);
|
||||
rbd.create(name, size, this.rbdFeatures, this.rbdOrder);
|
||||
rbd.create(name, size, rbdFeatures, rbdOrder);
|
||||
|
||||
r.ioCtxDestroy(io);
|
||||
} catch (RadosException e) {
|
||||
|
|
@ -702,7 +702,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
try {
|
||||
Connect conn = LibvirtConnection.getConnection();
|
||||
|
||||
StoragePool pool = conn.storagePoolLookupByUUIDString(poolUuid);
|
||||
conn.storagePoolLookupByUUIDString(poolUuid);
|
||||
|
||||
deleteStoragePool(poolUuid);
|
||||
|
||||
|
|
@ -753,7 +753,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
|
||||
LibvirtStoragePool libvirtPool = (LibvirtStoragePool)pool;
|
||||
try {
|
||||
StorageVol vol = this.getVolume(libvirtPool.getPool(), uuid);
|
||||
StorageVol vol = getVolume(libvirtPool.getPool(), uuid);
|
||||
deleteVol(libvirtPool, vol);
|
||||
vol.free();
|
||||
return true;
|
||||
|
|
@ -784,7 +784,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
So for RBD we don't create the image, but let qemu-img do that for us.
|
||||
|
||||
We then create a KVMPhysicalDisk object that we can return
|
||||
*/
|
||||
*/
|
||||
try {
|
||||
if (destPool.getType() != StoragePoolType.RBD) {
|
||||
disk = destPool.createPhysicalDisk(newUuid, format, template.getVirtualSize());
|
||||
|
|
@ -815,8 +815,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
QemuImg qemu = new QemuImg(timeout);
|
||||
QemuImgFile srcFile;
|
||||
QemuImgFile destFile =
|
||||
new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(), destPool.getSourcePort(), destPool.getAuthUserName(),
|
||||
destPool.getAuthSecret(), disk.getPath()));
|
||||
new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(), destPool.getSourcePort(), destPool.getAuthUserName(),
|
||||
destPool.getAuthSecret(), disk.getPath()));
|
||||
destFile.setFormat(format);
|
||||
|
||||
if (srcPool.getType() != StoragePoolType.RBD) {
|
||||
|
|
@ -850,9 +850,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
if (srcImage.isOldFormat()) {
|
||||
/* The source image is RBD format 1, we have to do a regular copy */
|
||||
s_logger.debug("The source image " + srcPool.getSourceDir() + "/" + template.getName() +
|
||||
" is RBD format 1. We have to perform a regular copy (" + template.getVirtualSize() + " bytes)");
|
||||
" is RBD format 1. We have to perform a regular copy (" + template.getVirtualSize() + " bytes)");
|
||||
|
||||
rbd.create(disk.getName(), template.getVirtualSize(), this.rbdFeatures, this.rbdOrder);
|
||||
rbd.create(disk.getName(), template.getVirtualSize(), rbdFeatures, rbdOrder);
|
||||
RbdImage destImage = rbd.open(disk.getName());
|
||||
|
||||
s_logger.debug("Starting to copy " + srcImage.getName() + " to " + destImage.getName() + " in Ceph pool " + srcPool.getSourceDir());
|
||||
|
|
@ -862,10 +862,10 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
rbd.close(destImage);
|
||||
} else {
|
||||
s_logger.debug("The source image " + srcPool.getSourceDir() + "/" + template.getName() +
|
||||
" is RBD format 2. We will perform a RBD clone using snapshot " + this.rbdTemplateSnapName);
|
||||
" is RBD format 2. We will perform a RBD clone using snapshot " + rbdTemplateSnapName);
|
||||
/* The source image is format 2, we can do a RBD snapshot+clone (layering) */
|
||||
rbd.clone(template.getName(), this.rbdTemplateSnapName, io, disk.getName(), this.rbdFeatures, this.rbdOrder);
|
||||
s_logger.debug("Succesfully cloned " + template.getName() + "@" + this.rbdTemplateSnapName + " to " + disk.getName());
|
||||
rbd.clone(template.getName(), rbdTemplateSnapName, io, disk.getName(), rbdFeatures, rbdOrder);
|
||||
s_logger.debug("Succesfully cloned " + template.getName() + "@" + rbdTemplateSnapName + " to " + disk.getName());
|
||||
}
|
||||
|
||||
rbd.close(srcImage);
|
||||
|
|
@ -893,14 +893,14 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
Rbd dRbd = new Rbd(dIO);
|
||||
|
||||
s_logger.debug("Creating " + disk.getName() + " on the destination cluster " + rDest.confGet("mon_host") + " in pool " +
|
||||
destPool.getSourceDir());
|
||||
dRbd.create(disk.getName(), template.getVirtualSize(), this.rbdFeatures, this.rbdOrder);
|
||||
destPool.getSourceDir());
|
||||
dRbd.create(disk.getName(), template.getVirtualSize(), rbdFeatures, rbdOrder);
|
||||
|
||||
RbdImage srcImage = sRbd.open(template.getName());
|
||||
RbdImage destImage = dRbd.open(disk.getName());
|
||||
|
||||
s_logger.debug("Copying " + template.getName() + " from Ceph cluster " + rSrc.confGet("mon_host") + " to " + disk.getName() + " on cluster " +
|
||||
rDest.confGet("mon_host"));
|
||||
rDest.confGet("mon_host"));
|
||||
sRbd.copy(srcImage, destImage);
|
||||
|
||||
sRbd.close(srcImage);
|
||||
|
|
@ -923,7 +923,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
}
|
||||
|
||||
if (disk == null) {
|
||||
throw new CloudRuntimeException("Failed to create " + disk.getPath() + " from template " + template.getName());
|
||||
throw new CloudRuntimeException("Failed to create disk from template " + template.getName());
|
||||
}
|
||||
|
||||
return disk;
|
||||
|
|
@ -942,7 +942,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
try {
|
||||
String[] vols = virtPool.listVolumes();
|
||||
for (String volName : vols) {
|
||||
KVMPhysicalDisk disk = this.getPhysicalDisk(volName, pool);
|
||||
KVMPhysicalDisk disk = getPhysicalDisk(volName, pool);
|
||||
disks.add(disk);
|
||||
}
|
||||
return disks;
|
||||
|
|
@ -1036,11 +1036,11 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
}
|
||||
} else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD)) {
|
||||
/**
|
||||
* Qemu doesn't support writing to RBD format 2 directly, so we have to write to a temporary RAW file first
|
||||
* which we then convert to RBD format 2.
|
||||
*
|
||||
* A HUGE performance gain can be achieved here if QCOW2 -> RBD format 2 can be done in one step
|
||||
*/
|
||||
* Qemu doesn't support writing to RBD format 2 directly, so we have to write to a temporary RAW file first
|
||||
* which we then convert to RBD format 2.
|
||||
*
|
||||
* A HUGE performance gain can be achieved here if QCOW2 -> RBD format 2 can be done in one step
|
||||
*/
|
||||
s_logger.debug("The source image is not RBD, but the destination is. We will convert into RBD format 2");
|
||||
String sourceFile;
|
||||
boolean useTmpFile = false;
|
||||
|
|
@ -1069,7 +1069,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
Rbd rbd = new Rbd(io);
|
||||
|
||||
s_logger.debug("Creating RBD image " + name + " in Ceph pool " + destPool.getSourceDir() + " with RBD format 2");
|
||||
rbd.create(name, disk.getVirtualSize(), this.rbdFeatures, this.rbdOrder);
|
||||
rbd.create(name, disk.getVirtualSize(), rbdFeatures, rbdOrder);
|
||||
|
||||
RbdImage image = rbd.open(name);
|
||||
|
||||
|
|
@ -1098,10 +1098,10 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
}
|
||||
|
||||
/* Snapshot the image and protect that snapshot so we can clone (layer) from it */
|
||||
s_logger.debug("Creating RBD snapshot " + this.rbdTemplateSnapName + " on image " + name);
|
||||
image.snapCreate(this.rbdTemplateSnapName);
|
||||
s_logger.debug("Protecting RBD snapshot " + this.rbdTemplateSnapName + " on image " + name);
|
||||
image.snapProtect(this.rbdTemplateSnapName);
|
||||
s_logger.debug("Creating RBD snapshot " + rbdTemplateSnapName + " on image " + name);
|
||||
image.snapCreate(rbdTemplateSnapName);
|
||||
s_logger.debug("Protecting RBD snapshot " + rbdTemplateSnapName + " on image " + name);
|
||||
image.snapProtect(rbdTemplateSnapName);
|
||||
|
||||
rbd.close(image);
|
||||
r.ioCtxDestroy(io);
|
||||
|
|
@ -1125,8 +1125,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
it doesn't benefit us. It's better to keep the current code in place which works
|
||||
*/
|
||||
srcFile =
|
||||
new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(srcPool.getSourceHost(), srcPool.getSourcePort(), srcPool.getAuthUserName(), srcPool.getAuthSecret(),
|
||||
sourcePath));
|
||||
new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(srcPool.getSourceHost(), srcPool.getSourcePort(), srcPool.getAuthUserName(), srcPool.getAuthSecret(),
|
||||
sourcePath));
|
||||
srcFile.setFormat(sourceFormat);
|
||||
destFile = new QemuImgFile(destPath);
|
||||
destFile.setFormat(destFormat);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.usage;
|
||||
|
||||
public class LibvirtSecretDefTest extends TestCase {
|
||||
|
||||
public void testVolumeSecretDef() {
|
||||
String uuid = "db66f42b-a79e-4666-9910-9dfc8a024427";
|
||||
String name = "myEncryptedQCOW2";
|
||||
usage use = usage.VOLUME;
|
||||
|
||||
LibvirtSecretDef def = new LibvirtSecretDef(use, uuid);
|
||||
def.setVolumeVolume(name);
|
||||
|
||||
String expectedXml = "<secret ephemeral='no' private='no'>\n<uuid>" + uuid + "</uuid>\n" +
|
||||
"<usage type='" + use.toString() + "'>\n<volume>" + name + "</volume>\n</usage>\n</secret>\n";
|
||||
|
||||
assertEquals(expectedXml, def.toString());
|
||||
}
|
||||
|
||||
public void testCephSecretDef() {
|
||||
String uuid = "a9febe83-ac5c-467a-bf19-eb75325ec23c";
|
||||
String name = "admin";
|
||||
usage use = usage.CEPH;
|
||||
|
||||
LibvirtSecretDef def = new LibvirtSecretDef(use, uuid);
|
||||
def.setCephName(name);
|
||||
|
||||
String expectedXml = "<secret ephemeral='no' private='no'>\n<uuid>" + uuid + "</uuid>\n" +
|
||||
"<usage type='" + use.toString() + "'>\n<name>" + name + "</name>\n</usage>\n</secret>\n";
|
||||
|
||||
assertEquals(expectedXml, def.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.poolType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.authType;
|
||||
|
||||
public class LibvirtStoragePoolDefTest extends TestCase {
|
||||
|
||||
public void testSetGetStoragePool() {
|
||||
poolType type = poolType.NETFS;
|
||||
String name = "myNFSPool";
|
||||
String uuid = "d7846cb0-f610-4a5b-8d38-ee6e8d63f37b";
|
||||
String host = "127.0.0.1";
|
||||
String dir = "/export/primary";
|
||||
String targetPath = "/mnt/" + uuid;
|
||||
int port = 1234;
|
||||
|
||||
LibvirtStoragePoolDef pool = new LibvirtStoragePoolDef(type, name, uuid, host, port, dir, targetPath);
|
||||
|
||||
assertEquals(type, pool.getPoolType());
|
||||
assertEquals(name, pool.getPoolName());
|
||||
assertEquals(host, pool.getSourceHost());
|
||||
assertEquals(port, pool.getSourcePort());
|
||||
assertEquals(dir, pool.getSourceDir());
|
||||
assertEquals(targetPath, pool.getTargetPath());
|
||||
}
|
||||
|
||||
public void testNfsStoragePool() {
|
||||
poolType type = poolType.NETFS;
|
||||
String name = "myNFSPool";
|
||||
String uuid = "89a605bc-d470-4637-b3df-27388be452f5";
|
||||
String host = "127.0.0.1";
|
||||
String dir = "/export/primary";
|
||||
String targetPath = "/mnt/" + uuid;
|
||||
|
||||
LibvirtStoragePoolDef pool = new LibvirtStoragePoolDef(type, name, uuid, host, dir, targetPath);
|
||||
|
||||
String expectedXml = "<pool type='" + type.toString() + "'>\n<name>" + name + "</name>\n<uuid>" + uuid + "</uuid>\n" +
|
||||
"<source>\n<host name='" + host + "'/>\n<dir path='" + dir + "'/>\n</source>\n<target>\n" +
|
||||
"<path>" + targetPath + "</path>\n</target>\n</pool>\n";
|
||||
|
||||
assertEquals(expectedXml, pool.toString());
|
||||
}
|
||||
|
||||
public void testRbdStoragePool() {
|
||||
poolType type = poolType.RBD;
|
||||
String name = "myRBDPool";
|
||||
String uuid = "921ef8b2-955a-4c18-a697-66bb9adf6131";
|
||||
String host = "127.0.0.1";
|
||||
String dir = "cloudstackrbdpool";
|
||||
String authUsername = "admin";
|
||||
String secretUuid = "08c2fa02-50d0-4a78-8903-b742d3f34934";
|
||||
authType auth = authType.CEPH;
|
||||
int port = 6789;
|
||||
|
||||
LibvirtStoragePoolDef pool = new LibvirtStoragePoolDef(type, name, uuid, host, port, dir, authUsername, auth, secretUuid);
|
||||
|
||||
String expectedXml = "<pool type='" + type.toString() + "'>\n<name>" + name + "</name>\n<uuid>" + uuid + "</uuid>\n" +
|
||||
"<source>\n<host name='" + host + "' port='" + port + "'/>\n<name>" + dir + "</name>\n" +
|
||||
"<auth username='" + authUsername + "' type='" + auth.toString() + "'>\n<secret uuid='" + secretUuid + "'/>\n" +
|
||||
"</auth>\n</source>\n</pool>\n";
|
||||
|
||||
assertEquals(expectedXml, pool.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,8 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.user.AccountManager;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -87,6 +89,7 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
|
|||
MockStorageManager _storageMgr = null;
|
||||
@Inject
|
||||
ResourceManager _resourceMgr;
|
||||
@Inject private AccountManager _accountMgr;
|
||||
|
||||
SimulatorSecondaryDiscoverer discoverer;
|
||||
@Inject
|
||||
|
|
@ -303,8 +306,10 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
|
|||
@Override
|
||||
@DB
|
||||
public void run() {
|
||||
CallContext.register(_accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
if (this.mode.equalsIgnoreCase("Stop")) {
|
||||
handleSystemVMStop();
|
||||
CallContext.unregister();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -359,10 +364,12 @@ public class MockAgentManagerImpl extends ManagerBase implements MockAgentManage
|
|||
_resourceMgr.discoverHosts(cmd);
|
||||
} catch (DiscoveryException e) {
|
||||
s_logger.debug("Failed to discover host: " + e.toString());
|
||||
CallContext.unregister();
|
||||
return;
|
||||
}
|
||||
} catch (ConfigurationException e) {
|
||||
s_logger.debug("Failed to load secondary storage resource: " + e.toString());
|
||||
CallContext.unregister();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
||||
}
|
||||
String updatedInventoryPath = validateCluster(url, vmwareDc);
|
||||
if (url.getPath() != updatedInventoryPath) {
|
||||
if (!url.getPath().equals(updatedInventoryPath)) {
|
||||
// If url from API doesn't specify DC then update url in database with DC associated with this zone.
|
||||
clusterDetails.put("url", url.getScheme() + "://" + url.getHost() + updatedInventoryPath);
|
||||
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -957,7 +957,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
|
||||
String backupUuid = UUID.randomUUID().toString();
|
||||
Pair<String, String[]> snapshotInfo = exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, installPath, backupUuid, workerVmName);
|
||||
return new Ternary<String, String, String[]>(backupUuid + "/" + backupUuid, snapshotInfo.first(), snapshotInfo.second());
|
||||
return new Ternary<String, String, String[]>(backupUuid, snapshotInfo.first(), snapshotInfo.second());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1040,8 +1040,25 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
answer = new CopyCmdAnswer(details);
|
||||
} else {
|
||||
details = "Successfully backedUp the snapshot with Uuid: " + snapshotUuid + " to secondary storage.";
|
||||
|
||||
// Get snapshot physical size
|
||||
long physicalSize = 0l;
|
||||
String secondaryMountPoint = mountService.getMountPoint(secondaryStorageUrl);
|
||||
String snapshotDir = destSnapshot.getPath() + "/" + snapshotBackupUuid;
|
||||
File[] files = new File(secondaryMountPoint + "/" + snapshotDir).listFiles();
|
||||
if(files != null) {
|
||||
for(File file : files) {
|
||||
String fileName = file.getName();
|
||||
if(fileName.toLowerCase().startsWith(snapshotBackupUuid) && fileName.toLowerCase().endsWith(".vmdk")) {
|
||||
physicalSize = new File(secondaryMountPoint + "/" + snapshotDir + "/" + fileName).length();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
|
||||
newSnapshot.setPath(destSnapshot.getPath() + "/" + snapshotBackupUuid);
|
||||
newSnapshot.setPath(snapshotDir + "/" + snapshotBackupUuid);
|
||||
newSnapshot.setPhysicalSize(physicalSize);
|
||||
answer = new CopyCmdAnswer(newSnapshot);
|
||||
}
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy {
|
|||
try {
|
||||
VMInstanceVO instance = instanceDao.findById(vmTo.getId());
|
||||
if (instance != null) {
|
||||
if (srcHost.getClusterId() == destHost.getClusterId()) {
|
||||
if (srcHost.getClusterId().equals(destHost.getClusterId())) {
|
||||
answer = migrateVmWithVolumesWithinCluster(instance, vmTo, srcHost, destHost, volumeMap);
|
||||
} else {
|
||||
answer = migrateVmWithVolumesAcrossCluster(instance, vmTo, srcHost, destHost, volumeMap);
|
||||
|
|
@ -119,7 +119,7 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy {
|
|||
}
|
||||
|
||||
private Answer migrateVmWithVolumesAcrossCluster(VMInstanceVO vm, VirtualMachineTO to, Host srcHost, Host destHost, Map<VolumeInfo, DataStore> volumeToPool)
|
||||
throws AgentUnavailableException {
|
||||
throws AgentUnavailableException {
|
||||
|
||||
// Initiate migration of a virtual machine with it's volumes.
|
||||
try {
|
||||
|
|
@ -157,7 +157,7 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy {
|
|||
}
|
||||
|
||||
private Answer migrateVmWithVolumesWithinCluster(VMInstanceVO vm, VirtualMachineTO to, Host srcHost, Host destHost, Map<VolumeInfo, DataStore> volumeToPool)
|
||||
throws AgentUnavailableException {
|
||||
throws AgentUnavailableException {
|
||||
|
||||
// Initiate migration of a virtual machine with it's volumes.
|
||||
try {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -16,25 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.hypervisor.xen.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
import com.xensource.xenapi.Connection;
|
||||
import com.xensource.xenapi.Host;
|
||||
import com.xensource.xenapi.Network;
|
||||
import com.xensource.xenapi.PIF;
|
||||
import com.xensource.xenapi.Types.IpConfigurationMode;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
import com.xensource.xenapi.VLAN;
|
||||
import com.xensource.xenapi.VM;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckOnHostAnswer;
|
||||
import com.cloud.agent.api.CheckOnHostCommand;
|
||||
|
|
@ -47,6 +28,22 @@ import com.cloud.agent.api.StartupCommand;
|
|||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.xensource.xenapi.Connection;
|
||||
import com.xensource.xenapi.Host;
|
||||
import com.xensource.xenapi.Network;
|
||||
import com.xensource.xenapi.PIF;
|
||||
import com.xensource.xenapi.Types.IpConfigurationMode;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
import com.xensource.xenapi.VLAN;
|
||||
import com.xensource.xenapi.VM;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Local(value = ServerResource.class)
|
||||
public class XenServer56Resource extends CitrixResourceBase {
|
||||
|
|
@ -127,7 +124,7 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
|
||||
@Override
|
||||
protected String networkUsage(Connection conn, final String privateIpAddress, final String option, final String vif) {
|
||||
String args = "netusage.sh " + privateIpAddress + " ";
|
||||
String args = "";
|
||||
if (option.equals("get")) {
|
||||
args += "-g";
|
||||
} else if (option.equals("create")) {
|
||||
|
|
@ -142,7 +139,7 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
args += vif;
|
||||
}
|
||||
|
||||
return callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
return executeInVR(privateIpAddress, "netusage.sh", args).getDetails();
|
||||
}
|
||||
|
||||
protected NetworkUsageAnswer VPCNetworkUsage(NetworkUsageCommand cmd) {
|
||||
|
|
@ -151,8 +148,7 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
String option = cmd.getOption();
|
||||
String publicIp = cmd.getGatewayIP();
|
||||
|
||||
String args = "vpc_netusage.sh " + cmd.getPrivateIP();
|
||||
args += " -l " + publicIp + " ";
|
||||
String args = " -l " + publicIp + " ";
|
||||
if (option.equals("get")) {
|
||||
args += "-g";
|
||||
} else if (option.equals("create")) {
|
||||
|
|
@ -169,7 +165,7 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
|
||||
}
|
||||
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
String result = executeInVR(cmd.getPrivateIP(), "vpc_netusage.sh", args).getDetails();
|
||||
if (option.equals("get") || option.equals("vpn")) {
|
||||
long[] stats = new long[2];
|
||||
if (result != null) {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
|
|||
try {
|
||||
VMInstanceVO instance = instanceDao.findById(vmTo.getId());
|
||||
if (instance != null) {
|
||||
if (srcHost.getClusterId() == destHost.getClusterId()) {
|
||||
if (srcHost.getClusterId().equals(destHost.getClusterId())) {
|
||||
answer = migrateVmWithVolumesWithinCluster(instance, vmTo, srcHost, destHost, volumeMap);
|
||||
} else {
|
||||
answer = migrateVmWithVolumesAcrossCluster(instance, vmTo, srcHost, destHost, volumeMap);
|
||||
|
|
@ -126,7 +126,7 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
|
|||
}
|
||||
|
||||
private Answer migrateVmWithVolumesAcrossCluster(VMInstanceVO vm, VirtualMachineTO to, Host srcHost, Host destHost, Map<VolumeInfo, DataStore> volumeToPool)
|
||||
throws AgentUnavailableException {
|
||||
throws AgentUnavailableException {
|
||||
|
||||
// Initiate migration of a virtual machine with it's volumes.
|
||||
try {
|
||||
|
|
@ -153,7 +153,7 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
|
|||
}
|
||||
|
||||
MigrateWithStorageSendCommand sendCmd =
|
||||
new MigrateWithStorageSendCommand(to, receiveAnswer.getVolumeToSr(), receiveAnswer.getNicToNetwork(), receiveAnswer.getToken());
|
||||
new MigrateWithStorageSendCommand(to, receiveAnswer.getVolumeToSr(), receiveAnswer.getNicToNetwork(), receiveAnswer.getToken());
|
||||
MigrateWithStorageSendAnswer sendAnswer = (MigrateWithStorageSendAnswer)agentMgr.send(srcHost.getId(), sendCmd);
|
||||
if (sendAnswer == null) {
|
||||
s_logger.error("Migration with storage of vm " + vm + " to host " + destHost + " failed.");
|
||||
|
|
@ -184,7 +184,7 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
|
|||
}
|
||||
|
||||
private Answer migrateVmWithVolumesWithinCluster(VMInstanceVO vm, VirtualMachineTO to, Host srcHost, Host destHost, Map<VolumeInfo, DataStore> volumeToPool)
|
||||
throws AgentUnavailableException {
|
||||
throws AgentUnavailableException {
|
||||
|
||||
// Initiate migration of a virtual machine with it's volumes.
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@
|
|||
<artifactId>cloud-framework-events</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-spring-lifecycle</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# 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.
|
||||
name=contrail
|
||||
parent=network
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
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/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"
|
||||
>
|
||||
<bean id="ContrailManager"
|
||||
class="org.apache.cloudstack.network.contrail.management.ContrailManagerImpl"/>
|
||||
<bean id="ContrailElement"
|
||||
class="org.apache.cloudstack.network.contrail.management.ContrailElementImpl">
|
||||
<property name="name" value="ContrailElement"/>
|
||||
</bean>
|
||||
<bean id="ContrailVpcElement"
|
||||
class="org.apache.cloudstack.network.contrail.management.ContrailVpcElementImpl">
|
||||
<property name="name" value="ContrailVpcElement"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ContrailGuru"
|
||||
class="org.apache.cloudstack.network.contrail.management.ContrailGuru">
|
||||
<property name="name" value="ContrailGuru"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ServerDBSync"
|
||||
class="org.apache.cloudstack.network.contrail.management.ServerDBSyncImpl"/>
|
||||
<bean id="ServerEventHandler"
|
||||
class="org.apache.cloudstack.network.contrail.management.ServerEventHandlerImpl"/>
|
||||
<bean id="EventUtils"
|
||||
class="org.apache.cloudstack.network.contrail.management.EventUtils"/>
|
||||
<bean id="ServiceManager"
|
||||
class="org.apache.cloudstack.network.contrail.management.ServiceManagerImpl"/>
|
||||
|
||||
</beans>
|
||||
|
|
@ -26,7 +26,6 @@ import java.util.Set;
|
|||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -90,12 +89,6 @@ public class ContrailElementImpl extends AdapterBase
|
|||
ServerDBSync _dbSync;
|
||||
private static final Logger s_logger = Logger.getLogger(ContrailElement.class);
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
s_logger.debug("configure");
|
||||
return true;
|
||||
}
|
||||
|
||||
// PluggableService
|
||||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.cloudstack.network.contrail.management;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ejb.Local;
|
||||
|
|
@ -54,6 +55,8 @@ import com.cloud.network.guru.NetworkGuru;
|
|||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
|
|
@ -94,7 +97,7 @@ public class ContrailGuru extends AdapterBase implements NetworkGuru {
|
|||
|
||||
private boolean canHandle(NetworkOffering offering, NetworkType networkType, PhysicalNetwork physicalNetwork) {
|
||||
if (networkType == NetworkType.Advanced
|
||||
&& offering.getId() == _manager.getRouterOffering().getId()
|
||||
&& (offering.getId() == _manager.getRouterOffering().getId() || offering.getId() == _manager.getVpcRouterOffering().getId())
|
||||
&& isMyTrafficType(offering.getTrafficType())
|
||||
&& offering.getGuestType() == Network.GuestType.Isolated
|
||||
&& physicalNetwork.getIsolationMethods().contains("L3VPN"))
|
||||
|
|
@ -148,6 +151,25 @@ public class ContrailGuru extends AdapterBase implements NetworkGuru {
|
|||
return network;
|
||||
}
|
||||
_manager.getDatabase().getVirtualNetworks().add(vnModel);
|
||||
|
||||
if (network.getVpcId() != null) {
|
||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedVpc(network.getVpcId(), true);
|
||||
if (ips.isEmpty()) {
|
||||
s_logger.debug("Creating a source nat ip for network " + network);
|
||||
Account owner = _accountMgr.getAccount(network.getAccountId());
|
||||
try {
|
||||
PublicIp publicIp = _ipAddrMgr.assignSourceNatIpAddressToGuestNetwork(owner, network);
|
||||
IPAddressVO ip = publicIp.ip();
|
||||
ip.setVpcId(network.getVpcId());
|
||||
_ipAddressDao.acquireInLockTable(ip.getId());
|
||||
_ipAddressDao.update(ip.getId(), ip);
|
||||
_ipAddressDao.releaseFromLockTable(ip.getId());
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unable to allocate source nat ip: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return network;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,19 @@ import com.cloud.network.dao.PhysicalNetworkVO;
|
|||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.projects.ProjectVO;
|
||||
import com.cloud.network.vpc.NetworkACLVO;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
|
||||
public interface ContrailManager {
|
||||
public static final String routerOfferingName = "Juniper Contrail Network Offering";
|
||||
public static final String routerOfferingDisplayText = "Juniper Contrail Network Offering";
|
||||
public static final String routerPublicOfferingName = "Juniper Contrail Public Network Offering";
|
||||
public static final String routerPublicOfferingDisplayText = "Juniper Contrail Public Network Offering";
|
||||
public static final String vpcRouterOfferingName = "Juniper Contrail VPC Network Offering";
|
||||
public static final String vpcRouterOfferingDisplayText = "Juniper Contrail VPC Network Offering";
|
||||
public static final String juniperVPCOfferingName = "Juniper Contrail VPC Offering";
|
||||
public static final String juniperVPCOfferingDisplayText = "Juniper Contrail VPC Offering";
|
||||
|
||||
public static final int DB_SYNC_INTERVAL_DEFAULT = 600000;
|
||||
public static final String VNC_ROOT_DOMAIN = "default-domain";
|
||||
public static final String VNC_DEFAULT_PROJECT = "default-project";
|
||||
|
|
@ -51,6 +58,8 @@ public interface ContrailManager {
|
|||
|
||||
public NetworkOffering getRouterOffering();
|
||||
public NetworkOffering getPublicRouterOffering();
|
||||
public NetworkOffering getVpcRouterOffering();
|
||||
public VpcOffering getVpcOffering();
|
||||
|
||||
public void syncNetworkDB(short syncMode) throws IOException;
|
||||
|
||||
|
|
@ -116,6 +125,8 @@ public interface ContrailManager {
|
|||
|
||||
public List<IPAddressVO> findManagedPublicIps();
|
||||
|
||||
public List<VpcVO> findManagedVpcs();
|
||||
|
||||
public List<NetworkACLVO> findManagedACLs();
|
||||
|
||||
public VirtualNetwork findDefaultVirtualNetwork(TrafficType trafficType) throws IOException;
|
||||
|
|
|
|||
|
|
@ -81,6 +81,12 @@ import com.cloud.offerings.NetworkOfferingVO;
|
|||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.projects.ProjectVO;
|
||||
import com.cloud.network.vpc.dao.NetworkACLDao;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
import com.cloud.network.vpc.VpcOfferingVO;
|
||||
import com.cloud.network.vpc.VpcProvisioningService;
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
import com.cloud.network.vpc.NetworkACLVO;
|
||||
import com.cloud.projects.dao.ProjectDao;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -132,6 +138,12 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
@Inject
|
||||
UserVmDao _vmDao;
|
||||
@Inject
|
||||
VpcOfferingDao _vpcOffDao;
|
||||
@Inject
|
||||
VpcProvisioningService _vpcProvSvc;
|
||||
@Inject
|
||||
VpcDao _vpcDao;
|
||||
@Inject
|
||||
NetworkACLDao _networkAclDao;
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(ContrailManager.class);
|
||||
|
|
@ -141,6 +153,9 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
private NetworkOffering _offering;
|
||||
private NetworkOffering _routerOffering;
|
||||
private NetworkOffering _routerPublicOffering;
|
||||
private NetworkOffering _vpcRouterOffering;
|
||||
private VpcOffering _vpcOffering;
|
||||
|
||||
private Timer _dbSyncTimer;
|
||||
private int _dbSyncInterval = DB_SYNC_INTERVAL_DEFAULT;
|
||||
private final String configuration = "contrail.properties";
|
||||
|
|
@ -175,7 +190,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
return _database;
|
||||
}
|
||||
|
||||
private NetworkOffering LocatePublicNetworkOffering(String offeringName,
|
||||
private NetworkOffering locatePublicNetworkOffering(String offeringName,
|
||||
String offeringDisplayText, Provider provider) {
|
||||
List<? extends NetworkOffering> offerList = _configService.listNetworkOfferings(TrafficType.Public, false);
|
||||
for (NetworkOffering offer: offerList) {
|
||||
|
|
@ -210,7 +225,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
return _networkOfferingDao.findById(id);
|
||||
}
|
||||
|
||||
private NetworkOffering LocateNetworkOffering(String offeringName,
|
||||
private NetworkOffering locateNetworkOffering(String offeringName,
|
||||
String offeringDisplayText, Provider provider) {
|
||||
List<? extends NetworkOffering> offerList = _configService.listNetworkOfferings(TrafficType.Guest, false);
|
||||
for (NetworkOffering offer : offerList) {
|
||||
|
|
@ -239,6 +254,38 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
return _networkOfferingDao.findById(id);
|
||||
}
|
||||
|
||||
private VpcOffering locateVpcOffering() {
|
||||
VpcOffering vpcOffer = _vpcOffDao.findByUniqueName(juniperVPCOfferingName);
|
||||
if (vpcOffer != null) {
|
||||
if (((VpcOfferingVO)vpcOffer).getState() == VpcOffering.State.Enabled) {
|
||||
return vpcOffer;
|
||||
}
|
||||
((VpcOfferingVO)vpcOffer).setState(VpcOffering.State.Enabled);
|
||||
long id = vpcOffer.getId();
|
||||
_vpcOffDao.update(id, (VpcOfferingVO)vpcOffer);
|
||||
return vpcOffer;
|
||||
}
|
||||
Map<String, List<String>> serviceProviderMap = new HashMap<String, List<String>>();
|
||||
List<String> providerSet = new ArrayList<String>();
|
||||
providerSet.add(Provider.JuniperContrailVpcRouter.getName());
|
||||
final List<String> services = new ArrayList<String>();
|
||||
services.add(Service.Connectivity.getName());
|
||||
services.add(Service.Dhcp.getName());
|
||||
services.add(Service.NetworkACL.getName());
|
||||
services.add(Service.StaticNat.getName());
|
||||
services.add(Service.SourceNat.getName());
|
||||
services.add(Service.Gateway.getName());
|
||||
|
||||
for (String svc: services) {
|
||||
serviceProviderMap.put(svc, providerSet);
|
||||
}
|
||||
vpcOffer = _vpcProvSvc.createVpcOffering(juniperVPCOfferingName, juniperVPCOfferingDisplayText, services, serviceProviderMap, null);
|
||||
((VpcOfferingVO)vpcOffer).setState(VpcOffering.State.Enabled);
|
||||
long id = vpcOffer.getId();
|
||||
_vpcOffDao.update(id, (VpcOfferingVO)vpcOffer);
|
||||
return _vpcOffDao.findById(id);
|
||||
}
|
||||
|
||||
private NetworkOffering EnableNetworkOffering(long id) {
|
||||
NetworkOfferingVO offering = _networkOfferingDao.createForUpdate(id);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
|
|
@ -281,10 +328,13 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
|
||||
_controller = new ModelController(this, _api, _vmDao, _networksDao, _nicDao, _vlanDao, _ipAddressDao);
|
||||
|
||||
_routerOffering = LocateNetworkOffering(routerOfferingName, routerOfferingDisplayText,
|
||||
_routerOffering = locateNetworkOffering(routerOfferingName, routerOfferingDisplayText,
|
||||
Provider.JuniperContrailRouter);
|
||||
_routerPublicOffering = LocatePublicNetworkOffering(routerPublicOfferingName, routerPublicOfferingDisplayText,
|
||||
_routerPublicOffering = locatePublicNetworkOffering(routerPublicOfferingName, routerPublicOfferingDisplayText,
|
||||
Provider.JuniperContrailRouter);
|
||||
_vpcRouterOffering = locateNetworkOffering(vpcRouterOfferingName, vpcRouterOfferingDisplayText,
|
||||
Provider.JuniperContrailVpcRouter);
|
||||
_vpcOffering = locateVpcOffering();
|
||||
|
||||
_eventHandler.subscribe();
|
||||
|
||||
|
|
@ -303,6 +353,16 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
return _routerOffering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOffering getVpcRouterOffering() {
|
||||
return _vpcRouterOffering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VpcOffering getVpcOffering() {
|
||||
return _vpcOffering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPhysicalNetworkName(PhysicalNetworkVO physNet) {
|
||||
String physname = physNet.getName();
|
||||
|
|
@ -465,7 +525,8 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
public boolean isManagedPhysicalNetwork(Network network) {
|
||||
List<PhysicalNetworkVO> net_list = _physicalNetworkDao.listByZone(network.getDataCenterId());
|
||||
for (PhysicalNetworkVO phys : net_list) {
|
||||
if (_physProviderDao.findByServiceProvider(phys.getId(), Network.Provider.JuniperContrailRouter.getName()) != null) {
|
||||
if(_physProviderDao.findByServiceProvider(phys.getId(), Provider.JuniperContrailRouter.getName()) != null ||
|
||||
_physProviderDao.findByServiceProvider(phys.getId(), Provider.JuniperContrailVpcRouter.getName()) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -564,6 +625,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
SearchCriteria<NetworkVO> sc = searchBuilder.create();
|
||||
List<Long> offerings = new ArrayList<Long>();
|
||||
offerings.add(getRouterOffering().getId());
|
||||
offerings.add(getVpcRouterOffering().getId());
|
||||
offerings.add(getPublicRouterOffering().getId());
|
||||
sc.setParameters("networkOfferingId", offerings.toArray());
|
||||
|
||||
|
|
@ -585,9 +647,11 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
|
||||
List<PhysicalNetworkVO> phys_list = _physicalNetworkDao.listAll();
|
||||
final String provider = Network.Provider.JuniperContrailRouter.getName();
|
||||
final String vpcProvider = Provider.JuniperContrailVpcRouter.getName();
|
||||
for (Iterator<PhysicalNetworkVO> iter = phys_list.iterator(); iter.hasNext();) {
|
||||
PhysicalNetworkVO phys = iter.next();
|
||||
if (_physProviderDao.findByServiceProvider(phys.getId(), provider) != null) {
|
||||
if (_physProviderDao.findByServiceProvider(phys.getId(), provider) != null ||
|
||||
_physProviderDao.findByServiceProvider(phys.getId(), vpcProvider) != null) {
|
||||
List<NetworkVO> infraNets = new ArrayList<NetworkVO>();
|
||||
findInfrastructureNetworks(phys, infraNets);
|
||||
for (NetworkVO net : infraNets) {
|
||||
|
|
@ -611,10 +675,51 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
return dbNets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VpcVO> findManagedVpcs() {
|
||||
SearchBuilder<VpcVO> searchBuilder = _vpcDao.createSearchBuilder();
|
||||
searchBuilder.and("vpcOffering", searchBuilder.entity().getVpcOfferingId(), Op.EQ);
|
||||
SearchCriteria<VpcVO> sc = searchBuilder.create();
|
||||
sc.setParameters("vpcOffering", getVpcOffering().getId());
|
||||
List<VpcVO> vpcs = _vpcDao.search(sc, null);
|
||||
if (vpcs == null || vpcs.size() == 0) {
|
||||
s_logger.debug("no vpcs found");
|
||||
return null;
|
||||
}
|
||||
return vpcs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkACLVO> findManagedACLs() {
|
||||
/* contrail vpc is not yet implemented */
|
||||
return null;
|
||||
List<VpcVO> vpcs = findManagedVpcs();
|
||||
if (vpcs == null || vpcs.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<Long> vpcIds = new ArrayList<Long>();
|
||||
/* default-allow, default-deny ACLs will be under vpcId '0', so include it*/
|
||||
vpcIds.add((long)0);
|
||||
for (VpcVO vpc:vpcs) {
|
||||
vpcIds.add(vpc.getId());
|
||||
}
|
||||
SearchBuilder<NetworkACLVO> searchBuilder = _networkAclDao.createSearchBuilder();
|
||||
searchBuilder.and("vpcId", searchBuilder.entity().getVpcId(), Op.IN);
|
||||
SearchCriteria<NetworkACLVO> sc = searchBuilder.create();
|
||||
sc.setParameters("vpcId", vpcIds.toArray());
|
||||
List<NetworkACLVO> acls = _networkAclDao.search(sc, null);
|
||||
if (acls == null || acls.size() == 0) {
|
||||
s_logger.debug("no acls found");
|
||||
return null;
|
||||
}
|
||||
/* only return if acl is associated to any network */
|
||||
List<NetworkACLVO> jnprAcls = new ArrayList<NetworkACLVO>();
|
||||
for (NetworkACLVO acl:acls) {
|
||||
List<NetworkVO> nets = _networksDao.listByAclId(acl.getId());
|
||||
if (nets == null || nets.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
jnprAcls.add(acl);
|
||||
}
|
||||
return jnprAcls;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,199 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.network.contrail.management;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.network.contrail.model.VirtualNetworkModel;
|
||||
import org.apache.cloudstack.network.contrail.model.NetworkPolicyModel;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.element.NetworkACLServiceProvider;
|
||||
import com.cloud.network.element.VpcProvider;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.vpc.NetworkACLVO;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.StaticRouteProfile;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.dao.NetworkACLDao;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
|
||||
@Component
|
||||
@Local(value = {NetworkACLServiceProvider.class, VpcProvider.class, ContrailElementImpl.class})
|
||||
public class ContrailVpcElementImpl extends ContrailElementImpl implements NetworkACLServiceProvider, VpcProvider {
|
||||
private static final Logger s_logger =
|
||||
Logger.getLogger(ContrailElement.class);
|
||||
|
||||
@Inject
|
||||
NetworkACLDao _networkACLDao;
|
||||
|
||||
// NetworkElement API
|
||||
@Override
|
||||
public Provider getProvider() {
|
||||
return Provider.JuniperContrailVpcRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implementVpc(Vpc vpc, DeployDestination dest,
|
||||
ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
s_logger.debug("NetworkElement implementVpc");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdownVpc(Vpc vpc, ReservationContext context)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
s_logger.debug("NetworkElement shutdownVpc");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPrivateGateway(PrivateGateway gateway)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
s_logger.debug("NetworkElement createPrivateGateway");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePrivateGateway(PrivateGateway privateGateway)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
s_logger.debug("NetworkElement deletePrivateGateway");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticRoutes(Vpc vpc, List<StaticRouteProfile> routes)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
s_logger.debug("NetworkElement applyStaticRoutes");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyNetworkACLs(Network net,
|
||||
List<? extends NetworkACLItem> rules)
|
||||
throws ResourceUnavailableException {
|
||||
s_logger.debug("NetworkElement applyNetworkACLs");
|
||||
if (rules == null || rules.isEmpty()) {
|
||||
s_logger.debug("no rules to apply");
|
||||
return true;
|
||||
}
|
||||
|
||||
Long aclId = rules.get(0).getAclId();
|
||||
NetworkACLVO acl = _networkACLDao.findById(aclId);
|
||||
NetworkPolicyModel policyModel = _manager.getDatabase().lookupNetworkPolicy(acl.getUuid());
|
||||
if (policyModel == null) {
|
||||
/*
|
||||
* For the first time, when a CS ACL applied to a network, create a network-policy in VNC
|
||||
* and when there are no networks associated to CS ACL, delete it from VNC.
|
||||
*/
|
||||
policyModel = new NetworkPolicyModel(acl.getUuid(), acl.getName());
|
||||
net.juniper.contrail.api.types.Project project;
|
||||
try {
|
||||
project = _manager.getVncProject(net.getDomainId(), net.getAccountId());
|
||||
if (project == null) {
|
||||
project = _manager.getDefaultVncProject();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
s_logger.warn("read project", ex);
|
||||
return false;
|
||||
}
|
||||
policyModel.setProject(project);
|
||||
}
|
||||
|
||||
VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(net.getUuid(),
|
||||
_manager.getCanonicalName(net), net.getTrafficType());
|
||||
NetworkPolicyModel oldPolicyModel = null;
|
||||
/* this method is called when network is destroyed too, hence vn model might have been deleted already */
|
||||
if (vnModel != null) {
|
||||
oldPolicyModel = vnModel.getNetworkPolicyModel();
|
||||
vnModel.addToNetworkPolicy(policyModel);
|
||||
}
|
||||
|
||||
try {
|
||||
policyModel.build(_manager.getModelController(), rules);
|
||||
} catch (Exception e) {
|
||||
s_logger.error(e);
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!policyModel.verify(_manager.getModelController())) {
|
||||
policyModel.update(_manager.getModelController());
|
||||
}
|
||||
_manager.getDatabase().getNetworkPolicys().add(policyModel);
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("network-policy update: ", ex);
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!policyModel.hasPolicyRules()) {
|
||||
try {
|
||||
policyModel.delete(_manager.getModelController());
|
||||
_manager.getDatabase().getNetworkPolicys().remove(policyModel);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if no other VNs are associated with the old policy,
|
||||
* we could delete it from the Contrail VNC
|
||||
*/
|
||||
if (policyModel != oldPolicyModel && oldPolicyModel != null && !oldPolicyModel.hasDescendents()) {
|
||||
try {
|
||||
oldPolicyModel.delete(_manager.getModelController());
|
||||
_manager.getDatabase().getNetworkPolicys().remove(oldPolicyModel);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyACLItemsToPrivateGw(PrivateGateway privateGateway,
|
||||
List<? extends NetworkACLItem> rules)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
s_logger.debug("NetworkElement applyACLItemsToPrivateGw");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -68,6 +68,8 @@ import com.cloud.network.vpc.NetworkACLItemDao;
|
|||
import com.cloud.network.vpc.NetworkACLItemVO;
|
||||
import com.cloud.network.vpc.NetworkACLVO;
|
||||
import com.cloud.network.vpc.dao.NetworkACLDao;
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.projects.ProjectVO;
|
||||
import com.cloud.projects.dao.ProjectDao;
|
||||
import com.cloud.vm.NicVO;
|
||||
|
|
@ -97,6 +99,8 @@ public class ServerDBSyncImpl implements ServerDBSync {
|
|||
@Inject
|
||||
ContrailManager _manager;
|
||||
@Inject
|
||||
VpcDao _vpcDao;
|
||||
@Inject
|
||||
NetworkACLItemDao _networkACLItemDao;
|
||||
@Inject
|
||||
NetworkACLDao _networkACLDao;
|
||||
|
|
@ -990,7 +994,12 @@ public class ServerDBSyncImpl implements ServerDBSync {
|
|||
NetworkPolicyModel policyModel = new NetworkPolicyModel(db.getUuid(), db.getName());
|
||||
net.juniper.contrail.api.types.Project project = null;
|
||||
try {
|
||||
project = _manager.getDefaultVncProject();
|
||||
VpcVO vpc = _vpcDao.findById(db.getVpcId());
|
||||
if (vpc != null) {
|
||||
project = _manager.getVncProject(vpc.getDomainId(), vpc.getAccountId());
|
||||
} else {
|
||||
project = _manager.getDefaultVncProject();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
s_logger.warn("read project", ex);
|
||||
throw ex;
|
||||
|
|
@ -1055,7 +1064,12 @@ public class ServerDBSyncImpl implements ServerDBSync {
|
|||
NetworkPolicyModel policyModel = new NetworkPolicyModel(db.getUuid(), db.getName());
|
||||
net.juniper.contrail.api.types.Project project = null;
|
||||
try {
|
||||
project = _manager.getDefaultVncProject();
|
||||
VpcVO vpc = _vpcDao.findById(db.getVpcId());
|
||||
if (vpc != null) {
|
||||
project = _manager.getVncProject(vpc.getDomainId(), vpc.getAccountId());
|
||||
} else {
|
||||
project = _manager.getDefaultVncProject();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
s_logger.warn("read project", ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class NetworkPolicyModel extends ModelObjectBase {
|
|||
|
||||
SearchCriteria<NetworkVO> sc = searchBuilder.create();
|
||||
|
||||
sc.setParameters("networkOfferingId", controller.getManager().getRouterOffering().getId());
|
||||
sc.setParameters("networkOfferingId", controller.getManager().getVpcRouterOffering().getId());
|
||||
sc.setParameters("cidr", cidr);
|
||||
sc.setParameters("trafficType", Networks.TrafficType.Guest);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,14 +45,17 @@ import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDaoImpl;
|
|||
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DcDetailsDaoImpl;
|
||||
import org.apache.cloudstack.engine.orchestration.NetworkOrchestrator;
|
||||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepotAdmin;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl;
|
||||
|
|
@ -65,6 +68,7 @@ import org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl;
|
|||
import org.apache.cloudstack.framework.jobs.impl.AsyncJobMonitor;
|
||||
import org.apache.cloudstack.framework.jobs.impl.SyncQueueManager;
|
||||
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDaoImpl;
|
||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElement;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
|
||||
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
|
||||
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
|
||||
|
|
@ -73,6 +77,9 @@ import org.apache.cloudstack.region.PortableIpDaoImpl;
|
|||
import org.apache.cloudstack.region.PortableIpRangeDaoImpl;
|
||||
import org.apache.cloudstack.region.RegionManager;
|
||||
import org.apache.cloudstack.region.dao.RegionDaoImpl;
|
||||
import org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
|
||||
import org.apache.cloudstack.storage.image.db.ImageStoreDaoImpl;
|
||||
import org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl;
|
||||
|
|
@ -120,6 +127,7 @@ import com.cloud.dc.dao.AccountVlanMapDaoImpl;
|
|||
import com.cloud.dc.dao.ClusterDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterDetailsDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterVnetDaoImpl;
|
||||
|
|
@ -141,11 +149,11 @@ import com.cloud.host.dao.HostDetailsDaoImpl;
|
|||
import com.cloud.host.dao.HostTagsDaoImpl;
|
||||
import com.cloud.hypervisor.HypervisorGuruManagerImpl;
|
||||
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl;
|
||||
import com.cloud.hypervisor.XenServerGuru;
|
||||
import com.cloud.network.ExternalDeviceUsageManager;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.IpAddressManagerImpl;
|
||||
import com.cloud.network.Ipv6AddressManagerImpl;
|
||||
import com.cloud.network.NetworkModelImpl;
|
||||
import com.cloud.network.NetworkServiceImpl;
|
||||
import com.cloud.network.NetworkUsageService;
|
||||
import com.cloud.network.StorageNetworkManager;
|
||||
|
|
@ -161,6 +169,7 @@ import com.cloud.network.as.dao.CounterDaoImpl;
|
|||
import com.cloud.network.dao.AccountGuestVlanMapDaoImpl;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
|
||||
import com.cloud.network.dao.FirewallRulesDaoImpl;
|
||||
import com.cloud.network.dao.IPAddressDaoImpl;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LBHealthCheckPolicyDaoImpl;
|
||||
import com.cloud.network.dao.LBStickinessPolicyDaoImpl;
|
||||
|
|
@ -183,7 +192,11 @@ import com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl;
|
|||
import com.cloud.network.dao.UserIpv6AddressDaoImpl;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.element.FirewallServiceProvider;
|
||||
import com.cloud.network.element.NetworkACLServiceProvider;
|
||||
import com.cloud.network.element.PortForwardingServiceProvider;
|
||||
import com.cloud.network.element.Site2SiteVpnServiceProvider;
|
||||
import com.cloud.network.element.VpcProvider;
|
||||
import com.cloud.network.firewall.FirewallManagerImpl;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManagerImpl;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManagerImpl;
|
||||
|
|
@ -234,7 +247,7 @@ import com.cloud.storage.VolumeApiService;
|
|||
import com.cloud.storage.dao.DiskOfferingDaoImpl;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDaoImpl;
|
||||
import com.cloud.storage.dao.GuestOSDaoImpl;
|
||||
import com.cloud.storage.dao.LaunchPermissionDao;
|
||||
import com.cloud.storage.dao.LaunchPermissionDaoImpl;
|
||||
import com.cloud.storage.dao.SnapshotDaoImpl;
|
||||
import com.cloud.storage.dao.SnapshotPolicyDaoImpl;
|
||||
import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
|
||||
|
|
@ -271,10 +284,13 @@ import com.cloud.utils.db.Transaction;
|
|||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.vm.ItWorkDaoImpl;
|
||||
import com.cloud.vm.UserVmManagerImpl;
|
||||
import com.cloud.vm.VirtualMachineManagerImpl;
|
||||
import com.cloud.vm.dao.ConsoleProxyDaoImpl;
|
||||
import com.cloud.vm.dao.DomainRouterDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupVMMapDaoImpl;
|
||||
import com.cloud.vm.dao.NicDaoImpl;
|
||||
import com.cloud.vm.dao.NicIpAliasDaoImpl;
|
||||
import com.cloud.vm.dao.NicSecondaryIpDaoImpl;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDaoImpl;
|
||||
|
|
@ -291,19 +307,19 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl;
|
|||
AsyncJobJournalDaoImpl.class, AsyncJobManagerImpl.class, AutoScalePolicyConditionMapDaoImpl.class, AutoScalePolicyDaoImpl.class, AutoScaleVmGroupDaoImpl.class,
|
||||
AutoScaleVmGroupPolicyMapDaoImpl.class, AutoScaleVmProfileDaoImpl.class, CapacityDaoImpl.class, ClusterDaoImpl.class, ClusterDetailsDaoImpl.class,
|
||||
ConditionDaoImpl.class, ConfigurationDaoImpl.class, ConfigurationManagerImpl.class, ConfigurationServerImpl.class, ConsoleProxyDaoImpl.class,
|
||||
ContrailElementImpl.class, ContrailGuru.class, ContrailManagerImpl.class, CounterDaoImpl.class, DataCenterDaoImpl.class, DataCenterIpAddressDaoImpl.class,
|
||||
ContrailElementImpl.class, ContrailGuru.class, ContrailManagerImpl.class, CounterDaoImpl.class, DataCenterDaoImpl.class, DataCenterDetailsDaoImpl.class, DataCenterIpAddressDaoImpl.class,
|
||||
DataCenterJoinDaoImpl.class, DataCenterLinkLocalIpAddressDaoImpl.class, DataCenterVnetDaoImpl.class, DcDetailsDaoImpl.class, DedicatedResourceDaoImpl.class,
|
||||
DiskOfferingDaoImpl.class, DiskOfferingJoinDaoImpl.class, DomainDaoImpl.class, DomainManagerImpl.class, DomainRouterDaoImpl.class, DomainRouterJoinDaoImpl.class,
|
||||
EventDaoImpl.class, EventJoinDaoImpl.class, EventUtils.class, EventUtils.class, FirewallManagerImpl.class, FirewallRulesCidrsDaoImpl.class,
|
||||
EventDaoImpl.class, EventJoinDaoImpl.class, EventUtils.class, ExtensionRegistry.class, FirewallManagerImpl.class, FirewallRulesCidrsDaoImpl.class,
|
||||
FirewallRulesDaoImpl.class, GuestOSCategoryDaoImpl.class, GuestOSDaoImpl.class, HostDaoImpl.class, HostDetailsDaoImpl.class, HostJoinDaoImpl.class,
|
||||
HostPodDaoImpl.class, HostTagsDaoImpl.class, HostTransferMapDaoImpl.class, HypervisorCapabilitiesDaoImpl.class, HypervisorGuruManagerImpl.class,
|
||||
ImageStoreDaoImpl.class, ImageStoreJoinDaoImpl.class, InstanceGroupDaoImpl.class, InstanceGroupJoinDaoImpl.class,
|
||||
InstanceGroupVMMapDaoImpl.class, IpAddressManagerImpl.class, Ipv6AddressManagerImpl.class, ItWorkDaoImpl.class, LBHealthCheckPolicyDaoImpl.class,
|
||||
LBStickinessPolicyDaoImpl.class, LaunchPermissionDao.class, LoadBalancerDaoImpl.class, LoadBalancerVMMapDaoImpl.class, LoadBalancingRulesManagerImpl.class,
|
||||
InstanceGroupVMMapDaoImpl.class, InternalLoadBalancerElement.class, IPAddressDaoImpl.class, IpAddressManagerImpl.class, Ipv6AddressManagerImpl.class, ItWorkDaoImpl.class, LBHealthCheckPolicyDaoImpl.class,
|
||||
LBStickinessPolicyDaoImpl.class, LaunchPermissionDaoImpl.class, LoadBalancerDaoImpl.class, LoadBalancerVMMapDaoImpl.class, LoadBalancingRulesManagerImpl.class,
|
||||
ManagementServerHostDaoImpl.class, MockAccountManager.class, NetworkACLDaoImpl.class, NetworkACLItemDaoImpl.class, NetworkACLManagerImpl.class,
|
||||
NetworkAccountDaoImpl.class, NetworkDaoImpl.class, NetworkDomainDaoImpl.class, NetworkModelImpl.class, NetworkOfferingDaoImpl.class,
|
||||
NetworkOfferingDetailsDaoImpl.class, NetworkOfferingServiceMapDaoImpl.class, NetworkOpDaoImpl.class, NetworkRuleConfigDaoImpl.class, NetworkServiceImpl.class,
|
||||
NetworkServiceMapDaoImpl.class, NicIpAliasDaoImpl.class, NicSecondaryIpDaoImpl.class, PhysicalNetworkDaoImpl.class, PhysicalNetworkServiceProviderDaoImpl.class,
|
||||
NetworkAccountDaoImpl.class, NetworkDaoImpl.class, NetworkDomainDaoImpl.class, NetworkOfferingDaoImpl.class,
|
||||
NetworkOfferingDetailsDaoImpl.class, NetworkOfferingServiceMapDaoImpl.class, NetworkOpDaoImpl.class, NetworkOrchestrator.class, NetworkRuleConfigDaoImpl.class, NetworkServiceImpl.class,
|
||||
NetworkServiceMapDaoImpl.class, NicDaoImpl.class, NicIpAliasDaoImpl.class, NicSecondaryIpDaoImpl.class, PhysicalNetworkDaoImpl.class, PhysicalNetworkServiceProviderDaoImpl.class,
|
||||
PhysicalNetworkTrafficTypeDaoImpl.class, PlannerHostReservationDaoImpl.class, PodVlanDaoImpl.class, PodVlanMapDaoImpl.class, PortForwardingRulesDaoImpl.class,
|
||||
PortableIpDaoImpl.class, PortableIpRangeDaoImpl.class, PrimaryDataStoreDaoImpl.class, PrivateIpDaoImpl.class, ProjectAccountDaoImpl.class,
|
||||
ProjectAccountJoinDaoImpl.class, ProjectInvitationDaoImpl.class, ProjectDaoImpl.class, ProjectInvitationJoinDaoImpl.class, ProjectJoinDaoImpl.class,
|
||||
|
|
@ -315,11 +331,11 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl;
|
|||
SnapshotDaoImpl.class, SnapshotPolicyDaoImpl.class, StaticRouteDaoImpl.class, StatsCollector.class, StoragePoolDetailsDaoImpl.class, StoragePoolHostDaoImpl.class,
|
||||
StoragePoolJoinDaoImpl.class, SyncQueueItemDaoImpl.class, TemplateDataStoreDaoImpl.class, TemplateJoinDaoImpl.class, UploadDaoImpl.class, UsageEventDaoImpl.class,
|
||||
UserAccountJoinDaoImpl.class, UserDaoImpl.class, UserIpv6AddressDaoImpl.class, UserStatisticsDaoImpl.class, UserStatsLogDaoImpl.class,
|
||||
UserVmCloneSettingDaoImpl.class, UserVmDaoImpl.class, UserVmDetailsDaoImpl.class, UserVmJoinDaoImpl.class, VMInstanceDaoImpl.class, VMSnapshotDaoImpl.class,
|
||||
VMTemplateDaoImpl.class, VMTemplateDetailsDaoImpl.class, VMTemplateHostDaoImpl.class, VMTemplateZoneDaoImpl.class, VirtualRouterProviderDaoImpl.class,
|
||||
UserVmCloneSettingDaoImpl.class, UserVmDaoImpl.class, UserVmDetailsDaoImpl.class, UserVmJoinDaoImpl.class, UserVmManagerImpl.class, VMInstanceDaoImpl.class, VMSnapshotDaoImpl.class,
|
||||
VMTemplateDaoImpl.class, VMTemplateDetailsDaoImpl.class, VMTemplateHostDaoImpl.class, VMTemplateZoneDaoImpl.class, VirtualMachineManagerImpl.class, VirtualRouterProviderDaoImpl.class,
|
||||
VlanDaoImpl.class, VmDiskStatisticsDaoImpl.class, VmRulesetLogDaoImpl.class, VolumeDaoImpl.class, VolumeHostDaoImpl.class, VolumeJoinDaoImpl.class, VpcDaoImpl.class,
|
||||
VpcGatewayDaoImpl.class, VpcManagerImpl.class, VpcOfferingDaoImpl.class, VpcOfferingServiceMapDaoImpl.class, VpcServiceMapDaoImpl.class,
|
||||
VpcVirtualNetworkApplianceManagerImpl.class, VpnUserDaoImpl.class}, includeFilters = {@Filter(value = IntegrationTestConfiguration.ComponentFilter.class,
|
||||
VpcVirtualNetworkApplianceManagerImpl.class, VpnUserDaoImpl.class, XenServerGuru.class}, includeFilters = {@Filter(value = IntegrationTestConfiguration.ComponentFilter.class,
|
||||
type = FilterType.CUSTOM)}, useDefaultFilters = false)
|
||||
@Configuration
|
||||
public class IntegrationTestConfiguration {
|
||||
|
|
@ -711,5 +727,36 @@ public class IntegrationTestConfiguration {
|
|||
public VolumeOrchestrationService volumeOrchestrationService() {
|
||||
return Mockito.mock(VolumeOrchestrationService.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FirewallServiceProvider firewallServiceProvider() {
|
||||
return Mockito.mock(FirewallServiceProvider.class);
|
||||
}
|
||||
@Bean
|
||||
public PortForwardingServiceProvider portForwardingServiceProvider() {
|
||||
return Mockito.mock(PortForwardingServiceProvider.class);
|
||||
}
|
||||
@Bean
|
||||
public NetworkACLServiceProvider networkACLServiceProvider() {
|
||||
return Mockito.mock(NetworkACLServiceProvider.class);
|
||||
}
|
||||
@Bean
|
||||
public VpcProvider vpcProvier() {
|
||||
return Mockito.mock(VpcProvider.class);
|
||||
}
|
||||
@Bean
|
||||
public VolumeService volumeService() {
|
||||
return Mockito.mock(VolumeService.class);
|
||||
}
|
||||
@Bean
|
||||
public PrimaryDataStoreProviderManager privateDataStoreProviderManager() {
|
||||
return Mockito.mock(PrimaryDataStoreProviderManager.class);
|
||||
}
|
||||
@Bean
|
||||
public ImageStoreProviderManager imageStoreProviderManager() {
|
||||
return Mockito.mock(ImageStoreProviderManager.class);
|
||||
}
|
||||
@Bean
|
||||
public DataStoreProvider dataStoreProvider() {
|
||||
return Mockito.mock(DataStoreProvider.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ public class ManagementServerMock {
|
|||
_znet = _networkService.getPhysicalNetwork(id);
|
||||
List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
|
||||
if (nets == null || nets.isEmpty()) {
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), null, null, null, null, null, null);
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), "vlan", null, null, null, null, null, null);
|
||||
}
|
||||
} catch (InvalidParameterValueException e) {
|
||||
List<String> isolationMethods = new ArrayList<String>();
|
||||
|
|
@ -337,7 +337,7 @@ public class ManagementServerMock {
|
|||
"znet");
|
||||
List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
|
||||
if (nets == null || nets.isEmpty()) {
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), null, null, null, null, null, null);
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), "vlan", null, null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
if (_znet.getState() != PhysicalNetwork.State.Enabled) {
|
||||
|
|
@ -353,7 +353,7 @@ public class ManagementServerMock {
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Guest.toString(), null, null, null, null, null, null);
|
||||
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Guest.toString(), "vlan", null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> providers =
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
|
|||
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.api.query.dao.AccountJoinDao;
|
||||
import com.cloud.configuration.ResourceLimit;
|
||||
import com.cloud.configuration.dao.ResourceCountDao;
|
||||
import com.cloud.domain.Domain;
|
||||
|
|
@ -68,8 +67,6 @@ public class MockAccountManager extends ManagerBase implements AccountManager {
|
|||
@Inject
|
||||
ResourceCountDao _resourceCountDao;
|
||||
|
||||
@Inject
|
||||
AccountJoinDao _accountJoinDao;
|
||||
@Inject
|
||||
UserDao _userDao;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
<!-- <context:component-scan base-package="org.apache.cloudstack, com.cloud" /> -->
|
||||
<!-- @DB support -->
|
||||
|
||||
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext"/>
|
||||
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||
<bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
|
||||
<bean id="contrailEventInterceptor"
|
||||
|
|
@ -40,103 +41,52 @@
|
|||
|
||||
<bean id="eventBus" class="org.apache.cloudstack.framework.messagebus.MessageBusBase" />
|
||||
|
||||
<bean id="eventDaoImpl" class="com.cloud.event.dao.EventDaoImpl" />
|
||||
|
||||
<bean id="actionEventUtils" class="com.cloud.event.ActionEventUtils" />
|
||||
<bean id="usageEventDaoImpl" class="com.cloud.event.dao.UsageEventDaoImpl" />
|
||||
<!-- registry definition -->
|
||||
<bean id="networkGurusRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
</bean>
|
||||
<bean id="networkElementsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
</bean>
|
||||
|
||||
<!--<bean id="eventUtils" class="com.cloud.event.EventUtils" /> -->
|
||||
<bean id="ipDeployersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
</bean>
|
||||
|
||||
<bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />
|
||||
<bean id="accountDetailsDaoImpl" class="com.cloud.user.AccountDetailsDaoImpl" />
|
||||
<bean id="accountJoinDaoImpl" class="com.cloud.api.query.dao.AccountJoinDaoImpl" />
|
||||
<bean id="accountVlanMapDaoImpl" class="com.cloud.dc.dao.AccountVlanMapDaoImpl" />
|
||||
<bean id="launchPermissionDaoImpl" class="com.cloud.storage.dao.LaunchPermissionDaoImpl" />
|
||||
<bean id="primaryDataStoreDaoImpl"
|
||||
class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
|
||||
<bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
|
||||
<bean id="apiResponseHelper" class="com.cloud.api.ApiResponseHelper" />
|
||||
<bean id="nicDaoImpl" class="com.cloud.vm.dao.NicDaoImpl" />
|
||||
<bean id="dhcpProvidersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
</bean>
|
||||
|
||||
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
|
||||
<!-- registry -->
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="networkElementsRegistry" />
|
||||
<property name="typeClass" value="com.cloud.network.element.NetworkElement" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="networkGurusRegistry" />
|
||||
<property name="typeClass" value="com.cloud.network.guru.NetworkGuru" />
|
||||
</bean>
|
||||
|
||||
<!-- registry users -->
|
||||
<bean id="NetworkModel" class="com.cloud.network.NetworkModelImpl">
|
||||
<property name="networkElements" value="#{networkElementsRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="networkServiceImpl" class="com.cloud.network.NetworkServiceImpl">
|
||||
<property name="networkGurus" value="#{networkGurusRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="networkOrchestrator"
|
||||
class="org.apache.cloudstack.engine.orchestration.NetworkOrchestrator">
|
||||
<property name="networkGurus" value="#{networkGurusRegistry.registered}" />
|
||||
<property name="networkElements" value="#{networkElementsRegistry.registered}" />
|
||||
<property name="ipDeployers" value="#{ipDeployersRegistry.registered}" />
|
||||
<property name="dhcpProviders" value="#{dhcpProvidersRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="IntegrationTestConfiguration"
|
||||
class="org.apache.cloudstack.network.contrail.management.IntegrationTestConfiguration" />
|
||||
class="org.apache.cloudstack.network.contrail.management.IntegrationTestConfiguration"/>
|
||||
|
||||
<bean id="HypervisorGuru" class="com.cloud.hypervisor.XenServerGuru" />
|
||||
|
||||
<!-- Management traffic -->
|
||||
<bean id="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru" />
|
||||
|
||||
<bean id="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru" />
|
||||
|
||||
<bean id="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru" />
|
||||
|
||||
<bean id="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru" />
|
||||
|
||||
<bean id="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru" />
|
||||
|
||||
<bean id="VpcVirtualRouterElement" class="com.cloud.network.element.VpcVirtualRouterElement" />
|
||||
|
||||
<bean id="VirtualRouterElement" class="com.cloud.network.element.VirtualRouterElement" />
|
||||
|
||||
<!-- <bean id="Ipv6AddressManager" class="com.cloud.network.Ipv6AddressManagerImpl"/> -->
|
||||
|
||||
|
||||
<bean id="com.cloud.network.security.SecurityGroupManager" class="com.cloud.network.security.SecurityGroupManagerImpl" />
|
||||
|
||||
<bean id="SecurityGroupElement" class="com.cloud.network.element.SecurityGroupElement" />
|
||||
|
||||
<bean id="InternalLbVm"
|
||||
class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
|
||||
<property name="name" value="InternalLbVm" />
|
||||
</bean>
|
||||
<!-- <bean id="UserAuthenticator" class="com.cloud.server.auth.PlainTextUserAuthenticator"/>
|
||||
<bean id="ManagementServer" class="com.cloud.server.ManagementServerImpl"/> <bean
|
||||
id="SecondaryStorageVmManager" class="com.cloud.storage.secondary.SecondaryStorageManagerImpl"/>
|
||||
<bean id="PodAllocator" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator"/> -->
|
||||
<bean id="com.cloud.vm.UserVmManager" class="com.cloud.vm.UserVmManagerImpl" />
|
||||
|
||||
<bean id="com.cloud.vm.VirtualMachineManager" class="com.cloud.vm.VirtualMachineManagerImpl" />
|
||||
|
||||
<!-- <bean id="com.cloud.vm.dao.UserVmDao" class="com.cloud.vm.dao.UserVmDaoImpl"/> -->
|
||||
<bean id="ContrailElement"
|
||||
class="org.apache.cloudstack.network.contrail.management.ContrailElementImpl" />
|
||||
|
||||
<bean id="ContrailGuru" class="org.apache.cloudstack.network.contrail.management.ContrailGuru" />
|
||||
|
||||
<bean id="networkElements" class="com.cloud.utils.component.AdapterList">
|
||||
<property name="Adapters">
|
||||
<list>
|
||||
<ref bean="ContrailElement" />
|
||||
<ref bean="VirtualRouterElement" />
|
||||
<ref bean="SecurityGroupElement" />
|
||||
<ref bean="VpcVirtualRouterElement" />
|
||||
<ref bean="InternalLbVm" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="networkGurus" class="com.cloud.utils.component.AdapterList">
|
||||
<property name="Adapters">
|
||||
<list>
|
||||
<ref bean="ContrailGuru" />
|
||||
<ref bean="PublicNetworkGuru" />
|
||||
<ref bean="PodBasedNetworkGuru" />
|
||||
<ref bean="ControlNetworkGuru" />
|
||||
<ref bean="StorageNetworkGuru" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="networkModelImpl" class="com.cloud.network.NetworkModelImpl">
|
||||
<property name="NetworkElements" value="#{networkElements.Adapters}" />
|
||||
</bean>
|
||||
|
||||
<bean id="networkOrchestrator" class="org.apache.cloudstack.engine.orchestration.NetworkOrchestrator">
|
||||
<property name="NetworkElements" value="#{networkElements.Adapters}" />
|
||||
<property name="NetworkGurus" value="#{networkGurus.Adapters}" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -102,11 +102,11 @@ public class NiciraNvpApi {
|
|||
|
||||
private final Gson gson;
|
||||
|
||||
protected static Map<Class, String> prefixMap;
|
||||
protected final static Map<Class, String> prefixMap;
|
||||
|
||||
protected static Map<Class, Type> listTypeMap;
|
||||
protected final static Map<Class, Type> listTypeMap;
|
||||
|
||||
protected static Map<String, String> defaultListParams;
|
||||
protected final static Map<String, String> defaultListParams;
|
||||
|
||||
static {
|
||||
prefixMap = new HashMap<Class, String>();
|
||||
|
|
|
|||
|
|
@ -17,26 +17,33 @@
|
|||
package org.apache.cloudstack.network.element;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpConnectionManager;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||
import org.apache.commons.httpclient.URIException;
|
||||
import org.apache.commons.httpclient.cookie.CookiePolicy;
|
||||
import org.apache.commons.httpclient.methods.DeleteMethod;
|
||||
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.apache.commons.httpclient.params.HttpClientParams;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.client.params.ClientPNames;
|
||||
import org.apache.http.client.params.CookiePolicy;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
|
|
@ -44,117 +51,75 @@ import com.google.gson.annotations.SerializedName;
|
|||
*/
|
||||
public class SspClient {
|
||||
private static final Logger s_logger = Logger.getLogger(SspClient.class);
|
||||
private static final HttpConnectionManager s_httpclient_manager = new MultiThreadedHttpConnectionManager();
|
||||
private static final HttpClientParams s_httpclient_params = new HttpClientParams();
|
||||
private static final HttpClient s_client = new DefaultHttpClient(
|
||||
new PoolingClientConnectionManager());
|
||||
static {
|
||||
s_httpclient_params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
|
||||
s_client.getParams()
|
||||
.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY)
|
||||
.setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000);
|
||||
}
|
||||
|
||||
private final String apiUrl;
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
protected HttpClient client;
|
||||
protected PostMethod postMethod;
|
||||
protected DeleteMethod deleteMethod;
|
||||
protected PutMethod putMethod;
|
||||
|
||||
public SspClient(String apiUrl, String username, String password) {
|
||||
super();
|
||||
this.apiUrl = apiUrl;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
client = new HttpClient(s_httpclient_params, s_httpclient_manager);
|
||||
postMethod = new PostMethod(apiUrl);
|
||||
deleteMethod = new DeleteMethod(apiUrl);
|
||||
putMethod = new PutMethod(apiUrl);
|
||||
}
|
||||
|
||||
protected HttpClient getHttpClient() { // for mock test
|
||||
return s_client;
|
||||
}
|
||||
|
||||
private HttpResponse innerExecuteMethod(HttpRequestBase req, String path) {
|
||||
try {
|
||||
URI base = new URI(apiUrl);
|
||||
req.setURI(new URI(base.getScheme(), base.getUserInfo(), base.getHost(),
|
||||
base.getPort(), path, null, null));
|
||||
} catch (URISyntaxException e) {
|
||||
s_logger.error("invalid API URL " + apiUrl + " path " + path, e);
|
||||
return null;
|
||||
}
|
||||
HttpResponse res = null;
|
||||
try {
|
||||
res = getHttpClient().execute(req);
|
||||
s_logger.info("ssp api call:" + req + " status=" + res.getStatusLine());
|
||||
} catch (IOException e) {
|
||||
s_logger.error("ssp api call failed: " + req, e);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private HttpResponse executeMethod(HttpRequestBase req, String path) {
|
||||
HttpResponse res = innerExecuteMethod(req, path);
|
||||
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED && login()) {
|
||||
req.reset();
|
||||
res = innerExecuteMethod(req, path);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean login() {
|
||||
PostMethod method = postMethod;
|
||||
method.setPath("/ws.v1/login"); // NOTE: /ws.v1/login is correct
|
||||
method.addParameter("username", username);
|
||||
method.addParameter("password", password);
|
||||
HttpPost method = new HttpPost();
|
||||
try {
|
||||
method.setEntity(new UrlEncodedFormEntity(Arrays.asList(
|
||||
new BasicNameValuePair("username", username),
|
||||
new BasicNameValuePair("password", password))));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
s_logger.error("invalid username or password", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
client.executeMethod(method);
|
||||
} catch (HttpException e) {
|
||||
s_logger.info("Login " + username + " to " + apiUrl + " failed", e);
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
s_logger.info("Login " + username + " to " + apiUrl + " failed", e);
|
||||
return false;
|
||||
} finally {
|
||||
method.releaseConnection();
|
||||
}
|
||||
String apiCallPath = null;
|
||||
try {
|
||||
apiCallPath = method.getName() + " " + method.getURI().toString();
|
||||
} catch (URIException e) {
|
||||
s_logger.error("method getURI failed", e);
|
||||
}
|
||||
s_logger.info("ssp api call:" + apiCallPath + " user=" + username + " status=" + method.getStatusLine());
|
||||
if (method.getStatusCode() == HttpStatus.SC_OK) {
|
||||
HttpResponse res = this.innerExecuteMethod(method, "/ws.v1/login");
|
||||
if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String executeMethod(HttpMethod method) {
|
||||
String apiCallPath = null;
|
||||
try {
|
||||
apiCallPath = method.getName() + " " + method.getURI().toString();
|
||||
} catch (URIException e) {
|
||||
s_logger.error("method getURI failed", e);
|
||||
}
|
||||
|
||||
String response = null;
|
||||
try {
|
||||
client.executeMethod(method);
|
||||
response = method.getResponseBodyAsString();
|
||||
} catch (HttpException e) {
|
||||
s_logger.error("ssp api call failed " + apiCallPath, e);
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
s_logger.error("ssp api call failed " + apiCallPath, e);
|
||||
return null;
|
||||
} finally {
|
||||
method.releaseConnection();
|
||||
}
|
||||
|
||||
if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
|
||||
if (!login()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
client.executeMethod(method);
|
||||
response = method.getResponseBodyAsString();
|
||||
} catch (HttpException e) {
|
||||
s_logger.error("ssp api call failed " + apiCallPath, e);
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
s_logger.error("ssp api call failed " + apiCallPath, e);
|
||||
return null;
|
||||
} finally {
|
||||
method.releaseConnection();
|
||||
}
|
||||
}
|
||||
s_logger.info("ssp api call:" + apiCallPath + " user=" + username + " status=" + method.getStatusLine());
|
||||
if (method instanceof EntityEnclosingMethod) {
|
||||
EntityEnclosingMethod emethod = (EntityEnclosingMethod)method;
|
||||
RequestEntity reqEntity = emethod.getRequestEntity();
|
||||
if (reqEntity instanceof StringRequestEntity) {
|
||||
StringRequestEntity strReqEntity = (StringRequestEntity)reqEntity;
|
||||
s_logger.debug("ssp api request body:" + strReqEntity.getContent());
|
||||
} else {
|
||||
s_logger.debug("ssp api request body:" + emethod.getRequestEntity());
|
||||
}
|
||||
}
|
||||
s_logger.debug("ssp api response body:" + response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public class TenantNetwork {
|
||||
public String uuid;
|
||||
public String name;
|
||||
|
|
@ -167,30 +132,31 @@ public class SspClient {
|
|||
req.name = networkName;
|
||||
req.tenantUuid = tenantUuid;
|
||||
|
||||
PostMethod method = postMethod;
|
||||
method.setPath("/ssp.v1/tenant-networks");
|
||||
StringRequestEntity entity = null;
|
||||
try {
|
||||
entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
s_logger.error("failed creating http request body", e);
|
||||
HttpPost method = new HttpPost();
|
||||
method.setEntity(new StringEntity(new Gson().toJson(req), ContentType.APPLICATION_JSON));
|
||||
HttpResponse res = executeMethod(method, "/ssp.v1/tenant-networks");
|
||||
if (res == null || res.getStatusLine().getStatusCode() != HttpStatus.SC_CREATED) {
|
||||
return null;
|
||||
}
|
||||
method.setRequestEntity(entity);
|
||||
|
||||
String response = executeMethod(method);
|
||||
if (response != null && method.getStatusCode() == HttpStatus.SC_CREATED) {
|
||||
return new Gson().fromJson(response, TenantNetwork.class);
|
||||
try {
|
||||
return new Gson().fromJson(new InputStreamReader(res.getEntity().getContent(), "UTF-8"),
|
||||
TenantNetwork.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (JsonIOException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (IllegalStateException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (IOException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean deleteTenantNetwork(String tenantNetworkUuid) {
|
||||
DeleteMethod method = deleteMethod;
|
||||
method.setPath("/ssp.v1/tenant-networks/" + tenantNetworkUuid);
|
||||
|
||||
executeMethod(method);
|
||||
if (method.getStatusCode() == HttpStatus.SC_NO_CONTENT) {
|
||||
HttpDelete method = new HttpDelete();
|
||||
HttpResponse res = executeMethod(method, "/ssp.v1/tenant-networks/" + tenantNetworkUuid);
|
||||
if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -214,30 +180,33 @@ public class SspClient {
|
|||
req.networkUuid = tenantNetworkUuid;
|
||||
req.attachmentType = "NoAttachment";
|
||||
|
||||
PostMethod method = postMethod;
|
||||
method.setPath("/ssp.v1/tenant-ports");
|
||||
StringRequestEntity entity = null;
|
||||
try {
|
||||
entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
s_logger.error("failed creating http request body", e);
|
||||
HttpPost method = new HttpPost();
|
||||
method.setEntity(new StringEntity(new Gson().toJson(req), ContentType.APPLICATION_JSON));
|
||||
HttpResponse res = executeMethod(method, "/ssp.v1/tenant-ports");
|
||||
|
||||
if (res == null || res.getStatusLine().getStatusCode() != HttpStatus.SC_CREATED) {
|
||||
return null;
|
||||
}
|
||||
method.setRequestEntity(entity);
|
||||
|
||||
String response = executeMethod(method);
|
||||
if (response != null && method.getStatusCode() == HttpStatus.SC_CREATED) {
|
||||
return new Gson().fromJson(response, TenantPort.class);
|
||||
try {
|
||||
return new Gson().fromJson(new InputStreamReader(res.getEntity().getContent(), "UTF-8"),
|
||||
TenantPort.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (JsonIOException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (IllegalStateException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (IOException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean deleteTenantPort(String tenantPortUuid) {
|
||||
DeleteMethod method = deleteMethod;
|
||||
method.setPath("/ssp.v1/tenant-ports/" + tenantPortUuid);
|
||||
HttpDelete method = new HttpDelete();
|
||||
HttpResponse res = executeMethod(method, "/ssp.v1/tenant-ports/" + tenantPortUuid);
|
||||
|
||||
executeMethod(method);
|
||||
if (method.getStatusCode() == HttpStatus.SC_NO_CONTENT) {
|
||||
if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -252,20 +221,23 @@ public class SspClient {
|
|||
req.attachmentType = "NoAttachment";
|
||||
}
|
||||
|
||||
PutMethod method = putMethod;
|
||||
method.setPath("/ssp.v1/tenant-ports/" + portUuid);
|
||||
StringRequestEntity entity = null;
|
||||
try {
|
||||
entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
s_logger.error("failed creating http request body", e);
|
||||
HttpPut method = new HttpPut();
|
||||
method.setEntity(new StringEntity(new Gson().toJson(req), ContentType.APPLICATION_JSON));
|
||||
HttpResponse res = executeMethod(method, "/ssp.v1/tenant-ports/" + portUuid);
|
||||
if (res == null || res.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
||||
return null;
|
||||
}
|
||||
method.setRequestEntity(entity);
|
||||
|
||||
String response = executeMethod(method);
|
||||
if (response != null && method.getStatusCode() == HttpStatus.SC_OK) {
|
||||
return new Gson().fromJson(response, TenantPort.class);
|
||||
try {
|
||||
return new Gson().fromJson(new InputStreamReader(res.getEntity().getContent(), "UTF-8"),
|
||||
TenantPort.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (JsonIOException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (IllegalStateException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
} catch (IOException e) {
|
||||
s_logger.error("reading response body failed", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ import com.cloud.vm.dao.NicDao;
|
|||
public class SspElement extends AdapterBase implements ConnectivityProvider, SspManager, SspService, NetworkMigrationResponder {
|
||||
private static final Logger s_logger = Logger.getLogger(SspElement.class);
|
||||
public static final String s_SSP_NAME = "StratosphereSsp";
|
||||
private static final Provider s_ssp_provider = new Provider(s_SSP_NAME, false);
|
||||
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
|
|
@ -134,15 +135,7 @@ public class SspElement extends AdapterBase implements ConnectivityProvider, Ssp
|
|||
|
||||
@Override
|
||||
public Provider getProvider() {
|
||||
Provider provider = null;
|
||||
synchronized (s_SSP_NAME) {
|
||||
provider = Provider.getProvider(s_SSP_NAME);
|
||||
if (provider == null) {
|
||||
provider = new Provider(s_SSP_NAME, true);
|
||||
s_logger.debug("registering Network.Provider " + s_SSP_NAME);
|
||||
}
|
||||
}
|
||||
return provider;
|
||||
return s_ssp_provider;
|
||||
}
|
||||
|
||||
private List<SspClient> fetchSspClients(Long physicalNetworkId, Long dataCenterId, boolean enabledOnly) {
|
||||
|
|
@ -187,14 +180,10 @@ public class SspElement extends AdapterBase implements ConnectivityProvider, Ssp
|
|||
public boolean isReady(PhysicalNetworkServiceProvider provider) {
|
||||
PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(provider.getPhysicalNetworkId());
|
||||
assert (physicalNetwork != null);
|
||||
if (physicalNetwork != null) {
|
||||
if (fetchSspClients(physicalNetwork.getId(), physicalNetwork.getDataCenterId(), false).size() > 0) {
|
||||
return true;
|
||||
}
|
||||
s_logger.warn("Ssp api endpoint not found. " + physicalNetwork.toString());
|
||||
} else {
|
||||
s_logger.warn("PhysicalNetwork is NULL.");
|
||||
if (fetchSspClients(physicalNetwork.getId(), physicalNetwork.getDataCenterId(), false).size() > 0) {
|
||||
return true;
|
||||
}
|
||||
s_logger.warn("Ssp api endpoint not found. " + physicalNetwork.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@
|
|||
|
||||
import json
|
||||
import uuid
|
||||
from flask import Flask
|
||||
from flask import Flask,request,make_response
|
||||
from beaker.middleware import SessionMiddleware
|
||||
app = Flask(__name__)
|
||||
|
||||
tenant_networks = []
|
||||
|
|
@ -25,50 +26,59 @@ tenant_ports = []
|
|||
|
||||
@app.route("/ws.v1/login", methods=["POST",])
|
||||
def login():
|
||||
response.content_type = "application/json"
|
||||
return ""
|
||||
assert "username" in request.form
|
||||
assert "password" in request.form
|
||||
request.environ["beaker.session"]["login"] = True
|
||||
res = make_response("", 200)
|
||||
res.headers["Content-type"] = "application/json"
|
||||
return res
|
||||
|
||||
@app.route("/ssp.v1/tenant-networks", methods=["POST",])
|
||||
def create_tenant_network():
|
||||
response.content_type = "application/json"
|
||||
response.status = 201
|
||||
if "login" not in request.environ["beaker.session"]:
|
||||
return make_response("", 401)
|
||||
obj = request.json
|
||||
obj["uuid"] = str(uuid.uuid1())
|
||||
tenant_networks.append(obj)
|
||||
return json.dumps(obj)
|
||||
res = make_response(json.dumps(obj), 201)
|
||||
res.headers["Content-type"] = "application/json"
|
||||
return res
|
||||
|
||||
@app.route("/ssp.v1/tenant-networks/<tenant_net_uuid>", methods=["DELETE",])
|
||||
def delete_tenant_network(tenant_net_uuid):
|
||||
if "login" not in request.environ["beaker.session"]:
|
||||
return make_response("", 401)
|
||||
for net in tenant_networks:
|
||||
if net["uuid"] == tenant_net_uuid:
|
||||
tenant_networks.remove(net)
|
||||
response.status = 204
|
||||
return ""
|
||||
response.status = 404
|
||||
return ""
|
||||
return make_response("", 204)
|
||||
return make_response("", 404)
|
||||
|
||||
@app.route("/ssp.v1/tenant-ports", methods=["POST",])
|
||||
def create_tenant_port():
|
||||
response.content_type = "application/json"
|
||||
response.status = 201
|
||||
if "login" not in request.environ["beaker.session"]:
|
||||
return make_response("", 401)
|
||||
obj = request.json
|
||||
obj["uuid"] = str(uuid.uuid1())
|
||||
tenant_ports.append(obj)
|
||||
return json.dumps(obj)
|
||||
res = make_response(json.dumps(obj), 201)
|
||||
res.headers["Content-type"] = "application/json"
|
||||
return res
|
||||
|
||||
@app.route("/ssp.v1/tenant-ports/<tenant_port_uuid>", methods=["DELETE",])
|
||||
def delete_tenant_port(tenant_port_uuid):
|
||||
if "login" not in request.environ["beaker.session"]:
|
||||
return make_response("", 401)
|
||||
for port in tenant_ports:
|
||||
if port["uuid"] == tenant_port_uuid:
|
||||
tenant_ports.remove(port)
|
||||
response.status = 204
|
||||
return ""
|
||||
response.status = 404
|
||||
return ""
|
||||
return make_response("", 204)
|
||||
return make_response("", 404)
|
||||
|
||||
@app.route("/ssp.v1/tenant-ports/<tenant_port_uuid>", methods=["PUT",])
|
||||
def update_tenant_port(tenant_port_uuid):
|
||||
response.content_type = "application/json"
|
||||
if "login" not in request.environ["beaker.session"]:
|
||||
return make_response("", 401)
|
||||
for port in tenant_ports:
|
||||
if port["uuid"] == tenant_port_uuid:
|
||||
obj = request.json
|
||||
|
|
@ -76,10 +86,14 @@ def update_tenant_port(tenant_port_uuid):
|
|||
obj["vlan_id"] = 100
|
||||
tenant_ports.remove(port)
|
||||
tenant_ports.append(obj)
|
||||
response.status = 200
|
||||
return json.dumps(obj)
|
||||
response.status = 404
|
||||
return ""
|
||||
res = make_response(json.dumps(obj), 200)
|
||||
res.headers["Content-type"] = "application/json"
|
||||
return res
|
||||
return make_response("", 404)
|
||||
|
||||
if __name__=="__main__":
|
||||
app.wsgi_app = SessionMiddleware(app.wsgi_app, {
|
||||
"session.auto":True,
|
||||
"session.type":"cookie",
|
||||
"session.validate_key":"hoge"})
|
||||
app.run(host="0.0.0.0", port=9080, debug=True)
|
||||
|
|
|
|||
|
|
@ -20,46 +20,37 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.URI;
|
||||
import org.apache.commons.httpclient.methods.DeleteMethod;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SspClientTest {
|
||||
HttpClient _client = mock(HttpClient.class);
|
||||
PostMethod _postMethod = mock(PostMethod.class);
|
||||
PutMethod _putMethod = mock(PutMethod.class);
|
||||
DeleteMethod _deleteMethod = mock(DeleteMethod.class);
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
String apiUrl = "http://a.example.jp/";
|
||||
String username = "foo";
|
||||
String password = "bar";
|
||||
SspClient sspClient = new SspClient(apiUrl, username, password) {
|
||||
{
|
||||
client = _client;
|
||||
postMethod = _postMethod;
|
||||
putMethod = _putMethod;
|
||||
deleteMethod = _deleteMethod;
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private URI getUri() throws Exception {
|
||||
return new URI(apiUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loginTest() throws Exception {
|
||||
when(_postMethod.getURI()).thenReturn(getUri());
|
||||
when(_postMethod.getStatusCode()).thenReturn(HttpStatus.SC_OK);
|
||||
SspClient sspClient = spy(new SspClient(apiUrl, username, password));
|
||||
|
||||
HttpClient client = mock(HttpClient.class);
|
||||
HttpResponse res = mock(HttpResponse.class, RETURNS_DEEP_STUBS);
|
||||
doReturn(client).when(sspClient).getHttpClient();
|
||||
when(client.execute(any(HttpUriRequest.class))).thenReturn(res);
|
||||
when(res.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK);
|
||||
|
||||
assertTrue(sspClient.login());
|
||||
assertTrue(sspClient.login());
|
||||
assertTrue(sspClient.login());
|
||||
|
|
@ -69,10 +60,18 @@ public class SspClientTest {
|
|||
public void createNetworkTest() throws Exception {
|
||||
String networkName = "example network 1";
|
||||
String tenant_net_uuid = UUID.randomUUID().toString();
|
||||
SspClient sspClient = spy(new SspClient(apiUrl, username, password));
|
||||
|
||||
HttpClient client = mock(HttpClient.class);
|
||||
HttpResponse res = mock(HttpResponse.class, RETURNS_DEEP_STUBS);
|
||||
doReturn(client).when(sspClient).getHttpClient();
|
||||
when(client.execute(any(HttpUriRequest.class))).thenReturn(res);
|
||||
when(res.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
|
||||
String body = "{\"uuid\":\"" + tenant_net_uuid + "\",\"name\":\"" + networkName
|
||||
+ "\",\"tenant_uuid\":\"" + uuid + "\"}";
|
||||
when(res.getEntity().getContent()).thenReturn(
|
||||
new ByteArrayInputStream(body.getBytes("UTF-8")));
|
||||
|
||||
when(_postMethod.getURI()).thenReturn(getUri());
|
||||
when(_postMethod.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
|
||||
when(_postMethod.getResponseBodyAsString()).thenReturn("{\"uuid\":\"" + tenant_net_uuid + "\",\"name\":\"" + networkName + "\",\"tenant_uuid\":\"" + uuid + "\"}");
|
||||
SspClient.TenantNetwork tnet = sspClient.createTenantNetwork(uuid, networkName);
|
||||
assertEquals(tnet.name, networkName);
|
||||
assertEquals(tnet.uuid, tenant_net_uuid);
|
||||
|
|
@ -82,9 +81,13 @@ public class SspClientTest {
|
|||
@Test
|
||||
public void deleteNetworkTest() throws Exception {
|
||||
String tenant_net_uuid = UUID.randomUUID().toString();
|
||||
SspClient sspClient = spy(new SspClient(apiUrl, username, password));
|
||||
|
||||
when(_deleteMethod.getURI()).thenReturn(getUri());
|
||||
when(_deleteMethod.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
|
||||
HttpClient client = mock(HttpClient.class);
|
||||
HttpResponse res = mock(HttpResponse.class, RETURNS_DEEP_STUBS);
|
||||
doReturn(client).when(sspClient).getHttpClient();
|
||||
when(client.execute(any(HttpUriRequest.class))).thenReturn(res);
|
||||
when(res.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
|
||||
|
||||
sspClient.deleteTenantNetwork(tenant_net_uuid);
|
||||
}
|
||||
|
|
|
|||
97
pom.xml
97
pom.xml
|
|
@ -34,7 +34,7 @@
|
|||
</issueManagement>
|
||||
|
||||
<properties>
|
||||
<cs.jdk.version>1.6</cs.jdk.version>
|
||||
<cs.jdk.version>1.7</cs.jdk.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<cs.log4j.version>1.2.16</cs.log4j.version>
|
||||
|
|
@ -469,6 +469,19 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>cloudstack-findbugs</id>
|
||||
<phase>none</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
|
@ -577,6 +590,15 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<port>9000</port>
|
||||
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings only.
|
||||
It has no influence on the Maven build itself. -->
|
||||
<plugin>
|
||||
|
|
@ -840,9 +862,64 @@
|
|||
</formats>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<configuration>
|
||||
<effort>Max</effort>
|
||||
<threshold>High</threshold>
|
||||
<xmlOutput>true</xmlOutput>
|
||||
<failOnError>false</failOnError>
|
||||
<maxHeap>2048</maxHeap>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>cloudstack-findbugs</id>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<threshold>Low</threshold><!-- High|Normal|Low|Exp|Ignore -->
|
||||
<effort>Default</effort><!-- Min|Default|Max -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<configuration>
|
||||
<minmemory>128m</minmemory>
|
||||
<maxmemory>1g</maxmemory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>awsapi</id>
|
||||
|
|
@ -916,5 +993,23 @@
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>enablefindbugs</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>cloudstack-findbugs</id>
|
||||
<phase>process-classes</phase>
|
||||
<inherited>true</inherited>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -230,12 +230,10 @@ def routerProxy(session, args):
|
|||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
if txt is None or len(txt) == 0 :
|
||||
txt = 'success'
|
||||
txt = 'succ#' + txt
|
||||
except:
|
||||
logging.debug("routerProxy command " + sargs + " failed " )
|
||||
txt = ''
|
||||
|
||||
txt = 'fail#' + txt
|
||||
return txt
|
||||
|
||||
@echo
|
||||
|
|
@ -265,13 +263,12 @@ def createFileInDomr(session, args):
|
|||
f.write(file_contents)
|
||||
f.close()
|
||||
target = "root@" + domrip + ":" + file_path
|
||||
util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',tmpfile, target])
|
||||
txt = util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',tmpfile, target])
|
||||
util.pread2(['rm',tmpfile])
|
||||
txt = 'success'
|
||||
txt = 'succ#' + txt
|
||||
except:
|
||||
logging.debug(" failed to create HA proxy cfg file ")
|
||||
txt = ''
|
||||
|
||||
logging.debug("failed to create file " + file_path + " in VR, contain: " + file_contents)
|
||||
txt = 'fail#' + txt
|
||||
return txt
|
||||
|
||||
@echo
|
||||
|
|
|
|||
|
|
@ -312,7 +312,9 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
|||
}
|
||||
}
|
||||
//didn't find in upper tree
|
||||
if (zoneDomainRecord.getPath().contains(accountDomainRecord.getPath())) {
|
||||
if (zoneDomainRecord != null &&
|
||||
accountDomainRecord != null &&
|
||||
zoneDomainRecord.getPath().contains(accountDomainRecord.getPath())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -243,35 +243,36 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
|
|||
// List<VMInstanceVO> vms = _vmInstanceDao.listByLastHostId(hostId);
|
||||
List<VMInstanceVO> vms = null;
|
||||
long usedCapacity = 0;
|
||||
for (VMInstanceVO vm : vms) {
|
||||
if (skipCalculation(vm)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ServiceOffering so = null;
|
||||
|
||||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
UserVmVO userVm = _vmDao.findById(vm.getId());
|
||||
if (userVm == null) {
|
||||
if (vms != null) {
|
||||
for (VMInstanceVO vm : vms) {
|
||||
if (skipCalculation(vm)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
so = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
|
||||
ServiceOffering so = null;
|
||||
|
||||
if (capacityType == Capacity.CAPACITY_TYPE_MEMORY) {
|
||||
usedCapacity += so.getRamSize() * 1024L * 1024L;
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId + ", currently counted: " +
|
||||
usedCapacity + " Bytes");
|
||||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
UserVmVO userVm = _vmDao.findById(vm.getId());
|
||||
if (userVm == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if (capacityType == Capacity.CAPACITY_TYPE_CPU) {
|
||||
usedCapacity += so.getCpu() * so.getSpeed();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed() + ", currently counted: " +
|
||||
usedCapacity + " Bytes");
|
||||
so = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
|
||||
if (capacityType == Capacity.CAPACITY_TYPE_MEMORY) {
|
||||
usedCapacity += so.getRamSize() * 1024L * 1024L;
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId + ", currently counted: " +
|
||||
usedCapacity + " Bytes");
|
||||
}
|
||||
} else if (capacityType == Capacity.CAPACITY_TYPE_CPU) {
|
||||
usedCapacity += so.getCpu() * so.getSpeed();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed() + ", currently counted: " +
|
||||
usedCapacity + " Bytes");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,8 +423,8 @@ public class ApiDispatcher {
|
|||
}
|
||||
} else {
|
||||
DateFormat format = BaseCmd.INPUT_FORMAT;
|
||||
format.setLenient(false);
|
||||
synchronized (format) {
|
||||
format.setLenient(false);
|
||||
field.set(cmdObj, format.parse(paramObj.toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ import java.util.TimeZone;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
|
|
@ -148,6 +146,7 @@ import org.apache.cloudstack.region.Region;
|
|||
import org.apache.cloudstack.usage.Usage;
|
||||
import org.apache.cloudstack.usage.UsageService;
|
||||
import org.apache.cloudstack.usage.UsageTypes;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.query.ViewResponseHelper;
|
||||
import com.cloud.api.query.vo.AccountJoinVO;
|
||||
|
|
@ -385,8 +384,9 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
populateDomain(resourceLimitResponse, accountTemp.getDomainId());
|
||||
}
|
||||
resourceLimitResponse.setResourceType(Integer.valueOf(limit.getType().getOrdinal()).toString());
|
||||
|
||||
if ((limit.getType() == ResourceType.primary_storage || limit.getType() == ResourceType.secondary_storage) && limit.getMax() >= 0) {
|
||||
resourceLimitResponse.setMax((long)Math.ceil(limit.getMax() / ResourceType.bytesToGiB));
|
||||
resourceLimitResponse.setMax((long)Math.ceil((double)limit.getMax() / ResourceType.bytesToGiB));
|
||||
} else {
|
||||
resourceLimitResponse.setMax(limit.getMax());
|
||||
}
|
||||
|
|
@ -1816,8 +1816,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
public SecurityGroupResponse createSecurityGroupResponseFromSecurityGroupRule(List<? extends SecurityRule> securityRules) {
|
||||
SecurityGroupResponse response = new SecurityGroupResponse();
|
||||
Map<Long, Account> securiytGroupAccounts = new HashMap<Long, Account>();
|
||||
Map<Long, SecurityGroup> allowedSecurityGroups = new HashMap<Long, SecurityGroup>();
|
||||
Map<Long, Account> allowedSecuriytGroupAccounts = new HashMap<Long, Account>();
|
||||
|
||||
if ((securityRules != null) && !securityRules.isEmpty()) {
|
||||
SecurityGroupJoinVO securityGroup = ApiDBUtils.findSecurityGroupViewById(securityRules.get(0).getSecurityGroupId()).get(0);
|
||||
|
|
@ -2980,7 +2978,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
if (profile != null) {
|
||||
response.setProfileId(profile.getUuid());
|
||||
}
|
||||
FirewallRuleVO fw = ApiDBUtils.findFirewallRuleById(vmGroup.getProfileId());
|
||||
FirewallRuleVO fw = ApiDBUtils.findFirewallRuleById(vmGroup.getLoadBalancerId());
|
||||
if (fw != null) {
|
||||
response.setLoadBalancerId(fw.getUuid());
|
||||
}
|
||||
|
|
@ -3019,11 +3017,10 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setCidr(result.getCidr());
|
||||
|
||||
StaticRoute.State state = result.getState();
|
||||
String stateToSet = state.toString();
|
||||
if (state.equals(FirewallRule.State.Revoke)) {
|
||||
stateToSet = "Deleting";
|
||||
if (state.equals(StaticRoute.State.Revoke)) {
|
||||
state = StaticRoute.State.Deleting;
|
||||
}
|
||||
response.setState(stateToSet);
|
||||
response.setState(state.toString());
|
||||
populateAccount(response, result.getAccountId());
|
||||
populateDomain(response, result.getDomainId());
|
||||
|
||||
|
|
@ -3512,11 +3509,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
ApplicationLoadBalancerRuleResponse ruleResponse = new ApplicationLoadBalancerRuleResponse();
|
||||
ruleResponse.setInstancePort(lb.getDefaultPortStart());
|
||||
ruleResponse.setSourcePort(lb.getSourcePortStart());
|
||||
String stateToSet = lb.getState().toString();
|
||||
FirewallRule.State stateToSet = lb.getState();
|
||||
if (stateToSet.equals(FirewallRule.State.Revoke)) {
|
||||
stateToSet = "Deleting";
|
||||
stateToSet = FirewallRule.State.Deleting;
|
||||
}
|
||||
ruleResponse.setState(stateToSet);
|
||||
ruleResponse.setState(stateToSet.toString());
|
||||
ruleResponse.setObjectName("loadbalancerrule");
|
||||
ruleResponses.add(ruleResponse);
|
||||
lbResponse.setLbRules(ruleResponses);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.cloudstack.api.ResponseObject;
|
|||
|
||||
public class ApiSerializerHelper {
|
||||
public static final Logger s_logger = Logger.getLogger(ApiSerializerHelper.class.getName());
|
||||
public static String token = "/";
|
||||
private static String token = "/";
|
||||
|
||||
public static String toSerializedString(Object result) {
|
||||
if (result != null) {
|
||||
|
|
|
|||
|
|
@ -160,11 +160,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
|||
private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
|
||||
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
|
||||
|
||||
public static boolean encodeApiResponse = false;
|
||||
public static String jsonContentType = "text/javascript";
|
||||
public static String controlCharacters = "[\000-\011\013-\014\016-\037\177]"; // Non-printable ASCII characters - numbers 0 to 31 and 127 decimal
|
||||
@Inject
|
||||
ApiDispatcher _dispatcher;
|
||||
private static boolean encodeApiResponse = false;
|
||||
private static String jsonContentType = "text/javascript";
|
||||
private static String controlCharacters = "[\000-\011\013-\014\016-\037\177]"; // Non-printable ASCII characters - numbers 0 to 31 and 127 decimal
|
||||
@Inject ApiDispatcher _dispatcher;
|
||||
|
||||
@Inject
|
||||
private AccountManager _accountMgr;
|
||||
|
|
@ -245,7 +244,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
|||
|
||||
}
|
||||
|
||||
encodeApiResponse = Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key()));
|
||||
setEncodeApiResponse(Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key())));
|
||||
String jsonType = _configDao.getValue(Config.JavaScriptDefaultContentType.key());
|
||||
if (jsonType != null) {
|
||||
jsonContentType = jsonType;
|
||||
|
|
@ -383,7 +382,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
|||
buildAuditTrail(auditTrailSb, command[0], response);
|
||||
} else {
|
||||
if (!command[0].equalsIgnoreCase("login") && !command[0].equalsIgnoreCase("logout")) {
|
||||
String errorString = "Unknown API command: " + ((command == null) ? "null" : command[0]);
|
||||
String errorString = "Unknown API command: " + command[0];
|
||||
s_logger.warn(errorString);
|
||||
auditTrailSb.append(" " + errorString);
|
||||
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, errorString);
|
||||
|
|
@ -1154,4 +1153,16 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
|||
public void setApiAccessCheckers(List<APIChecker> apiAccessCheckers) {
|
||||
_apiAccessCheckers = apiAccessCheckers;
|
||||
}
|
||||
|
||||
public static boolean isEncodeApiResponse() {
|
||||
return encodeApiResponse;
|
||||
}
|
||||
|
||||
private static void setEncodeApiResponse(boolean encodeApiResponse) {
|
||||
ApiServer.encodeApiResponse = encodeApiResponse;
|
||||
}
|
||||
|
||||
public static String getJsonContentType() {
|
||||
return jsonContentType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ public class ApiServlet extends HttpServlet {
|
|||
private void writeResponse(HttpServletResponse resp, String response, int responseCode, String responseType) {
|
||||
try {
|
||||
if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
resp.setContentType(ApiServer.jsonContentType + "; charset=UTF-8");
|
||||
resp.setContentType(ApiServer.getJsonContentType() + "; charset=UTF-8");
|
||||
} else {
|
||||
resp.setContentType("text/xml; charset=UTF-8");
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue