Skip to content

Commit eb5b254

Browse files
authored
Merge branch 'apache:4.19' into 4.19
2 parents 99c17e9 + 9d9737a commit eb5b254

File tree

44 files changed

+992
-1042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+992
-1042
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class ApiConstants {
4646
public static final String BACKUP_OFFERING_NAME = "backupofferingname";
4747
public static final String BACKUP_OFFERING_ID = "backupofferingid";
4848
public static final String BASE64_IMAGE = "base64image";
49-
public static final String BATCH_SIZE = "batchsize";
5049
public static final String BITS = "bits";
5150
public static final String BOOTABLE = "bootable";
5251
public static final String BIND_DN = "binddn";
@@ -438,12 +437,11 @@ public class ApiConstants {
438437
public static final String STATE = "state";
439438
public static final String STATS = "stats";
440439
public static final String STATUS = "status";
440+
public static final String STORAGE_TYPE = "storagetype";
441+
public static final String STORAGE_POLICY = "storagepolicy";
442+
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
441443
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
442444
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
443-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
444-
public static final String STORAGE_POLICY = "storagepolicy";
445-
public static final String STORAGE_POOL = "storagepool";
446-
public static final String STORAGE_TYPE = "storagetype";
447445
public static final String SUBNET = "subnet";
448446
public static final String OWNER = "owner";
449447
public static final String SWAP_OWNER = "swapowner";
@@ -1108,7 +1106,6 @@ public class ApiConstants {
11081106
public static final String PARAMETER_DESCRIPTION_IS_TAG_A_RULE = "Whether the informed tag is a JS interpretable rule or not.";
11091107

11101108
public static final String NFS_MOUNT_OPTIONS = "nfsmountopts";
1111-
public static final String VMWARE_DC = "vmwaredc";
11121109

11131110
/**
11141111
* This enum specifies IO Drivers, each option controls specific policies on I/O.

api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
152152
@Deprecated
153153
@SerializedName("memoryallocated")
154154
@Param(description = "the amount of the host's memory currently allocated")
155-
private Long memoryAllocated;
155+
private long memoryAllocated;
156156

157157
@SerializedName("memoryallocatedpercentage")
158158
@Param(description = "the amount of the host's memory currently allocated in percentage")
@@ -395,7 +395,7 @@ public void setMemWithOverprovisioning(String memWithOverprovisioning){
395395
this.memWithOverprovisioning=memWithOverprovisioning;
396396
}
397397

398-
public void setMemoryAllocated(Long memoryAllocated) {
398+
public void setMemoryAllocated(long memoryAllocated) {
399399
this.memoryAllocated = memoryAllocated;
400400
}
401401

@@ -659,8 +659,8 @@ public Long getMemoryTotal() {
659659
return memoryTotal;
660660
}
661661

662-
public Long getMemoryAllocated() {
663-
return memoryAllocated == null ? 0 : memoryAllocated;
662+
public long getMemoryAllocated() {
663+
return memoryAllocated;
664664
}
665665

666666
public void setMemoryAllocatedPercentage(String memoryAllocatedPercentage) {

engine/components-api/src/main/java/com/cloud/event/UsageEventUtils.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import javax.annotation.PostConstruct;
2626
import javax.inject.Inject;
2727

28+
import com.cloud.network.Network;
2829
import org.apache.commons.collections.MapUtils;
2930
import org.apache.log4j.Logger;
3031
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -246,4 +247,22 @@ private static void publishUsageEvent(String usageEventType, Long accountId, Lon
246247

247248
static final String Name = "management-server";
248249

250+
public static void publishNetworkCreation(Network network) {
251+
publishUsageEvent(EventTypes.EVENT_NETWORK_CREATE, network.getAccountId(), network.getDataCenterId(),
252+
network.getId(), network.getName(), network.getNetworkOfferingId(), null, null, null, network.getState().name(),
253+
network.getUuid());
254+
}
255+
256+
public static void publishNetworkUpdate(Network network) {
257+
publishUsageEvent(EventTypes.EVENT_NETWORK_UPDATE, network.getAccountId(), network.getDataCenterId(),
258+
network.getId(), network.getName(), network.getNetworkOfferingId(), null, network.getState().name(),
259+
Network.class.getName(), network.getUuid(), true);
260+
}
261+
262+
public static void publishNetworkDeletion(Network network) {
263+
publishUsageEvent(EventTypes.EVENT_NETWORK_DELETE, network.getAccountId(), network.getDataCenterId(),
264+
network.getId(), network.getName(), network.getNetworkOfferingId(), null, null, null,
265+
Network.class.getName(), network.getUuid());
266+
}
267+
249268
}

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,6 @@ public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final
14611461
if (isNetworkImplemented(network)) {
14621462
s_logger.debug("Network id=" + networkId + " is already implemented");
14631463
implemented.set(guru, network);
1464-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_UPDATE, network.getAccountId(), network.getDataCenterId(), network.getId(),
1465-
network.getName(), network.getNetworkOfferingId(), null, network.getState().name(), Network.class.getName(), network.getUuid(), true);
14661464
return implemented;
14671465
}
14681466

@@ -1522,9 +1520,8 @@ public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final
15221520

15231521
network.setRestartRequired(false);
15241522
_networksDao.update(network.getId(), network);
1523+
UsageEventUtils.publishNetworkUpdate(network);
15251524
implemented.set(guru, network);
1526-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_CREATE, network.getAccountId(), network.getDataCenterId(), network.getId(),
1527-
network.getName(), network.getNetworkOfferingId(), null, null, null, network.getState().name(), network.getUuid());
15281525
return implemented;
15291526
} catch (final NoTransitionException e) {
15301527
s_logger.error(e.getMessage());
@@ -3005,6 +3002,7 @@ public Network doInTransaction(final TransactionStatus status) {
30053002
if (updateResourceCount) {
30063003
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.network, isDisplayNetworkEnabled);
30073004
}
3005+
UsageEventUtils.publishNetworkCreation(network);
30083006

30093007
return network;
30103008
}
@@ -3089,12 +3087,13 @@ public boolean shutdownNetwork(final long networkId, final ReservationContext co
30893087
s_logger.debug("Lock is acquired for network " + network + " as a part of network shutdown");
30903088
}
30913089

3092-
if (network.getState() == Network.State.Allocated) {
3090+
final Network.State initialState = network.getState();
3091+
if (initialState == Network.State.Allocated) {
30933092
s_logger.debug(String.format("Network [%s] is in Allocated state, no need to shutdown.", network));
30943093
return true;
30953094
}
30963095

3097-
if (network.getState() != Network.State.Implemented && network.getState() != Network.State.Shutdown) {
3096+
if (initialState != Network.State.Implemented && initialState != Network.State.Shutdown) {
30983097
s_logger.debug("Network is not implemented: " + network);
30993098
return false;
31003099
}
@@ -3141,6 +3140,9 @@ public Boolean doInTransaction(final TransactionStatus status) {
31413140
}
31423141
_networksDao.update(networkFinal.getId(), networkFinal);
31433142
_networksDao.clearCheckForGc(networkId);
3143+
if (initialState == Network.State.Implemented) {
3144+
UsageEventUtils.publishNetworkUpdate(networkFinal);
3145+
}
31443146
result = true;
31453147
} else {
31463148
try {
@@ -3393,8 +3395,7 @@ public List<VlanVO> doInTransaction(TransactionStatus status) {
33933395
final Pair<Class<?>, Long> networkMsg = new Pair<Class<?>, Long>(Network.class, networkFinal.getId());
33943396
_messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, networkMsg);
33953397
}
3396-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_DELETE, network.getAccountId(), network.getDataCenterId(), network.getId(),
3397-
network.getName(), network.getNetworkOfferingId(), null, null, null, Network.class.getName(), network.getUuid());
3398+
UsageEventUtils.publishNetworkDeletion(network);
33983399
return true;
33993400
} catch (final CloudRuntimeException e) {
34003401
s_logger.error("Failed to delete network", e);

engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ public void testShutdownNetworkInImplementingState() {
894894
boolean shutdownNetworkStatus = testOrchestrator.shutdownNetwork(networkId, reservationContext, false);
895895
Assert.assertFalse(shutdownNetworkStatus);
896896

897-
verify(network, times(3)).getState();
897+
verify(network).getState();
898898
verify(testOrchestrator._networksDao, times(1)).acquireInLockTable(networkId, NetworkLockTimeout.value());
899899
verify(testOrchestrator._networksDao, times(1)).releaseFromLockTable(networkId);
900900
}

plugins/acl/dynamic-role-based/src/main/java/org/apache/cloudstack/acl/DynamicRoleBasedAPIAccessChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public class DynamicRoleBasedAPIAccessChecker extends AdapterBase implements API
4747
private RoleService roleService;
4848

4949
private List<PluggableService> services;
50-
private Map<RoleType, Set<String>> annotationRoleBasedApisMap = new HashMap<>();
50+
private Map<RoleType, Set<String>> annotationRoleBasedApisMap = new HashMap<RoleType, Set<String>>();
5151

5252
private static final Logger LOGGER = Logger.getLogger(DynamicRoleBasedAPIAccessChecker.class.getName());
5353

5454
protected DynamicRoleBasedAPIAccessChecker() {
5555
super();
5656
for (RoleType roleType : RoleType.values()) {
57-
annotationRoleBasedApisMap.put(roleType, new HashSet<>());
57+
annotationRoleBasedApisMap.put(roleType, new HashSet<String>());
5858
}
5959
}
6060

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareDatacenterService.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@
2222
import com.cloud.dc.VsphereStoragePolicy;
2323
import com.cloud.exception.DiscoveryException;
2424
import com.cloud.exception.ResourceInUseException;
25-
import com.cloud.hypervisor.vmware.mo.HostMO;
2625
import com.cloud.storage.StoragePool;
27-
import com.cloud.utils.Pair;
2826
import com.cloud.utils.component.PluggableService;
2927
import com.cloud.utils.exception.CloudRuntimeException;
3028
import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
3129
import org.apache.cloudstack.api.command.admin.zone.ImportVsphereStoragePoliciesCmd;
3230
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcVmsCmd;
33-
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcHostsCmd;
3431
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcsCmd;
3532
import org.apache.cloudstack.api.command.admin.zone.ListVsphereStoragePoliciesCmd;
3633
import org.apache.cloudstack.api.command.admin.zone.ListVsphereStoragePolicyCompatiblePoolsCmd;
@@ -56,7 +53,5 @@ public interface VmwareDatacenterService extends PluggableService {
5653

5754
List<StoragePool> listVsphereStoragePolicyCompatibleStoragePools(ListVsphereStoragePolicyCompatiblePoolsCmd cmd);
5855

59-
List<HostMO> listHostsInDatacenter(ListVmwareDcHostsCmd cmd);
60-
61-
Pair<String, List<UnmanagedInstanceTO>> listVMsInDatacenter(ListVmwareDcVmsCmd cmd);
56+
List<UnmanagedInstanceTO> listVMsInDatacenter(ListVmwareDcVmsCmd cmd);
6257
}

0 commit comments

Comments
 (0)