Skip to content

Commit 08ad1c7

Browse files
committed
Merge branch '4.19' into 4.20
2 parents c80b886 + e196275 commit 08ad1c7

File tree

35 files changed

+264
-165
lines changed

35 files changed

+264
-165
lines changed

api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class RemoteInstanceTO implements Serializable {
2727

2828
private Hypervisor.HypervisorType hypervisorType;
2929
private String instanceName;
30+
private String instancePath;
3031

3132
// VMware Remote Instances parameters (required for exporting OVA through ovftool)
3233
// TODO: cloud.agent.transport.Request#getCommands() cannot handle gsoc decode for polymorphic classes
@@ -44,9 +45,10 @@ public RemoteInstanceTO(String instanceName) {
4445
this.instanceName = instanceName;
4546
}
4647

47-
public RemoteInstanceTO(String instanceName, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {
48+
public RemoteInstanceTO(String instanceName, String instancePath, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {
4849
this.hypervisorType = Hypervisor.HypervisorType.VMware;
4950
this.instanceName = instanceName;
51+
this.instancePath = instancePath;
5052
this.vcenterHost = vcenterHost;
5153
this.vcenterUsername = vcenterUsername;
5254
this.vcenterPassword = vcenterPassword;
@@ -61,6 +63,10 @@ public String getInstanceName() {
6163
return this.instanceName;
6264
}
6365

66+
public String getInstancePath() {
67+
return this.instancePath;
68+
}
69+
6470
public String getVcenterUsername() {
6571
return vcenterUsername;
6672
}

api/src/main/java/com/cloud/storage/VolumeApiService.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
import java.util.List;
2323
import java.util.Map;
2424

25+
import com.cloud.exception.ResourceAllocationException;
26+
import com.cloud.offering.DiskOffering;
27+
import com.cloud.user.Account;
2528
import com.cloud.utils.Pair;
29+
import com.cloud.utils.fsm.NoTransitionException;
30+
2631
import org.apache.cloudstack.api.command.user.volume.AssignVolumeCmd;
2732
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
2833
import org.apache.cloudstack.api.command.user.volume.ChangeOfferingForVolumeCmd;
@@ -37,21 +42,17 @@
3742
import org.apache.cloudstack.api.response.GetUploadParamsResponse;
3843
import org.apache.cloudstack.framework.config.ConfigKey;
3944

40-
import com.cloud.exception.ResourceAllocationException;
41-
import com.cloud.user.Account;
42-
import com.cloud.utils.fsm.NoTransitionException;
43-
4445
public interface VolumeApiService {
4546

46-
ConfigKey<Long> ConcurrentMigrationsThresholdPerDatastore = new ConfigKey<Long>("Advanced"
47+
ConfigKey<Long> ConcurrentMigrationsThresholdPerDatastore = new ConfigKey<>("Advanced"
4748
, Long.class
4849
, "concurrent.migrations.per.target.datastore"
4950
, "0"
5051
, "Limits number of migrations that can be handled per datastore concurrently; default is 0 - unlimited"
5152
, true // not sure if this is to be dynamic
5253
, ConfigKey.Scope.Global);
5354

54-
ConfigKey<Boolean> UseHttpsToUpload = new ConfigKey<Boolean>("Advanced",
55+
ConfigKey<Boolean> UseHttpsToUpload = new ConfigKey<>("Advanced",
5556
Boolean.class,
5657
"use.https.to.upload",
5758
"true",
@@ -85,7 +86,7 @@ public interface VolumeApiService {
8586
* @param cmd
8687
* the API command wrapping the criteria
8788
* @return the volume object
88-
* @throws ResourceAllocationException
89+
* @throws ResourceAllocationException no capacity to allocate the new volume size
8990
*/
9091
Volume resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationException;
9192

@@ -139,13 +140,13 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
139140
Snapshot allocSnapshotForVm(Long vmId, Long volumeId, String snapshotName) throws ResourceAllocationException;
140141

141142
/**
142-
* Checks if the target storage supports the disk offering.
143+
* Checks if the storage pool supports the disk offering tags.
143144
* This validation is consistent with the mechanism used to select a storage pool to deploy a volume when a virtual machine is deployed or when a data disk is allocated.
144145
*
145146
* The scenarios when this method returns true or false is presented in the following table.
146147
* <table border="1">
147148
* <tr>
148-
* <th>#</th><th>Disk offering tags</th><th>Storage tags</th><th>Does the storage support the disk offering?</th>
149+
* <th>#</th><th>Disk offering diskOfferingTags</th><th>Storage diskOfferingTags</th><th>Does the storage support the disk offering?</th>
149150
* </tr>
150151
* <body>
151152
* <tr>
@@ -169,7 +170,8 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
169170
* </body>
170171
* </table>
171172
*/
172-
boolean doesTargetStorageSupportDiskOffering(StoragePool destPool, String diskOfferingTags);
173+
boolean doesStoragePoolSupportDiskOffering(StoragePool destPool, DiskOffering diskOffering);
174+
boolean doesStoragePoolSupportDiskOfferingTags(StoragePool destPool, String diskOfferingTags);
173175

174176
Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge);
175177

api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstanceTO.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public enum PowerState {
3333

3434
private String internalCSName;
3535

36+
private String path;
37+
3638
private PowerState powerState;
3739

3840
private PowerState cloneSourcePowerState;
@@ -75,6 +77,14 @@ public void setInternalCSName(String internalCSName) {
7577
this.internalCSName = internalCSName;
7678
}
7779

80+
public String getPath() {
81+
return path;
82+
}
83+
84+
public void setPath(String path) {
85+
this.path = path;
86+
}
87+
7888
public PowerState getPowerState() {
7989
return powerState;
8090
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public Answer execute(ConvertInstanceCommand cmd, LibvirtComputingResource serve
7070
Hypervisor.HypervisorType sourceHypervisorType = sourceInstance.getHypervisorType();
7171
String sourceInstanceName = sourceInstance.getInstanceName();
7272
Hypervisor.HypervisorType destinationHypervisorType = cmd.getDestinationHypervisorType();
73-
List<String> destinationStoragePools = cmd.getDestinationStoragePools();
7473
DataStoreTO conversionTemporaryLocation = cmd.getConversionTemporaryLocation();
7574
long timeout = (long) cmd.getWait() * 1000;
7675

@@ -193,9 +192,15 @@ private String getExportOVAUrlFromRemoteInstance(RemoteInstanceTO vmwareInstance
193192
String password = vmwareInstance.getVcenterPassword();
194193
String datacenter = vmwareInstance.getDatacenterName();
195194
String vm = vmwareInstance.getInstanceName();
195+
String path = vmwareInstance.getInstancePath();
196196

197197
String encodedUsername = encodeUsername(username);
198198
String encodedPassword = encodeUsername(password);
199+
if (StringUtils.isNotBlank(path)) {
200+
logger.info("VM path: {}", path);
201+
return String.format("vi://%s:%s@%s/%s/%s/%s",
202+
encodedUsername, encodedPassword, vcenter, datacenter, path, vm);
203+
}
199204
return String.format("vi://%s:%s@%s/%s/vm/%s",
200205
encodedUsername, encodedPassword, vcenter, datacenter, vm);
201206
}

plugins/outofbandmanagement-drivers/ipmitool/src/main/java/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolOutOfBandManagementDriver.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public final class IpmitoolOutOfBandManagementDriver extends AdapterBase impleme
4545
private final ExecutorService ipmitoolExecutor = Executors.newFixedThreadPool(OutOfBandManagementService.SyncThreadPoolSize.value(), new NamedThreadFactory("IpmiToolDriver"));
4646
private final IpmitoolWrapper IPMITOOL = new IpmitoolWrapper(ipmitoolExecutor);
4747

48-
public final ConfigKey<String> IpmiToolPath = new ConfigKey<String>("Advanced", String.class, "outofbandmanagement.ipmitool.path", "/usr/bin/ipmitool",
48+
public final ConfigKey<String> IpmiToolPath = new ConfigKey<>("Advanced", String.class, "outofbandmanagement.ipmitool.path", "/usr/bin/ipmitool",
4949
"The out of band management ipmitool path used by the IpmiTool driver. Default: /usr/bin/ipmitool.", true, ConfigKey.Scope.Global);
5050

51-
public final ConfigKey<String> IpmiToolInterface = new ConfigKey<String>("Advanced", String.class, "outofbandmanagement.ipmitool.interface", "lanplus",
51+
public final ConfigKey<String> IpmiToolInterface = new ConfigKey<>("Advanced", String.class, "outofbandmanagement.ipmitool.interface", "lanplus",
5252
"The out of band management IpmiTool driver interface to use. Default: lanplus. Valid values are: lan, lanplus, open etc.", true, ConfigKey.Scope.Global);
5353

54-
public final ConfigKey<String> IpmiToolRetries = new ConfigKey<String>("Advanced", String.class, "outofbandmanagement.ipmitool.retries", "1",
54+
public final ConfigKey<String> IpmiToolRetries = new ConfigKey<>("Advanced", String.class, "outofbandmanagement.ipmitool.retries", "1",
5555
"The out of band management IpmiTool driver retries option -R. Default 1.", true, ConfigKey.Scope.Global);
5656

5757
private String getIpmiUserId(ImmutableMap<OutOfBandManagement.Option, String> options, final Duration timeOut) {
@@ -120,7 +120,7 @@ private OutOfBandManagementDriverResponse execute(final OutOfBandManagementDrive
120120

121121
final OutOfBandManagementDriverResponse response = IPMITOOL.executeCommands(ipmiToolCommands, cmd.getTimeout());
122122

123-
String oneLineCommand = StringUtils.join(ipmiToolCommands, " ");
123+
String oneLineCommand = StringUtils.join(IPMITOOL.getSanatisedCommandStrings(ipmiToolCommands), " ");
124124
String result = response.getResult().trim();
125125

126126
if (response.isSuccess()) {

plugins/outofbandmanagement-drivers/ipmitool/src/main/java/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapper.java

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
import org.apache.cloudstack.utils.process.ProcessRunner;
2828
import org.apache.logging.log4j.Logger;
2929
import org.apache.logging.log4j.LogManager;
30+
3031
import org.joda.time.Duration;
3132

3233
import java.util.ArrayList;
3334
import java.util.List;
3435
import java.util.concurrent.ExecutorService;
3536

3637
public final class IpmitoolWrapper {
37-
protected Logger logger = LogManager.getLogger(getClass());
38+
Logger logger = LogManager.getLogger(getClass());
3839

3940
private final ProcessRunner RUNNER;
4041

@@ -110,12 +111,12 @@ public List<String> getIpmiToolCommandArgs(final String ipmiToolPath, final Stri
110111
return ipmiToolCommands.build();
111112
}
112113

114+
/**
115+
* Expected usersList string contains legends on first line and users on rest
116+
* ID Name Callin Link Auth IPMI Msg Channel Priv Limit
117+
* 1 admin true true true ADMINISTRATOR
118+
*/
113119
public String findIpmiUser(final String usersList, final String username) {
114-
/**
115-
* Expected usersList string contains legends on first line and users on rest
116-
* ID Name Callin Link Auth IPMI Msg Channel Priv Limit
117-
* 1 admin true true true ADMINISTRATOR
118-
*/
119120

120121
// Assuming user 'ID' index on 1st position
121122
int idIndex = 0;
@@ -157,25 +158,31 @@ public OutOfBandManagementDriverResponse executeCommands(final List<String> comm
157158
public OutOfBandManagementDriverResponse executeCommands(final List<String> commands, final Duration timeOut) {
158159
final ProcessResult result = RUNNER.executeCommands(commands, timeOut);
159160
if (logger.isTraceEnabled()) {
160-
List<String> cleanedCommands = new ArrayList<String>();
161-
int maskNextCommand = 0;
162-
for (String command : commands) {
163-
if (maskNextCommand > 0) {
164-
cleanedCommands.add("**** ");
165-
maskNextCommand--;
166-
continue;
167-
}
168-
if (command.equalsIgnoreCase("-P")) {
169-
maskNextCommand = 1;
170-
} else if (command.toLowerCase().endsWith("password")) {
171-
maskNextCommand = 2;
172-
}
173-
cleanedCommands.add(command);
174-
}
175-
logger.trace("Executed ipmitool process with commands: " + StringUtils.join(cleanedCommands, ", ") +
176-
"\nIpmitool execution standard output: " + result.getStdOutput() +
177-
"\nIpmitool execution error output: " + result.getStdError());
161+
List<String> cleanedCommands = getSanatisedCommandStrings(commands);
162+
logger.trace("Executed ipmitool process with commands: {}\nIpmitool execution standard output: {}\nIpmitool execution error output: {}",
163+
StringUtils.join(cleanedCommands, ", "),
164+
result.getStdOutput(),
165+
result.getStdError());
178166
}
179167
return new OutOfBandManagementDriverResponse(result.getStdOutput(), result.getStdError(), result.isSuccess());
180168
}
169+
170+
List<String> getSanatisedCommandStrings(List<String> commands) {
171+
List<String> cleanedCommands = new ArrayList<>();
172+
int maskNextCommand = 0;
173+
for (String command : commands) {
174+
if (maskNextCommand > 0) {
175+
cleanedCommands.add("**** ");
176+
maskNextCommand--;
177+
continue;
178+
}
179+
if (command.equalsIgnoreCase("-P")) {
180+
maskNextCommand = 1;
181+
} else if (command.toLowerCase().endsWith("password")) {
182+
maskNextCommand = 2;
183+
}
184+
cleanedCommands.add(command);
185+
}
186+
return cleanedCommands;
187+
}
181188
}

0 commit comments

Comments
 (0)