mirror of https://github.com/apache/cloudstack.git
Merge branch 'nsx-integration' of https://github.com/apache/cloudstack into nsx-fix-routed-mode
This commit is contained in:
commit
b0b4175e6e
|
|
@ -22,4 +22,5 @@ import org.apache.cloudstack.acl.ControlledEntity;
|
|||
public interface KubernetesClusterHelper extends Adapter {
|
||||
|
||||
ControlledEntity findByUuid(String uuid);
|
||||
ControlledEntity findByVmId(long vmId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,30 +39,38 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
|||
};
|
||||
|
||||
enum State {
|
||||
Allocated("The volume is allocated but has not been created yet."),
|
||||
Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."),
|
||||
Ready("The volume is ready to be used."),
|
||||
Migrating("The volume is migrating to other storage pool"),
|
||||
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
|
||||
RevertSnapshotting("There is a snapshot created on this volume, the volume is being reverting from snapshot"),
|
||||
Resizing("The volume is being resized"),
|
||||
Expunging("The volume is being expunging"),
|
||||
Expunged("The volume has been expunged, and can no longer be recovered"),
|
||||
Destroy("The volume is destroyed, and can be recovered."),
|
||||
Destroying("The volume is destroying, and can't be recovered."),
|
||||
UploadOp("The volume upload operation is in progress or in short the volume is on secondary storage"),
|
||||
Copying("Volume is copying from image store to primary, in case it's an uploaded volume"),
|
||||
Uploaded("Volume is uploaded"),
|
||||
NotUploaded("The volume entry is just created in DB, not yet uploaded"),
|
||||
UploadInProgress("Volume upload is in progress"),
|
||||
UploadError("Volume upload encountered some error"),
|
||||
UploadAbandoned("Volume upload is abandoned since the upload was never initiated within a specified time"),
|
||||
Attaching("The volume is attaching to a VM from Ready state."),
|
||||
Restoring("The volume is being restored from backup.");
|
||||
Allocated(false, "The volume is allocated but has not been created yet."),
|
||||
Creating(true, "The volume is being created. getPoolId() should reflect the pool where it is being created."),
|
||||
Ready(false, "The volume is ready to be used."),
|
||||
Migrating(true, "The volume is migrating to other storage pool"),
|
||||
Snapshotting(true, "There is a snapshot created on this volume, not backed up to secondary storage yet"),
|
||||
RevertSnapshotting(true, "There is a snapshot created on this volume, the volume is being reverting from snapshot"),
|
||||
Resizing(true, "The volume is being resized"),
|
||||
Expunging(true, "The volume is being expunging"),
|
||||
Expunged(false, "The volume has been expunged, and can no longer be recovered"),
|
||||
Destroy(false, "The volume is destroyed, and can be recovered."),
|
||||
Destroying(false, "The volume is destroying, and can't be recovered."),
|
||||
UploadOp(true, "The volume upload operation is in progress or in short the volume is on secondary storage"),
|
||||
Copying(true, "Volume is copying from image store to primary, in case it's an uploaded volume"),
|
||||
Uploaded(false, "Volume is uploaded"),
|
||||
NotUploaded(true, "The volume entry is just created in DB, not yet uploaded"),
|
||||
UploadInProgress(true, "Volume upload is in progress"),
|
||||
UploadError(false, "Volume upload encountered some error"),
|
||||
UploadAbandoned(false, "Volume upload is abandoned since the upload was never initiated within a specified time"),
|
||||
Attaching(true, "The volume is attaching to a VM from Ready state."),
|
||||
Restoring(true, "The volume is being restored from backup.");
|
||||
|
||||
boolean _transitional;
|
||||
|
||||
String _description;
|
||||
|
||||
private State(String description) {
|
||||
/**
|
||||
* Volume State
|
||||
* @param transitional true for transition/non-final state, otherwise false
|
||||
* @param description description of the state
|
||||
*/
|
||||
private State(boolean transitional, String description) {
|
||||
_transitional = transitional;
|
||||
_description = description;
|
||||
}
|
||||
|
||||
|
|
@ -70,6 +78,10 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
|||
return s_fsm;
|
||||
}
|
||||
|
||||
public boolean isTransitional() {
|
||||
return _transitional;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return _description;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
|||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
|
@ -271,6 +272,8 @@ public interface NetworkOrchestrationService {
|
|||
|
||||
Map<String, String> finalizeServicesAndProvidersForNetwork(NetworkOffering offering, Long physicalNetworkId);
|
||||
|
||||
boolean stateTransitTo(Network network, Network.Event e) throws NoTransitionException;
|
||||
|
||||
List<Provider> getProvidersForServiceInNetwork(Network network, Service service);
|
||||
|
||||
StaticNatServiceProvider getStaticNatProviderForNetwork(Network network);
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.exception.StorageAccessException;
|
||||
import com.cloud.host.Host;
|
||||
|
|
@ -35,6 +35,9 @@ import com.cloud.user.Account;
|
|||
import com.cloud.utils.Pair;
|
||||
|
||||
public interface VolumeService {
|
||||
|
||||
String SNAPSHOT_ID = "SNAPSHOT_ID";
|
||||
|
||||
class VolumeApiResult extends CommandResult {
|
||||
private final VolumeInfo volume;
|
||||
|
||||
|
|
|
|||
|
|
@ -596,6 +596,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||
|
||||
final Long dcId = host.getDataCenterId();
|
||||
final ReadyCommand ready = new ReadyCommand(dcId, host.getId(), NumbersUtil.enableHumanReadableSizes);
|
||||
ready.setWait(60);
|
||||
final Answer answer = easySend(hostId, ready);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
// this is tricky part for secondary storage
|
||||
|
|
|
|||
|
|
@ -4493,7 +4493,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
return accessDetails;
|
||||
}
|
||||
|
||||
protected boolean stateTransitTo(final NetworkVO network, final Network.Event e) throws NoTransitionException {
|
||||
@Override
|
||||
public boolean stateTransitTo(final Network network, final Network.Event e) throws NoTransitionException {
|
||||
return _stateMachine.transitTo(network, e, null, _networksDao);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ public class DefaultHostListener implements HypervisorHostListener {
|
|||
public boolean hostConnect(long hostId, long poolId) throws StorageConflictException {
|
||||
StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
|
||||
ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
|
||||
cmd.setWait(60);
|
||||
final Answer answer = agentMgr.easySend(hostId, cmd);
|
||||
|
||||
if (answer == null) {
|
||||
|
|
|
|||
|
|
@ -851,7 +851,7 @@ public class VolumeObject implements VolumeInfo {
|
|||
|
||||
@Override
|
||||
public boolean delete() {
|
||||
return dataStore == null ? true : dataStore.delete(this);
|
||||
return dataStore == null || dataStore.delete(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.secret.dao.PassphraseDao;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.resource.StorageProcessor;
|
||||
import org.apache.cloudstack.annotation.AnnotationService;
|
||||
import org.apache.cloudstack.annotation.dao.AnnotationDao;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
|
|
@ -66,6 +62,7 @@ import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
|||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcContext;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.secret.dao.PassphraseDao;
|
||||
import org.apache.cloudstack.storage.RemoteHostEndPoint;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
|
||||
|
|
@ -83,6 +80,7 @@ import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
|
|||
import org.apache.cloudstack.storage.image.store.TemplateObject;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -122,13 +120,16 @@ import com.cloud.storage.StoragePool;
|
|||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Volume.State;
|
||||
import com.cloud.storage.VolumeDetailVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.dao.VolumeDetailsDao;
|
||||
import com.cloud.storage.resource.StorageProcessor;
|
||||
import com.cloud.storage.snapshot.SnapshotApiService;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.storage.template.TemplateConstants;
|
||||
|
|
@ -142,7 +143,6 @@ import com.cloud.utils.db.DB;
|
|||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Component
|
||||
public class VolumeServiceImpl implements VolumeService {
|
||||
|
|
@ -206,8 +206,6 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
@Inject
|
||||
private PassphraseDao passphraseDao;
|
||||
|
||||
private final static String SNAPSHOT_ID = "SNAPSHOT_ID";
|
||||
|
||||
public VolumeServiceImpl() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-utils</artifactId>
|
||||
<version>4.19.0.0-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -38,9 +38,13 @@ import javax.naming.ConfigurationException;
|
|||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJob;
|
||||
|
|
@ -65,7 +69,12 @@ import org.apache.log4j.MDC;
|
|||
import org.apache.log4j.NDC;
|
||||
|
||||
import com.cloud.cluster.ClusterManagerListener;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeDetailVO;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.dao.SnapshotDetailsDao;
|
||||
import com.cloud.storage.dao.SnapshotDetailsVO;
|
||||
|
|
@ -93,7 +102,11 @@ import com.cloud.utils.db.TransactionCallbackNoReturn;
|
|||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.exception.ExceptionUtil;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.mgmt.JmxUtil;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, ClusterManagerListener, Configurable {
|
||||
|
|
@ -148,6 +161,15 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
@Inject
|
||||
private SnapshotDetailsDao _snapshotDetailsDao;
|
||||
|
||||
@Inject
|
||||
private VolumeDataFactory volFactory;
|
||||
@Inject
|
||||
private VirtualMachineManager virtualMachineManager;
|
||||
@Inject
|
||||
private NetworkDao networkDao;
|
||||
@Inject
|
||||
private NetworkOrchestrationService networkOrchestrationService;
|
||||
|
||||
private volatile long _executionRunNumber = 1;
|
||||
|
||||
private final ScheduledExecutorService _heartbeatScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AsyncJobMgr-Heartbeat"));
|
||||
|
|
@ -1089,6 +1111,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cancel left-over job-" + job.getId());
|
||||
}
|
||||
cleanupResources(job);
|
||||
job.setStatus(JobInfo.Status.FAILED);
|
||||
job.setResultCode(ApiErrorCode.INTERNAL_ERROR.getHttpCode());
|
||||
job.setResult("job cancelled because of management server restart or shutdown");
|
||||
|
|
@ -1101,26 +1124,8 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
s_logger.debug("Purge queue item for cancelled job-" + job.getId());
|
||||
}
|
||||
_queueMgr.purgeAsyncJobQueueItemId(job.getId());
|
||||
if (ApiCommandResourceType.Volume.toString().equals(job.getInstanceType())) {
|
||||
|
||||
try {
|
||||
_volumeDetailsDao.removeDetail(job.getInstanceId(), "SNAPSHOT_ID");
|
||||
_volsDao.remove(job.getInstanceId());
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unexpected exception while removing concurrent request meta data :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
final List<SnapshotDetailsVO> snapshotList = _snapshotDetailsDao.findDetails(AsyncJob.Constants.MS_ID, Long.toString(msid), false);
|
||||
for (final SnapshotDetailsVO snapshotDetailsVO : snapshotList) {
|
||||
SnapshotInfo snapshot = snapshotFactory.getSnapshotOnPrimaryStore(snapshotDetailsVO.getResourceId());
|
||||
if (snapshot == null) {
|
||||
_snapshotDetailsDao.remove(snapshotDetailsVO.getId());
|
||||
continue;
|
||||
}
|
||||
snapshotSrv.processEventOnSnapshotObject(snapshot, Snapshot.Event.OperationFailed);
|
||||
_snapshotDetailsDao.removeDetail(snapshotDetailsVO.getResourceId(), AsyncJob.Constants.MS_ID);
|
||||
}
|
||||
cleanupFailedSnapshotsCreatedWithDefaultStrategy(msid);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
|
|
@ -1128,6 +1133,106 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Cleanup Resources in transition state and move them to appropriate state
|
||||
This will allow other operation on the resource, instead of being stuck in transition state
|
||||
*/
|
||||
protected boolean cleanupResources(AsyncJobVO job) {
|
||||
try {
|
||||
ApiCommandResourceType resourceType = ApiCommandResourceType.fromString(job.getInstanceType());
|
||||
if (resourceType == null) {
|
||||
s_logger.warn("Unknown ResourceType. Skip Cleanup: " + job.getInstanceType());
|
||||
return true;
|
||||
}
|
||||
switch (resourceType) {
|
||||
case Volume:
|
||||
return cleanupVolume(job.getInstanceId());
|
||||
case VirtualMachine:
|
||||
return cleanupVirtualMachine(job.getInstanceId());
|
||||
case Network:
|
||||
return cleanupNetwork(job.getInstanceId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Error while cleaning up resource: [" + job.getInstanceType().toString() + "] with Id: " + job.getInstanceId(), e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean cleanupVolume(final long volumeId) {
|
||||
VolumeInfo vol = volFactory.getVolume(volumeId);
|
||||
if (vol == null) {
|
||||
s_logger.warn("Volume not found. Skip Cleanup. VolumeId: " + volumeId);
|
||||
return true;
|
||||
}
|
||||
if (vol.getState().isTransitional()) {
|
||||
s_logger.debug("Cleaning up volume with Id: " + volumeId);
|
||||
boolean status = vol.stateTransit(Volume.Event.OperationFailed);
|
||||
cleanupFailedVolumesCreatedFromSnapshots(volumeId);
|
||||
return status;
|
||||
}
|
||||
s_logger.debug("Volume not in transition state. Skip cleanup. VolumeId: " + volumeId);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean cleanupVirtualMachine(final long vmId) throws Exception {
|
||||
VMInstanceVO vmInstanceVO = _vmInstanceDao.findById(vmId);
|
||||
if (vmInstanceVO == null) {
|
||||
s_logger.warn("Instance not found. Skip Cleanup. InstanceId: " + vmId);
|
||||
return true;
|
||||
}
|
||||
if (vmInstanceVO.getState().isTransitional()) {
|
||||
s_logger.debug("Cleaning up Instance with Id: " + vmId);
|
||||
return virtualMachineManager.stateTransitTo(vmInstanceVO, VirtualMachine.Event.OperationFailed, vmInstanceVO.getHostId());
|
||||
}
|
||||
s_logger.debug("Instance not in transition state. Skip cleanup. InstanceId: " + vmId);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean cleanupNetwork(final long networkId) throws Exception {
|
||||
NetworkVO networkVO = networkDao.findById(networkId);
|
||||
if (networkVO == null) {
|
||||
s_logger.warn("Network not found. Skip Cleanup. NetworkId: " + networkId);
|
||||
return true;
|
||||
}
|
||||
if (Network.State.Implementing.equals(networkVO.getState())) {
|
||||
try {
|
||||
s_logger.debug("Cleaning up Network with Id: " + networkId);
|
||||
return networkOrchestrationService.stateTransitTo(networkVO, Network.Event.OperationFailed);
|
||||
} catch (final NoTransitionException e) {
|
||||
networkVO.setState(Network.State.Shutdown);
|
||||
networkDao.update(networkVO.getId(), networkVO);
|
||||
}
|
||||
}
|
||||
s_logger.debug("Network not in transition state. Skip cleanup. NetworkId: " + networkId);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cleanupFailedVolumesCreatedFromSnapshots(final long volumeId) {
|
||||
try {
|
||||
VolumeDetailVO volumeDetail = _volumeDetailsDao.findDetail(volumeId, VolumeService.SNAPSHOT_ID);
|
||||
if (volumeDetail != null) {
|
||||
_volumeDetailsDao.removeDetail(volumeId, VolumeService.SNAPSHOT_ID);
|
||||
_volsDao.remove(volumeId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unexpected exception while removing concurrent request meta data :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanupFailedSnapshotsCreatedWithDefaultStrategy(final long msid) {
|
||||
final List<SnapshotDetailsVO> snapshotList = _snapshotDetailsDao.findDetails(AsyncJob.Constants.MS_ID, Long.toString(msid), false);
|
||||
for (final SnapshotDetailsVO snapshotDetailsVO : snapshotList) {
|
||||
SnapshotInfo snapshot = snapshotFactory.getSnapshotOnPrimaryStore(snapshotDetailsVO.getResourceId());
|
||||
if (snapshot == null) {
|
||||
_snapshotDetailsDao.remove(snapshotDetailsVO.getId());
|
||||
continue;
|
||||
}
|
||||
snapshotSrv.processEventOnSnapshotObject(snapshot, Snapshot.Event.OperationFailed);
|
||||
_snapshotDetailsDao.removeDetail(snapshotDetailsVO.getResourceId(), AsyncJob.Constants.MS_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onManagementNodeJoined(List<? extends ManagementServerHost> nodeList, long selfNodeId) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,96 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.framework.jobs.impl;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AsyncJobManagerImplTest {
|
||||
@Spy
|
||||
@InjectMocks
|
||||
AsyncJobManagerImpl asyncJobManager;
|
||||
@Mock
|
||||
VolumeDataFactory volFactory;
|
||||
@Mock
|
||||
VMInstanceDao vmInstanceDao;
|
||||
@Mock
|
||||
VirtualMachineManager virtualMachineManager;
|
||||
@Mock
|
||||
NetworkDao networkDao;
|
||||
@Mock
|
||||
NetworkOrchestrationService networkOrchestrationService;
|
||||
|
||||
@Test
|
||||
public void testCleanupVolumeResource() {
|
||||
AsyncJobVO job = new AsyncJobVO();
|
||||
job.setInstanceType(ApiCommandResourceType.Volume.toString());
|
||||
job.setInstanceId(1L);
|
||||
VolumeInfo volumeInfo = Mockito.mock(VolumeInfo.class);
|
||||
when(volFactory.getVolume(Mockito.anyLong())).thenReturn(volumeInfo);
|
||||
when(volumeInfo.getState()).thenReturn(Volume.State.Attaching);
|
||||
asyncJobManager.cleanupResources(job);
|
||||
Mockito.verify(volumeInfo, Mockito.times(1)).stateTransit(Volume.Event.OperationFailed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCleanupVmResource() throws NoTransitionException {
|
||||
AsyncJobVO job = new AsyncJobVO();
|
||||
job.setInstanceType(ApiCommandResourceType.VirtualMachine.toString());
|
||||
job.setInstanceId(1L);
|
||||
VMInstanceVO vmInstanceVO = Mockito.mock(VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(Mockito.anyLong())).thenReturn(vmInstanceVO);
|
||||
when(vmInstanceVO.getState()).thenReturn(VirtualMachine.State.Starting);
|
||||
when(vmInstanceVO.getHostId()).thenReturn(1L);
|
||||
asyncJobManager.cleanupResources(job);
|
||||
Mockito.verify(virtualMachineManager, Mockito.times(1)).stateTransitTo(vmInstanceVO, VirtualMachine.Event.OperationFailed, 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCleanupNetworkResource() throws NoTransitionException {
|
||||
AsyncJobVO job = new AsyncJobVO();
|
||||
job.setInstanceType(ApiCommandResourceType.Network.toString());
|
||||
job.setInstanceId(1L);
|
||||
NetworkVO networkVO = Mockito.mock(NetworkVO.class);
|
||||
when(networkDao.findById(Mockito.anyLong())).thenReturn(networkVO);
|
||||
when(networkVO.getState()).thenReturn(Network.State.Implementing);
|
||||
asyncJobManager.cleanupResources(job);
|
||||
Mockito.verify(networkOrchestrationService, Mockito.times(1)).stateTransitTo(networkVO,
|
||||
Network.Event.OperationFailed);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-non-strict-host-affinity</artifactId>
|
||||
<version>4.19.0.0-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public final class LibvirtReadyCommandWrapper extends CommandWrapper<ReadyComman
|
|||
cmd = "dpkg -l ovmf";
|
||||
}
|
||||
s_logger.debug("Running command : " + cmd);
|
||||
int result = Script.runSimpleBashScriptForExitValue(cmd);
|
||||
int result = Script.runSimpleBashScriptForExitValue(cmd, 60, false);
|
||||
s_logger.debug("Got result : " + result);
|
||||
return result == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package com.cloud.kubernetes.cluster;
|
||||
|
||||
import com.cloud.kubernetes.cluster.dao.KubernetesClusterDao;
|
||||
import com.cloud.kubernetes.cluster.dao.KubernetesClusterVmMapDao;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
|
@ -24,18 +25,30 @@ import org.apache.cloudstack.framework.config.Configurable;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class KubernetesClusterHelperImpl extends AdapterBase implements KubernetesClusterHelper, Configurable {
|
||||
|
||||
@Inject
|
||||
private KubernetesClusterDao kubernetesClusterDao;
|
||||
@Inject
|
||||
private KubernetesClusterVmMapDao kubernetesClusterVmMapDao;
|
||||
|
||||
@Override
|
||||
public ControlledEntity findByUuid(String uuid) {
|
||||
return kubernetesClusterDao.findByUuid(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControlledEntity findByVmId(long vmId) {
|
||||
KubernetesClusterVmMapVO clusterVmMapVO = kubernetesClusterVmMapDao.getClusterMapFromVmId(vmId);
|
||||
if (Objects.isNull(clusterVmMapVO)) {
|
||||
return null;
|
||||
}
|
||||
return kubernetesClusterDao.findById(clusterVmMapVO.getClusterId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return KubernetesClusterHelper.class.getSimpleName();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import java.util.List;
|
|||
|
||||
public interface KubernetesClusterVmMapDao extends GenericDao<KubernetesClusterVmMapVO, Long> {
|
||||
public List<KubernetesClusterVmMapVO> listByClusterId(long clusterId);
|
||||
|
||||
public KubernetesClusterVmMapVO getClusterMapFromVmId(long vmId);
|
||||
public List<KubernetesClusterVmMapVO> listByClusterIdAndVmIdsIn(long clusterId, List<Long> vmIds);
|
||||
|
||||
int removeByClusterIdAndVmIdsIn(long clusterId, List<Long> vmIds);
|
||||
|
|
|
|||
|
|
@ -31,12 +31,17 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
public class KubernetesClusterVmMapDaoImpl extends GenericDaoBase<KubernetesClusterVmMapVO, Long> implements KubernetesClusterVmMapDao {
|
||||
|
||||
private final SearchBuilder<KubernetesClusterVmMapVO> clusterIdSearch;
|
||||
private final SearchBuilder<KubernetesClusterVmMapVO> vmIdSearch;
|
||||
|
||||
public KubernetesClusterVmMapDaoImpl() {
|
||||
clusterIdSearch = createSearchBuilder();
|
||||
clusterIdSearch.and("clusterId", clusterIdSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
clusterIdSearch.and("vmIdsIN", clusterIdSearch.entity().getVmId(), SearchCriteria.Op.IN);
|
||||
clusterIdSearch.done();
|
||||
|
||||
vmIdSearch = createSearchBuilder();
|
||||
vmIdSearch.and("vmId", vmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
|
||||
vmIdSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -47,6 +52,13 @@ public class KubernetesClusterVmMapDaoImpl extends GenericDaoBase<KubernetesClus
|
|||
return listBy(sc, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KubernetesClusterVmMapVO getClusterMapFromVmId(long vmId) {
|
||||
SearchCriteria<KubernetesClusterVmMapVO> sc = vmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KubernetesClusterVmMapVO> listByClusterIdAndVmIdsIn(long clusterId, List<Long> vmIds) {
|
||||
SearchCriteria<KubernetesClusterVmMapVO> sc = clusterIdSearch.create();
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
|
||||
import com.vmware.nsx.model.TransportZone;
|
||||
import com.vmware.nsx.model.TransportZoneListResult;
|
||||
import com.vmware.nsx_policy.model.EnforcementPointListResult;
|
||||
import com.vmware.nsx_policy.model.Segment;
|
||||
import com.vmware.nsx_policy.model.SiteListResult;
|
||||
import org.apache.cloudstack.NsxAnswer;
|
||||
import org.apache.cloudstack.StartupNsxCommand;
|
||||
import org.apache.cloudstack.agent.api.CreateNsxDhcpRelayConfigCommand;
|
||||
|
|
@ -320,33 +318,17 @@ public class NsxResource implements ServerResource {
|
|||
|
||||
private Answer executeRequest(CreateNsxSegmentCommand cmd) {
|
||||
try {
|
||||
SiteListResult sites = nsxApiClient.getSites();
|
||||
String errorMsg;
|
||||
String networkName = cmd.getNetworkName();
|
||||
if (CollectionUtils.isEmpty(sites.getResults())) {
|
||||
errorMsg = String.format("Failed to create network: %s as no sites are found in the linked NSX infrastructure", networkName);
|
||||
LOGGER.error(errorMsg);
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(errorMsg));
|
||||
}
|
||||
String siteId = sites.getResults().get(0).getId();
|
||||
|
||||
EnforcementPointListResult epList = nsxApiClient.getEnforcementPoints(siteId);
|
||||
if (CollectionUtils.isEmpty(epList.getResults())) {
|
||||
errorMsg = String.format("Failed to create network: %s as no enforcement points are found in the linked NSX infrastructure", networkName);
|
||||
LOGGER.error(errorMsg);
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(errorMsg));
|
||||
}
|
||||
String enforcementPointPath = epList.getResults().get(0).getPath();
|
||||
|
||||
String siteId = nsxApiClient.getDefaultSiteId();
|
||||
String enforcementPointPath = nsxApiClient.getDefaultEnforcementPointPath(siteId);
|
||||
TransportZoneListResult transportZoneListResult = nsxApiClient.getTransportZones();
|
||||
if (CollectionUtils.isEmpty(transportZoneListResult.getResults())) {
|
||||
errorMsg = String.format("Failed to create network: %s as no transport zones were found in the linked NSX infrastructure", networkName);
|
||||
String errorMsg = String.format("Failed to create network: %s as no transport zones were found in the linked NSX infrastructure", cmd.getNetworkName());
|
||||
LOGGER.error(errorMsg);
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(errorMsg));
|
||||
}
|
||||
List<TransportZone> transportZones = transportZoneListResult.getResults().stream().filter(tz -> tz.getDisplayName().equals(transportZone)).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(transportZones)) {
|
||||
errorMsg = String.format("Failed to create network: %s as no transport zone of name %s was found in the linked NSX infrastructure", networkName, transportZone);
|
||||
String errorMsg = String.format("Failed to create network: %s as no transport zone of name %s was found in the linked NSX infrastructure", cmd.getNetworkName(), transportZone);
|
||||
LOGGER.error(errorMsg);
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(errorMsg));
|
||||
}
|
||||
|
|
@ -371,14 +353,9 @@ public class NsxResource implements ServerResource {
|
|||
String segmentName = NsxControllerUtils.getNsxSegmentId(cmd.getDomainId(), cmd.getAccountId(), cmd.getZoneId(),
|
||||
cmd.getVpcId(), cmd.getNetworkId());
|
||||
try {
|
||||
Thread.sleep(30 * 1000L);
|
||||
nsxApiClient.deleteSegment(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getVpcId(), cmd.getNetworkId(), segmentName);
|
||||
} catch (InterruptedException | ThreadDeath e) {
|
||||
LOGGER.error("Thread interrupted", e);
|
||||
Thread.currentThread().interrupt();
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(e.getMessage()));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(String.format("Failed to delete NSX segment: %s", segmentName));
|
||||
LOGGER.error(String.format("Failed to delete NSX segment %s: %s", segmentName, e.getMessage()));
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(e.getMessage()));
|
||||
}
|
||||
return new NsxAnswer(cmd, true, null);
|
||||
|
|
@ -444,7 +421,7 @@ public class NsxResource implements ServerResource {
|
|||
String ruleName = NsxControllerUtils.getLoadBalancerRuleName(tier1GatewayName, cmd.getLbId());
|
||||
try {
|
||||
nsxApiClient.createAndAddNsxLbVirtualServer(tier1GatewayName, cmd.getLbId(), cmd.getPublicIp(), cmd.getPublicPort(),
|
||||
cmd.getMemberList(), cmd.getAlgorithm(), cmd.getProtocol());
|
||||
cmd.getMemberList(), cmd.getAlgorithm(), cmd.getProtocol(), cmd.getPrivatePort());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(String.format("Failed to add NSX load balancer rule %s for network: %s", ruleName, cmd.getNetworkResourceName()));
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(e.getMessage()));
|
||||
|
|
@ -485,7 +462,7 @@ public class NsxResource implements ServerResource {
|
|||
try {
|
||||
nsxApiClient.deleteDistributedFirewallRules(segmentName, rules);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(String.format("Failed to create NSX distributed firewall %s: %s", segmentName, e.getMessage()), e);
|
||||
LOGGER.error(String.format("Failed to delete NSX distributed firewall %s: %s", segmentName, e.getMessage()), e);
|
||||
return new NsxAnswer(cmd, new CloudRuntimeException(e.getMessage()));
|
||||
}
|
||||
return new NsxAnswer(cmd, true, null);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.vmware.nsx.model.TransportZone;
|
|||
import com.vmware.nsx.model.TransportZoneListResult;
|
||||
import com.vmware.nsx_policy.infra.DhcpRelayConfigs;
|
||||
import com.vmware.nsx_policy.infra.LbAppProfiles;
|
||||
import com.vmware.nsx_policy.infra.LbMonitorProfiles;
|
||||
import com.vmware.nsx_policy.infra.LbPools;
|
||||
import com.vmware.nsx_policy.infra.LbServices;
|
||||
import com.vmware.nsx_policy.infra.LbVirtualServers;
|
||||
|
|
@ -31,6 +32,7 @@ import com.vmware.nsx_policy.infra.Sites;
|
|||
import com.vmware.nsx_policy.infra.Tier1s;
|
||||
import com.vmware.nsx_policy.infra.domains.Groups;
|
||||
import com.vmware.nsx_policy.infra.domains.SecurityPolicies;
|
||||
import com.vmware.nsx_policy.infra.domains.groups.members.SegmentPorts;
|
||||
import com.vmware.nsx_policy.infra.domains.security_policies.Rules;
|
||||
import com.vmware.nsx_policy.infra.sites.EnforcementPoints;
|
||||
import com.vmware.nsx_policy.infra.tier_0s.LocaleServices;
|
||||
|
|
@ -43,14 +45,18 @@ import com.vmware.nsx_policy.model.GroupListResult;
|
|||
import com.vmware.nsx_policy.model.ICMPTypeServiceEntry;
|
||||
import com.vmware.nsx_policy.model.L4PortSetServiceEntry;
|
||||
import com.vmware.nsx_policy.model.LBAppProfileListResult;
|
||||
import com.vmware.nsx_policy.model.LBMonitorProfileListResult;
|
||||
import com.vmware.nsx_policy.model.LBPool;
|
||||
import com.vmware.nsx_policy.model.LBPoolListResult;
|
||||
import com.vmware.nsx_policy.model.LBPoolMember;
|
||||
import com.vmware.nsx_policy.model.LBService;
|
||||
import com.vmware.nsx_policy.model.LBTcpMonitorProfile;
|
||||
import com.vmware.nsx_policy.model.LBUdpMonitorProfile;
|
||||
import com.vmware.nsx_policy.model.LBVirtualServer;
|
||||
import com.vmware.nsx_policy.model.LBVirtualServerListResult;
|
||||
import com.vmware.nsx_policy.model.LocaleServicesListResult;
|
||||
import com.vmware.nsx_policy.model.PathExpression;
|
||||
import com.vmware.nsx_policy.model.PolicyGroupMembersListResult;
|
||||
import com.vmware.nsx_policy.model.PolicyNatRule;
|
||||
import com.vmware.nsx_policy.model.PolicyNatRuleListResult;
|
||||
import com.vmware.nsx_policy.model.Rule;
|
||||
|
|
@ -93,6 +99,7 @@ import static org.apache.cloudstack.utils.NsxControllerUtils.getVirtualServerNam
|
|||
import static org.apache.cloudstack.utils.NsxControllerUtils.getServiceEntryName;
|
||||
import static org.apache.cloudstack.utils.NsxControllerUtils.getLoadBalancerName;
|
||||
import static org.apache.cloudstack.utils.NsxControllerUtils.getLoadBalancerAlgorithm;
|
||||
import static org.apache.cloudstack.utils.NsxControllerUtils.getActiveMonitorProfileName;
|
||||
|
||||
public class NsxApiClient {
|
||||
|
||||
|
|
@ -111,6 +118,10 @@ public class NsxApiClient {
|
|||
protected static final String SEGMENTS_PATH = "/infra/segments";
|
||||
protected static final String DEFAULT_DOMAIN = "default";
|
||||
protected static final String GROUPS_PATH_PREFIX = "/infra/domains/default/groups";
|
||||
// TODO: Pass as global / zone-level setting?
|
||||
protected static final String NSX_LB_PASSIVE_MONITOR = "/infra/lb-monitor-profiles/default-passive-lb-monitor";
|
||||
protected static final String TCP_MONITOR_PROFILE = "LBTcpMonitorProfile";
|
||||
protected static final String UDP_MONITOR_PROFILE = "LBUdpMonitorProfile";
|
||||
|
||||
private enum PoolAllocation { ROUTING, LB_SMALL, LB_MEDIUM, LB_LARGE, LB_XLARGE }
|
||||
|
||||
|
|
@ -343,7 +354,17 @@ public class NsxApiClient {
|
|||
|
||||
}
|
||||
|
||||
public SiteListResult getSites() {
|
||||
public String getDefaultSiteId() {
|
||||
SiteListResult sites = getSites();
|
||||
if (CollectionUtils.isEmpty(sites.getResults())) {
|
||||
String errorMsg = "No sites are found in the linked NSX infrastructure";
|
||||
LOGGER.error(errorMsg);
|
||||
throw new CloudRuntimeException(errorMsg);
|
||||
}
|
||||
return sites.getResults().get(0).getId();
|
||||
}
|
||||
|
||||
protected SiteListResult getSites() {
|
||||
try {
|
||||
Sites sites = (Sites) nsxService.apply(Sites.class);
|
||||
return sites.list(null, false, null, null, null, null);
|
||||
|
|
@ -352,7 +373,17 @@ public class NsxApiClient {
|
|||
}
|
||||
}
|
||||
|
||||
public EnforcementPointListResult getEnforcementPoints(String siteId) {
|
||||
public String getDefaultEnforcementPointPath(String siteId) {
|
||||
EnforcementPointListResult epList = getEnforcementPoints(siteId);
|
||||
if (CollectionUtils.isEmpty(epList.getResults())) {
|
||||
String errorMsg = String.format("No enforcement points are found in the linked NSX infrastructure for site ID %s", siteId);
|
||||
LOGGER.error(errorMsg);
|
||||
throw new CloudRuntimeException(errorMsg);
|
||||
}
|
||||
return epList.getResults().get(0).getPath();
|
||||
}
|
||||
|
||||
protected EnforcementPointListResult getEnforcementPoints(String siteId) {
|
||||
try {
|
||||
EnforcementPoints enforcementPoints = (EnforcementPoints) nsxService.apply(EnforcementPoints.class);
|
||||
return enforcementPoints.list(siteId, null, false, null, null, null, null);
|
||||
|
|
@ -397,11 +428,8 @@ public class NsxApiClient {
|
|||
|
||||
public void deleteSegment(long zoneId, long domainId, long accountId, Long vpcId, long networkId, String segmentName) {
|
||||
try {
|
||||
Segments segmentService = (Segments) nsxService.apply(Segments.class);
|
||||
removeSegmentDistributedFirewallRules(segmentName);
|
||||
removeGroupForSegment(segmentName);
|
||||
LOGGER.debug(String.format("Removing the segment with ID %s", segmentName));
|
||||
segmentService.delete(segmentName);
|
||||
removeSegment(segmentName);
|
||||
DhcpRelayConfigs dhcpRelayConfig = (DhcpRelayConfigs) nsxService.apply(DhcpRelayConfigs.class);
|
||||
String dhcpRelayConfigId = NsxControllerUtils.getNsxDhcpRelayConfigId(zoneId, domainId, accountId, vpcId, networkId);
|
||||
LOGGER.debug(String.format("Removing the DHCP relay config with ID %s", dhcpRelayConfigId));
|
||||
|
|
@ -414,6 +442,30 @@ public class NsxApiClient {
|
|||
}
|
||||
}
|
||||
|
||||
protected void removeSegment(String segmentName) {
|
||||
LOGGER.debug(String.format("Removing the segment with ID %s", segmentName));
|
||||
Segments segmentService = (Segments) nsxService.apply(Segments.class);
|
||||
Segment segment = segmentService.get(segmentName);
|
||||
if (segment == null) {
|
||||
LOGGER.error(String.format("The segment with ID %s is not found, skipping removal", segmentName));
|
||||
return;
|
||||
}
|
||||
String siteId = getDefaultSiteId();
|
||||
String enforcementPointPath = getDefaultEnforcementPointPath(siteId);
|
||||
SegmentPorts segmentPortsService = (SegmentPorts) nsxService.apply(SegmentPorts.class);
|
||||
PolicyGroupMembersListResult segmentPortsList = segmentPortsService.list(DEFAULT_DOMAIN, segmentName, null, enforcementPointPath,
|
||||
false, null, 50L, false, null);
|
||||
if (segmentPortsList.getResultCount() == 0L) {
|
||||
LOGGER.debug(String.format("Removing the segment with ID %s", segmentName));
|
||||
removeGroupForSegment(segmentName);
|
||||
segmentService.delete(segmentName);
|
||||
} else {
|
||||
String msg = String.format("Cannot remove the NSX segment %s because there are still %s port group(s) attached to it", segmentName, segmentPortsList.getResultCount());
|
||||
LOGGER.debug(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void createStaticNatRule(String vpcName, String tier1GatewayName,
|
||||
String ruleName, String publicIp, String vmIp) {
|
||||
try {
|
||||
|
|
@ -506,8 +558,10 @@ public class NsxApiClient {
|
|||
}
|
||||
return members;
|
||||
}
|
||||
public void createNsxLbServerPool(List<NsxLoadBalancerMember> memberList, String tier1GatewayName, String lbServerPoolName, String algorithm) {
|
||||
public void createNsxLbServerPool(List<NsxLoadBalancerMember> memberList, String tier1GatewayName, String lbServerPoolName,
|
||||
String algorithm, String privatePort, String protocol) {
|
||||
try {
|
||||
String activeMonitorPath = getLbActiveMonitorPath(lbServerPoolName, privatePort, protocol);
|
||||
List<LBPoolMember> members = getLbPoolMembers(memberList, tier1GatewayName);
|
||||
LbPools lbPools = (LbPools) nsxService.apply(LbPools.class);
|
||||
LBPool lbPool = new LBPool.Builder()
|
||||
|
|
@ -515,6 +569,8 @@ public class NsxApiClient {
|
|||
.setDisplayName(lbServerPoolName)
|
||||
.setAlgorithm(getLoadBalancerAlgorithm(algorithm))
|
||||
.setMembers(members)
|
||||
.setPassiveMonitorPath(NSX_LB_PASSIVE_MONITOR)
|
||||
.setActiveMonitorPaths(List.of(activeMonitorPath))
|
||||
.build();
|
||||
lbPools.patch(lbServerPoolName, lbPool);
|
||||
} catch (Error error) {
|
||||
|
|
@ -525,6 +581,32 @@ public class NsxApiClient {
|
|||
}
|
||||
}
|
||||
|
||||
private String getLbActiveMonitorPath(String lbServerPoolName, String port, String protocol) {
|
||||
LbMonitorProfiles lbActiveMonitor = (LbMonitorProfiles) nsxService.apply(LbMonitorProfiles.class);
|
||||
String lbMonitorProfileId = getActiveMonitorProfileName(lbServerPoolName, port, protocol);
|
||||
if ("TCP".equals(protocol.toUpperCase(Locale.ROOT))) {
|
||||
LBTcpMonitorProfile lbTcpMonitorProfile = new LBTcpMonitorProfile.Builder(TCP_MONITOR_PROFILE)
|
||||
.setDisplayName(lbMonitorProfileId)
|
||||
.setMonitorPort(Long.parseLong(port))
|
||||
.build();
|
||||
lbActiveMonitor.patch(lbMonitorProfileId, lbTcpMonitorProfile);
|
||||
} else if ("UDP".equals(protocol.toUpperCase(Locale.ROOT))) {
|
||||
LBUdpMonitorProfile lbUdpMonitorProfile = new LBUdpMonitorProfile.Builder(UDP_MONITOR_PROFILE)
|
||||
.setDisplayName(lbMonitorProfileId)
|
||||
.setMonitorPort(Long.parseLong(port))
|
||||
.build();
|
||||
lbActiveMonitor.patch(lbMonitorProfileId, lbUdpMonitorProfile);
|
||||
}
|
||||
|
||||
LBMonitorProfileListResult listResult = listLBActiveMonitors(lbActiveMonitor);
|
||||
Optional<Structure> monitorProfile = listResult.getResults().stream().filter(profile -> profile._getDataValue().getField("id").toString().equals(lbMonitorProfileId)).findFirst();
|
||||
return monitorProfile.map(structure -> structure._getDataValue().getField("path").toString()).orElse(null);
|
||||
}
|
||||
|
||||
LBMonitorProfileListResult listLBActiveMonitors(LbMonitorProfiles lbActiveMonitor) {
|
||||
return lbActiveMonitor.list(null, false, null, null, null, null);
|
||||
}
|
||||
|
||||
public void createNsxLoadBalancer(String tier1GatewayName) {
|
||||
try {
|
||||
String lbName = getLoadBalancerName(tier1GatewayName);
|
||||
|
|
@ -550,10 +632,10 @@ public class NsxApiClient {
|
|||
}
|
||||
|
||||
public void createAndAddNsxLbVirtualServer(String tier1GatewayName, long lbId, String publicIp, String publicPort,
|
||||
List<NsxLoadBalancerMember> memberList, String algorithm, String protocol) {
|
||||
List<NsxLoadBalancerMember> memberList, String algorithm, String protocol, String privatePort) {
|
||||
try {
|
||||
String lbServerPoolName = getServerPoolName(tier1GatewayName, lbId);
|
||||
createNsxLbServerPool(memberList, tier1GatewayName, lbServerPoolName, algorithm);
|
||||
createNsxLbServerPool(memberList, tier1GatewayName, lbServerPoolName, algorithm, privatePort, protocol);
|
||||
createNsxLoadBalancer(tier1GatewayName);
|
||||
|
||||
String lbVirtualServerName = getVirtualServerName(tier1GatewayName, lbId);
|
||||
|
|
@ -589,6 +671,14 @@ public class NsxApiClient {
|
|||
String lbServerPoolName = getServerPoolName(tier1GatewayName, lbId);
|
||||
lbPools.delete(lbServerPoolName, false);
|
||||
|
||||
// delete associated LB Active monitor profile
|
||||
LbMonitorProfiles lbActiveMonitor = (LbMonitorProfiles) nsxService.apply(LbMonitorProfiles.class);
|
||||
LBMonitorProfileListResult listResult = listLBActiveMonitors(lbActiveMonitor);
|
||||
List<String> profileIds = listResult.getResults().stream().filter(profile -> profile._getDataValue().getField("id").toString().contains(lbServerPoolName))
|
||||
.map(profile -> profile._getDataValue().getField("id").toString()).collect(Collectors.toList());
|
||||
for(String profileId : profileIds) {
|
||||
lbActiveMonitor.delete(profileId, true);
|
||||
}
|
||||
// Delete load balancer
|
||||
LBVirtualServerListResult lbVsListResult = lbVirtualServers.list(null, null, null, null, null, null);
|
||||
LBPoolListResult lbPoolListResult = lbPools.list(null, null, null, null, null, null);
|
||||
|
|
|
|||
|
|
@ -505,10 +505,12 @@ public class NsxElement extends AdapterBase implements DhcpServiceProvider, Dns
|
|||
if (!canHandle(network, Network.Service.PortForwarding)) {
|
||||
return false;
|
||||
}
|
||||
boolean result = true;
|
||||
for (PortForwardingRule rule : rules) {
|
||||
IPAddressVO publicIp = ApiDBUtils.findIpAddressById(rule.getSourceIpAddressId());
|
||||
UserVm vm = ApiDBUtils.findUserVmById(rule.getVirtualMachineId());
|
||||
if (vm == null || networkModel.getNicInNetwork(vm.getId(), network.getId()) == null) {
|
||||
if ((vm == null && (rule.getState() != FirewallRule.State.Revoke)) ||
|
||||
(vm != null && networkModel.getNicInNetwork(vm.getId(), network.getId()) == null)) {
|
||||
continue;
|
||||
}
|
||||
NsxOpObject nsxObject = getNsxOpObject(network);
|
||||
|
|
@ -523,8 +525,8 @@ public class NsxElement extends AdapterBase implements DhcpServiceProvider, Dns
|
|||
.setNetworkResourceId(nsxObject.getNetworkResourceId())
|
||||
.setNetworkResourceName(nsxObject.getNetworkResourceName())
|
||||
.setVpcResource(nsxObject.isVpcResource())
|
||||
.setVmId(vm.getId())
|
||||
.setVmIp(vm.getPrivateIpAddress())
|
||||
.setVmId(Objects.nonNull(vm) ? vm.getId() : 0)
|
||||
.setVmIp(Objects.nonNull(vm) ? vm.getPrivateIpAddress() : null)
|
||||
.setPublicIp(publicIp.getAddress().addr())
|
||||
.setPrivatePort(privatePort)
|
||||
.setPublicPort(publicPort)
|
||||
|
|
@ -532,12 +534,12 @@ public class NsxElement extends AdapterBase implements DhcpServiceProvider, Dns
|
|||
.setProtocol(rule.getProtocol().toUpperCase(Locale.ROOT))
|
||||
.build();
|
||||
if (rule.getState() == FirewallRule.State.Add) {
|
||||
return nsxService.createPortForwardRule(networkRule);
|
||||
result &= nsxService.createPortForwardRule(networkRule);
|
||||
} else if (rule.getState() == FirewallRule.State.Revoke) {
|
||||
return nsxService.deletePortForwardRule(networkRule);
|
||||
result &= nsxService.deletePortForwardRule(networkRule);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Pair<VpcVO, NetworkVO> getVpcOrNetwork(Long vpcId, long networkId) {
|
||||
|
|
@ -613,6 +615,7 @@ public class NsxElement extends AdapterBase implements DhcpServiceProvider, Dns
|
|||
|
||||
@Override
|
||||
public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
|
||||
boolean result = true;
|
||||
for (LoadBalancingRule loadBalancingRule : rules) {
|
||||
if (loadBalancingRule.getState() == FirewallRule.State.Active) {
|
||||
continue;
|
||||
|
|
@ -638,12 +641,12 @@ public class NsxElement extends AdapterBase implements DhcpServiceProvider, Dns
|
|||
.setAlgorithm(loadBalancingRule.getAlgorithm())
|
||||
.build();
|
||||
if (loadBalancingRule.getState() == FirewallRule.State.Add) {
|
||||
return nsxService.createLbRule(networkRule);
|
||||
result &= nsxService.createLbRule(networkRule);
|
||||
} else if (loadBalancingRule.getState() == FirewallRule.State.Revoke) {
|
||||
return nsxService.deleteLbRule(networkRule);
|
||||
result &= nsxService.deleteLbRule(networkRule);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class NsxServiceImpl implements NsxService {
|
|||
network.getVpcId(), vpcName, network.getId(), network.getName());
|
||||
NsxAnswer result = nsxControllerUtils.sendNsxCommand(deleteNsxSegmentCommand, network.getDataCenterId());
|
||||
if (!result.getResult()) {
|
||||
String msg = String.format("Could not remove the NSX segment for network %s", network.getName());
|
||||
String msg = String.format("Could not remove the NSX segment for network %s: %s", network.getName(), result.getDetails());
|
||||
LOGGER.error(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ public class NsxControllerUtils {
|
|||
return getLoadBalancerRuleName(tier1GatewayName, lbId) + "-SP";
|
||||
}
|
||||
|
||||
public static String getActiveMonitorProfileName(String lbServerPoolName, String port, String protocol) {
|
||||
return lbServerPoolName + "-" + protocol + "-" + port + "-AM";
|
||||
}
|
||||
|
||||
public static String getVirtualServerName(String tier1GatewayName, long lbId) {
|
||||
return getLoadBalancerRuleName(tier1GatewayName, lbId) + "-VS";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
import com.vmware.nsx.model.TransportZone;
|
||||
import com.vmware.nsx.model.TransportZoneListResult;
|
||||
import com.vmware.nsx_policy.model.EnforcementPoint;
|
||||
import com.vmware.nsx_policy.model.EnforcementPointListResult;
|
||||
import com.vmware.nsx_policy.model.Site;
|
||||
import com.vmware.nsx_policy.model.SiteListResult;
|
||||
import junit.framework.Assert;
|
||||
import org.apache.cloudstack.NsxAnswer;
|
||||
import org.apache.cloudstack.agent.api.CreateNsxDistributedFirewallRulesCommand;
|
||||
|
|
@ -74,10 +72,6 @@ public class NsxResourceTest {
|
|||
NsxResource nsxResource;
|
||||
AutoCloseable closeable;
|
||||
@Mock
|
||||
EnforcementPointListResult enforcementPointListResult;
|
||||
@Mock
|
||||
SiteListResult siteListResult;
|
||||
@Mock
|
||||
TransportZoneListResult transportZoneListResult;
|
||||
|
||||
private static final String transportZone = "Overlay";
|
||||
|
|
@ -177,13 +171,9 @@ public class NsxResourceTest {
|
|||
NsxCommand command = new CreateNsxSegmentCommand(domainId, accountId, zoneId,
|
||||
2L, "VPC01", 3L, "Web", "10.10.10.1", "10.10.10.0/24");
|
||||
|
||||
when(nsxApi.getSites()).thenReturn(siteListResult);
|
||||
when(siteListResult.getResults()).thenReturn(siteList);
|
||||
when(siteList.get(0).getId()).thenReturn("site1");
|
||||
when(nsxApi.getDefaultSiteId()).thenReturn("site1");
|
||||
|
||||
when(nsxApi.getEnforcementPoints(anyString())).thenReturn(enforcementPointListResult);
|
||||
when(enforcementPointListResult.getResults()).thenReturn(enforcementPointList);
|
||||
when(enforcementPointList.get(0).getPath()).thenReturn("enforcementPointPath");
|
||||
when(nsxApi.getDefaultEnforcementPointPath(anyString())).thenReturn("enforcementPointPath");
|
||||
|
||||
when(nsxApi.getTransportZones()).thenReturn(transportZoneListResult);
|
||||
when(transportZoneListResult.getResults()).thenReturn(transportZoneList);
|
||||
|
|
@ -194,7 +184,7 @@ public class NsxResourceTest {
|
|||
|
||||
@Test
|
||||
public void testCreateNsxSegmentEmptySites() {
|
||||
when(nsxApi.getSites()).thenReturn(null);
|
||||
when(nsxApi.getDefaultSiteId()).thenReturn(null);
|
||||
CreateNsxSegmentCommand command = Mockito.mock(CreateNsxSegmentCommand.class);
|
||||
NsxAnswer answer = (NsxAnswer) nsxResource.executeRequest(command);
|
||||
assertFalse(answer.getResult());
|
||||
|
|
@ -203,11 +193,8 @@ public class NsxResourceTest {
|
|||
@Test
|
||||
public void testCreateNsxSegmentEmptyEnforcementPoints() {
|
||||
Site site = mock(Site.class);
|
||||
List<Site> siteList = List.of(site);
|
||||
when(nsxApi.getSites()).thenReturn(siteListResult);
|
||||
when(siteListResult.getResults()).thenReturn(siteList);
|
||||
when(siteList.get(0).getId()).thenReturn("site1");
|
||||
when(nsxApi.getEnforcementPoints(anyString())).thenReturn(null);
|
||||
when(nsxApi.getDefaultSiteId()).thenReturn("site1");
|
||||
when(nsxApi.getDefaultEnforcementPointPath(anyString())).thenReturn(null);
|
||||
CreateNsxSegmentCommand command = Mockito.mock(CreateNsxSegmentCommand.class);
|
||||
NsxAnswer answer = (NsxAnswer) nsxResource.executeRequest(command);
|
||||
assertFalse(answer.getResult());
|
||||
|
|
@ -216,10 +203,7 @@ public class NsxResourceTest {
|
|||
@Test
|
||||
public void testCreateNsxSegmentEmptyTransportZones() {
|
||||
Site site = mock(Site.class);
|
||||
List<Site> siteList = List.of(site);
|
||||
when(nsxApi.getSites()).thenReturn(siteListResult);
|
||||
when(siteListResult.getResults()).thenReturn(siteList);
|
||||
when(siteList.get(0).getId()).thenReturn("site1");
|
||||
when(nsxApi.getDefaultSiteId()).thenReturn("site1");
|
||||
CreateNsxSegmentCommand command = Mockito.mock(CreateNsxSegmentCommand.class);
|
||||
NsxAnswer answer = (NsxAnswer) nsxResource.executeRequest(command);
|
||||
assertFalse(answer.getResult());
|
||||
|
|
|
|||
|
|
@ -273,8 +273,13 @@ public class NsxElementTest {
|
|||
5L, 2L, 15L);
|
||||
rule.setState(FirewallRule.State.Revoke);
|
||||
Network.Service service = new Network.Service("service1", new Network.Capability("capability"));
|
||||
|
||||
VpcVO vpcVO = Mockito.mock(VpcVO.class);
|
||||
when(vpcDao.findById(1L)).thenReturn(vpcVO);
|
||||
when(vpcVO.getDomainId()).thenReturn(2L);
|
||||
IPAddressVO ipAddress = new IPAddressVO(new Ip("10.1.13.10"), 1L, 1L, 1L,false);
|
||||
when(ApiDBUtils.findIpAddressById(anyLong())).thenReturn(ipAddress);
|
||||
when(nsxElement.canHandle(networkVO, service)).thenReturn(true);
|
||||
when(nsxService.deletePortForwardRule(any(NsxNetworkRule.class))).thenReturn(true);
|
||||
assertTrue(nsxElement.applyPFRules(networkVO, List.of(rule)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-storage</artifactId>
|
||||
<version>4.19.0.0-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
@ -214,7 +214,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-storage-object</artifactId>
|
||||
<version>4.19.0.0-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -143,6 +143,10 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
|
|||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject
|
||||
EntityManager entityManager;
|
||||
@Inject
|
||||
NsxProviderDao nsxProviderDao;
|
||||
List<FirewallServiceProvider> _firewallElements;
|
||||
|
||||
List<PortForwardingServiceProvider> _pfElements;
|
||||
|
|
@ -152,10 +156,6 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
|
|||
List<NetworkACLServiceProvider> _networkAclElements;
|
||||
@Inject
|
||||
IpAddressManager _ipAddrMgr;
|
||||
@Inject
|
||||
EntityManager entityManager;
|
||||
@Inject
|
||||
NsxProviderDao nsxProviderDao;
|
||||
|
||||
private boolean _elbEnabled = false;
|
||||
static Boolean rulesContinueOnErrFlag = true;
|
||||
|
|
@ -699,9 +699,10 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
|
|||
}
|
||||
|
||||
for (FirewallRuleVO rule : rules) {
|
||||
// load cidrs if any
|
||||
// validate rule - for NSX
|
||||
long networkId = rule.getNetworkId();
|
||||
validateNsxConstraints(networkId, rule.getProtocol(), rule);
|
||||
validateNsxConstraints(networkId, rule);
|
||||
// load cidrs if any
|
||||
rule.setSourceCidrList(_firewallCidrsDao.getSourceCidrs(rule.getId()));
|
||||
rule.setDestinationCidrsList(_firewallDcidrsDao.getDestCidrs(rule.getId()));
|
||||
}
|
||||
|
|
@ -722,13 +723,15 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
|
|||
return true;
|
||||
}
|
||||
|
||||
private void validateNsxConstraints(long networkId, String protocol, FirewallRuleVO rule) {
|
||||
private void validateNsxConstraints(long networkId, FirewallRuleVO rule) {
|
||||
String protocol = rule.getProtocol();
|
||||
final Network network = entityManager.findById(Network.class, networkId);
|
||||
final DataCenter dc = entityManager.findById(DataCenter.class, network.getDataCenterId());
|
||||
final NsxProviderVO nsxProvider = nsxProviderDao.findByZoneId(dc.getId());
|
||||
if (Objects.isNull(nsxProvider)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NetUtils.ICMP_PROTO.equals(protocol.toLowerCase(Locale.ROOT)) && (rule.getIcmpType() == -1 || rule.getIcmpCode() == -1)) {
|
||||
String errorMsg = "Passing -1 for ICMP type is not supported for NSX enabled zones";
|
||||
s_logger.error(errorMsg);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ import javax.naming.ConfigurationException;
|
|||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import com.cloud.kubernetes.cluster.KubernetesClusterHelper;
|
||||
import com.cloud.network.dao.NsxProviderDao;
|
||||
import com.cloud.network.element.NsxProviderVO;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
|
|
@ -589,6 +592,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
|
||||
@Inject
|
||||
VMScheduleManager vmScheduleManager;
|
||||
@Inject
|
||||
NsxProviderDao nsxProviderDao;
|
||||
|
||||
private ScheduledExecutorService _executor = null;
|
||||
private ScheduledExecutorService _vmIpFetchExecutor = null;
|
||||
|
|
@ -597,6 +602,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
private boolean _dailyOrHourly = false;
|
||||
private int capacityReleaseInterval;
|
||||
private ExecutorService _vmIpFetchThreadExecutor;
|
||||
private List<KubernetesClusterHelper> kubernetesClusterHelpers;
|
||||
|
||||
|
||||
private String _instance;
|
||||
|
|
@ -610,6 +616,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
private static final int NUM_OF_2K_BLOCKS = 512;
|
||||
private static final int MAX_HTTP_POST_LENGTH = NUM_OF_2K_BLOCKS * MAX_USER_DATA_LENGTH_BYTES;
|
||||
|
||||
public List<KubernetesClusterHelper> getKubernetesClusterHelpers() {
|
||||
return kubernetesClusterHelpers;
|
||||
}
|
||||
|
||||
public void setKubernetesClusterHelpers(final List<KubernetesClusterHelper> kubernetesClusterHelpers) {
|
||||
this.kubernetesClusterHelpers = kubernetesClusterHelpers;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private OrchestrationService _orchSrvc;
|
||||
|
||||
|
|
@ -2528,11 +2542,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
|
||||
// cleanup port forwarding rules
|
||||
if (_rulesMgr.revokePortForwardingRulesForVm(vmId)) {
|
||||
s_logger.debug("Port forwarding rules are removed successfully as a part of vm id=" + vmId + " expunge");
|
||||
} else {
|
||||
success = false;
|
||||
s_logger.warn("Fail to remove port forwarding rules as a part of vm id=" + vmId + " expunge");
|
||||
VMInstanceVO vmInstanceVO = _vmInstanceDao.findById(vmId);
|
||||
NsxProviderVO nsx = nsxProviderDao.findByZoneId(vmInstanceVO.getDataCenterId());
|
||||
if (Objects.isNull(nsx) || Objects.isNull(kubernetesClusterHelpers.get(0).findByVmId(vmId))) {
|
||||
if (_rulesMgr.revokePortForwardingRulesForVm(vmId)) {
|
||||
s_logger.debug("Port forwarding rules are removed successfully as a part of vm id=" + vmId + " expunge");
|
||||
} else {
|
||||
success = false;
|
||||
s_logger.warn("Fail to remove port forwarding rules as a part of vm id=" + vmId + " expunge");
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup load balancer rules
|
||||
|
|
|
|||
|
|
@ -106,8 +106,9 @@
|
|||
|
||||
<bean id="configurationServerImpl" class="com.cloud.server.ConfigurationServerImpl" />
|
||||
|
||||
|
||||
<bean id="userVmManagerImpl" class="com.cloud.vm.UserVmManagerImpl" />
|
||||
<bean id="userVmManagerImpl" class="com.cloud.vm.UserVmManagerImpl">
|
||||
<property name="kubernetesClusterHelpers" value="#{kubernetesClusterHelperRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl">
|
||||
<property name="consoleProxyAllocators"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,39 @@
|
|||
// under the License.
|
||||
package com.cloud.vpc;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.network.PublicIpQuarantine;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.api.command.admin.address.ReleasePodIpCmdByAdmin;
|
||||
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListGuestVlansCmd;
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.address.RemoveQuarantinedIpCmd;
|
||||
import org.apache.cloudstack.api.command.user.address.UpdateQuarantinedIpCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RemoveNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ResetNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
|
||||
import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
|
|
@ -40,7 +72,6 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkTrafficType;
|
||||
import com.cloud.network.PublicIpQuarantine;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.element.DhcpServiceProvider;
|
||||
|
|
@ -68,34 +99,6 @@ import com.cloud.vm.ReservationContext;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.api.command.admin.address.ReleasePodIpCmdByAdmin;
|
||||
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListGuestVlansCmd;
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.address.RemoveQuarantinedIpCmd;
|
||||
import org.apache.cloudstack.api.command.user.address.UpdateQuarantinedIpCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RemoveNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ResetNetworkPermissionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
|
||||
import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrchestrationService, NetworkService {
|
||||
|
|
@ -827,6 +830,11 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stateTransitTo(Network network, Network.Event e) throws NoTransitionException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkInlineMode(Network network) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
|||
|
|
@ -675,9 +675,9 @@
|
|||
"label.deploymentplanner": "Deployment planner",
|
||||
"label.desc.db.stats": "Database Statistics",
|
||||
"label.desc.importexportinstancewizard": "Import and export Instances to/from an existing VMware or KVM cluster.",
|
||||
"label.desc.import.ext.kvm.wizard": "Import libvirt domain from KVM Host",
|
||||
"label.desc.import.local.kvm.wizard": "Import QCOW image from Local Storage",
|
||||
"label.desc.import.shared.kvm.wizard": "Import QCOW image from Shared Storage",
|
||||
"label.desc.import.ext.kvm.wizard": "Import Instance from remote KVM host",
|
||||
"label.desc.import.local.kvm.wizard": "Import QCOW2 image from Local Storage",
|
||||
"label.desc.import.shared.kvm.wizard": "Import QCOW2 image from Shared Storage",
|
||||
"label.desc.ingesttinstancewizard": "Ingest instances from an external KVM host",
|
||||
"label.desc.importmigratefromvmwarewizard": "Import instances from VMware into a KVM cluster",
|
||||
"label.desc.usage.stats": "Usage Server Statistics",
|
||||
|
|
@ -2719,8 +2719,8 @@
|
|||
"message.desc.host": "Each cluster must contain at least one host (computer) for guest Instances to run on. We will add the first host now. For a host to function in CloudStack, you must install hypervisor software on the host, assign an IP address to the host, and ensure the host is connected to the CloudStack management server.<br/><br/>Give the host's DNS or IP address, the user name (usually root) and password, and any labels you use to categorize hosts.",
|
||||
"message.desc.importingestinstancewizard": "This feature only applies to libvirt based KVM instances. Only Stopped instances can be ingested",
|
||||
"message.desc.import.ext.kvm.wizard": "Import libvirt domain from External KVM Host not managed by CloudStack",
|
||||
"message.desc.import.local.kvm.wizard": "Import QCOW image from Local Storage of selected KVM Host",
|
||||
"message.desc.import.shared.kvm.wizard": "Import QCOW image from selected Primary Storage Pool",
|
||||
"message.desc.import.local.kvm.wizard": "Import QCOW2 image from Local Storage of selected KVM Host",
|
||||
"message.desc.import.shared.kvm.wizard": "Import QCOW2 image from selected Primary Storage Pool",
|
||||
"message.desc.importexportinstancewizard": "By choosing to manage an Instance, CloudStack takes over the orchestration of that Instance. Unmanaging an Instance removes CloudStack ability to manage it. In both cases, the Instance is left running and no changes are done to the VM on the hypervisor.<br><br>For KVM, managing a VM is an experimental feature.",
|
||||
"message.desc.importmigratefromvmwarewizard": "By selecting an existing or external VMware Datacenter and an instance to import, CloudStack migrates the selected instance from VMware to KVM on a conversion host using virt-v2v and imports it into a KVM cluster",
|
||||
"message.desc.primary.storage": "Each cluster must contain one or more primary storage servers. We will add the first one now. Primary storage contains the disk volumes for all the Instances running on hosts in the cluster. Use any standards-compliant protocol that is supported by the underlying hypervisor.",
|
||||
|
|
|
|||
|
|
@ -259,18 +259,12 @@ export default {
|
|||
this.apiParams = this.$getApiParams('createKubernetesCluster')
|
||||
},
|
||||
created () {
|
||||
this.networks = [
|
||||
{
|
||||
id: null,
|
||||
name: ''
|
||||
}
|
||||
]
|
||||
this.keyPairs = [
|
||||
{
|
||||
id: null,
|
||||
name: ''
|
||||
}
|
||||
]
|
||||
this.emptyEntry = {
|
||||
id: null,
|
||||
name: ''
|
||||
}
|
||||
this.networks = [this.emptyEntry]
|
||||
this.keyPairs = [this.emptyEntry]
|
||||
this.initForm()
|
||||
this.fetchData()
|
||||
},
|
||||
|
|
@ -322,7 +316,6 @@ export default {
|
|||
},
|
||||
fetchData () {
|
||||
this.fetchZoneData()
|
||||
this.fetchNetworkData()
|
||||
this.fetchKeyPairData()
|
||||
},
|
||||
isValidValueForKey (obj, key) {
|
||||
|
|
@ -417,15 +410,16 @@ export default {
|
|||
params.zoneid = this.selectedZone.id
|
||||
}
|
||||
this.networkLoading = true
|
||||
this.networks = []
|
||||
api('listNetworks', params).then(json => {
|
||||
var listNetworks = json.listnetworksresponse.network
|
||||
if (this.arrayHasItems(listNetworks)) {
|
||||
listNetworks = listNetworks.filter(n => n.type !== 'L2')
|
||||
var ids = new Set(this.networks.map(n => n.id))
|
||||
this.networks = [...this.networks, ...listNetworks.filter(n => !ids.has(n.id))]
|
||||
this.networks = listNetworks
|
||||
}
|
||||
}).finally(() => {
|
||||
this.networkLoading = false
|
||||
this.networks = [this.emptyEntry].concat(this.networks)
|
||||
if (this.arrayHasItems(this.networks)) {
|
||||
this.form.networkid = 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ export default {
|
|||
},
|
||||
{
|
||||
name: 'external',
|
||||
label: 'Import libvirt domain from KVM Host',
|
||||
label: 'Import Instance from remote KVM host',
|
||||
sourceDestHypervisors: {
|
||||
kvm: 'kvm'
|
||||
},
|
||||
|
|
@ -576,7 +576,7 @@ export default {
|
|||
},
|
||||
{
|
||||
name: 'local',
|
||||
label: 'Import QCOW image from Local Storage',
|
||||
label: 'Import QCOW2 image from Local Storage',
|
||||
sourceDestHypervisors: {
|
||||
kvm: 'kvm'
|
||||
},
|
||||
|
|
@ -585,7 +585,7 @@ export default {
|
|||
},
|
||||
{
|
||||
name: 'shared',
|
||||
label: 'Import QCOW image from Shared Storage',
|
||||
label: 'Import QCOW2 image from Shared Storage',
|
||||
sourceDestHypervisors: {
|
||||
kvm: 'kvm'
|
||||
},
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-core</artifactId>
|
||||
<version>4.19.0.0-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
Loading…
Reference in New Issue