Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
fa3e30e
pokemon anihilation and class-javadoc
DaanHoogland May 28, 2020
41ebfd0
add ovf properties to template details
May 29, 2020
432797e
disected ova processing
May 29, 2020
39722ee
import
Jun 3, 2020
08d57ac
ovf string props hack
Jun 4, 2020
34d10ff
refactor plan in comments
Jun 5, 2020
81f16a0
trace
Jun 8, 2020
bda8848
hack to deal with: ovf property attributes in details
Jun 10, 2020
4bd8b37
PoC code for properties iso
Jun 11, 2020
3c219fc
flag for deploy as is
Jun 11, 2020
0093a3b
factor out 700 line start command and callees
Jun 12, 2020
0768d3d
execute start; init of disk info factorred out
Jun 12, 2020
43d5f2b
license
DaanHoogland Jun 15, 2020
3affec5
howto pass deploy OVA as is?
Jun 15, 2020
0e47904
logging during ingestion and guest net creation
Jun 15, 2020
80a77d3
more todos in comment
Jun 15, 2020
7ab0e7e
tested in production '{' is really needed
Jun 16, 2020
925acc9
deploy ovf without stripping networks
Jun 16, 2020
83fff23
deploy as is parameter to DB
Jun 18, 2020
9306f33
show deploy as is hack
Jun 18, 2020
f0c0ce7
extract extension
Jun 19, 2020
e70f78e
path correction
Jun 19, 2020
892c780
further disect of start
Jun 19, 2020
0fde9d9
ui strings
Jun 22, 2020
e0594cf
parse networks for later reconsiliation
Jun 24, 2020
5592b00
debug and trace on registration time template processing
Jun 24, 2020
c544cdd
logging and NPE fixes
Jun 24, 2020
021032a
template size over all disks
Jun 25, 2020
9e134d7
template details to contain json descriptions
Jun 25, 2020
16f269e
make deployasis default in API
Jun 29, 2020
4047fa6
fix deplayAsIs ui
Jun 29, 2020
f893f91
try-with-resource
Jun 29, 2020
fd3723c
details.value width
Jun 29, 2020
2233934
prevent password logging
Jun 29, 2020
cb49556
whiteline
Jun 29, 2020
4537927
deployAsIs register fixes
Jun 29, 2020
45346dd
simple test for marshalling
Jun 29, 2020
2081a7c
details to template properties
Jun 30, 2020
db9d5fe
property in detail finalised
Jul 1, 2020
e3f75cc
1st stab at integrating content libs
Jul 6, 2020
515b244
license
Jul 7, 2020
2492812
ovf props in details
Jul 7, 2020
508d47a
code in comment
Jul 7, 2020
5599a45
unused class removed
Jul 7, 2020
e1791eb
make sure deployAsIs is passed to template installation procedure
Jul 8, 2020
1b76ff9
create snapshot only when not deploy as is
Jul 8, 2020
845e2b0
explore need to copy
Jul 9, 2020
8857ee8
some code analyser complaints auto-fixed
Jul 10, 2020
318f4cf
intermediate state for copy OVA to primary
Jul 13, 2020
217775f
clone multidisk template vm
Jul 13, 2020
cf1cdb7
small cleanup for handover
Jul 14, 2020
ff50b9d
cleanup content library a.o.
Jul 14, 2020
2d2d855
Move the VM cloning out of volume orchestration and place it on the S…
nvazquez Jul 15, 2020
cc44c37
api: change map name to properties for deployVM cmd (#60)
yadvr Jul 15, 2020
48b538e
fr37: return volumeto in copycmd answer, fix start command to use def…
yadvr Jul 15, 2020
2fea952
licenses
Jul 15, 2020
91c784b
disk info in details
Jul 15, 2020
6ba43a6
multidisk as is deploy verified
Jul 15, 2020
fa8dbe3
clone before startcommand, volume TO has VM name we can use
yadvr Jul 16, 2020
0900f6d
NPE fix
yadvr Jul 16, 2020
ce2c0e8
startcommand: clone when only VM is not found and it's install as-is
yadvr Jul 16, 2020
235ecfa
fix regression in properties
Jul 16, 2020
34a03b1
deal with boolean properties
Jul 16, 2020
a61b9fc
Volume allocation refactor
nvazquez Jul 16, 2020
8d5f0a1
vmware: teardown nics for cloned deploy as-is VM
yadvr Jul 17, 2020
fb5cb78
fake root disk
Jul 17, 2020
a105d4d
Fix volume naming
nvazquez Jul 17, 2020
538ffc8
Refactor volume allocation
nvazquez Jul 17, 2020
0dded67
old ui properties rename
Jul 20, 2020
d71a814
send all details as details as well
Jul 20, 2020
dd64653
set proper value on vm
Jul 20, 2020
6a3edd1
Send capacity in GB for OVA disks
nvazquez Jul 20, 2020
d661adf
Revert sending in GB to avoid division in favour of using bytes
nvazquez Jul 20, 2020
237bb1a
comment update for status of dev work
Jul 21, 2020
2a40e85
rename method for clarification
Jul 21, 2020
3c15be3
comment change base on exception starting existing VM
Jul 21, 2020
6f3d3fb
further start method modularisation
Jul 21, 2020
d2959a3
teradown again :(
Jul 21, 2020
50d92c2
log nics to tear down
Jul 21, 2020
317b5da
Discard ISOs on volumes allocation
nvazquez Jul 21, 2020
ef79f60
Add new class to parse the hardware item section
nvazquez Jul 21, 2020
ecf8e4e
further disection of start method
Jul 22, 2020
0aca1bd
network creation refactor/cleanup
Jul 22, 2020
1d6b24c
Add parsing of virtual hardware section and deployment options
nvazquez Jul 22, 2020
2ddc8fa
Send deployment options and store them as template details
nvazquez Jul 22, 2020
300bf22
Setter fix
nvazquez Jul 23, 2020
f956df2
Filter fix for configuration hardware items
nvazquez Jul 23, 2020
c382e0b
log message format error fixed
Jul 23, 2020
4759e5d
null checks
Jul 23, 2020
a1ca741
Remove unused disks size template detail
nvazquez Jul 23, 2020
a7c46e7
Persist trimmed hardware items keys
nvazquez Jul 23, 2020
1eda6a4
Process CPU and memory configurations from OVF
nvazquez Jul 24, 2020
8a64d01
Remove spaces from hardware items
nvazquez Jul 24, 2020
32f5a8d
nic allocation refactor
Jul 24, 2020
ee214dc
factor out removal of old VM
Jul 24, 2020
9951b10
minor cleanup
Jul 28, 2020
467b5e4
Fix add diskTOs to VM spec again
nvazquez Jul 28, 2020
39bc971
Fix Vm start - disks mapping in progress
nvazquez Jul 28, 2020
2dc41d1
Fix GB size bug when registering template
nvazquez Jul 29, 2020
dc920cd
Fix volumes missing path and chain info
nvazquez Jul 30, 2020
dcf4695
Remove OVFProperty interface and deprecated VO and its related classe…
nvazquez Jul 31, 2020
b0a9f9f
Remove unused interface NetworkPrerequisite
nvazquez Jul 31, 2020
db1240c
Remove comments
nvazquez Jul 31, 2020
df2e5f4
Apply suggestions from code review
nvazquez Jul 31, 2020
c8232e8
Apply suggestions from code review
nvazquez Jul 31, 2020
2506ea0
Apply suggestions from code review
nvazquez Jul 31, 2020
e0bfb50
Remove import
nvazquez Jul 31, 2020
c2d2d1f
Fix rebase issue
nvazquez Aug 1, 2020
b560724
Minor refactors after review
nvazquez Aug 2, 2020
7e8c971
Fix clone VM and volumes destination
nvazquez Aug 4, 2020
83d7ace
Fix to ensure deploy as is volumes get allocated to the same storage …
nvazquez Aug 5, 2020
62d320e
handling deployvm API (#61)
shwstppr Aug 5, 2020
d97817b
npe fix for network map
shwstppr Aug 5, 2020
98092f1
unit test fix
shwstppr Aug 5, 2020
ebdc456
wip: vapps vm smoke test
shwstppr Aug 5, 2020
31af4fd
Register templates as non-deploy-as-is if empty field
nvazquez Aug 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handling deployvm API (#61)
deployVirtualMachine API changes
  • Loading branch information
shwstppr authored Aug 5, 2020
commit 62d320e920ea4b05b2d084fd6bbc47ac2eaff802
12 changes: 12 additions & 0 deletions api/src/main/java/com/cloud/vm/NicProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class NicProfile implements InternalIdentity, Serializable {
Integer networkRate;
boolean isSecurityGroupEnabled;

Integer orderIndex;

// IPv4
String iPv4Address;
String iPv4Netmask;
Expand Down Expand Up @@ -381,6 +383,14 @@ public void setRequestedIPv6(String requestedIPv6) {
this.requestedIPv6 = requestedIPv6;
}

public Integer getOrderIndex() {
return orderIndex;
}

public void setOrderIndex(Integer orderIndex) {
this.orderIndex = orderIndex;
}

//
// OTHER METHODS
//
Expand Down Expand Up @@ -410,6 +420,8 @@ public void deallocate() {
broadcastUri = null;
isolationUri = null;

orderIndex = null;

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.log4j.Logger;

Expand All @@ -71,6 +72,8 @@
import com.cloud.utils.net.Dhcp;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VmDetailConstants;
import com.google.common.base.Strings;

@APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
Expand Down Expand Up @@ -225,6 +228,12 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
@LogLevel(LogLevel.Log4jLevel.Off)
private Map vAppProperties;

@Parameter(name = ApiConstants.NIC_NETWORK_LIST, type = CommandType.MAP, since = "4.15",
description = "used to specify the vApp network mapping." +
" Example nicnetworklist[0].ip=Nic-101&nicnetworklist[0].network=uuid")
@LogLevel(LogLevel.Log4jLevel.Off)
private Map vAppNetworks;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -310,7 +319,6 @@ public ApiConstants.BootMode getBootMode() {
return null;
}


public Map<String, String> getVmProperties() {
Map<String, String> map = new HashMap<>();
if (MapUtils.isNotEmpty(vAppProperties)) {
Expand All @@ -324,6 +332,30 @@ public Map<String, String> getVmProperties() {
return map;
}

public Map<Integer, Long> getVmNetworkMap() {
Map<Integer, Long> map = new HashMap<>();
Collection parameterCollection = vAppNetworks.values();
Iterator iterator = parameterCollection.iterator();
while (iterator.hasNext()) {
HashMap<String, String> entry = (HashMap<String, String>)iterator.next();
Integer nic;
try {
nic = Integer.valueOf(entry.get(VmDetailConstants.NIC));
} catch (NumberFormatException nfe) {
nic = null;
}
String networkUuid = entry.get(VmDetailConstants.NETWORK);
if (s_logger.isTraceEnabled()) {
s_logger.trace(String.format("nic, '%s', goes on net, '%s'", nic, networkUuid));
}
if (nic == null || Strings.isNullOrEmpty(networkUuid) || _entityMgr.findByUuid(Network.class, networkUuid) == null) {
throw new InvalidParameterValueException(String.format("Network ID: %s for NIC ID: %s is invalid", networkUuid, nic));
}
map.put(nic, _entityMgr.findByUuid(Network.class, networkUuid).getId());
}
return map;
}

public String getGroup() {
return group;
}
Expand Down Expand Up @@ -373,6 +405,13 @@ public Long getZoneId() {
}

public List<Long> getNetworkIds() {
if (MapUtils.isNotEmpty(vAppNetworks)) {
if (CollectionUtils.isNotEmpty(networkIds) || ipAddress != null || getIp6Address() != null || MapUtils.isNotEmpty(ipToNetworkList)) {
throw new InvalidParameterValueException(String.format("%s can't be specified along with %s, %s, %s", ApiConstants.NIC_NETWORK_LIST, ApiConstants.NETWORK_IDS, ApiConstants.IP_ADDRESS, ApiConstants.IP_NETWORK_LIST));
} else {
return new ArrayList<>();
}
}
if (ipToNetworkList != null && !ipToNetworkList.isEmpty()) {
if ((networkIds != null && !networkIds.isEmpty()) || ipAddress != null || getIp6Address() != null) {
throw new InvalidParameterValueException("ipToNetworkMap can't be specified along with networkIds or ipAddress");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface OrchestrationService {
* @param memory memory to allocate in bytes
* @param computeTags tags for the compute
* @param rootDiskTags tags for the root disk
* @param networks networks that this VM should join
* @param networkNicMap map networks to nic profiles that this VM should join
* @param rootDiskSize size the root disk in case of templates.
* @return VirtualMachineEntity
*/
Expand All @@ -65,7 +65,7 @@ VirtualMachineEntity createVirtualMachine(@QueryParam("id") String id, @QueryPar
@QueryParam("host-name") String hostName, @QueryParam("display-name") String displayName, @QueryParam("hypervisor") String hypervisor,
@QueryParam("cpu") int cpu, @QueryParam("speed") int speed, @QueryParam("ram") long memory, @QueryParam("disk-size") Long diskSize,
@QueryParam("compute-tags") List<String> computeTags, @QueryParam("root-disk-tags") List<String> rootDiskTags,
@QueryParam("network-nic-map") Map<String, NicProfile> networkNicMap, @QueryParam("deploymentplan") DeploymentPlan plan,
@QueryParam("network-nic-map") Map<String, List<NicProfile>> networkNicMap, @QueryParam("deploymentplan") DeploymentPlan plan,
@QueryParam("root-disk-size") Long rootDiskSize, @QueryParam("extra-dhcp-option-map") Map<String, Map<Integer, String>> extraDhcpOptionMap,
@QueryParam("datadisktemplate-diskoffering-map") Map<Long, DiskOffering> datadiskTemplateToDiskOfferingMap) throws InsufficientCapacityException;

Expand All @@ -74,7 +74,7 @@ VirtualMachineEntity createVirtualMachineFromScratch(@QueryParam("id") String id
@QueryParam("host-name") String hostName, @QueryParam("display-name") String displayName, @QueryParam("hypervisor") String hypervisor,
@QueryParam("os") String os, @QueryParam("cpu") int cpu, @QueryParam("speed") int speed, @QueryParam("ram") long memory, @QueryParam("disk-size") Long diskSize,
@QueryParam("compute-tags") List<String> computeTags, @QueryParam("root-disk-tags") List<String> rootDiskTags,
@QueryParam("network-nic-map") Map<String, NicProfile> networkNicMap, @QueryParam("deploymentplan") DeploymentPlan plan, @QueryParam("extra-dhcp-option-map") Map<String, Map<Integer, String>> extraDhcpOptionMap) throws InsufficientCapacityException;
@QueryParam("network-nic-map") Map<String, List<NicProfile>> networkNicMap, @QueryParam("deploymentplan") DeploymentPlan plan, @QueryParam("extra-dhcp-option-map") Map<String, Map<Integer, String>> extraDhcpOptionMap) throws InsufficientCapacityException;

@POST
NetworkEntity createNetwork(String id, String name, String domainName, String cidr, String gateway);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -159,7 +158,7 @@ public void destroyVolume(String volumeEntity) {

@Override
public VirtualMachineEntity createVirtualMachine(String id, String owner, String templateId, String hostName, String displayName, String hypervisor, int cpu,
int speed, long memory, Long diskSize, List<String> computeTags, List<String> rootDiskTags, Map<String, NicProfile> networkNicMap, DeploymentPlan plan,
int speed, long memory, Long diskSize, List<String> computeTags, List<String> rootDiskTags, Map<String, List<NicProfile>> networkNicMap, DeploymentPlan plan,
Long rootDiskSize, Map<String, Map<Integer, String>> extraDhcpOptionMap, Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap) throws InsufficientCapacityException {

if (LOGGER.isTraceEnabled()) {
Expand All @@ -170,7 +169,7 @@ public VirtualMachineEntity createVirtualMachine(String id, String owner, String
for (String uuid : networkNicMap.keySet()) {
NetworkVO network = _networkDao.findByUuid(uuid);
if(network != null){
networkIpMap.put(network, new ArrayList<NicProfile>(Arrays.asList(networkNicMap.get(uuid))));
networkIpMap.put(network, networkNicMap.get(uuid));
}
}

Expand Down Expand Up @@ -259,7 +258,7 @@ public VirtualMachineEntity createVirtualMachine(String id, String owner, String

@Override
public VirtualMachineEntity createVirtualMachineFromScratch(String id, String owner, String isoId, String hostName, String displayName, String hypervisor, String os,
int cpu, int speed, long memory, Long diskSize, List<String> computeTags, List<String> rootDiskTags, Map<String, NicProfile> networkNicMap, DeploymentPlan plan, Map<String, Map<Integer, String>> extraDhcpOptionMap)
int cpu, int speed, long memory, Long diskSize, List<String> computeTags, List<String> rootDiskTags, Map<String, List<NicProfile>> networkNicMap, DeploymentPlan plan, Map<String, Map<Integer, String>> extraDhcpOptionMap)
throws InsufficientCapacityException {

// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
Expand Down Expand Up @@ -311,7 +310,7 @@ public VirtualMachineEntity createVirtualMachineFromScratch(String id, String ow
for (String uuid : networkNicMap.keySet()) {
NetworkVO network = _networkDao.findByUuid(uuid);
if(network != null){
networkIpMap.put(network, new ArrayList<NicProfile>(Arrays.asList(networkNicMap.get(uuid))));
networkIpMap.put(network, networkNicMap.get(uuid));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.apache.cloudstack.engine.orchestration;


import static org.apache.commons.lang.StringUtils.isNotBlank;

import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -39,11 +41,6 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;

import com.cloud.event.EventTypes;
import com.cloud.event.UsageEventUtils;
import com.cloud.network.dao.NetworkDetailVO;
import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.storage.dao.VMTemplateDetailsDao;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.net.NetworkPrerequisiteTO;
Expand Down Expand Up @@ -91,6 +88,8 @@
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.domain.Domain;
import com.cloud.event.EventTypes;
import com.cloud.event.UsageEventUtils;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.ConnectionException;
import com.cloud.exception.InsufficientAddressCapacityException;
Expand Down Expand Up @@ -132,6 +131,8 @@
import com.cloud.network.dao.NetworkAccountDao;
import com.cloud.network.dao.NetworkAccountVO;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkDetailVO;
import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.network.dao.NetworkDomainDao;
import com.cloud.network.dao.NetworkDomainVO;
import com.cloud.network.dao.NetworkServiceMapDao;
Expand Down Expand Up @@ -181,6 +182,7 @@
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.offerings.dao.NetworkOfferingDetailsDao;
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
import com.cloud.storage.dao.VMTemplateDetailsDao;
import com.cloud.user.Account;
import com.cloud.user.ResourceLimitService;
import com.cloud.user.User;
Expand Down Expand Up @@ -233,8 +235,6 @@
import com.cloud.vm.dao.VMInstanceDao;
import com.google.common.base.Strings;

import static org.apache.commons.lang.StringUtils.isNotBlank;

/**
* NetworkManagerImpl implements NetworkManager.
*/
Expand Down Expand Up @@ -764,25 +764,15 @@ public void doInTransactionWithoutResult(final TransactionStatus status) throws
final boolean[] deviceIds = new boolean[size];
Arrays.fill(deviceIds, false);

List<Pair<Network, NicProfile>> profilesList = getOrderedNetworkNicProfileMapping(networks);
final List<NicProfile> nics = new ArrayList<NicProfile>(size);
NicProfile defaultNic = null;

Network nextNetwork = null;
for (final Map.Entry<? extends Network, List<? extends NicProfile>> network : networks.entrySet()) {
nextNetwork = network.getKey();
List<? extends NicProfile> requestedProfiles = network.getValue();
if (requestedProfiles == null) {
requestedProfiles = new ArrayList<NicProfile>();
}
if (requestedProfiles.isEmpty()) {
requestedProfiles.add(null);
}

for (final NicProfile requested : requestedProfiles) {
Pair<NicProfile, Integer> newDeviceInfo = addRequestedNicToNicListWithDeviceNumberAndRetrieveDefaultDevice( requested, deviceIds, deviceId, nextNetwork, nics, defaultNic);
defaultNic = newDeviceInfo.first();
deviceId = newDeviceInfo.second();
}
for (Pair <Network, NicProfile> networkNicPair : profilesList) {
nextNetwork = networkNicPair.first();
Pair<NicProfile, Integer> newDeviceInfo = addRequestedNicToNicListWithDeviceNumberAndRetrieveDefaultDevice(networkNicPair.second(), deviceIds, deviceId, nextNetwork, nics, defaultNic);
defaultNic = newDeviceInfo.first();
deviceId = newDeviceInfo.second();
}
createExtraNics(size, nics, nextNetwork);

Expand Down Expand Up @@ -841,6 +831,42 @@ Pair<NicProfile,Integer> addRequestedNicToNicListWithDeviceNumberAndRetrieveDefa
return rc;
}

/**
* private transaction method to get oredered list of Network and NicProfile pair
* @return ordered list of Network and NicProfile pair
* @param networks the map od networks to nic profiles list
*/
private List<Pair<Network, NicProfile>> getOrderedNetworkNicProfileMapping(final LinkedHashMap<? extends Network, List<? extends NicProfile>> networks) {
List<Pair<Network, NicProfile>> profilesList = new ArrayList<>();
for (final Map.Entry<? extends Network, List<? extends NicProfile>> network : networks.entrySet()) {
List<? extends NicProfile> requestedProfiles = network.getValue();
if (requestedProfiles == null) {
requestedProfiles = new ArrayList<NicProfile>();
}
if (requestedProfiles.isEmpty()) {
requestedProfiles.add(null);
}
for (final NicProfile requested : requestedProfiles) {
profilesList.add(new Pair<Network, NicProfile>(network.getKey(), requested));
}
}
profilesList.sort(new Comparator<Pair<Network, NicProfile>>() {
@Override
public int compare(Pair<Network, NicProfile> pair1, Pair<Network, NicProfile> pair2) {
int profile1Order = Integer.MAX_VALUE;
int profile2Order = Integer.MAX_VALUE;
if (pair1 != null && pair1.second() != null && pair1.second().getOrderIndex() != null) {
profile1Order = pair1.second().getOrderIndex();
}
if (pair2 != null && pair2.second() != null && pair2.second().getOrderIndex() != null) {
profile2Order = pair2.second().getOrderIndex();
}
return profile1Order - profile2Order;
}
});
return profilesList;
}

/**
* private transaction method to run over the objects and determine nic requirements
* @return the total numer of nics required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
package com.cloud.storage.dao;


import com.cloud.agent.api.storage.OVFPropertyTO;
import com.cloud.agent.api.to.DatadiskTO;
import com.cloud.storage.ImageStore;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.TransactionLegacy;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.net.NetworkPrerequisiteTO;
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;

import com.cloud.agent.api.storage.OVFPropertyTO;
import com.cloud.agent.api.to.DatadiskTO;
import com.cloud.storage.ImageStore;
import com.cloud.storage.VMTemplateDetailVO;

import java.util.ArrayList;
import java.util.List;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.TransactionLegacy;
import com.google.gson.Gson;

@Component
public class VMTemplateDetailsDaoImpl extends ResourceDetailsDaoBase<VMTemplateDetailVO> implements VMTemplateDetailsDao {
Expand Down Expand Up @@ -111,6 +111,12 @@ public List<NetworkPrerequisiteTO> listNetworkRequirementsByTemplateId(long temp
NetworkPrerequisiteTO ovfPropertyTO = gson.fromJson(property.getValue(), NetworkPrerequisiteTO.class);
networkPrereqs.add(ovfPropertyTO);
}
networkPrereqs.sort(new Comparator<NetworkPrerequisiteTO>() {
@Override
public int compare(NetworkPrerequisiteTO o1, NetworkPrerequisiteTO o2) {
return o1.getInstanceID() - o2.getInstanceID();
}
});
return networkPrereqs;
}

Expand Down
Loading