mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cloudstack into disk_io_throttling
This commit is contained in:
commit
691bc9d394
|
|
@ -16,8 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.offering;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.acl.InfrastructureEntity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
|
@ -61,6 +59,8 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
|
|||
public final static String DefaultSharedEIPandELBNetworkOffering = "DefaultSharedNetscalerEIPandELBNetworkOffering";
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworks = "DefaultIsolatedNetworkOfferingForVpcNetworks";
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworksNoLB = "DefaultIsolatedNetworkOfferingForVpcNetworksNoLB";
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB = "DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB";
|
||||
|
||||
|
||||
/**
|
||||
* @return name for the network offering.
|
||||
|
|
|
|||
|
|
@ -70,9 +70,6 @@ public class ListClustersCmd extends BaseListCmd {
|
|||
@Parameter(name=ApiConstants.MANAGED_STATE, type=CommandType.STRING, description="whether this cluster is managed by cloudstack")
|
||||
private String managedState;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
@Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the clusters")
|
||||
private Boolean showCapacities;
|
||||
|
||||
|
|
@ -117,10 +114,7 @@ public class ListClustersCmd extends BaseListCmd {
|
|||
this.managedState = managedstate;
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getShowCapacities() {
|
||||
return showCapacities;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,13 +70,12 @@ public class FindHostsForMigrationCmd extends BaseListCmd {
|
|||
public void execute() {
|
||||
ListResponse<HostForMigrationResponse> response = null;
|
||||
Pair<List<? extends Host>,Integer> result;
|
||||
List<? extends Host> hostsWithCapacity = new ArrayList<Host>();
|
||||
Map<Host, Boolean> hostsRequiringStorageMotion;
|
||||
|
||||
Ternary<Pair<List<? extends Host>,Integer>, List<? extends Host>, Map<Host, Boolean>> hostsForMigration =
|
||||
_mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal());
|
||||
result = hostsForMigration.first();
|
||||
hostsWithCapacity = hostsForMigration.second();
|
||||
List<? extends Host> hostsWithCapacity = hostsForMigration.second();
|
||||
hostsRequiringStorageMotion = hostsForMigration.third();
|
||||
|
||||
response = new ListResponse<HostForMigrationResponse>();
|
||||
|
|
|
|||
|
|
@ -171,11 +171,10 @@ public class ListHostsCmd extends BaseListCmd {
|
|||
response = _queryService.searchForServers(this);
|
||||
} else {
|
||||
Pair<List<? extends Host>,Integer> result;
|
||||
List<? extends Host> hostsWithCapacity = new ArrayList<Host>();
|
||||
Ternary<Pair<List<? extends Host>,Integer>, List<? extends Host>, Map<Host, Boolean>> hostsForMigration =
|
||||
_mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal());
|
||||
result = hostsForMigration.first();
|
||||
hostsWithCapacity = hostsForMigration.second();
|
||||
List<? extends Host> hostsWithCapacity = hostsForMigration.second();
|
||||
|
||||
response = new ListResponse<HostResponse>();
|
||||
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.IS_PERSISTENT, type=CommandType.BOOLEAN, description="true if network offering supports persistent networks; defaulted to false if not specified")
|
||||
private Boolean isPersistent;
|
||||
|
||||
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, since="4.2.0", description="Template details in key/value pairs." +
|
||||
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, since="4.2.0", description="Network offering details in key/value pairs." +
|
||||
" Supported keys are internallbprovider/publiclbprovider with service provider as a value")
|
||||
protected Map details;
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,6 @@ public class ListPodsByCmd extends BaseListCmd {
|
|||
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="list pods by allocation state")
|
||||
private String allocationState;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
@Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the pods")
|
||||
private Boolean showCapacities;
|
||||
|
||||
|
|
@ -81,10 +78,6 @@ public class ListPodsByCmd extends BaseListCmd {
|
|||
return allocationState;
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
public Boolean getShowCapacities() {
|
||||
return showCapacities;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,9 +81,8 @@ public class ListPortableIpRangesCmd extends BaseListCmd {
|
|||
public void execute(){
|
||||
ListResponse<PortableIpRangeResponse> response = new ListResponse<PortableIpRangeResponse>();
|
||||
List<PortableIpRangeResponse> responses = new ArrayList<PortableIpRangeResponse>();
|
||||
List<? extends PortableIpRange> portableIpRanges = new ArrayList<PortableIpRange>();
|
||||
|
||||
portableIpRanges = _configService.listPortableIpRanges(this);
|
||||
List<? extends PortableIpRange> portableIpRanges = _configService.listPortableIpRanges(this);
|
||||
if (portableIpRanges != null && !portableIpRanges.isEmpty()) {
|
||||
for (PortableIpRange range : portableIpRanges) {
|
||||
PortableIpRangeResponse rangeResponse = _responseGenerator.createPortableIPRangeResponse(range);
|
||||
|
|
|
|||
|
|
@ -74,9 +74,6 @@ public class ListSystemVMsCmd extends BaseListCmd {
|
|||
description="the storage ID where vm's volumes belong to", since="3.0.1")
|
||||
private Long storageId;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -113,10 +110,6 @@ public class ListSystemVMsCmd extends BaseListCmd {
|
|||
return storageId;
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -78,9 +78,6 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
|
|||
description="the ID of the zone")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -118,10 +115,6 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
|
|||
return zoneId;
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
public boolean listInReadyState() {
|
||||
Account account = UserContext.current().getCaller();
|
||||
// It is account specific if account is admin type and domainId and accountName are not null
|
||||
|
|
@ -160,8 +153,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
|
|||
List<TemplateResponse> templateResponses = new ArrayList<TemplateResponse>();
|
||||
|
||||
for (Pair<Long, Long> iso : isoZonePairSet) {
|
||||
List<TemplateResponse> responses = new ArrayList<TemplateResponse>();
|
||||
responses = _responseGenerator.createIsoResponses(iso.first(), iso.second(), listInReadyState());
|
||||
List<TemplateResponse> responses = _responseGenerator.createIsoResponses(iso.first(), iso.second(), listInReadyState());
|
||||
templateResponses.addAll(responses);
|
||||
}
|
||||
response.setResponses(templateResponses);
|
||||
|
|
|
|||
|
|
@ -48,9 +48,6 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd {
|
|||
description="the Zone ID of the network")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
@Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the type of the network. Supported values are: Isolated and Shared")
|
||||
private String guestIpType;
|
||||
|
||||
|
|
@ -99,10 +96,6 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd {
|
|||
return zoneId;
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
public String getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,13 +59,11 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd {
|
|||
@Parameter(name=ApiConstants.VOLUME_ID, type=CommandType.UUID, entityType = VolumeResponse.class,
|
||||
description="the ID of the disk volume")
|
||||
private Long volumeId;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "list snapshots by zone id")
|
||||
private Long zoneId;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -90,14 +88,10 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd {
|
|||
return volumeId;
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -68,10 +68,6 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
|
|||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
|
||||
description="list templates by zoneId")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -96,10 +92,6 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
|
|||
return zoneId;
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
public boolean listInReadyState() {
|
||||
|
||||
Account account = UserContext.current().getCaller();
|
||||
|
|
@ -133,8 +125,7 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
|
|||
List<TemplateResponse> templateResponses = new ArrayList<TemplateResponse>();
|
||||
|
||||
for (Pair<Long, Long> template : templateZonePairSet) {
|
||||
List<TemplateResponse> responses = new ArrayList<TemplateResponse>();
|
||||
responses = _responseGenerator.createTemplateResponses(template.first().longValue(), template.second(), listInReadyState());
|
||||
List<TemplateResponse> responses = _responseGenerator.createTemplateResponses(template.first().longValue(), template.second(), listInReadyState());
|
||||
templateResponses.addAll(responses);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,17 @@
|
|||
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
|
||||
<web-app>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
<display-name>CloudBridge</display-name>
|
||||
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>classpath:applicationContext.xml</param-value>
|
||||
</context-param>
|
||||
|
||||
<display-name>CloudBridge</display-name>
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>EC2MainServlet</servlet-name>
|
||||
<display-name>EC2 Main Servlet</display-name>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import com.cloud.agent.api.to.LoadBalancerTO;
|
|||
import com.cloud.agent.api.to.PortForwardingRuleTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.DestinationTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.StickinessPolicyTO;
|
||||
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
|
||||
import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
|
|
@ -41,6 +40,7 @@ import com.cloud.utils.net.NetUtils;
|
|||
public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(HAProxyConfigurator.class);
|
||||
private static final String blankLine = "\t ";
|
||||
private static String[] globalSection = { "global",
|
||||
"\tlog 127.0.0.1:3914 local0 warning",
|
||||
"\tmaxconn 4096",
|
||||
|
|
@ -86,9 +86,9 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
List<String> result = new ArrayList<String>();
|
||||
|
||||
result.addAll(Arrays.asList(globalSection));
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
result.addAll(Arrays.asList(defaultsSection));
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
|
||||
if (pools.isEmpty()) {
|
||||
// haproxy cannot handle empty listen / frontend or backend, so add
|
||||
|
|
@ -96,7 +96,7 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
// on port 9
|
||||
result.addAll(Arrays.asList(defaultListen));
|
||||
}
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
|
||||
for (Map.Entry<String, List<PortForwardingRuleTO>> e : pools.entrySet()) {
|
||||
List<String> poolRules = getRulesForPool(e.getKey(), e.getValue());
|
||||
|
|
@ -143,7 +143,7 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
.append(rule.getDstPortRange()[0]).append(" check");
|
||||
result.add(sb.toString());
|
||||
}
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -507,14 +507,10 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
result.add(sb.toString());
|
||||
}
|
||||
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getBlankLine() {
|
||||
return new String("\t ");
|
||||
}
|
||||
|
||||
private String generateStatsRule(LoadBalancerConfigCommand lbCmd,
|
||||
String ruleName, String statsIp) {
|
||||
StringBuilder rule = new StringBuilder("\nlisten ").append(ruleName)
|
||||
|
|
@ -534,7 +530,7 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
List<String> result = new ArrayList<String>();
|
||||
|
||||
result.addAll(Arrays.asList(globalSection));
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
result.addAll(Arrays.asList(defaultsSection));
|
||||
if (!lbCmd.lbStatsVisibility.equals("disabled")) {
|
||||
/* new rule : listen admin_page guestip/link-local:8081 */
|
||||
|
|
@ -568,7 +564,7 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
}
|
||||
|
||||
}
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
boolean has_listener = false;
|
||||
for (LoadBalancerTO lbTO : lbCmd.getLoadBalancers()) {
|
||||
if ( lbTO.isRevoked() ) {
|
||||
|
|
@ -578,7 +574,7 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
result.addAll(poolRules);
|
||||
has_listener = true;
|
||||
}
|
||||
result.add(getBlankLine());
|
||||
result.add(blankLine);
|
||||
if ( !has_listener) {
|
||||
// haproxy cannot handle empty listen / frontend or backend, so add
|
||||
// a dummy listener
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ under the License.
|
|||
SSH keypair assigned to a virtual machine.</para>
|
||||
</section>
|
||||
</section>
|
||||
<section id="issues-fixed-4.0">
|
||||
<section id="issues-fixed-4.1">
|
||||
<title>Issues Fixed in 4.1.0</title>
|
||||
<para>Apache CloudStack uses <ulink url="https://issues.apache.org/jira/browse/CLOUDSTACK"
|
||||
>Jira</ulink> to track its issues. All new features and bugs for 4.1.0 have been tracked
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
<title>DEB package repository</title>
|
||||
<para>You can add a DEB package repository to your apt sources with the following commands. Please note that only packages for Ubuntu 12.04 LTS (precise) are being built at this time.</para>
|
||||
<para>Use your preferred editor and open (or create) <filename>/etc/apt/sources.list.d/cloudstack.list</filename>. Add the community provided repository to the file:</para>
|
||||
<programlisting>deb http://cloudstack.apt-get.eu/ubuntu precise 4.0</programlisting>
|
||||
<programlisting>deb http://cloudstack.apt-get.eu/ubuntu precise 4.1</programlisting>
|
||||
<para>We now have to add the public key to the trusted keys.</para>
|
||||
<programlisting language="Bash"><prompt>$</prompt> <command>wget</command> -O - http://cloudstack.apt-get.eu/release.asc|apt-key add -</programlisting>
|
||||
<para>Now update your local apt cache.</para>
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
<programlisting>
|
||||
[cloudstack]
|
||||
name=cloudstack
|
||||
baseurl=<replaceable>http://cloudstack.apt-get.eu/rhel/4.0/</replaceable>
|
||||
baseurl=<replaceable>http://cloudstack.apt-get.eu/rhel/4.1/</replaceable>
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
</programlisting>
|
||||
|
|
|
|||
|
|
@ -143,6 +143,14 @@ binlog-format = 'ROW'</programlisting>
|
|||
-i <management_server_ip></programlisting>
|
||||
<para>When this script is finished, you should see a message like “Successfully initialized
|
||||
the database.”</para>
|
||||
<note>
|
||||
<para>If the script is unable to connect to the MySQL database, check
|
||||
the "localhost" loopback address in <filename>/etc/hosts</filename>. It should
|
||||
be pointing to the IPv4 loopback address "127.0.0.1" and not the IPv6 loopback
|
||||
address ::1. Alternatively, reconfigure MySQL to bind to the IPv6 loopback
|
||||
interface.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If you are running the KVM hypervisor on the same machine with the Management Server,
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ msgstr ""
|
|||
|
||||
#. Tag: programlisting
|
||||
#, no-c-format
|
||||
msgid "deb http://cloudstack.apt-get.eu/ubuntu precise 4.0"
|
||||
msgid "deb http://cloudstack.apt-get.eu/ubuntu precise 4.1"
|
||||
msgstr ""
|
||||
|
||||
#. Tag: para
|
||||
|
|
@ -118,7 +118,7 @@ msgstr ""
|
|||
msgid "\n"
|
||||
"[cloudstack]\n"
|
||||
"name=cloudstack\n"
|
||||
"baseurl=<replaceable>http://cloudstack.apt-get.eu/rhel/4.0/</replaceable>\n"
|
||||
"baseurl=<replaceable>http://cloudstack.apt-get.eu/rhel/4.1/</replaceable>\n"
|
||||
"enabled=1\n"
|
||||
"gpgcheck=0\n"
|
||||
" "
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
|
|||
Pair<String, Long> allocatePrivateIpAddress(long id, long podId, long instanceId, String reservationId);
|
||||
DataCenterIpAddressVO allocatePrivateIpAddress(long id, String reservationId);
|
||||
String allocateLinkLocalIpAddress(long id, long podId, long instanceId, String reservationId);
|
||||
String allocateVnet(long dcId, long physicalNetworkId, long accountId, String reservationId);
|
||||
String allocateVnet(long dcId, long physicalNetworkId, long accountId, String reservationId, boolean canUseSystemGuestVlans);
|
||||
|
||||
void releaseVnet(String vnet, long dcId, long physicalNetworkId, long accountId, String reservationId);
|
||||
void releasePrivateIpAddress(String ipAddress, long dcId, Long instanceId);
|
||||
|
|
|
|||
|
|
@ -192,22 +192,27 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public String allocateVnet(long dataCenterId, long physicalNetworkId, long accountId, String reservationId) {
|
||||
public String allocateVnet(long dataCenterId, long physicalNetworkId, long accountId, String reservationId,
|
||||
boolean canUseSystemGuestVlans) {
|
||||
ArrayList<Long> dedicatedVlanDbIds = new ArrayList<Long>();
|
||||
boolean useDedicatedGuestVlans = false;
|
||||
List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(accountId);
|
||||
for (AccountGuestVlanMapVO map : maps) {
|
||||
dedicatedVlanDbIds.add(map.getId());
|
||||
}
|
||||
if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty()) {
|
||||
useDedicatedGuestVlans = true;
|
||||
DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId, dedicatedVlanDbIds);
|
||||
if (vo != null)
|
||||
return vo.getVnet();
|
||||
}
|
||||
DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId, null);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
if (!useDedicatedGuestVlans || (useDedicatedGuestVlans && canUseSystemGuestVlans)) {
|
||||
DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId, null);
|
||||
if (vo != null) {
|
||||
return vo.getVnet();
|
||||
}
|
||||
}
|
||||
return vo.getVnet();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -414,4 +414,8 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
return publicLb;
|
||||
}
|
||||
|
||||
public void setInternalLb(boolean internalLb) {
|
||||
this.internalLb = internalLb;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<
|
|||
public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter templateFilter, boolean isIso,
|
||||
List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex, Long zoneId,
|
||||
HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller,
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags, String zoneType);
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags);
|
||||
|
||||
public Set<Pair<Long, Long>> searchSwiftTemplates(String name, String keyword, TemplateFilter templateFilter,
|
||||
boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex,
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter templateFilter,
|
||||
boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex,
|
||||
Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr,List<Account> permittedAccounts,
|
||||
Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags, String zoneType) {
|
||||
Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (!permittedAccounts.isEmpty()) {
|
||||
for (Account permittedAccount : permittedAccounts) {
|
||||
|
|
@ -565,12 +565,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
if ((templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.community)) {
|
||||
dataCenterJoin = " INNER JOIN data_center dc on (h.data_center_id = dc.id)";
|
||||
}
|
||||
|
||||
if (zoneType != null) {
|
||||
dataCenterJoin = " INNER JOIN template_host_ref thr on (t.id = thr.template_id) INNER JOIN host h on (thr.host_id = h.id)";
|
||||
dataCenterJoin += " INNER JOIN data_center dc on (h.data_center_id = dc.id)";
|
||||
}
|
||||
|
||||
|
||||
if (templateFilter == TemplateFilter.sharedexecutable || templateFilter == TemplateFilter.shared ){
|
||||
lpjoin = " INNER JOIN launch_permission lp ON t.id = lp.template_id ";
|
||||
}
|
||||
|
|
@ -697,7 +692,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
}
|
||||
|
||||
sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso, bootable, hyperType, zoneId,
|
||||
onlyReady, showDomr, zoneType) + groupByClause + getOrderByLimit(pageSize, startIndex);
|
||||
onlyReady, showDomr) + groupByClause + getOrderByLimit(pageSize, startIndex);
|
||||
|
||||
pstmt = txn.prepareStatement(sql);
|
||||
rs = pstmt.executeQuery();
|
||||
|
|
@ -758,7 +753,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
return templateZonePairList;
|
||||
}
|
||||
|
||||
private String getExtrasWhere(TemplateFilter templateFilter, String name, String keyword, boolean isIso, Boolean bootable, HypervisorType hyperType, Long zoneId, boolean onlyReady, boolean showDomr, String zoneType) {
|
||||
private String getExtrasWhere(TemplateFilter templateFilter, String name, String keyword, boolean isIso, Boolean bootable, HypervisorType hyperType, Long zoneId, boolean onlyReady, boolean showDomr) {
|
||||
String sql = "";
|
||||
if (keyword != null) {
|
||||
sql += " t.name LIKE \"%" + keyword + "%\" AND";
|
||||
|
|
@ -788,15 +783,11 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
sql += " AND h.data_center_id = " +zoneId;
|
||||
}
|
||||
}else if (zoneId != null){
|
||||
sql += " AND tzr.zone_id = " +zoneId+ " AND tzr.removed is null" ;
|
||||
sql += " AND tzr.zone_id = " +zoneId+ " AND tzr.removed is null" ;
|
||||
}else{
|
||||
sql += " AND tzr.removed is null ";
|
||||
}
|
||||
|
||||
if (zoneType != null){
|
||||
sql += " AND dc.networktype = '" + zoneType + "'";
|
||||
}
|
||||
|
||||
|
||||
if (!showDomr){
|
||||
sql += " AND t.type != '" +Storage.TemplateType.SYSTEM.toString() + "'";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class HypervisorHostEndPointRpcServer implements HostEndpointRpcServer {
|
|||
}
|
||||
|
||||
public HypervisorHostEndPointRpcServer(RpcProvider rpcProvider) {
|
||||
rpcProvider = rpcProvider;
|
||||
this.rpcProvider = rpcProvider;
|
||||
rpcProvider.registerRpcServiceEndpoint(RpcServiceDispatcher.getDispatcher(this));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
}
|
||||
|
||||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId,
|
||||
network.getAccountId(), context.getReservationId());
|
||||
network.getAccountId(), context.getReservationId(), canUseSystemGuestVlan(network.getAccountId()));
|
||||
if (vnet == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
|
||||
"part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
protected void allocateVnet(Network network, NetworkVO implemented, long dcId,
|
||||
long physicalNetworkId, String reservationId) throws InsufficientVirtualNetworkCapcityException {
|
||||
if (network.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId);
|
||||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId,
|
||||
canUseSystemGuestVlan(network.getAccountId()));
|
||||
if (vnet == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import javax.inject.Inject;
|
|||
import com.cloud.capacity.Capacity;
|
||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -79,17 +80,12 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
|
|||
poolResponse.setZoneId(pool.getZoneUuid());
|
||||
poolResponse.setZoneName(pool.getZoneName());
|
||||
poolResponse.setZoneType(pool.getZoneType());
|
||||
if (pool.getPoolType() != null) {
|
||||
poolResponse.setType(pool.getPoolType().toString());
|
||||
}
|
||||
poolResponse.setType(ObjectUtils.toString(pool.getPoolType(), null));
|
||||
poolResponse.setPodId(pool.getPodUuid());
|
||||
poolResponse.setPodName(pool.getPodName());
|
||||
poolResponse.setCreated(pool.getCreated());
|
||||
poolResponse.setScope(pool.getScope().toString());
|
||||
if (pool.getHypervisor() != null) {
|
||||
poolResponse.setHypervisor(pool.getHypervisor().toString());
|
||||
}
|
||||
|
||||
poolResponse.setScope(ObjectUtils.toString(pool.getScope(), null));
|
||||
poolResponse.setHypervisor(ObjectUtils.toString(pool.getHypervisor(), null));
|
||||
|
||||
long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
|
||||
poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
|
||||
|
|
|
|||
|
|
@ -216,7 +216,14 @@ public enum Config {
|
|||
AlertPurgeInterval("Advanced", ManagementServer.class, Integer.class, "alert.purge.interval", "86400", "The interval (in seconds) to wait before running the alert purge thread", null),
|
||||
AlertPurgeDelay("Advanced", ManagementServer.class, Integer.class, "alert.purge.delay", "0", "Alerts older than specified number days will be purged. Set this value to 0 to never delete alerts", null),
|
||||
HostReservationReleasePeriod("Advanced", ManagementServer.class, Integer.class, "host.reservation.release.period", "300000", "The interval in milliseconds between host reservation release checks", null),
|
||||
|
||||
UseSystemPublicIps("Advanced", ManagementServer.class, Boolean.class, "use.system.public.ips", "true",
|
||||
"If true, when account has dedicated public ip range(s), once the ips dedicated to the account have been" +
|
||||
" consumed ips will be acquired from the system pool",
|
||||
null, ConfigurationParameterScope.account.toString()),
|
||||
UseSystemGuestVlans("Advanced", ManagementServer.class, Boolean.class, "use.system.guest.vlans", "true",
|
||||
"If true, when account has dedicated guest vlan range(s), once the vlans dedicated to the account have been" +
|
||||
" consumed vlans will be allocated from the system pool",
|
||||
null, ConfigurationParameterScope.account.toString()),
|
||||
|
||||
// LB HealthCheck Interval.
|
||||
LBHealthCheck("Advanced", ManagementServer.class, String.class, "healthcheck.update.interval", "600",
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import javax.naming.NamingException;
|
|||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.InitialDirContext;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
import org.apache.cloudstack.api.ApiConstants.LDAPParams;
|
||||
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
|
||||
|
|
@ -125,7 +124,6 @@ import com.cloud.exception.ConcurrentOperationException;
|
|||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.MissingParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
|
@ -193,6 +191,7 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
|
|
@ -3993,9 +3992,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.LbSchemes, publicLbStr);
|
||||
internalLb = publicLbStr.contains("internal");
|
||||
publicLb = publicLbStr.contains("public");
|
||||
} else {
|
||||
//if not specified, default public lb to true
|
||||
publicLb = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4034,6 +4030,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (serviceProviderMap != null && serviceProviderMap.containsKey(Service.Lb) && !internalLb && !publicLb) {
|
||||
//if not specified, default public lb to true
|
||||
publicLb = true;
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan,
|
||||
networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb,
|
||||
|
|
|
|||
|
|
@ -445,7 +445,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
|
||||
// If all the dedicated IPs of the owner are in use fetch an IP from the system pool
|
||||
if (addrs.size() == 0 && fetchFromDedicatedRange) {
|
||||
if (nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
|
||||
// Verify if account is allowed to acquire IPs from the system
|
||||
boolean useSystemIps = Boolean.parseBoolean(_configServer.getConfigValue(Config.UseSystemPublicIps.key(),
|
||||
Config.ConfigurationParameterScope.account.toString(), owner.getId()));
|
||||
if(useSystemIps && nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
|
||||
fetchFromDedicatedRange = false;
|
||||
sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
|
||||
errorMessage.append(", vlanId id=" + nonDedicatedVlanDbIds.toArray());
|
||||
|
|
@ -1236,9 +1239,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
|
||||
_networkLockTimeout = NumbersUtil.parseInt(_configs.get(Config.NetworkLockTimeout.key()), 600);
|
||||
|
||||
|
||||
|
||||
|
||||
// populate providers
|
||||
Map<Network.Service, Set<Network.Provider>> defaultSharedNetworkOfferingProviders = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
|
|
@ -1249,6 +1249,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
defaultSharedNetworkOfferingProviders.put(Service.UserData, defaultProviders);
|
||||
|
||||
Map<Network.Service, Set<Network.Provider>> defaultIsolatedNetworkOfferingProviders = defaultSharedNetworkOfferingProviders;
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.Dhcp, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.Dns, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.UserData, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.Firewall, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.Gateway, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.Lb, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.StaticNat, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.PortForwarding, defaultProviders);
|
||||
defaultIsolatedNetworkOfferingProviders.put(Service.Vpn, defaultProviders);
|
||||
|
||||
Map<Network.Service, Set<Network.Provider>> defaultSharedSGEnabledNetworkOfferingProviders = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
defaultSharedSGEnabledNetworkOfferingProviders.put(Service.Dhcp, defaultProviders);
|
||||
|
|
@ -1291,9 +1300,9 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
// diff between offering #1 and #2 - securityGroup is enabled for the first, and disabled for the third
|
||||
|
||||
NetworkOfferingVO offering = null;
|
||||
//#1 - quick cloud network offering
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.QuickCloudNoServices) == null) {
|
||||
offering =
|
||||
_configMgr.createNetworkOffering(NetworkOffering.QuickCloudNoServices,
|
||||
|
|
@ -1303,6 +1312,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
//#2 - SG enabled network offering
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOfferingWithSGService) == null) {
|
||||
offering =
|
||||
_configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOfferingWithSGService,
|
||||
|
|
@ -1313,36 +1324,26 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
//#3 - shared network offering with no SG service
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, null, true, Availability.Optional, null,
|
||||
defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true, false, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
|
||||
Map<Network.Service, Set<Network.Provider>> defaultINetworkOfferingProvidersForVpcNetwork = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
defaultProviders.clear();
|
||||
defaultProviders.add(Network.Provider.VPCVirtualRouter);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Dhcp, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Dns, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.UserData, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Firewall, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Gateway, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Lb, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.SourceNat, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.StaticNat, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.PortForwarding, defaultProviders);
|
||||
defaultINetworkOfferingProvidersForVpcNetwork.put(Service.Vpn, defaultProviders);
|
||||
|
||||
//#4 - default isolated offering with Source nat service
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService,
|
||||
"Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest,
|
||||
null, false, Availability.Required, null, defaultINetworkOfferingProvidersForVpcNetwork,
|
||||
null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders,
|
||||
true, Network.GuestType.Isolated, false, null, true, null, false, false, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
//#5 - default vpc offering with LB service
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
|
||||
"Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest,
|
||||
|
|
@ -1352,6 +1353,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
//#6 - default vpc offering with no LB service
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB) == null) {
|
||||
//remove LB service
|
||||
defaultVPCOffProviders.remove(Service.Lb);
|
||||
|
|
@ -1363,6 +1365,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
//#7 - isolated offering with source nat disabled
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering,
|
||||
"Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null, true,
|
||||
|
|
@ -1371,6 +1374,33 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
//#8 - network offering with internal lb service
|
||||
Map<Network.Service, Set<Network.Provider>> internalLbOffProviders =
|
||||
new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultVpcProvider = new HashSet<Network.Provider>();
|
||||
defaultVpcProvider.add(Network.Provider.VPCVirtualRouter);
|
||||
|
||||
Set<Network.Provider> defaultInternalLbProvider = new HashSet<Network.Provider>();
|
||||
defaultInternalLbProvider.add(Network.Provider.InternalLbVm);
|
||||
|
||||
internalLbOffProviders.put(Service.Dhcp, defaultVpcProvider);
|
||||
internalLbOffProviders.put(Service.Dns, defaultVpcProvider);
|
||||
internalLbOffProviders.put(Service.UserData, defaultVpcProvider);
|
||||
internalLbOffProviders.put(Service.NetworkACL, defaultVpcProvider);
|
||||
internalLbOffProviders.put(Service.Gateway, defaultVpcProvider);
|
||||
internalLbOffProviders.put(Service.Lb, defaultInternalLbProvider);
|
||||
internalLbOffProviders.put(Service.SourceNat, defaultVpcProvider);
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB,
|
||||
"Offering for Isolated VPC networks with Internal Lb support", TrafficType.Guest,
|
||||
null, false, Availability.Optional, null, internalLbOffProviders,
|
||||
true, Network.GuestType.Isolated, false, null, false, null, false, false, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
offering.setInternalLb(true);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
Map<Network.Service, Set<Network.Provider>> netscalerServiceProviders = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
|
||||
|
|
|
|||
|
|
@ -1355,7 +1355,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
Long id = cmd.getId();
|
||||
String keyword = cmd.getKeyword();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
String zoneType = cmd.getZoneType();
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
|
|
@ -1503,40 +1502,40 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
if (!permittedAccounts.isEmpty()) {
|
||||
//get account level networks
|
||||
networksToReturn.addAll(listAccountSpecificNetworks(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags, zoneType), searchFilter,
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter,
|
||||
permittedAccounts));
|
||||
//get domain level networks
|
||||
if (domainId != null) {
|
||||
networksToReturn
|
||||
.addAll(listDomainLevelNetworks(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, vpcId, tags, zoneType), searchFilter,
|
||||
physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, vpcId, tags), searchFilter,
|
||||
domainId, false));
|
||||
}
|
||||
} else {
|
||||
//add account specific networks
|
||||
networksToReturn.addAll(listAccountSpecificNetworksByDomainPath(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags, zoneType), searchFilter, path,
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path,
|
||||
isRecursive));
|
||||
//add domain specific networks of domain + parent domains
|
||||
networksToReturn.addAll(listDomainSpecificNetworksByDomainPath(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags, zoneType), searchFilter, path,
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path,
|
||||
isRecursive));
|
||||
//add networks of subdomains
|
||||
if (domainId == null) {
|
||||
networksToReturn
|
||||
.addAll(listDomainLevelNetworks(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
|
||||
physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, vpcId, tags, zoneType), searchFilter,
|
||||
physicalNetworkId, aclType, true, restartRequired, specifyIpRanges, vpcId, tags), searchFilter,
|
||||
caller.getDomainId(), true));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId,
|
||||
guestIpType, trafficType, physicalNetworkId, null, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags, zoneType),
|
||||
guestIpType, trafficType, physicalNetworkId, null, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags),
|
||||
searchFilter);
|
||||
}
|
||||
|
||||
|
|
@ -1581,7 +1580,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
|
||||
private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id,
|
||||
Boolean isSystem, Long zoneId, String guestIpType, String trafficType, Long physicalNetworkId,
|
||||
String aclType, boolean skipProjectNetworks, Boolean restartRequired, Boolean specifyIpRanges, Long vpcId, Map<String, String> tags, String zoneType) {
|
||||
String aclType, boolean skipProjectNetworks, Boolean restartRequired, Boolean specifyIpRanges, Long vpcId, Map<String, String> tags) {
|
||||
|
||||
SearchCriteria<NetworkVO> sc = sb.create();
|
||||
|
||||
|
|
@ -1603,10 +1602,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
|
||||
}
|
||||
|
||||
if(zoneType != null) {
|
||||
sc.setJoinParameters("zoneSearch", "networkType", zoneType);
|
||||
}
|
||||
|
||||
if (guestIpType != null) {
|
||||
sc.addAnd("guestType", SearchCriteria.Op.EQ, guestIpType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
// Get a vlan tag
|
||||
int vlanTag;
|
||||
if (config.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(zone.getId(), config.getPhysicalNetworkId(), config.getAccountId(), context.getReservationId());
|
||||
String vnet = _dcDao.allocateVnet(zone.getId(), config.getPhysicalNetworkId(), config.getAccountId(),
|
||||
context.getReservationId(), canUseSystemGuestVlan(config.getAccountId()));
|
||||
|
||||
try {
|
||||
vlanTag = Integer.parseInt(vnet);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.event.ActionEventUtils;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.utils.Pair;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -98,6 +99,8 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
IPAddressDao _ipAddressDao;
|
||||
@Inject
|
||||
protected PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
ConfigurationServer _configServer;
|
||||
Random _rand = new Random(System.currentTimeMillis());
|
||||
|
||||
private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
|
||||
|
|
@ -155,6 +158,11 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
return _isolationMethods;
|
||||
}
|
||||
|
||||
public boolean canUseSystemGuestVlan(long accountId) {
|
||||
return Boolean.parseBoolean(_configServer.getConfigValue(Config.UseSystemGuestVlans.key(),
|
||||
Config.ConfigurationParameterScope.account.toString(), accountId));
|
||||
}
|
||||
|
||||
protected abstract boolean canHandle(NetworkOffering offering, final NetworkType networkType, PhysicalNetwork physicalNetwork);
|
||||
|
||||
@Override
|
||||
|
|
@ -260,7 +268,8 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
protected void allocateVnet(Network network, NetworkVO implemented, long dcId,
|
||||
long physicalNetworkId, String reservationId) throws InsufficientVirtualNetworkCapcityException {
|
||||
if (network.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId);
|
||||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId,
|
||||
canUseSystemGuestVlan(network.getAccountId()));
|
||||
if (vnet == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
|
||||
"part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
|
|
|
|||
|
|
@ -1151,8 +1151,33 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
|||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
//offering #8 - network offering with internal lb service
|
||||
NetworkOfferingVO internalLbOff = new NetworkOfferingVO(
|
||||
NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB,
|
||||
"Offering for Isolated Vpc networks with Internal LB support",
|
||||
TrafficType.Guest,
|
||||
false, false, null, null, true, Availability.Optional,
|
||||
null, Network.GuestType.Isolated, false, false, false, true, false);
|
||||
|
||||
internalLbOff.setState(NetworkOffering.State.Enabled);
|
||||
internalLbOff = _networkOfferingDao.persistDefaultNetworkOffering(internalLbOff);
|
||||
|
||||
Map<Network.Service, Network.Provider> internalLbOffProviders = new HashMap<Network.Service, Network.Provider>();
|
||||
internalLbOffProviders.put(Service.Dhcp, Provider.VPCVirtualRouter);
|
||||
internalLbOffProviders.put(Service.Dns, Provider.VPCVirtualRouter);
|
||||
internalLbOffProviders.put(Service.UserData, Provider.VPCVirtualRouter);
|
||||
internalLbOffProviders.put(Service.NetworkACL, Provider.VPCVirtualRouter);
|
||||
internalLbOffProviders.put(Service.Gateway, Provider.VPCVirtualRouter);
|
||||
internalLbOffProviders.put(Service.Lb, Provider.InternalLbVm);
|
||||
internalLbOffProviders.put(Service.SourceNat, Provider.VPCVirtualRouter);
|
||||
|
||||
for (Service service : internalLbOffProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(internalLbOff.getId(), service, internalLbOffProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -996,67 +996,46 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
|
||||
@Override
|
||||
public Pair<List<? extends Cluster>, Integer> searchForClusters(ListClustersCmd cmd) {
|
||||
Object id = cmd.getId();
|
||||
Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
|
||||
|
||||
Object id = cmd.getId();
|
||||
Object name = cmd.getClusterName();
|
||||
Object podId = cmd.getPodId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
Object hypervisorType = cmd.getHypervisorType();
|
||||
Object clusterType = cmd.getClusterType();
|
||||
Object allocationState = cmd.getAllocationState();
|
||||
String zoneType = cmd.getZoneType();
|
||||
String keyword = cmd.getKeyword();
|
||||
|
||||
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId);
|
||||
|
||||
|
||||
Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
|
||||
SearchBuilder<ClusterVO> sb = _clusterDao.createSearchBuilder();
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
|
||||
sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
|
||||
sb.and("clusterType", sb.entity().getClusterType(), SearchCriteria.Op.EQ);
|
||||
sb.and("allocationState", sb.entity().getAllocationState(), SearchCriteria.Op.EQ);
|
||||
|
||||
if(zoneType != null) {
|
||||
SearchBuilder<DataCenterVO> zoneSb = _dcDao.createSearchBuilder();
|
||||
zoneSb.and("zoneNetworkType", zoneSb.entity().getNetworkType(), SearchCriteria.Op.EQ);
|
||||
sb.join("zoneSb", zoneSb, sb.entity().getDataCenterId(), zoneSb.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
|
||||
SearchCriteria<ClusterVO> sc = sb.create();
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
sc.setParameters("name", "%" + name + "%");
|
||||
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
|
||||
}
|
||||
|
||||
if (podId != null) {
|
||||
sc.setParameters("podId", podId);
|
||||
sc.addAnd("podId", SearchCriteria.Op.EQ, podId);
|
||||
}
|
||||
|
||||
if (zoneId != null) {
|
||||
sc.setParameters("dataCenterId", zoneId);
|
||||
sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
|
||||
}
|
||||
|
||||
if (hypervisorType != null) {
|
||||
sc.setParameters("hypervisorType", hypervisorType);
|
||||
sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisorType);
|
||||
}
|
||||
|
||||
if (clusterType != null) {
|
||||
sc.setParameters("clusterType", clusterType);
|
||||
sc.addAnd("clusterType", SearchCriteria.Op.EQ, clusterType);
|
||||
}
|
||||
|
||||
if (allocationState != null) {
|
||||
sc.setParameters("allocationState", allocationState);
|
||||
}
|
||||
|
||||
if(zoneType != null) {
|
||||
sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);
|
||||
sc.addAnd("allocationState", SearchCriteria.Op.EQ, allocationState);
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
|
|
@ -1469,29 +1448,17 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
|
||||
@Override
|
||||
public Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd) {
|
||||
Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<HostPodVO> sc = _hostPodDao.createSearchCriteria();
|
||||
|
||||
String podName = cmd.getPodName();
|
||||
Long id = cmd.getId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
Object keyword = cmd.getKeyword();
|
||||
Object allocationState = cmd.getAllocationState();
|
||||
String zoneType = cmd.getZoneType();
|
||||
|
||||
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId);
|
||||
|
||||
|
||||
Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchBuilder<HostPodVO> sb = _hostPodDao.createSearchBuilder();
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
|
||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
sb.and("allocationState", sb.entity().getAllocationState(), SearchCriteria.Op.EQ);
|
||||
|
||||
if(zoneType != null) {
|
||||
SearchBuilder<DataCenterVO> zoneSb = _dcDao.createSearchBuilder();
|
||||
zoneSb.and("zoneNetworkType", zoneSb.entity().getNetworkType(), SearchCriteria.Op.EQ);
|
||||
sb.join("zoneSb", zoneSb, sb.entity().getDataCenterId(), zoneSb.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
SearchCriteria<HostPodVO> sc = sb.create();
|
||||
if (keyword != null) {
|
||||
SearchCriteria<HostPodVO> ssc = _hostPodDao.createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
|
|
@ -1501,23 +1468,19 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
}
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
}
|
||||
|
||||
if (podName != null) {
|
||||
sc.setParameters("name", "%" + podName + "%");
|
||||
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + podName + "%");
|
||||
}
|
||||
|
||||
if (zoneId != null) {
|
||||
sc.setParameters("dataCenterId", zoneId);
|
||||
sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
|
||||
}
|
||||
|
||||
if (allocationState != null) {
|
||||
sc.setParameters("allocationState", allocationState);
|
||||
}
|
||||
|
||||
if(zoneType != null) {
|
||||
sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);
|
||||
sc.addAnd("allocationState", SearchCriteria.Op.EQ, allocationState);
|
||||
}
|
||||
|
||||
Pair<List<HostPodVO>, Integer> result = _hostPodDao.searchAndCount(sc, searchFilter);
|
||||
|
|
@ -1756,7 +1719,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
|
||||
return listTemplates(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter, true, cmd.isBootable(), cmd.getPageSizeVal(),
|
||||
cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, true, cmd.listInReadyState(), permittedAccounts, caller,
|
||||
listProjectResourcesCriteria, tags, cmd.getZoneType());
|
||||
listProjectResourcesCriteria, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1789,12 +1752,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
|
||||
|
||||
return listTemplates(id, cmd.getTemplateName(), cmd.getKeyword(), templateFilter, false, null, cmd.getPageSizeVal(), cmd.getStartIndex(),
|
||||
cmd.getZoneId(), hypervisorType, showDomr, cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags, cmd.getZoneType());
|
||||
cmd.getZoneId(), hypervisorType, showDomr, cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria, tags);
|
||||
}
|
||||
|
||||
private Set<Pair<Long, Long>> listTemplates(Long templateId, String name, String keyword, TemplateFilter templateFilter, boolean isIso,
|
||||
Boolean bootable, Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean showDomr, boolean onlyReady,
|
||||
List<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags, String zoneType) {
|
||||
List<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags) {
|
||||
|
||||
VMTemplateVO template = null;
|
||||
if (templateId != null) {
|
||||
|
|
@ -1835,7 +1798,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, tags);
|
||||
Set<Pair<Long, Long>> templateZonePairSet2 = new HashSet<Pair<Long, Long>>();
|
||||
templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize,
|
||||
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags, zoneType);
|
||||
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags);
|
||||
|
||||
for (Pair<Long, Long> tmpltPair : templateZonePairSet2) {
|
||||
if (!templateZonePairSet.contains(new Pair<Long, Long>(tmpltPair.first(), -1L))) {
|
||||
|
|
@ -1859,7 +1822,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
Set<Pair<Long, Long>> templateZonePairSet2 = new HashSet<Pair<Long, Long>>();
|
||||
templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers,
|
||||
bootable, domain, pageSize, startIndex, zoneId, hyperType, onlyReady, showDomr,
|
||||
permittedAccounts, caller, listProjectResourcesCriteria, tags, zoneType);
|
||||
permittedAccounts, caller, listProjectResourcesCriteria, tags);
|
||||
|
||||
for (Pair<Long, Long> tmpltPair : templateZonePairSet2) {
|
||||
if (!templateZonePairSet.contains(new Pair<Long, Long>(tmpltPair.first(), -1L))) {
|
||||
|
|
@ -1877,7 +1840,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
} else {
|
||||
if (template == null) {
|
||||
templateZonePairSet = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize,
|
||||
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags, zoneType);
|
||||
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags);
|
||||
} else {
|
||||
// if template is not public, perform permission check here
|
||||
if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||
|
|
@ -3115,7 +3078,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSystemVMsCmd cmd) {
|
||||
String type = cmd.getSystemVmType();
|
||||
Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
|
||||
String zoneType = cmd.getZoneType();
|
||||
Long id = cmd.getId();
|
||||
String name = cmd.getSystemVmName();
|
||||
String state = cmd.getState();
|
||||
|
|
@ -3142,12 +3104,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
if(zoneType != null) {
|
||||
SearchBuilder<DataCenterVO> zoneSb = _dcDao.createSearchBuilder();
|
||||
zoneSb.and("zoneNetworkType", zoneSb.entity().getNetworkType(), SearchCriteria.Op.EQ);
|
||||
sb.join("zoneSb", zoneSb, sb.entity().getDataCenterId(), zoneSb.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
SearchCriteria<VMInstanceVO> sc = sb.create();
|
||||
|
||||
if (keyword != null) {
|
||||
|
|
@ -3188,10 +3144,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
sc.setJoinParameters("volumeSearch", "poolId", storageId);
|
||||
}
|
||||
|
||||
if(zoneType != null) {
|
||||
sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);
|
||||
}
|
||||
|
||||
Pair<List<VMInstanceVO>, Integer> result = _vmInstanceDao.searchAndCount(sc, searchFilter);
|
||||
return new Pair<List<? extends VirtualMachine>, Integer>(result.first(), result.second());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -779,6 +779,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||
|
||||
HypervisorType hypervisorType = HypervisorType.KVM;
|
||||
if (scopeType == ScopeType.ZONE) {
|
||||
// ignore passed clusterId and podId
|
||||
clusterId = null;
|
||||
podId = null;
|
||||
String hypervisor = cmd.getHypervisor();
|
||||
if (hypervisor != null) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
|
@ -193,13 +192,12 @@ public class S3ManagerImpl extends ManagerBase implements S3Manager {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String determineLockId(final long accountId, final long templateId) {
|
||||
static String determineLockId(final long accountId, final long templateId) {
|
||||
|
||||
// TBD The lock scope may be too coarse grained. Deletes need to lock
|
||||
// the template across all zones where upload and download could
|
||||
// probably safely scoped to the zone ...
|
||||
return join(asList("S3_TEMPLATE", accountId, templateId), "_");
|
||||
return join("_", "S3_TEMPLATE", accountId, templateId);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -397,9 +395,7 @@ public class S3ManagerImpl extends ManagerBase implements S3Manager {
|
|||
throw new CloudRuntimeException(errMsg);
|
||||
}
|
||||
|
||||
final String installPath = join(
|
||||
asList("template", "tmpl", accountId,
|
||||
templateId), File.separator);
|
||||
final String installPath = join(File.separator, "template", "tmpl", accountId, templateId);
|
||||
final VMTemplateHostVO tmpltHost = new VMTemplateHostVO(
|
||||
secondaryStorageHost.getId(), templateId,
|
||||
now(), 100, Status.DOWNLOADED, null, null,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ import com.cloud.configuration.Resource.ResourceType;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -572,7 +571,6 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
String keyword = cmd.getKeyword();
|
||||
String snapshotTypeStr = cmd.getSnapshotType();
|
||||
String intervalTypeStr = cmd.getIntervalType();
|
||||
String zoneType = cmd.getZoneType();
|
||||
Map<String, String> tags = cmd.getTags();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
|
|
@ -606,23 +604,17 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
|
||||
for (int count=0; count < tags.size(); count++) {
|
||||
tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
|
||||
tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
|
||||
tagSearch.cp();
|
||||
}
|
||||
tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
|
||||
sb.groupBy(sb.entity().getId());
|
||||
sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
|
||||
SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
|
||||
for (int count=0; count < tags.size(); count++) {
|
||||
tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
|
||||
tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
|
||||
tagSearch.cp();
|
||||
}
|
||||
tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
|
||||
sb.groupBy(sb.entity().getId());
|
||||
sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
if(zoneType != null) {
|
||||
SearchBuilder<DataCenterVO> zoneSb = _dcDao.createSearchBuilder();
|
||||
zoneSb.and("zoneNetworkType", zoneSb.entity().getNetworkType(), SearchCriteria.Op.EQ);
|
||||
sb.join("zoneSb", zoneSb, sb.entity().getDataCenterId(), zoneSb.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
SearchCriteria<SnapshotVO> sc = sb.create();
|
||||
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
|
|
@ -640,14 +632,10 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
}
|
||||
}
|
||||
|
||||
if(zoneType != null) {
|
||||
sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);
|
||||
}
|
||||
|
||||
if (zoneId != null) {
|
||||
sc.setParameters("dataCenterId", zoneId);
|
||||
}
|
||||
|
||||
|
||||
if (name != null) {
|
||||
sc.setParameters("name", "%" + name + "%");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -509,18 +509,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
// update the password in vm_details table too
|
||||
// Check if an SSH key pair was selected for the instance and if so
|
||||
// use it to encrypt & save the vm password
|
||||
String sshPublicKey = userVm.getDetail("SSH.PublicKey");
|
||||
if (sshPublicKey != null && !sshPublicKey.equals("")
|
||||
&& password != null && !password.equals("saved_password")) {
|
||||
String encryptedPasswd = RSAHelper.encryptWithSSHPublicKey(
|
||||
sshPublicKey, password);
|
||||
if (encryptedPasswd == null) {
|
||||
throw new CloudRuntimeException("Error encrypting password");
|
||||
}
|
||||
|
||||
userVm.setDetail("Encrypted.Password", encryptedPasswd);
|
||||
_vmDao.saveDetails(userVm);
|
||||
}
|
||||
encryptAndStorePassword(userVm, password);
|
||||
} else {
|
||||
throw new CloudRuntimeException(
|
||||
"Failed to reset password for the virtual machine ");
|
||||
|
|
@ -643,13 +632,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
if (template != null && template.getEnablePassword()) {
|
||||
userVm.setPassword(password);
|
||||
//update the encrypted password in vm_details table too
|
||||
if (sshPublicKey != null && !sshPublicKey.equals("") && password != null && !password.equals("saved_password")) {
|
||||
String encryptedPasswd = RSAHelper.encryptWithSSHPublicKey(sshPublicKey, password);
|
||||
if (encryptedPasswd == null) {
|
||||
throw new CloudRuntimeException("Error encrypting password");
|
||||
}
|
||||
userVm.setDetail("Encrypted.Password", encryptedPasswd);
|
||||
}
|
||||
encryptAndStorePassword(userVm, password);
|
||||
}
|
||||
_vmDao.saveDetails(userVm);
|
||||
} else {
|
||||
|
|
@ -3304,18 +3287,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
|
||||
// Check if an SSH key pair was selected for the instance and if so
|
||||
// use it to encrypt & save the vm password
|
||||
String sshPublicKey = vm.getDetail("SSH.PublicKey");
|
||||
if (sshPublicKey != null && !sshPublicKey.equals("")
|
||||
&& password != null && !password.equals("saved_password")) {
|
||||
String encryptedPasswd = RSAHelper.encryptWithSSHPublicKey(
|
||||
sshPublicKey, password);
|
||||
if (encryptedPasswd == null) {
|
||||
throw new CloudRuntimeException("Error encrypting password");
|
||||
}
|
||||
|
||||
vm.setDetail("Encrypted.Password", encryptedPasswd);
|
||||
_vmDao.saveDetails(vm);
|
||||
}
|
||||
encryptAndStorePassword(vm, password);
|
||||
|
||||
params = new HashMap<VirtualMachineProfile.Param, Object>();
|
||||
if (additionalParams != null) {
|
||||
|
|
@ -3832,7 +3804,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
"No permission to migrate VM, Only Root Admin can migrate a VM!");
|
||||
}
|
||||
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
VMInstanceVO vm = _vmInstanceDao.findById(vmId);
|
||||
if (vm == null) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Unable to find the VM by id=" + vmId);
|
||||
|
|
@ -3923,7 +3895,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
+ " already has max Running VMs(count includes system VMs), cannot migrate to this host");
|
||||
}
|
||||
|
||||
collectVmDiskStatistics(vm);
|
||||
UserVmVO uservm = _vmDao.findById(vmId);
|
||||
if (uservm != null) {
|
||||
collectVmDiskStatistics(uservm);
|
||||
}
|
||||
VMInstanceVO migratedVm = _itMgr.migrate(vm, srcHostId, dest);
|
||||
return migratedVm;
|
||||
}
|
||||
|
|
@ -4621,15 +4596,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
// update the password in vm_details table too
|
||||
// Check if an SSH key pair was selected for the instance and if so
|
||||
// use it to encrypt & save the vm password
|
||||
String sshPublicKey = vm.getDetail("SSH.PublicKey");
|
||||
if (sshPublicKey != null && !sshPublicKey.equals("") && password != null && !password.equals("saved_password")) {
|
||||
String encryptedPasswd = RSAHelper.encryptWithSSHPublicKey(sshPublicKey, password);
|
||||
if (encryptedPasswd == null) {
|
||||
throw new CloudRuntimeException("VM reset is completed but error occurred when encrypting newly created password");
|
||||
}
|
||||
vm.setDetail("Encrypted.Password", encryptedPasswd);
|
||||
_vmDao.saveDetails(vm);
|
||||
}
|
||||
encryptAndStorePassword(vm, password);
|
||||
} else {
|
||||
throw new CloudRuntimeException("VM reset is completed but failed to reset password for the virtual machine ");
|
||||
}
|
||||
|
|
@ -4717,5 +4684,24 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
if (vm.getState() == State.Running)
|
||||
collectVmDiskStatistics(vm);
|
||||
}
|
||||
|
||||
private void encryptAndStorePassword(UserVmVO vm, String password) {
|
||||
String sshPublicKey = vm.getDetail("SSH.PublicKey");
|
||||
if (sshPublicKey != null && !sshPublicKey.equals("")
|
||||
&& password != null && !password.equals("saved_password")) {
|
||||
if (!sshPublicKey.startsWith("ssh-rsa")) {
|
||||
s_logger.warn("Only RSA public keys can be used to encrypt a vm password.");
|
||||
return;
|
||||
}
|
||||
String encryptedPasswd = RSAHelper.encryptWithSSHPublicKey(
|
||||
sshPublicKey, password);
|
||||
if (encryptedPasswd == null) {
|
||||
throw new CloudRuntimeException("Error encrypting password");
|
||||
}
|
||||
|
||||
vm.setDetail("Encrypted.Password", encryptedPasswd);
|
||||
_vmDao.saveDetails(vm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import static com.cloud.utils.S3Utils.putDirectory;
|
|||
import static com.cloud.utils.StringUtils.join;
|
||||
import static com.cloud.utils.db.GlobalLock.executeWithNoWaitLock;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.apache.commons.lang.StringUtils.substringAfterLast;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
|
|
@ -217,19 +216,16 @@ SecondaryStorageResource {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String determineS3TemplateDirectory(final Long accountId,
|
||||
static String determineS3TemplateDirectory(final Long accountId,
|
||||
final Long templateId) {
|
||||
return join(asList(TEMPLATE_ROOT_DIR, accountId, templateId),
|
||||
S3Utils.SEPARATOR);
|
||||
return join(S3Utils.SEPARATOR, TEMPLATE_ROOT_DIR, accountId, templateId);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String determineStorageTemplatePath(final String storagePath,
|
||||
final Long accountId, final Long templateId) {
|
||||
return join(
|
||||
asList(getRootDir(storagePath), TEMPLATE_ROOT_DIR, accountId,
|
||||
templateId), File.separator);
|
||||
return join(File.separator,
|
||||
getRootDir(storagePath), TEMPLATE_ROOT_DIR, accountId,
|
||||
templateId);
|
||||
}
|
||||
|
||||
private Answer execute(
|
||||
|
|
@ -405,10 +401,7 @@ SecondaryStorageResource {
|
|||
s_logger.debug(String
|
||||
.format("Determining key using account id %1$s and template id %2$s",
|
||||
accountId, templateId));
|
||||
return join(
|
||||
asList(determineS3TemplateDirectory(
|
||||
accountId, templateId), file
|
||||
.getName()), S3Utils.SEPARATOR);
|
||||
return join(S3Utils.SEPARATOR, determineS3TemplateDirectory(accountId, templateId), file.getName());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1881,3 +1881,6 @@ SET foreign_key_checks = 1;
|
|||
UPDATE `cloud`.`snapshot_policy` set uuid=id WHERE uuid is NULL;
|
||||
#update shared sg enabled network with not null name in Advance Security Group enabled network
|
||||
UPDATE `cloud`.`networks` set name='Shared SG enabled network', display_text='Shared SG enabled network' WHERE name IS null AND traffic_type='Guest' AND data_center_id IN (select id from data_center where networktype='Advanced' and is_security_group_enabled=1) AND acl_type='Domain';
|
||||
|
||||
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'use.system.public.ips', 'true', 'If true, when account has dedicated public ip range(s), once the ips dedicated to the account have been consumed ips will be acquired from the system pool');
|
||||
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'use.system.guest.vlans', 'true', 'If true, when account has dedicated guest vlan range(s), once the vlans dedicated to the account have been consumed vlans will be allocated from the system pool');
|
||||
|
|
|
|||
|
|
@ -218,7 +218,8 @@
|
|||
"mgtSvrIp": "localhost",
|
||||
"passwd": "password",
|
||||
"user": "root",
|
||||
"port": 8096
|
||||
"port": 8096,
|
||||
"hypervisor" : "simulator"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,11 +68,6 @@ class Services:
|
|||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"volume": {
|
||||
"diskname": "APP Data Volume",
|
||||
"size": 1, # in GBs
|
||||
"diskdevice": "/dev/xvdb", # Data Disk
|
||||
},
|
||||
"templates": {
|
||||
"displaytext": 'Template from snapshot',
|
||||
"name": 'Template from snapshot',
|
||||
|
|
@ -86,13 +81,6 @@ class Services:
|
|||
"isextractable": True,
|
||||
"passwordenabled": True,
|
||||
},
|
||||
"paths": {
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sub_dir": "test",
|
||||
"sub_lvl_dir1": "test1",
|
||||
"sub_lvl_dir2": "test2",
|
||||
"random_data": "random.data",
|
||||
},
|
||||
"static_nat": {
|
||||
"startport": 22,
|
||||
"endport": 22,
|
||||
|
|
@ -104,297 +92,6 @@ class Services:
|
|||
}
|
||||
|
||||
|
||||
class TestSnapshots(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.api_client = super(TestSnapshots, cls).getClsTestClient().getApiClient()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.services['mode'] = cls.zone.networktype
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["disk_offering"]
|
||||
)
|
||||
cls.template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["volume"]["zoneid"] = cls.zone.id
|
||||
|
||||
cls.services["template"] = cls.template.id
|
||||
cls.services["zoneid"] = cls.zone.id
|
||||
|
||||
# Create VMs, NAT Rules etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.services["account"] = cls.account.name
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls.virtual_machine = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["virtual_machine"],
|
||||
templateid=cls.template.id,
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
cls.disk_offering,
|
||||
cls.account,
|
||||
]
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
#Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created instance, volumes and snapshots
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "advancedns"])
|
||||
def test_01_volume_from_snapshot(self):
|
||||
"""TS_BUG_001-Test Creating snapshot from volume having spaces in name(KVM)
|
||||
"""
|
||||
|
||||
|
||||
# Validate the following
|
||||
#1. Create a virtual machine and data volume
|
||||
#2. Attach data volume to VM
|
||||
#3. Login to machine; create temp/test directories on data volume
|
||||
#4. Snapshot the Volume
|
||||
#5. Create another Volume from snapshot
|
||||
#6. Mount/Attach volume to another server
|
||||
#7. Compare data
|
||||
|
||||
random_data_0 = random_gen(100)
|
||||
random_data_1 = random_gen(100)
|
||||
|
||||
volume = Volume.create(
|
||||
self.apiclient,
|
||||
self.services["volume"],
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
diskofferingid=self.disk_offering.id
|
||||
)
|
||||
self.debug("Created volume with ID: %s" % volume.id)
|
||||
self.virtual_machine.attach_volume(
|
||||
self.apiclient,
|
||||
volume
|
||||
)
|
||||
self.debug("Attach volume: %s to VM: %s" %
|
||||
(volume.id, self.virtual_machine.id))
|
||||
try:
|
||||
ssh_client = self.virtual_machine.get_ssh_client()
|
||||
except Exception as e:
|
||||
self.fail("SSH failed for VM: %s" %
|
||||
self.virtual_machine.ipaddress)
|
||||
|
||||
self.debug("Formatting volume: %s to ext3" % volume.id)
|
||||
#Format partition using ext3
|
||||
format_volume_to_ext3(
|
||||
ssh_client,
|
||||
self.services["volume"]["diskdevice"]
|
||||
)
|
||||
cmds = [
|
||||
"mkdir -p %s" % self.services["paths"]["mount_dir"],
|
||||
"mount %s1 %s" % (
|
||||
self.services["volume"]["diskdevice"],
|
||||
self.services["paths"]["mount_dir"]
|
||||
),
|
||||
"mkdir -p %s/%s/{%s,%s} " % (
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir1"],
|
||||
self.services["paths"]["sub_lvl_dir2"]
|
||||
),
|
||||
"echo %s > %s/%s/%s/%s" % (
|
||||
random_data_0,
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir1"],
|
||||
self.services["paths"]["random_data"]
|
||||
),
|
||||
"echo %s > %s/%s/%s/%s" % (
|
||||
random_data_1,
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir2"],
|
||||
self.services["paths"]["random_data"]
|
||||
),
|
||||
]
|
||||
for c in cmds:
|
||||
self.debug("Command: %s" % c)
|
||||
ssh_client.execute(c)
|
||||
|
||||
# Unmount the Sec Storage
|
||||
cmds = [
|
||||
"umount %s" % (self.services["paths"]["mount_dir"]),
|
||||
]
|
||||
for c in cmds:
|
||||
self.debug("Command: %s" % c)
|
||||
ssh_client.execute(c)
|
||||
|
||||
list_volume_response = Volume.list(
|
||||
self.apiclient,
|
||||
virtualmachineid=self.virtual_machine.id,
|
||||
type='DATADISK',
|
||||
listall=True
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
isinstance(list_volume_response, list),
|
||||
True,
|
||||
"Check list volume response for valid data"
|
||||
)
|
||||
volume_response = list_volume_response[0]
|
||||
#Create snapshot from attached volume
|
||||
snapshot = Snapshot.create(
|
||||
self.apiclient,
|
||||
volume_response.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.debug("Created snapshot: %s" % snapshot.id)
|
||||
#Create volume from snapshot
|
||||
volume_from_snapshot = Volume.create_from_snapshot(
|
||||
self.apiclient,
|
||||
snapshot.id,
|
||||
self.services["volume"],
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.debug("Created Volume: %s from Snapshot: %s" % (
|
||||
volume_from_snapshot.id,
|
||||
snapshot.id))
|
||||
volumes = Volume.list(
|
||||
self.apiclient,
|
||||
id=volume_from_snapshot.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(volumes, list),
|
||||
True,
|
||||
"Check list response returns a valid list"
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(volumes),
|
||||
None,
|
||||
"Check Volume list Length"
|
||||
)
|
||||
self.assertEqual(
|
||||
volumes[0].id,
|
||||
volume_from_snapshot.id,
|
||||
"Check Volume in the List Volumes"
|
||||
)
|
||||
#Attaching volume to new VM
|
||||
new_virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
templateid=self.template.id,
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
mode=self.services["mode"]
|
||||
)
|
||||
self.debug("Deployed new VM for account: %s" % self.account.name)
|
||||
self.cleanup.append(new_virtual_machine)
|
||||
|
||||
self.debug("Attaching volume: %s to VM: %s" % (
|
||||
volume_from_snapshot.id,
|
||||
new_virtual_machine.id
|
||||
))
|
||||
|
||||
cmd = attachVolume.attachVolumeCmd()
|
||||
cmd.id = volume_from_snapshot.id
|
||||
cmd.virtualmachineid = new_virtual_machine.id
|
||||
self.apiclient.attachVolume(cmd)
|
||||
|
||||
try:
|
||||
#Login to VM to verify test directories and files
|
||||
ssh = new_virtual_machine.get_ssh_client()
|
||||
|
||||
cmds = [
|
||||
"mkdir -p %s" % self.services["paths"]["mount_dir"],
|
||||
"mount %s1 %s" % (
|
||||
self.services["volume"]["diskdevice"],
|
||||
self.services["paths"]["mount_dir"]
|
||||
),
|
||||
]
|
||||
|
||||
for c in cmds:
|
||||
self.debug("Command: %s" % c)
|
||||
ssh.execute(c)
|
||||
|
||||
returned_data_0 = ssh.execute(
|
||||
"cat %s/%s/%s/%s" % (
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir1"],
|
||||
self.services["paths"]["random_data"]
|
||||
))
|
||||
returned_data_1 = ssh.execute(
|
||||
"cat %s/%s/%s/%s" % (
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir2"],
|
||||
self.services["paths"]["random_data"]
|
||||
))
|
||||
except Exception as e:
|
||||
self.fail("SSH access failed for VM: %s" %
|
||||
new_virtual_machine.ipaddress)
|
||||
#Verify returned data
|
||||
self.assertEqual(
|
||||
random_data_0,
|
||||
returned_data_0[0],
|
||||
"Verify newly attached volume contents with existing one"
|
||||
)
|
||||
self.assertEqual(
|
||||
random_data_1,
|
||||
returned_data_1[0],
|
||||
"Verify newly attached volume contents with existing one"
|
||||
)
|
||||
# Unmount the Sec Storage
|
||||
cmds = [
|
||||
"umount %s" % (self.services["paths"]["mount_dir"]),
|
||||
]
|
||||
for c in cmds:
|
||||
self.debug("Command: %s" % c)
|
||||
ssh_client.execute(c)
|
||||
return
|
||||
|
||||
|
||||
class TestTemplate(cloudstackTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
|
|
@ -87,9 +87,6 @@ class Services:
|
|||
"name": "Cent OS Template",
|
||||
"passwordenabled": True,
|
||||
},
|
||||
"diskdevice": '/dev/xvdd',
|
||||
# Disk device where ISO is attached to instance
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
"ostype": 'CentOS 5.3 (64-bit)'
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ class Services:
|
|||
"name": "Cent OS Template",
|
||||
"passwordenabled": True,
|
||||
},
|
||||
"diskdevice": '/dev/xvdd',
|
||||
# Disk device where ISO is attached to instance
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
#Migrate VM to hostid
|
||||
|
|
|
|||
|
|
@ -1085,7 +1085,7 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
|
|||
# 3. Acquire Ip address and create LB rule on it. Add multiple VMs to
|
||||
# this rule. LB rule should be
|
||||
# In Netscaler: For every Vm added to the LB rule:
|
||||
# 1. A server and service instance is created using guest VM’s IP and
|
||||
# 1. A server and service instance is created using guest VMs IP and
|
||||
# port number on the Netscaler LB device,
|
||||
# 2. This service is bound to lb virtual server corresponding to lb
|
||||
# rule.
|
||||
|
|
|
|||
|
|
@ -65,13 +65,6 @@ class Services:
|
|||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"volume": {
|
||||
"diskname": "APP Data Volume",
|
||||
"size": 1,
|
||||
# in GBs
|
||||
"diskdevice": "/dev/xvdb",
|
||||
# Data Disk
|
||||
},
|
||||
"static_nat": {
|
||||
"startport": 22,
|
||||
"endport": 22,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
"""
|
||||
#Import Local Modules
|
||||
import marvin
|
||||
from nose.plugins.attrib import attr
|
||||
from marvin.cloudstackTestCase import *
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.integration.lib.utils import *
|
||||
|
|
|
|||
|
|
@ -108,6 +108,18 @@ class Services:
|
|||
"ostype": "CentOS 5.3 (64-bit)",
|
||||
"templatefilter": 'self',
|
||||
},
|
||||
"volume": {
|
||||
"diskname": "APP Data Volume",
|
||||
"size": 1, # in GBs
|
||||
"diskdevice": "/dev/xvdb", # Data Disk
|
||||
},
|
||||
"paths": {
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sub_dir": "test",
|
||||
"sub_lvl_dir1": "test1",
|
||||
"sub_lvl_dir2": "test2",
|
||||
"random_data": "random.data",
|
||||
},
|
||||
"diskdevice": "/dev/xvda",
|
||||
"diskname": "TestDiskServ",
|
||||
"size": 1, # GBs
|
||||
|
|
@ -377,6 +389,11 @@ class TestSnapshots(cloudstackTestCase):
|
|||
cls.services["zoneid"] = cls.zone.id
|
||||
cls.services["diskoffering"] = cls.disk_offering.id
|
||||
|
||||
#determine device type from hypervisor
|
||||
hosts = Host.list(cls.api_client, id=cls.virtual_machine.hostid)
|
||||
if len(hosts) > 0 and hosts[0].hypervisor.lower() == "kvm":
|
||||
cls.service["volume"]["diskdevice"] = "/dev/vdb"
|
||||
|
||||
# Create VMs, NAT Rules etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
|
|
@ -583,81 +600,102 @@ class TestSnapshots(cloudstackTestCase):
|
|||
return
|
||||
|
||||
@attr(speed = "slow")
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "xen"])
|
||||
def test_03_volume_from_snapshot(self):
|
||||
"""Create volumes from snapshots
|
||||
@attr(tags = ["advanced", "advancedns", "basic", "sg"])
|
||||
def test_01_volume_from_snapshot(self):
|
||||
"""Test Creating snapshot from volume having spaces in name(KVM)
|
||||
"""
|
||||
#1. Login to machine; create temp/test directories on data volume
|
||||
#2. Snapshot the Volume
|
||||
#3. Create another Volume from snapshot
|
||||
#4. Mount/Attach volume to another server
|
||||
#5. Compare data
|
||||
# Validate the following
|
||||
#1. Create a virtual machine and data volume
|
||||
#2. Attach data volume to VM
|
||||
#3. Login to machine; create temp/test directories on data volume
|
||||
#4. Snapshot the Volume
|
||||
#5. Create another Volume from snapshot
|
||||
#6. Mount/Attach volume to another server
|
||||
#7. Compare data
|
||||
|
||||
random_data_0 = random_gen(100)
|
||||
random_data_1 = random_gen(100)
|
||||
|
||||
volume = Volume.create(
|
||||
self.apiclient,
|
||||
self.services["volume"],
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
diskofferingid=self.disk_offering.id
|
||||
)
|
||||
self.debug("Created volume with ID: %s" % volume.id)
|
||||
self.virtual_machine.attach_volume(
|
||||
self.apiclient,
|
||||
volume
|
||||
)
|
||||
self.debug("Attach volume: %s to VM: %s" %
|
||||
(volume.id, self.virtual_machine.id))
|
||||
|
||||
|
||||
try:
|
||||
ssh_client = self.virtual_machine.get_ssh_client()
|
||||
except Exception as e:
|
||||
self.fail("SSH failed for VM: %s" %
|
||||
self.virtual_machine.ipaddress)
|
||||
|
||||
#Format partition using ext3
|
||||
format_volume_to_ext3(
|
||||
self.debug("Formatting volume: %s to ext3" % volume.id)
|
||||
#Format partition using ext3
|
||||
format_volume_to_ext3(
|
||||
ssh_client,
|
||||
self.services["diskdevice"]
|
||||
self.services["volume"]["diskdevice"]
|
||||
)
|
||||
cmds = [
|
||||
"mkdir -p %s" % self.services["mount_dir"],
|
||||
cmds = [
|
||||
"mkdir -p %s" % self.services["paths"]["mount_dir"],
|
||||
"mount %s1 %s" % (
|
||||
self.services["diskdevice"],
|
||||
self.services["mount_dir"]
|
||||
self.services["volume"]["diskdevice"],
|
||||
self.services["paths"]["mount_dir"]
|
||||
),
|
||||
"mkdir -p %s/%s/{%s,%s} " % (
|
||||
self.services["mount_dir"],
|
||||
self.services["sub_dir"],
|
||||
self.services["sub_lvl_dir1"],
|
||||
self.services["sub_lvl_dir2"]
|
||||
),
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir1"],
|
||||
self.services["paths"]["sub_lvl_dir2"]
|
||||
),
|
||||
"echo %s > %s/%s/%s/%s" % (
|
||||
random_data_0,
|
||||
self.services["mount_dir"],
|
||||
self.services["sub_dir"],
|
||||
self.services["sub_lvl_dir1"],
|
||||
self.services["random_data"]
|
||||
),
|
||||
random_data_0,
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir1"],
|
||||
self.services["paths"]["random_data"]
|
||||
),
|
||||
"echo %s > %s/%s/%s/%s" % (
|
||||
random_data_1,
|
||||
self.services["mount_dir"],
|
||||
self.services["sub_dir"],
|
||||
self.services["sub_lvl_dir2"],
|
||||
self.services["random_data"]
|
||||
),
|
||||
random_data_1,
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir2"],
|
||||
self.services["paths"]["random_data"]
|
||||
),
|
||||
]
|
||||
for c in cmds:
|
||||
self.debug(c)
|
||||
ssh_client.execute(c)
|
||||
for c in cmds:
|
||||
self.debug("Command: %s" % c)
|
||||
ssh_client.execute(c)
|
||||
|
||||
except Exception as e:
|
||||
self.fail("SSH failed for VM with IP: %s" %
|
||||
self.virtual_machine.ipaddress)
|
||||
# Unmount the Sec Storage
|
||||
cmds = [
|
||||
"umount %s" % (self.services["mount_dir"]),
|
||||
"umount %s" % (self.services["paths"]["mount_dir"]),
|
||||
]
|
||||
for c in cmds:
|
||||
self.debug("Command: %s" % c)
|
||||
ssh_client.execute(c)
|
||||
|
||||
try:
|
||||
for c in cmds:
|
||||
self.debug(c)
|
||||
ssh_client.execute(c)
|
||||
|
||||
except Exception as e:
|
||||
self.fail("SSH failed for VM with IP: %s" %
|
||||
self.virtual_machine.ipaddress)
|
||||
|
||||
list_volume_response = list_volumes(
|
||||
list_volume_response = Volume.list(
|
||||
self.apiclient,
|
||||
virtualmachineid=self.virtual_machine.id,
|
||||
type='DATADISK',
|
||||
listall=True
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
isinstance(list_volume_response, list),
|
||||
True,
|
||||
"Check list volume response for valid data"
|
||||
)
|
||||
volume_response = list_volume_response[0]
|
||||
#Create snapshot from attached volume
|
||||
snapshot = Snapshot.create(
|
||||
|
|
@ -666,81 +704,94 @@ class TestSnapshots(cloudstackTestCase):
|
|||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.debug("Created Snapshot from volume: %s" % volume_response.id)
|
||||
|
||||
self.debug("Created snapshot: %s" % snapshot.id)
|
||||
#Create volume from snapshot
|
||||
self.debug("Creating volume from snapshot: %s" % snapshot.id)
|
||||
volume = Volume.create_from_snapshot(
|
||||
volume_from_snapshot = Volume.create_from_snapshot(
|
||||
self.apiclient,
|
||||
snapshot.id,
|
||||
self.services,
|
||||
self.services["volume"],
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
|
||||
volumes = list_volumes(
|
||||
self.debug("Created Volume: %s from Snapshot: %s" % (
|
||||
volume_from_snapshot.id,
|
||||
snapshot.id))
|
||||
volumes = Volume.list(
|
||||
self.apiclient,
|
||||
id=volume.id
|
||||
id=volume_from_snapshot.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(volumes, list),
|
||||
True,
|
||||
"Check list response returns a valid list"
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(volumes),
|
||||
None,
|
||||
"Check Volume list Length"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
volumes[0].id,
|
||||
volume.id,
|
||||
volume_from_snapshot.id,
|
||||
"Check Volume in the List Volumes"
|
||||
)
|
||||
#Attaching volume to new VM
|
||||
new_virtual_machine = self.virtual_machine_without_disk
|
||||
new_virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["server_without_disk"],
|
||||
templateid=self.template.id,
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
mode=self.services["mode"]
|
||||
)
|
||||
self.debug("Deployed new VM for account: %s" % self.account.name)
|
||||
self.cleanup.append(new_virtual_machine)
|
||||
|
||||
cmd = attachVolume.attachVolumeCmd()
|
||||
cmd.id = volume.id
|
||||
cmd.virtualmachineid = new_virtual_machine.id
|
||||
self.apiclient.attachVolume(cmd)
|
||||
self.debug("Attaching volume: %s to VM: %s" % (
|
||||
volume_from_snapshot.id,
|
||||
new_virtual_machine.id
|
||||
))
|
||||
|
||||
self.new_virtual_machine.attach_volume(
|
||||
self.apiclient,
|
||||
volume_from_snapshot
|
||||
)
|
||||
|
||||
try:
|
||||
#Login to VM to verify test directories and files
|
||||
ssh = new_virtual_machine.get_ssh_client()
|
||||
|
||||
cmds = [
|
||||
"mkdir -p %s" % self.services["mount_dir"],
|
||||
"mkdir -p %s" % self.services["paths"]["mount_dir"],
|
||||
"mount %s1 %s" % (
|
||||
self.services["diskdevice"],
|
||||
self.services["mount_dir"]
|
||||
self.services["volume"]["diskdevice"],
|
||||
self.services["paths"]["mount_dir"]
|
||||
),
|
||||
]
|
||||
|
||||
for c in cmds:
|
||||
self.debug(c)
|
||||
result = ssh.execute(c)
|
||||
self.debug(result)
|
||||
|
||||
returned_data_0 = ssh.execute("cat %s/%s/%s/%s" % (
|
||||
self.services["mount_dir"],
|
||||
self.services["sub_dir"],
|
||||
self.services["sub_lvl_dir1"],
|
||||
self.services["random_data"]
|
||||
))
|
||||
returned_data_1 = ssh.execute("cat %s/%s/%s/%s" % (
|
||||
self.services["mount_dir"],
|
||||
self.services["sub_dir"],
|
||||
self.services["sub_lvl_dir2"],
|
||||
self.services["random_data"]
|
||||
))
|
||||
self.debug("Command: %s" % c)
|
||||
ssh.execute(c)
|
||||
|
||||
returned_data_0 = ssh.execute(
|
||||
"cat %s/%s/%s/%s" % (
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir1"],
|
||||
self.services["paths"]["random_data"]
|
||||
))
|
||||
returned_data_1 = ssh.execute(
|
||||
"cat %s/%s/%s/%s" % (
|
||||
self.services["paths"]["mount_dir"],
|
||||
self.services["paths"]["sub_dir"],
|
||||
self.services["paths"]["sub_lvl_dir2"],
|
||||
self.services["paths"]["random_data"]
|
||||
))
|
||||
except Exception as e:
|
||||
self.fail("SSH failed for VM with IP: %s" %
|
||||
self.new_virtual_machine.ipaddress)
|
||||
|
||||
self.fail("SSH access failed for VM: %s" %
|
||||
new_virtual_machine.ipaddress)
|
||||
#Verify returned data
|
||||
self.assertEqual(
|
||||
random_data_0,
|
||||
|
|
@ -754,15 +805,11 @@ class TestSnapshots(cloudstackTestCase):
|
|||
)
|
||||
# Unmount the Sec Storage
|
||||
cmds = [
|
||||
"umount %s" % (self.services["mount_dir"]),
|
||||
"umount %s" % (self.services["paths"]["mount_dir"]),
|
||||
]
|
||||
try:
|
||||
for c in cmds:
|
||||
ssh_client.execute(c)
|
||||
|
||||
except Exception as e:
|
||||
self.fail("SSH failed for VM with IP: %s" %
|
||||
self.new_virtual_machine.ipaddress)
|
||||
for c in cmds:
|
||||
self.debug("Command: %s" % c)
|
||||
ssh_client.execute(c)
|
||||
return
|
||||
|
||||
@attr(speed = "slow")
|
||||
|
|
@ -1182,6 +1229,7 @@ class TestSnapshots(cloudstackTestCase):
|
|||
new_virtual_machine.ipaddress)
|
||||
return
|
||||
|
||||
|
||||
class TestCreateVMsnapshotTemplate(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
|
|
@ -1560,7 +1608,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
|
|||
return
|
||||
|
||||
@attr(speed = "slow")
|
||||
@attr(tags = ["advanced", "advancedns"])
|
||||
@attr(tags = ["advanced", "advancedns", "basic", "sg"])
|
||||
def test_02_accountSnapshotClean(self):
|
||||
"""Test snapshot cleanup after account deletion
|
||||
"""
|
||||
|
|
@ -1852,6 +1900,11 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
|
|||
|
||||
cls.services["template"] = template.id
|
||||
|
||||
#determine device type from hypervisor
|
||||
hosts = Host.list(cls.api_client, id=cls.virtual_machine.hostid)
|
||||
if len(hosts) > 0 and hosts[0].hypervisor.lower() == "kvm":
|
||||
cls.service["volume"]["diskdevice"] = "/dev/vdb"
|
||||
|
||||
# Create VMs, NAT Rules etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
|
|
@ -1905,7 +1958,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
|
|||
return
|
||||
|
||||
@attr(speed = "slow")
|
||||
@attr(tags = ["advanced", "advancedns", "xen"])
|
||||
@attr(tags = ["advanced", "advancedns", "basic", "sg"])
|
||||
def test_03_snapshot_detachedDisk(self):
|
||||
"""Test snapshot from detached disk
|
||||
"""
|
||||
|
|
@ -1941,7 +1994,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
|
|||
#Format partition using ext3
|
||||
format_volume_to_ext3(
|
||||
ssh_client,
|
||||
self.services["diskdevice"]
|
||||
self.services["volume"]["diskdevice"]
|
||||
)
|
||||
cmds = [
|
||||
"mkdir -p %s" % self.services["mount_dir"],
|
||||
|
|
|
|||
|
|
@ -79,9 +79,6 @@ class Services:
|
|||
"name": "Cent OS Template",
|
||||
"passwordenabled": True,
|
||||
},
|
||||
"diskdevice": '/dev/xvdd',
|
||||
# Disk device where ISO is attached to instance
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
#Migrate VM to hostid
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ from marvin.integration.lib.base import *
|
|||
from marvin.integration.lib.common import *
|
||||
from marvin.remoteSSHClient import remoteSSHClient
|
||||
#Import System modules
|
||||
import os
|
||||
import urllib
|
||||
import time
|
||||
import tempfile
|
||||
|
||||
|
||||
class Services:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#Import Local Modules
|
||||
from nose.plugins.attrib import attr
|
||||
from marvin.cloudstackTestCase import *
|
||||
from marvin.cloudstackException import cloudstackAPIException
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.integration.lib.utils import *
|
||||
from marvin.integration.lib.base import *
|
||||
|
|
@ -795,16 +796,16 @@ class TestVPC(cloudstackTestCase):
|
|||
self.services["vpc"],
|
||||
vpcofferingid=self.vpc_off.id,
|
||||
zoneid=self.zone.id,
|
||||
account=self.user.account.name,
|
||||
domainid=self.user.account.domainid
|
||||
account=self.user.name,
|
||||
domainid=self.user.domainid
|
||||
)
|
||||
self.validate_vpc_network(vpc_2)
|
||||
|
||||
self.debug("Validating list VPCs call by passing account and domain")
|
||||
vpcs = VPC.list(
|
||||
self.apiclient,
|
||||
account=self.user.account.name,
|
||||
domainid=self.user.account.domainid,
|
||||
account=self.user.name,
|
||||
domainid=self.user.domainid,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
|
|
@ -820,7 +821,7 @@ class TestVPC(cloudstackTestCase):
|
|||
)
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
@attr(tags=["advanced", "intervlan", "multiple"])
|
||||
def test_07_restart_network_vm_running(self):
|
||||
""" Test Restart VPC when there are multiple networks associated
|
||||
"""
|
||||
|
|
@ -1650,7 +1651,7 @@ class TestVPC(cloudstackTestCase):
|
|||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_11_deploy_vm_wo_network_netdomain(self):
|
||||
""" Test deployment of vm in a VPC without network netdomain
|
||||
""" Test deployment of vm in a VPC without network domain
|
||||
"""
|
||||
|
||||
# 1. Create VPC without providing networkDomain.
|
||||
|
|
@ -1923,8 +1924,7 @@ class TestVPC(cloudstackTestCase):
|
|||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_14_deploy_vm_1(self):
|
||||
""" Test deployment of vm in a network from user account. But the VPC is created
|
||||
without account/domain ID
|
||||
""" Test vm deploy in network by a user where VPC was created without account/domain ID
|
||||
"""
|
||||
|
||||
# 1. Create VPC without providing account/domain ID.
|
||||
|
|
@ -1935,18 +1935,19 @@ class TestVPC(cloudstackTestCase):
|
|||
self.apiclient,
|
||||
self.services["account"]
|
||||
)
|
||||
self.debug("Created account: %s" % user.account.name)
|
||||
self.debug("Created account: %s" % user.name)
|
||||
self.cleanup.append(user)
|
||||
|
||||
self.services["vpc"]["cidr"] = "10.1.1.1/16"
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
user.account.name)
|
||||
user.name)
|
||||
|
||||
userapiclient = self.testClient.createNewApiClient(
|
||||
UserName=user.account.name,
|
||||
DomainName=user.account.domain,
|
||||
userapiclient = self.testClient.createUserApiClient(
|
||||
UserName=user.name,
|
||||
DomainName=user.domain,
|
||||
acctType=0)
|
||||
|
||||
|
||||
vpc = VPC.create(
|
||||
userapiclient,
|
||||
self.services["vpc"],
|
||||
|
|
@ -1999,8 +2000,7 @@ class TestVPC(cloudstackTestCase):
|
|||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_15_deploy_vm_2(self):
|
||||
""" Test deployment of vm in a network from domain admin account. But the VPC is created
|
||||
without account/domain ID
|
||||
""" Test deployment of vm in a network in a domain admin account where VPC is created without account/domain ID
|
||||
"""
|
||||
|
||||
# 1. Create VPC without providing account/domain ID.
|
||||
|
|
@ -2016,18 +2016,18 @@ class TestVPC(cloudstackTestCase):
|
|||
self.apiclient,
|
||||
self.services["account"]
|
||||
)
|
||||
self.debug("Created account: %s" % user.account.name)
|
||||
self.debug("Created account: %s" % user.name)
|
||||
self.cleanup.append(user)
|
||||
|
||||
self.services["vpc"]["cidr"] = "10.1.1.1/16"
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
user.account.name)
|
||||
user.name)
|
||||
|
||||
#0 - User, 1 - Root Admin, 2 - Domain Admin
|
||||
userapiclient = self.testClient.createNewApiClient(
|
||||
UserName=user.account.name,
|
||||
DomainName=self.services["domain"]["name"],
|
||||
acctType=2)
|
||||
userapiclient = self.testClient.getUserApiClient(
|
||||
account=user.name,
|
||||
domain=self.services["domain"]["name"],
|
||||
type=2)
|
||||
|
||||
vpc = VPC.create(
|
||||
userapiclient,
|
||||
|
|
@ -2092,23 +2092,23 @@ class TestVPC(cloudstackTestCase):
|
|||
self.apiclient,
|
||||
self.services["account"]
|
||||
)
|
||||
self.debug("Created account: %s" % user.account.name)
|
||||
self.debug("Created account: %s" % user.name)
|
||||
self.cleanup.append(user)
|
||||
|
||||
self.services["vpc"]["cidr"] = "10.1.1.1/16"
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
user.account.name)
|
||||
user.name)
|
||||
|
||||
userapiclient = self.testClient.createNewApiClient(
|
||||
UserName=user.account.name,
|
||||
DomainName=user.account.domain,
|
||||
acctType=0)
|
||||
userapiclient = self.testClient.getUserApiClient(
|
||||
account=user.name,
|
||||
domain=user.domain,
|
||||
type=0)
|
||||
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
self.services["vpc"],
|
||||
account=user.account.name,
|
||||
domainid=user.account.domainid,
|
||||
account=user.name,
|
||||
domainid=user.domainid,
|
||||
vpcofferingid=self.vpc_off.id,
|
||||
zoneid=self.zone.id,
|
||||
)
|
||||
|
|
@ -2176,82 +2176,39 @@ class TestVPC(cloudstackTestCase):
|
|||
self.apiclient,
|
||||
self.services["domain_admin"]
|
||||
)
|
||||
self.debug("Created account: %s" % domain_admin.account.name)
|
||||
self.debug("Created account: %s" % domain_admin.name)
|
||||
self.cleanup.append(domain_admin)
|
||||
da_apiclient = self.testClient.createNewApiClient(
|
||||
UserName=domain_admin.account.name,
|
||||
#DomainName=self.services["domain"]["name"],
|
||||
DomainName=domain_admin.account.domain,
|
||||
acctType=2)
|
||||
da_apiclient = self.testClient.getUserApiClient(
|
||||
account=domain_admin.name,
|
||||
domain=domain_admin.domain,
|
||||
type=2)
|
||||
|
||||
user = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"]
|
||||
)
|
||||
self.debug("Created account: %s" % user.account.name)
|
||||
self.debug("Created account: %s" % user.name)
|
||||
self.cleanup.append(user)
|
||||
|
||||
self.services["vpc"]["cidr"] = "10.1.1.1/16"
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
user.account.name)
|
||||
user.name)
|
||||
|
||||
#0 - User, 1 - Root Admin, 2 - Domain Admin
|
||||
userapiclient = self.testClient.createNewApiClient(
|
||||
UserName=user.account.name,
|
||||
DomainName=user.account.domain,
|
||||
acctType=0)
|
||||
userapiclient = self.testClient.getUserApiClient(
|
||||
account=user.name,
|
||||
domain=user.domain,
|
||||
type=0)
|
||||
|
||||
vpc = VPC.create(
|
||||
da_apiclient,
|
||||
self.services["vpc"],
|
||||
account=user.account.name,
|
||||
domainid=user.account.domainid,
|
||||
vpcofferingid=self.vpc_off.id,
|
||||
zoneid=self.zone.id,
|
||||
)
|
||||
self.validate_vpc_network(vpc)
|
||||
|
||||
self.network_offering = NetworkOffering.create(
|
||||
self.apiclient,
|
||||
self.services["network_offering"],
|
||||
conservemode=False
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(self.network_offering)
|
||||
|
||||
gateway = vpc.cidr.split('/')[0]
|
||||
# Split the cidr to retrieve gateway
|
||||
# for eg. cidr = 10.0.0.1/24
|
||||
# Gateway = 10.0.0.1
|
||||
|
||||
# Creating network using the network offering created
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
userapiclient,
|
||||
self.services["network"],
|
||||
networkofferingid=self.network_offering.id,
|
||||
zoneid=self.zone.id,
|
||||
gateway=gateway,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Created network with ID: %s" % network.id)
|
||||
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
userapiclient,
|
||||
self.services["virtual_machine"],
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(network.id)]
|
||||
)
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
|
||||
self.assertNotEqual(virtual_machine,
|
||||
None,
|
||||
"VM creation in the network failed")
|
||||
|
||||
return
|
||||
with self.assertRaises(cloudstackAPIException):
|
||||
vpc = VPC.create(
|
||||
da_apiclient,
|
||||
self.services["vpc"],
|
||||
account=user.name,
|
||||
domainid=user.domainid,
|
||||
vpcofferingid=self.vpc_off.id,
|
||||
zoneid=self.zone.id,
|
||||
)
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_18_create_net_for_user_diff_domain_by_doadmin(self):
|
||||
|
|
@ -2271,29 +2228,29 @@ class TestVPC(cloudstackTestCase):
|
|||
self.apiclient,
|
||||
self.services["domain_admin"]
|
||||
)
|
||||
self.debug("Created account: %s" % domain_admin.account.name)
|
||||
self.debug("Created account: %s" % domain_admin.name)
|
||||
self.cleanup.append(domain_admin)
|
||||
da_apiclient = self.testClient.createNewApiClient(
|
||||
UserName=domain_admin.account.name,
|
||||
DomainName=self.services["domain"]["name"],
|
||||
acctType=2)
|
||||
da_apiclient = self.testClient.getUserApiClient(
|
||||
account=domain_admin.name,
|
||||
domain=self.services["domain"]["name"],
|
||||
type=2)
|
||||
|
||||
user = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"]
|
||||
)
|
||||
self.debug("Created account: %s" % user.account.name)
|
||||
self.debug("Created account: %s" % user.name)
|
||||
self.cleanup.append(user)
|
||||
|
||||
self.services["vpc"]["cidr"] = "10.1.1.1/16"
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
user.account.name)
|
||||
user.name)
|
||||
|
||||
#0 - User, 1 - Root Admin, 2 - Domain Admin
|
||||
userapiclient = self.testClient.createNewApiClient(
|
||||
UserName=user.account.name,
|
||||
DomainName=user.account.domain,
|
||||
acctType=0)
|
||||
userapiclient = self.testClient.getUserApiClient(
|
||||
account=user.name,
|
||||
domain=user.domain,
|
||||
type=0)
|
||||
|
||||
vpc = VPC.create(
|
||||
da_apiclient,
|
||||
|
|
@ -2453,7 +2410,7 @@ class TestVPC(cloudstackTestCase):
|
|||
|
||||
vpc_networks = VPC.list(
|
||||
self.apiclient,
|
||||
id=network.id
|
||||
id=vpc.id
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
|
|
@ -2467,7 +2424,4 @@ class TestVPC(cloudstackTestCase):
|
|||
|
||||
self.assertEqual(vpc_networks[0].displaytext,
|
||||
new_display_text,
|
||||
"Updation of VPC display text failed.")
|
||||
|
||||
|
||||
|
||||
"Updation of VPC display text failed.")
|
||||
|
|
@ -408,7 +408,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
|||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(self.vpc_off)
|
||||
self._cleanup.append(vpc_off)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
|||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(self.vpc_off)
|
||||
self._cleanup.append(vpc_off)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||
from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering, Host
|
||||
from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster
|
||||
from marvin.integration.lib.common import get_zone, get_domain, get_template, cleanup_resources
|
||||
|
||||
from nose.plugins.attrib import attr
|
||||
|
|
@ -77,6 +77,7 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
|
|||
)
|
||||
cls.services["account"] = cls.account.name
|
||||
cls.hosts = Host.list(cls.apiclient, type='Routing')
|
||||
cls.clusters = Cluster.list(cls.apiclient)
|
||||
cls.cleanup = [
|
||||
cls.account
|
||||
]
|
||||
|
|
@ -241,10 +242,13 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
|
|||
)
|
||||
vm1clusterid = filter(lambda c: c.id == vm1.hostid, self.hosts)[0].clusterid
|
||||
vm2clusterid = filter(lambda c: c.id == vm2.hostid, self.hosts)[0].clusterid
|
||||
|
||||
vm1podid = filter(lambda p: p.id == vm1clusterid, self.clusters)[0].podid
|
||||
vm2podid = filter(lambda p: p.id == vm2clusterid, self.clusters)[0].podid
|
||||
self.assertEqual(
|
||||
vm1clusterid,
|
||||
vm2clusterid,
|
||||
msg="VMs (%s, %s) meant to be concentrated are deployed on different clusters (%s, %s)" % (vm1.id, vm2.id, vm1clusterid, vm2clusterid)
|
||||
vm1podid,
|
||||
vm2podid,
|
||||
msg="VMs (%s, %s) meant to be pod concentrated are deployed on different pods (%s, %s)" % (vm1.id, vm2.id, vm1clusterid, vm2clusterid)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -122,9 +122,6 @@ class Services:
|
|||
"name": "Cent OS Template",
|
||||
"passwordenabled": True,
|
||||
},
|
||||
"diskdevice": '/dev/xvdd',
|
||||
# Disk device where ISO is attached to instance
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
#Migrate VM to hostid
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ from marvin.cloudstackAPI import *
|
|||
from marvin.integration.lib.utils import *
|
||||
from marvin.integration.lib.base import *
|
||||
from marvin.integration.lib.common import *
|
||||
from marvin import remoteSSHClient
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
class Services:
|
||||
|
|
|
|||
|
|
@ -91,9 +91,6 @@ class Services:
|
|||
"name": "xs",
|
||||
"passwordenabled": False,
|
||||
},
|
||||
"diskdevice": '/dev/xvdd',
|
||||
# Disk device where ISO is attached to instance
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
#Migrate VM to hostid
|
||||
|
|
|
|||
|
|
@ -85,9 +85,6 @@ class Services:
|
|||
"name": "xs",
|
||||
"passwordenabled": False,
|
||||
},
|
||||
"diskdevice": '/dev/xvdd',
|
||||
# Disk device where ISO is attached to instance
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
#Migrate VM to hostid
|
||||
|
|
|
|||
|
|
@ -739,7 +739,7 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
self.debug("Found %s host" % hosts[0].hypervisor)
|
||||
|
||||
if hosts[0].hypervisor.lower() == "kvm":
|
||||
self.services["diskdevice"] = "/dev/vda"
|
||||
self.services["diskdevice"] = "/dev/vdb"
|
||||
|
||||
try:
|
||||
ssh_client = self.virtual_machine.get_ssh_client()
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ class Services:
|
|||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
"diskdevice": "/dev/xvdb",
|
||||
"ostype": 'CentOS 5.5 (64-bit)',
|
||||
"sleep": 10,
|
||||
"timeout": 600,
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ class cloudstackTestClient(object):
|
|||
apiKey, securityKey, self.connection.asyncTimeout, self.connection.logging)
|
||||
self.userApiClient = cloudstackAPIClient.CloudStackAPIClient(newUserConnection)
|
||||
self.userApiClient.connection = newUserConnection
|
||||
self.userApiClient.hypervisor = self.apiClient.hypervisor
|
||||
return self.userApiClient
|
||||
|
||||
def close(self):
|
||||
|
|
|
|||
|
|
@ -4532,78 +4532,67 @@
|
|||
docID: 'helpVPCDomain',
|
||||
label: 'label.DNS.domain.for.guest.networks'
|
||||
},
|
||||
|
||||
loadbalancer:{ //Support for Netscaler as an external device for load balancing
|
||||
label:'Load Balancer',
|
||||
publicLoadBalancerProvider:{
|
||||
label:'Public Load Balancer Provider',
|
||||
select:function(args){
|
||||
$.ajax({
|
||||
url:createURL('listVPCOfferings&listall=true'),
|
||||
dataType:'json',
|
||||
success:function(json){
|
||||
var items=[];
|
||||
var vpcObj = json.listvpcofferingsresponse.vpcoffering;
|
||||
$(vpcObj).each(function(){
|
||||
items.push({id:this.id , description:this.name});
|
||||
});
|
||||
args.response.success({data:items});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var items = [];
|
||||
items.push({id: 'VpcVirtualRouter', description: 'VpcVirtualRouter'});
|
||||
items.push({id: 'Netscaler', description: 'Netscaler'});
|
||||
args.response.success({data: items});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
/* var defaultvpcofferingid;
|
||||
$.ajax({
|
||||
url: createURL("listVPCOfferings"),
|
||||
dataType: "json",
|
||||
data: {
|
||||
isdefault: true
|
||||
},
|
||||
async: false,
|
||||
success: function(json) {
|
||||
defaultvpcofferingid = json.listvpcofferingsresponse.vpcoffering[0].id;
|
||||
}
|
||||
});*/
|
||||
|
||||
var dataObj = {
|
||||
name: args.data.name,
|
||||
displaytext: args.data.displaytext,
|
||||
zoneid: args.data.zoneid,
|
||||
cidr: args.data.cidr,
|
||||
vpcofferingid: args.data.loadbalancer // Support for external load balancer
|
||||
};
|
||||
|
||||
if(args.data.networkdomain != null && args.data.networkdomain.length > 0)
|
||||
$.extend(dataObj, { networkdomain: args.data.networkdomain });
|
||||
|
||||
$.ajax({
|
||||
url: createURL("createVPC"),
|
||||
dataType: "json",
|
||||
data: dataObj,
|
||||
async: true,
|
||||
success: function(json) {
|
||||
var jid = json.createvpcresponse.jobid;
|
||||
args.response.success(
|
||||
{_custom:
|
||||
{jobId: jid,
|
||||
getUpdatedItem: function(json) {
|
||||
return json.queryasyncjobresultresponse.jobresult.vpc;
|
||||
}
|
||||
action: function(args) {
|
||||
var vpcOfferingName;
|
||||
if (args.data.publicLoadBalancerProvider == 'VpcVirtualRouter')
|
||||
vpcOfferingName = 'Default VPC offering';
|
||||
else if (args.data.publicLoadBalancerProvider == 'Netscaler')
|
||||
vpcOfferingName = 'Default VPC offering with Netscaler';
|
||||
|
||||
$.ajax({
|
||||
url:createURL('listVPCOfferings'),
|
||||
data: {
|
||||
name: vpcOfferingName
|
||||
},
|
||||
success:function(json){
|
||||
var vpcofferingid = json.listvpcofferingsresponse.vpcoffering[0].id;
|
||||
|
||||
var dataObj = {
|
||||
name: args.data.name,
|
||||
displaytext: args.data.displaytext,
|
||||
zoneid: args.data.zoneid,
|
||||
cidr: args.data.cidr,
|
||||
vpcofferingid: vpcofferingid
|
||||
};
|
||||
|
||||
if(args.data.networkdomain != null && args.data.networkdomain.length > 0)
|
||||
$.extend(dataObj, { networkdomain: args.data.networkdomain });
|
||||
|
||||
$.ajax({
|
||||
url: createURL("createVPC"),
|
||||
dataType: "json",
|
||||
data: dataObj,
|
||||
async: true,
|
||||
success: function(json) {
|
||||
var jid = json.createvpcresponse.jobid;
|
||||
args.response.success(
|
||||
{_custom:
|
||||
{jobId: jid,
|
||||
getUpdatedItem: function(json) {
|
||||
return json.queryasyncjobresultresponse.jobresult.vpc;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(data) {
|
||||
args.response.error(parseXMLHttpResponse(data));
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(data) {
|
||||
args.response.error(parseXMLHttpResponse(data));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
notification: {
|
||||
poll: pollAsyncJobResult
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ public final class S3Utils {
|
|||
try {
|
||||
|
||||
tempFile = createTempFile(
|
||||
join(asList(targetDirectory.getName(), currentTimeMillis(),
|
||||
"part"), "-"), "tmp", targetDirectory);
|
||||
join("-", targetDirectory.getName(), currentTimeMillis(),
|
||||
"part"), "tmp", targetDirectory);
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.utils;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
|
@ -25,8 +23,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.owasp.esapi.StringUtilities;
|
||||
|
||||
// StringUtils exists in Apache Commons Lang, but rather than import the entire JAR to our system, for now
|
||||
// just implement the method needed
|
||||
public class StringUtils {
|
||||
private static final char[] hexChar = {
|
||||
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
|
||||
|
|
@ -50,7 +46,7 @@ public class StringUtils {
|
|||
|
||||
public static String join(final String delimiter,
|
||||
final Object... components) {
|
||||
return join(asList(components), delimiter);
|
||||
return org.apache.commons.lang.StringUtils.join(components, delimiter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ public class NetUtils {
|
|||
return ipFromInetAddress(addr);
|
||||
}
|
||||
|
||||
return new String("127.0.0.1");
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
public static String ipFromInetAddress(InetAddress addr) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class SSHKeysHelper {
|
|||
if (!keyMaterial.contains(" "))
|
||||
keyMaterial = new String(Base64.decodeBase64(keyMaterial.getBytes()));
|
||||
|
||||
if (!keyMaterial.startsWith("ssh-rsa") || !keyMaterial.contains(" "))
|
||||
if ((!keyMaterial.startsWith("ssh-rsa") && !keyMaterial.startsWith("ssh-dss")) || !keyMaterial.contains(" "))
|
||||
return null;
|
||||
|
||||
String[] key = keyMaterial.split(" ");
|
||||
|
|
|
|||
|
|
@ -103,4 +103,9 @@ public class StringUtilsTest {
|
|||
assertEquals(result, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoin() {
|
||||
assertEquals("a-b-c", StringUtils.join("-", "a", "b", "c"));
|
||||
assertEquals("", StringUtils.join("-"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.utils.crypto;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.utils.crypt.RSAHelper;
|
||||
|
||||
public class RSAHelperTest {
|
||||
@Test
|
||||
public void testEncryptWithRSA() {
|
||||
String rsaKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2D2Cs0XAEqm+ajJpumIPrMpKp0CWtIW+8ZY2/MJCW" +
|
||||
"hge1eY18u9I3PPnkMVJsTOaN0wQojjw4AkKgKjNZXA9wyUq56UyN/stmipu8zifWPgxQGDRkuzzZ6buk" +
|
||||
"ef8q2Awjpo8hv5/0SRPJxQLEafESnUP+Uu/LUwk5VVC7PHzywJRUGFuzDl/uT72+6hqpL2YpC6aTl4/P" +
|
||||
"2eDvUQhCdL9dBmUSFX8ftT53W1jhsaQl7mPElVgSCtWz3IyRkogobMPrpJW/IPKEiojKIuvNoNv4CDR6" +
|
||||
"ybeVjHOJMb9wi62rXo+CzUsW0Y4jPOX/OykAm5vrNOhQhw0aaBcv5XVv8BRX";
|
||||
String encryptedString = RSAHelper.encryptWithSSHPublicKey(rsaKey, "content");
|
||||
assertNotNull(encryptedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncryptWithDSA() {
|
||||
String dssKey = "ssh-dss AAAAB3NzaC1kc3MAAACBALbaewDnzZ5AcGbZno7VW1m7Si3Q+yEANXZioVupfSwOP0q9aP2iV"+
|
||||
"tyqq575JnUVZXMDR2Gr254F/qCJ0TKAvucN0gcd2XslX4jBcu1Z7s7YZf6d7fC58k0NE6/keokJNKhQO" +
|
||||
"i56iirRzSA/YFrD64mzfq6rEmai0q7GjGGP0RT1AAAAFQDO5++6JonyqnoRkV9Yl1OaEOPjVwAAAIAYA" +
|
||||
"tqtKtU/INlTIuL3wt3nyKzwPUnz3fqxP5Ger3OlRZsOahalTFt2OF5jGGmCunyBTRteOetZObr0QhUIF" +
|
||||
"4bSDr6UiYYYbH1ES0ws/t1mDIeTh3UUHV1QYACN6c07FKyKLMtB9AthiG2FMLKCEedG3NeXItuNzsuQD" +
|
||||
"+n/K1rzMAAAAIBi5SM4pFPiB7BvTZvARV56vrG5QNgWVazSwbwgl/EACiWYbRauHDUQA9f+Rq+ayWcsR" +
|
||||
"os1CD+Q81y9SmlQaZVKkSPZLxXfu5bi3s4o431xjilhZdt4vKbj2pK364IjghJPNBBfmRXzlj9awKxr/" +
|
||||
"UebZcBgNRyeky7VZSbbF2jQSQ==";
|
||||
String encryptedString = RSAHelper.encryptWithSSHPublicKey(dssKey, "content");
|
||||
assertNull(encryptedString);
|
||||
}
|
||||
}
|
||||
|
|
@ -168,4 +168,9 @@ public class NetUtilsTest extends TestCase {
|
|||
newMac = NetUtils.generateMacOnIncrease(mac, 16);
|
||||
assertTrue(newMac.equals("06:00:0f:00:45:67"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLocalIPString() {
|
||||
assertNotNull(NetUtils.getLocalIPString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
// 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.ssh;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SSHKeysHelperTest {
|
||||
@Test
|
||||
public void rsaKeyTest() {
|
||||
String rsaKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2D2Cs0XAEqm+ajJpumIPrMpKp0CWtIW+8ZY2/MJCW" +
|
||||
"hge1eY18u9I3PPnkMVJsTOaN0wQojjw4AkKgKjNZXA9wyUq56UyN/stmipu8zifWPgxQGDRkuzzZ6buk" +
|
||||
"ef8q2Awjpo8hv5/0SRPJxQLEafESnUP+Uu/LUwk5VVC7PHzywJRUGFuzDl/uT72+6hqpL2YpC6aTl4/P" +
|
||||
"2eDvUQhCdL9dBmUSFX8ftT53W1jhsaQl7mPElVgSCtWz3IyRkogobMPrpJW/IPKEiojKIuvNoNv4CDR6" +
|
||||
"ybeVjHOJMb9wi62rXo+CzUsW0Y4jPOX/OykAm5vrNOhQhw0aaBcv5XVv8BRX test@testkey";
|
||||
String storedRsaKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2D2Cs0XAEqm+ajJpumIPrMpKp0CWtIW+8ZY2/MJCW" +
|
||||
"hge1eY18u9I3PPnkMVJsTOaN0wQojjw4AkKgKjNZXA9wyUq56UyN/stmipu8zifWPgxQGDRkuzzZ6buk" +
|
||||
"ef8q2Awjpo8hv5/0SRPJxQLEafESnUP+Uu/LUwk5VVC7PHzywJRUGFuzDl/uT72+6hqpL2YpC6aTl4/P" +
|
||||
"2eDvUQhCdL9dBmUSFX8ftT53W1jhsaQl7mPElVgSCtWz3IyRkogobMPrpJW/IPKEiojKIuvNoNv4CDR6" +
|
||||
"ybeVjHOJMb9wi62rXo+CzUsW0Y4jPOX/OykAm5vrNOhQhw0aaBcv5XVv8BRX";
|
||||
String parsedKey = SSHKeysHelper.getPublicKeyFromKeyMaterial(rsaKey);
|
||||
String fingerprint = SSHKeysHelper.getPublicKeyFingerprint(parsedKey);
|
||||
|
||||
assertTrue(storedRsaKey.equals(parsedKey));
|
||||
assertTrue("f6:96:3f:f4:78:f7:80:11:6c:f8:e3:2b:40:20:f1:14".equals(fingerprint));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dsaKeyTest() {
|
||||
String dssKey = "ssh-dss AAAAB3NzaC1kc3MAAACBALbaewDnzZ5AcGbZno7VW1m7Si3Q+yEANXZioVupfSwOP0q9aP2iV"+
|
||||
"tyqq575JnUVZXMDR2Gr254F/qCJ0TKAvucN0gcd2XslX4jBcu1Z7s7YZf6d7fC58k0NE6/keokJNKhQO" +
|
||||
"i56iirRzSA/YFrD64mzfq6rEmai0q7GjGGP0RT1AAAAFQDO5++6JonyqnoRkV9Yl1OaEOPjVwAAAIAYA" +
|
||||
"tqtKtU/INlTIuL3wt3nyKzwPUnz3fqxP5Ger3OlRZsOahalTFt2OF5jGGmCunyBTRteOetZObr0QhUIF" +
|
||||
"4bSDr6UiYYYbH1ES0ws/t1mDIeTh3UUHV1QYACN6c07FKyKLMtB9AthiG2FMLKCEedG3NeXItuNzsuQD" +
|
||||
"+n/K1rzMAAAAIBi5SM4pFPiB7BvTZvARV56vrG5QNgWVazSwbwgl/EACiWYbRauHDUQA9f+Rq+ayWcsR" +
|
||||
"os1CD+Q81y9SmlQaZVKkSPZLxXfu5bi3s4o431xjilhZdt4vKbj2pK364IjghJPNBBfmRXzlj9awKxr/" +
|
||||
"UebZcBgNRyeky7VZSbbF2jQSQ== test key";
|
||||
String storedDssKey = "ssh-dss AAAAB3NzaC1kc3MAAACBALbaewDnzZ5AcGbZno7VW1m7Si3Q+yEANXZioVupfSwOP0q9aP2iV"+
|
||||
"tyqq575JnUVZXMDR2Gr254F/qCJ0TKAvucN0gcd2XslX4jBcu1Z7s7YZf6d7fC58k0NE6/keokJNKhQO" +
|
||||
"i56iirRzSA/YFrD64mzfq6rEmai0q7GjGGP0RT1AAAAFQDO5++6JonyqnoRkV9Yl1OaEOPjVwAAAIAYA" +
|
||||
"tqtKtU/INlTIuL3wt3nyKzwPUnz3fqxP5Ger3OlRZsOahalTFt2OF5jGGmCunyBTRteOetZObr0QhUIF" +
|
||||
"4bSDr6UiYYYbH1ES0ws/t1mDIeTh3UUHV1QYACN6c07FKyKLMtB9AthiG2FMLKCEedG3NeXItuNzsuQD" +
|
||||
"+n/K1rzMAAAAIBi5SM4pFPiB7BvTZvARV56vrG5QNgWVazSwbwgl/EACiWYbRauHDUQA9f+Rq+ayWcsR" +
|
||||
"os1CD+Q81y9SmlQaZVKkSPZLxXfu5bi3s4o431xjilhZdt4vKbj2pK364IjghJPNBBfmRXzlj9awKxr/" +
|
||||
"UebZcBgNRyeky7VZSbbF2jQSQ==";
|
||||
String parsedKey = SSHKeysHelper.getPublicKeyFromKeyMaterial(dssKey);
|
||||
String fingerprint = SSHKeysHelper.getPublicKeyFingerprint(parsedKey);
|
||||
|
||||
assertTrue(storedDssKey.equals(parsedKey));
|
||||
assertTrue("fc:6e:ef:31:93:f8:92:2b:a9:03:c7:06:90:f5:ec:bb".equals(fingerprint));
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue