mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Removed several unused fields after the refactoring
This commit is contained in:
parent
f70413f144
commit
fc33ef2be2
@ -39,8 +39,6 @@ public interface VirtualRouter extends VirtualMachine {
|
||||
|
||||
public String getPublicNetmask();
|
||||
|
||||
public String getPrivateNetmask();
|
||||
|
||||
public String getVnet();
|
||||
|
||||
public String getVlanId();
|
||||
@ -73,11 +71,13 @@ public interface VirtualRouter extends VirtualMachine {
|
||||
/**
|
||||
* @return account id that the domain router belongs to.
|
||||
*/
|
||||
@Override
|
||||
long getAccountId();
|
||||
|
||||
/**
|
||||
* @return domain id that the domain router belongs to.
|
||||
*/
|
||||
@Override
|
||||
long getDomainId();
|
||||
|
||||
Role getRole();
|
||||
|
||||
@ -1,123 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.resource;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
/**
|
||||
* Indicates a resource in CloudStack.
|
||||
* Any resource that requires an reservation and release system
|
||||
* must implement this interface.
|
||||
*
|
||||
*/
|
||||
public interface Resource {
|
||||
enum Event {
|
||||
ReservationRequested,
|
||||
ReleaseRequested,
|
||||
CancelRequested,
|
||||
OperationCompleted,
|
||||
OperationFailed,
|
||||
}
|
||||
|
||||
enum State implements FiniteState<State, Event> {
|
||||
Allocated("Resource is allocated but not reserved"),
|
||||
Reserving("Resource is being reserved right now"),
|
||||
Reserved("Resource has been reserved."),
|
||||
Releasing("Resource is being released"),
|
||||
Deallocating("Resource is being deallocated");
|
||||
|
||||
String _description;
|
||||
|
||||
@Override
|
||||
public StateMachine<State, Event> getStateMachine() {
|
||||
return s_fsm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getNextState(Event event) {
|
||||
return s_fsm.getNextState(this, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<State> getFromStates(Event event) {
|
||||
return s_fsm.getFromStates(this, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Event> getPossibleEvents() {
|
||||
return s_fsm.getPossibleEvents(this);
|
||||
}
|
||||
|
||||
private State(String description) {
|
||||
_description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return _description;
|
||||
}
|
||||
|
||||
final static private StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
|
||||
static {
|
||||
s_fsm.addTransition(State.Allocated, Event.ReservationRequested, State.Reserving);
|
||||
s_fsm.addTransition(State.Reserving, Event.CancelRequested, State.Allocated);
|
||||
s_fsm.addTransition(State.Reserving, Event.OperationCompleted, State.Reserved);
|
||||
s_fsm.addTransition(State.Reserving, Event.OperationFailed, State.Allocated);
|
||||
s_fsm.addTransition(State.Reserved, Event.ReleaseRequested, State.Releasing);
|
||||
s_fsm.addTransition(State.Releasing, Event.OperationCompleted, State.Allocated);
|
||||
s_fsm.addTransition(State.Releasing, Event.OperationFailed, State.Reserved);
|
||||
}
|
||||
}
|
||||
|
||||
enum ReservationStrategy {
|
||||
PlaceHolder,
|
||||
Create,
|
||||
Start;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id in the CloudStack database
|
||||
*/
|
||||
long getId();
|
||||
|
||||
/**
|
||||
* @return reservation id returned by the allocation source. This can be the
|
||||
* String version of the database id if the allocation source does not need it's
|
||||
* own implementation of the reservation id. This is passed back to the
|
||||
* allocation source to release the resource.
|
||||
*/
|
||||
String getReservationId();
|
||||
|
||||
/**
|
||||
* @return unique name for the allocation source.
|
||||
*/
|
||||
String getReserver();
|
||||
|
||||
/**
|
||||
* @return the time a reservation request was made to the allocation source.
|
||||
*/
|
||||
Date getUpdateTime();
|
||||
|
||||
/**
|
||||
* @return the expected reservation interval. -1 indicates
|
||||
*/
|
||||
int getExpectedReservationInterval();
|
||||
|
||||
/**
|
||||
* @return the expected release interval.
|
||||
*/
|
||||
int getExpectedReleaseInterval();
|
||||
|
||||
/**
|
||||
* @return the reservation state of the resource.
|
||||
*/
|
||||
State getState();
|
||||
|
||||
ReservationStrategy getReservationStrategy();
|
||||
}
|
||||
@ -152,7 +152,6 @@ public interface Volume extends ControlledEntity, BasedOn {
|
||||
|
||||
Date getCreated();
|
||||
AsyncInstanceCreateStatus getStatus();
|
||||
boolean getDestroyed();
|
||||
|
||||
long getDiskOfferingId();
|
||||
|
||||
|
||||
@ -18,15 +18,112 @@
|
||||
package com.cloud.vm;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.resource.Resource;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
|
||||
/**
|
||||
* Nic represents one nic on the VM.
|
||||
*/
|
||||
public interface Nic extends Resource {
|
||||
public interface Nic {
|
||||
enum Event {
|
||||
ReservationRequested,
|
||||
ReleaseRequested,
|
||||
CancelRequested,
|
||||
OperationCompleted,
|
||||
OperationFailed,
|
||||
}
|
||||
|
||||
public enum State implements FiniteState<State, Event> {
|
||||
Allocated("Resource is allocated but not reserved"),
|
||||
Reserving("Resource is being reserved right now"),
|
||||
Reserved("Resource has been reserved."),
|
||||
Releasing("Resource is being released"),
|
||||
Deallocating("Resource is being deallocated");
|
||||
|
||||
String _description;
|
||||
|
||||
@Override
|
||||
public StateMachine<State, Event> getStateMachine() {
|
||||
return s_fsm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getNextState(Event event) {
|
||||
return s_fsm.getNextState(this, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<State> getFromStates(Event event) {
|
||||
return s_fsm.getFromStates(this, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Event> getPossibleEvents() {
|
||||
return s_fsm.getPossibleEvents(this);
|
||||
}
|
||||
|
||||
private State(String description) {
|
||||
_description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return _description;
|
||||
}
|
||||
|
||||
final static private StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
|
||||
static {
|
||||
s_fsm.addTransition(State.Allocated, Event.ReservationRequested, State.Reserving);
|
||||
s_fsm.addTransition(State.Reserving, Event.CancelRequested, State.Allocated);
|
||||
s_fsm.addTransition(State.Reserving, Event.OperationCompleted, State.Reserved);
|
||||
s_fsm.addTransition(State.Reserving, Event.OperationFailed, State.Allocated);
|
||||
s_fsm.addTransition(State.Reserved, Event.ReleaseRequested, State.Releasing);
|
||||
s_fsm.addTransition(State.Releasing, Event.OperationCompleted, State.Allocated);
|
||||
s_fsm.addTransition(State.Releasing, Event.OperationFailed, State.Reserved);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ReservationStrategy {
|
||||
PlaceHolder,
|
||||
Create,
|
||||
Start;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id in the CloudStack database
|
||||
*/
|
||||
long getId();
|
||||
|
||||
/**
|
||||
* @return reservation id returned by the allocation source. This can be the
|
||||
* String version of the database id if the allocation source does not need it's
|
||||
* own implementation of the reservation id. This is passed back to the
|
||||
* allocation source to release the resource.
|
||||
*/
|
||||
String getReservationId();
|
||||
|
||||
/**
|
||||
* @return unique name for the allocation source.
|
||||
*/
|
||||
String getReserver();
|
||||
|
||||
/**
|
||||
* @return the time a reservation request was made to the allocation source.
|
||||
*/
|
||||
Date getUpdateTime();
|
||||
|
||||
/**
|
||||
* @return the reservation state of the resource.
|
||||
*/
|
||||
State getState();
|
||||
|
||||
ReservationStrategy getReservationStrategy();
|
||||
boolean isDefaultNic();
|
||||
|
||||
String getIp4Address();
|
||||
@ -54,5 +151,4 @@ public interface Nic extends Resource {
|
||||
URI getIsolationUri();
|
||||
|
||||
URI getBroadcastUri();
|
||||
|
||||
}
|
||||
|
||||
@ -10,8 +10,7 @@ import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.resource.Resource;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
|
||||
public class NicProfile {
|
||||
long id;
|
||||
@ -220,7 +219,7 @@ public class NicProfile {
|
||||
this.vmId = vmId;
|
||||
}
|
||||
|
||||
public NicProfile(Resource.ReservationStrategy strategy, String ip4Address, String macAddress, String gateway, String netmask) {
|
||||
public NicProfile(ReservationStrategy strategy, String ip4Address, String macAddress, String gateway, String netmask) {
|
||||
this.format = AddressFormat.Ip4;
|
||||
this.ip4Address = ip4Address;
|
||||
this.macAddress = macAddress;
|
||||
|
||||
@ -84,9 +84,6 @@ public class VolumeVO implements Volume {
|
||||
@Column(name="pod_id")
|
||||
Long podId;
|
||||
|
||||
@Column(name="destroyed")
|
||||
boolean destroyed = false;
|
||||
|
||||
@Column(name="created")
|
||||
Date created;
|
||||
|
||||
@ -104,10 +101,6 @@ public class VolumeVO implements Volume {
|
||||
@Column(name="disk_offering_id")
|
||||
long diskOfferingId;
|
||||
|
||||
@Expose
|
||||
@Column(name="mirror_vol")
|
||||
Long mirrorVolume;
|
||||
|
||||
@Column(name="template_id")
|
||||
Long templateId;
|
||||
|
||||
@ -119,11 +112,6 @@ public class VolumeVO implements Volume {
|
||||
@Enumerated(EnumType.STRING)
|
||||
VolumeType volumeType = Volume.VolumeType.UNKNOWN;
|
||||
|
||||
@Expose
|
||||
@Column(name="mirror_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
MirrorState mirrorState = Volume.MirrorState.NOT_MIRRORED;
|
||||
|
||||
@Expose
|
||||
@Column(name="pool_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
@ -185,8 +173,6 @@ public class VolumeVO implements Volume {
|
||||
this.size = size;
|
||||
this.status = AsyncInstanceCreateStatus.Creating;
|
||||
this.templateId = null;
|
||||
this.mirrorState = MirrorState.NOT_MIRRORED;
|
||||
this.mirrorVolume = null;
|
||||
this.storageResourceType = Storage.StorageResourceType.STORAGE_POOL;
|
||||
this.poolType = null;
|
||||
}
|
||||
@ -199,8 +185,6 @@ public class VolumeVO implements Volume {
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.size = size;
|
||||
this.mirrorVolume = null;
|
||||
this.mirrorState = MirrorState.NOT_MIRRORED;
|
||||
this.diskOfferingId = diskOfferingId;
|
||||
this.status = AsyncInstanceCreateStatus.Creating;
|
||||
this.state = State.Allocated;
|
||||
@ -319,7 +303,8 @@ public class VolumeVO implements Volume {
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
public Long getDeviceId() {
|
||||
@Override
|
||||
public Long getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
@ -380,18 +365,11 @@ public class VolumeVO implements Volume {
|
||||
volumeType = type;
|
||||
}
|
||||
|
||||
public boolean getDestroyed() {
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setDestroyed(boolean destroyed) {
|
||||
this.destroyed = destroyed;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
@ -400,15 +378,8 @@ public class VolumeVO implements Volume {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
public MirrorState getMirrorState() {
|
||||
return mirrorState;
|
||||
}
|
||||
|
||||
public void setMirrorState(MirrorState mirrorState) {
|
||||
this.mirrorState = mirrorState;
|
||||
}
|
||||
|
||||
public long getDiskOfferingId() {
|
||||
@Override
|
||||
public long getDiskOfferingId() {
|
||||
return diskOfferingId;
|
||||
}
|
||||
|
||||
@ -433,14 +404,6 @@ public class VolumeVO implements Volume {
|
||||
this.firstSnapshotBackupUuid = firstSnapshotBackupUuid;
|
||||
}
|
||||
|
||||
public Long getMirrorVolume() {
|
||||
return mirrorVolume;
|
||||
}
|
||||
|
||||
public void setMirrorVolume(Long mirrorVolume) {
|
||||
this.mirrorVolume = mirrorVolume;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Storage.StorageResourceType getStorageResourceType() {
|
||||
return storageResourceType;
|
||||
@ -459,6 +422,7 @@ public class VolumeVO implements Volume {
|
||||
this.poolId = poolId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncInstanceCreateStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ public interface SystemVm extends VirtualMachine {
|
||||
public String getPublicMacAddress();
|
||||
public Long getVlanDbId();
|
||||
public String getVlanId();
|
||||
public String getPrivateNetmask();
|
||||
public int getRamSize();
|
||||
public Date getLastUpdateTime();
|
||||
}
|
||||
|
||||
@ -110,7 +110,6 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
|
||||
public void setGuestNetmask(String guestNetmask) {
|
||||
this.guestNetmask = guestNetmask;
|
||||
setPrivateNetmask(guestNetmask);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -99,9 +99,6 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
@Column(name="private_mac_address", updatable=true, nullable=true)
|
||||
protected String privateMacAddress;
|
||||
|
||||
@Column(name="private_netmask")
|
||||
protected String privateNetmask;
|
||||
|
||||
@Column(name="data_center_id", updatable=true, nullable=false)
|
||||
protected long dataCenterId;
|
||||
|
||||
@ -112,9 +109,6 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
@Column(name="ha_enabled", updatable=true, nullable=true)
|
||||
protected boolean haEnabled;
|
||||
|
||||
@Column(name="mirrored_vols", updatable=true, nullable=true)
|
||||
protected boolean mirroredVols;
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code.
|
||||
|
||||
@ -164,7 +158,6 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
this.type = type;
|
||||
this.guestOSId = guestOSId;
|
||||
this.haEnabled = haEnabled;
|
||||
this.mirroredVols = false;
|
||||
this.vncPassword = Long.toHexString(new Random().nextLong());
|
||||
this.state = State.Stopped;
|
||||
this.accountId = accountId;
|
||||
@ -223,19 +216,6 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public void setPrivateNetmask(String privateNetmask) {
|
||||
this.privateNetmask = privateNetmask;
|
||||
}
|
||||
|
||||
public String getPrivateNetmask() {
|
||||
return privateNetmask;
|
||||
}
|
||||
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -375,18 +355,10 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
public boolean isMirroredVols() {
|
||||
return mirroredVols;
|
||||
}
|
||||
|
||||
public void setHaEnabled(boolean value) {
|
||||
haEnabled = value;
|
||||
}
|
||||
|
||||
public void setMirroredVols(boolean mirroredVols) {
|
||||
this.mirroredVols = mirroredVols;
|
||||
}
|
||||
|
||||
public void setReservationId(String reservationId) {
|
||||
this.reservationId = reservationId;
|
||||
}
|
||||
|
||||
@ -824,7 +824,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
}
|
||||
volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString());
|
||||
volResponse.setAttached(volume.getAttached());
|
||||
volResponse.setDestroyed(volume.getDestroyed());
|
||||
volResponse.setDestroyed(volume.getState() == Volume.State.Destroy);
|
||||
VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId());
|
||||
boolean isExtractable = template != null&& template.isExtractable()&& !(template.getTemplateType()== TemplateType.SYSTEM);
|
||||
volResponse.setExtractable(isExtractable);
|
||||
|
||||
@ -75,9 +75,6 @@ import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -928,7 +925,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
return;
|
||||
}
|
||||
console.setPrivateIpAddress(cmd.getPrivateIpAddress());
|
||||
console.setPrivateNetmask(cmd.getPrivateNetmask());
|
||||
console.setPublicIpAddress(cmd.getPublicIpAddress());
|
||||
console.setPublicNetmask(cmd.getPublicNetmask());
|
||||
_consoleProxyDao.persist(console);
|
||||
@ -1675,7 +1671,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
proxy.setGuestMacAddress(nic.getMacAddress());
|
||||
} else if (network.getTrafficType() == TrafficType.Management) {
|
||||
proxy.setPrivateIpAddress(nic.getIp4Address());
|
||||
proxy.setPrivateNetmask(nic.getNetmask());
|
||||
proxy.setPrivateMacAddress(nic.getMacAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ package com.cloud.network;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.api.commands.CreateNetworkCmd;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
@ -55,8 +54,6 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
*
|
||||
*/
|
||||
public interface NetworkManager extends NetworkService {
|
||||
public static final boolean USE_POD_VLAN = false;
|
||||
|
||||
/**
|
||||
* Assigns a new public ip address.
|
||||
*
|
||||
@ -155,4 +152,8 @@ public interface NetworkManager extends NetworkService {
|
||||
*/
|
||||
boolean associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId) throws InsufficientAddressCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
Nic getNicInNetwork(long vmId, long networkId);
|
||||
|
||||
Nic getNicForTraffic(long vmId, TrafficType type);
|
||||
}
|
||||
|
||||
@ -98,8 +98,6 @@ import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.Resource;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
@ -200,6 +198,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
SearchBuilder<IPAddressVO> AssignIpAddressSearch;
|
||||
SearchBuilder<IPAddressVO> AssignIpAddressFromPodVlanSearch;
|
||||
SearchBuilder<IPAddressVO> IpAddressSearch;
|
||||
SearchBuilder<NicVO> NicForTrafficTypeSearch;
|
||||
|
||||
int _networkGcWait;
|
||||
int _networkGcInterval;
|
||||
@ -674,6 +673,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
virtualNetworkVlanSB.and("vlanType", virtualNetworkVlanSB.entity().getVlanType(), Op.EQ);
|
||||
IpAddressSearch.join("virtualNetworkVlanSB", virtualNetworkVlanSB, IpAddressSearch.entity().getVlanId(), virtualNetworkVlanSB.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
IpAddressSearch.done();
|
||||
|
||||
NicForTrafficTypeSearch = _nicDao.createSearchBuilder();
|
||||
SearchBuilder<NetworkVO> networkSearch = _networksDao.createSearchBuilder();
|
||||
NicForTrafficTypeSearch.join("network", networkSearch, networkSearch.entity().getId(), NicForTrafficTypeSearch.entity().getNetworkId(), JoinType.INNER);
|
||||
NicForTrafficTypeSearch.and("instance", NicForTrafficTypeSearch.entity().getInstanceId(), Op.EQ);
|
||||
networkSearch.and("traffictype", networkSearch.entity().getTrafficType(), Op.EQ);
|
||||
NicForTrafficTypeSearch.done();
|
||||
|
||||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Network-Scavenger"));
|
||||
|
||||
@ -1009,8 +1015,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
Integer networkRate = _configMgr.getNetworkRate(no.getId());
|
||||
NicProfile profile = null;
|
||||
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
||||
nic.setState(Resource.State.Reserving);
|
||||
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
|
||||
nic.setState(Nic.State.Reserving);
|
||||
nic.setReservationId(context.getReservationId());
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
URI broadcastUri = nic.getBroadcastUri();
|
||||
@ -1028,7 +1034,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
nic.setIsolationUri(profile.getIsolationUri());
|
||||
nic.setBroadcastUri(profile.getBroadCastUri());
|
||||
nic.setReserver(concierge.getName());
|
||||
nic.setState(Resource.State.Reserved);
|
||||
nic.setState(Nic.State.Reserved);
|
||||
nic.setNetmask(profile.getNetmask());
|
||||
nic.setGateway(profile.getGateway());
|
||||
nic.setAddressFormat(profile.getFormat());
|
||||
@ -1071,13 +1077,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkVO network = _networksDao.findById(nic.getNetworkId());
|
||||
if (nic.getState() == Nic.State.Reserved || nic.getState() == Nic.State.Reserving) {
|
||||
Nic.State originalState = nic.getState();
|
||||
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
||||
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
|
||||
NetworkGuru concierge = _networkGurus.get(network.getGuruName());
|
||||
nic.setState(Resource.State.Releasing);
|
||||
nic.setState(Nic.State.Releasing);
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
NicProfile profile = new NicProfile(nic, network, null, null, null);
|
||||
if (concierge.release(profile, vmProfile, nic.getReservationId())) {
|
||||
nic.setState(Resource.State.Allocated);
|
||||
nic.setState(Nic.State.Allocated);
|
||||
if (originalState == Nic.State.Reserved) {
|
||||
updateNic(nic, network.getId(), -1);
|
||||
} else {
|
||||
@ -1922,6 +1928,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nic getNicInNetwork(long vmId, long networkId) {
|
||||
return _nicDao.findByInstanceIdAndNetworkId(networkId, vmId);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public boolean associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId) throws InsufficientAddressCapacityException,
|
||||
@ -1974,4 +1985,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nic getNicForTraffic(long vmId, TrafficType type) {
|
||||
SearchCriteria<NicVO> sc = NicForTrafficTypeSearch.create();
|
||||
sc.setParameters("instance", vmId);
|
||||
sc.setJoinParameters("network", "traffictype", type);
|
||||
|
||||
List<NicVO> vos = _nicDao.search(sc, null);
|
||||
assert vos.size() <= 1 : "If we have multiple networks of the same type, then this method should no longer be used.";
|
||||
return vos.size() == 1 ? vos.get(0) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,12 +40,12 @@ import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
@ -95,7 +95,7 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
||||
}
|
||||
|
||||
if(vm.getHypervisorType() == HypervisorType.VmWare && vm.getType() != VirtualMachine.Type.DomainRouter) {
|
||||
NicProfile nicProf = new NicProfile(ReservationStrategy.Create, null, null, null, null);
|
||||
NicProfile nicProf = new NicProfile(Nic.ReservationStrategy.Create, null, null, null, null);
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId());
|
||||
nicProf.setMacAddress(mac);
|
||||
return nicProf;
|
||||
@ -105,7 +105,7 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
||||
throw new CloudRuntimeException("Does not support nic specification at this time: " + nic);
|
||||
}
|
||||
|
||||
return new NicProfile(ReservationStrategy.Start, null, null, null, null);
|
||||
return new NicProfile(Nic.ReservationStrategy.Start, null, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -46,10 +46,10 @@ import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@ -26,9 +26,9 @@ import javax.ejb.Local;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
@ -45,8 +45,8 @@ import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
@ -63,6 +63,7 @@ private static final Logger s_logger = Logger.getLogger(DirectPodBasedNetworkGur
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
//this guru handles system Direct pod based network
|
||||
if (dc.getNetworkType() == NetworkType.Basic && offering.getTrafficType() == TrafficType.Guest && offering.isSystemOnly()) {
|
||||
|
||||
@ -45,12 +45,12 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
@ -206,7 +206,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
|
||||
@DB
|
||||
protected String acquireGuestIpAddress(Network network) {
|
||||
List<String> ips = _nicDao.listIpAddressInNetworkConfiguration(network.getId());
|
||||
List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());
|
||||
String[] cidr = network.getCidr().split("/");
|
||||
Set<Long> allPossibleIps = NetUtils.getAllIpsFromCidr(cidr[0], Integer.parseInt(cidr[1]));
|
||||
Set<Long> usedIps = new TreeSet<Long> ();
|
||||
|
||||
@ -24,12 +24,12 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@ -18,9 +18,9 @@ import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
@ -30,11 +30,11 @@ import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@ -1120,7 +1120,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
router.setGuestMacAddress(nic.getMacAddress());
|
||||
} else if (network.getTrafficType() == TrafficType.Control) {
|
||||
router.setPrivateIpAddress(nic.getIp4Address());
|
||||
router.setPrivateNetmask(nic.getNetmask());
|
||||
router.setPrivateMacAddress(nic.getMacAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,6 @@ import com.cloud.dc.dao.PodVlanMapDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
@ -263,7 +262,6 @@ import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.InstanceGroupVO;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.UserVmDetailVO;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
@ -274,7 +272,6 @@ import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.InstanceGroupDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class ManagementServerImpl implements ManagementServer {
|
||||
@ -2360,7 +2357,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
sb.and("status", sb.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
|
||||
// Only return volumes that are not destroyed
|
||||
sb.and("destroyed", sb.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.NEQ);
|
||||
|
||||
if (((accountId == null) && (domainId != null) && isRecursive)) {
|
||||
// if accountId isn't specified, we can do a domain match for the admin case if isRecursive is true
|
||||
@ -2421,7 +2418,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
*/
|
||||
|
||||
// Only return volumes that are not destroyed
|
||||
sc.setParameters("destroyed", false);
|
||||
sc.setParameters("state", Volume.State.Destroy);
|
||||
|
||||
List<VolumeVO> allVolumes = _volumeDao.search(sc, searchFilter);
|
||||
List<VolumeVO> returnableVolumes = new ArrayList<VolumeVO>(); //these are ones without domr and console proxy
|
||||
@ -2460,7 +2457,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public VolumeVO findVolumeByInstanceAndDeviceId(long instanceId, long deviceId) {
|
||||
VolumeVO volume = _volumeDao.findByInstanceAndDeviceId(instanceId, deviceId).get(0);
|
||||
if (volume != null && !volume.getDestroyed() && volume.getRemoved() == null) {
|
||||
if (volume != null && volume.getState() != Volume.State.Destroy && volume.getRemoved() == null) {
|
||||
return volume;
|
||||
} else {
|
||||
return null;
|
||||
@ -4686,8 +4683,9 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public SSHKeyPair createSSHKeyPair(CreateSSHKeyPairCmd cmd) {
|
||||
Account account = UserContext.current().getCaller();
|
||||
SSHKeyPairVO s = _sshKeyPairDao.findByName(account.getAccountId(), account.getDomainId(), cmd.getName());
|
||||
if (s != null)
|
||||
throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' already exists.");
|
||||
if (s != null) {
|
||||
throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' already exists.");
|
||||
}
|
||||
|
||||
SSHKeysHelper keys = new SSHKeysHelper();
|
||||
|
||||
@ -4703,8 +4701,9 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public boolean deleteSSHKeyPair(DeleteSSHKeyPairCmd cmd) {
|
||||
Account account = UserContext.current().getCaller();
|
||||
SSHKeyPairVO s = _sshKeyPairDao.findByName(account.getAccountId(), account.getDomainId(), cmd.getName());
|
||||
if (s == null)
|
||||
throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' does not exist.");
|
||||
if (s == null) {
|
||||
throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' does not exist.");
|
||||
}
|
||||
|
||||
return _sshKeyPairDao.deleteByName(account.getAccountId(), account.getDomainId(), cmd.getName());
|
||||
}
|
||||
@ -4713,11 +4712,13 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public List<? extends SSHKeyPair> listSSHKeyPairs(ListSSHKeyPairsCmd cmd) {
|
||||
Account account = UserContext.current().getCaller();
|
||||
|
||||
if (cmd.getName() != null && cmd.getName().length() > 0)
|
||||
return _sshKeyPairDao.listKeyPairsByName(account.getAccountId(), account.getDomainId(), cmd.getName());
|
||||
if (cmd.getName() != null && cmd.getName().length() > 0) {
|
||||
return _sshKeyPairDao.listKeyPairsByName(account.getAccountId(), account.getDomainId(), cmd.getName());
|
||||
}
|
||||
|
||||
if (cmd.getFingerprint() != null && cmd.getFingerprint().length() > 0)
|
||||
return _sshKeyPairDao.listKeyPairsByFingerprint(account.getAccountId(), account.getDomainId(), cmd.getFingerprint());
|
||||
if (cmd.getFingerprint() != null && cmd.getFingerprint().length() > 0) {
|
||||
return _sshKeyPairDao.listKeyPairsByFingerprint(account.getAccountId(), account.getDomainId(), cmd.getFingerprint());
|
||||
}
|
||||
|
||||
return _sshKeyPairDao.listKeyPairs(account.getAccountId(), account.getDomainId());
|
||||
}
|
||||
@ -4726,15 +4727,17 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public SSHKeyPair registerSSHKeyPair(RegisterSSHKeyPairCmd cmd) {
|
||||
Account account = UserContext.current().getCaller();
|
||||
SSHKeyPairVO s = _sshKeyPairDao.findByName(account.getAccountId(), account.getDomainId(), cmd.getName());
|
||||
if (s != null)
|
||||
throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' already exists.");
|
||||
if (s != null) {
|
||||
throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' already exists.");
|
||||
}
|
||||
|
||||
String name = cmd.getName();
|
||||
String publicKey = SSHKeysHelper.getPublicKeyFromKeyMaterial(cmd.getPublicKey());
|
||||
String fingerprint = SSHKeysHelper.getPublicKeyFingerprint(publicKey);
|
||||
|
||||
if (publicKey == null)
|
||||
throw new InvalidParameterValueException("Public key is invalid");
|
||||
if (publicKey == null) {
|
||||
throw new InvalidParameterValueException("Public key is invalid");
|
||||
}
|
||||
|
||||
return createAndSaveSSHKeyPair(name, fingerprint, publicKey, null);
|
||||
}
|
||||
@ -4759,13 +4762,15 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public String getVMPassword(GetVMPasswordCmd cmd) {
|
||||
Account account = UserContext.current().getCaller();
|
||||
UserVmVO vm = _userVmDao.findById(cmd.getId());
|
||||
if (vm == null || vm.getAccountId() != account.getAccountId())
|
||||
throw new InvalidParameterValueException("No VM with id '" + cmd.getId() + "' found.");
|
||||
if (vm == null || vm.getAccountId() != account.getAccountId()) {
|
||||
throw new InvalidParameterValueException("No VM with id '" + cmd.getId() + "' found.");
|
||||
}
|
||||
|
||||
_userVmDao.loadDetails(vm);
|
||||
String password = vm.getDetail("Encrypted.Password");
|
||||
if (password == null || password.equals(""))
|
||||
throw new InvalidParameterValueException("No password for VM with id '" + cmd.getId() + "' found.");
|
||||
if (password == null || password.equals("")) {
|
||||
throw new InvalidParameterValueException("No password for VM with id '" + cmd.getId() + "' found.");
|
||||
}
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
@ -120,7 +120,6 @@ import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.Storage.StorageResourceType;
|
||||
import com.cloud.storage.Volume.MirrorState;
|
||||
import com.cloud.storage.Volume.SourceType;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.storage.allocator.StoragePoolAllocator;
|
||||
@ -531,7 +530,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
createdVolume.setState(Volume.State.Ready);
|
||||
} else {
|
||||
createdVolume.setStatus(AsyncInstanceCreateStatus.Corrupted);
|
||||
createdVolume.setDestroyed(true);
|
||||
createdVolume.setState(Volume.State.Destroy);
|
||||
}
|
||||
|
||||
_volsDao.update(volumeId, createdVolume);
|
||||
@ -682,7 +681,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
s_logger.debug("Unable to create a volume for " + volume);
|
||||
}
|
||||
volume.setStatus(AsyncInstanceCreateStatus.Failed);
|
||||
volume.setDestroyed(true);
|
||||
volume.setState(Volume.State.Destroy);
|
||||
_volsDao.persist(volume);
|
||||
_volsDao.remove(volume.getId());
|
||||
volume = null;
|
||||
@ -1566,7 +1565,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
volume.setPodId(null);
|
||||
volume.setAccountId(targetAccount.getId());
|
||||
volume.setDomainId(((account == null) ? Domain.ROOT_DOMAIN : account.getDomainId()));
|
||||
volume.setMirrorState(MirrorState.NOT_MIRRORED);
|
||||
volume.setDiskOfferingId(diskOfferingId);
|
||||
volume.setSize(size);
|
||||
volume.setStorageResourceType(StorageResourceType.STORAGE_POOL);
|
||||
@ -2098,7 +2096,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
//3. If the volume is not removed AND not destroyed, start the vm corresponding to it
|
||||
for(VolumeVO volume: allVolumes)
|
||||
{
|
||||
if((!volume.getDestroyed()) && (volume.getRemoved() == null))
|
||||
if((volume.getState() != Volume.State.Destroy) && (volume.getRemoved() == null))
|
||||
{
|
||||
VMInstanceVO vmInstance = _vmInstanceDao.findById(volume.getInstanceId());
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long> {
|
||||
List<VolumeVO> findByInstance(long id);
|
||||
List<VolumeVO> findByInstanceAndType(long id, Volume.VolumeType vType);
|
||||
List<VolumeVO> findByInstanceIdDestroyed(long vmId);
|
||||
List<VolumeVO> findByDetachedDestroyed();
|
||||
List<VolumeVO> findByAccountAndPod(long accountId, long podId);
|
||||
List<VolumeVO> findByTemplateAndZone(long templateId, long zoneId);
|
||||
List<Long> findVmsStoredOnHost(long hostId);
|
||||
@ -41,7 +40,6 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long> {
|
||||
void attachVolume(long volumeId, long vmId, long deviceId);
|
||||
void detachVolume(long volumeId);
|
||||
boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId);
|
||||
List<VolumeVO> listRemovedButNotDestroyed();
|
||||
List<VolumeVO> findCreatedByInstance(long id);
|
||||
List<VolumeVO> findByPoolId(long poolId);
|
||||
List<VolumeVO> findByInstanceAndDeviceId(long instanceId, long deviceId);
|
||||
|
||||
@ -53,9 +53,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
protected final SearchBuilder<VolumeVO> DetachedAccountIdSearch;
|
||||
protected final SearchBuilder<VolumeVO> TemplateZoneSearch;
|
||||
protected final GenericSearchBuilder<VolumeVO, SumCount> TotalSizeByPoolSearch;
|
||||
protected final SearchBuilder<VolumeVO> DetachedDestroyedSearch;
|
||||
protected final GenericSearchBuilder<VolumeVO, Long> ActiveTemplateSearch;
|
||||
protected final SearchBuilder<VolumeVO> RemovedButNotDestroyedSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
|
||||
|
||||
protected final SearchBuilder<VolumeVO> AllFieldsSearch;
|
||||
@ -66,14 +64,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
protected static final String SELECT_VM_ID_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ?";
|
||||
protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?";
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> listRemovedButNotDestroyed() {
|
||||
SearchCriteria<VolumeVO> sc = RemovedButNotDestroyedSearch.create();
|
||||
sc.setParameters("destroyed", false);
|
||||
|
||||
return searchIncludingRemoved(sc, null, null, false);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public List<Long> findVmsStoredOnHost(long hostId) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
@ -100,7 +90,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
public List<VolumeVO> findDetachedByAccount(long accountId) {
|
||||
SearchCriteria<VolumeVO> sc = DetachedAccountIdSearch.create();
|
||||
sc.setParameters("accountId", accountId);
|
||||
sc.setParameters("destroyed", false);
|
||||
sc.setParameters("destroyed", Volume.State.Destroy);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@ -169,13 +159,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByDetachedDestroyed() {
|
||||
SearchCriteria<VolumeVO> sc = DetachedDestroyedSearch.create();
|
||||
sc.setParameters("destroyed", true);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByAccountAndPod(long accountId, long podId) {
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
@ -283,7 +266,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
protected VolumeDaoImpl() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
||||
AllFieldsSearch.and("destroyed", AllFieldsSearch.entity().getDestroyed(), Op.EQ);
|
||||
AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
|
||||
AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), Op.EQ);
|
||||
AllFieldsSearch.and("status", AllFieldsSearch.entity().getStatus(), Op.EQ);
|
||||
@ -296,7 +278,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
DetachedAccountIdSearch = createSearchBuilder();
|
||||
DetachedAccountIdSearch.and("accountId", DetachedAccountIdSearch.entity().getAccountId(), Op.EQ);
|
||||
DetachedAccountIdSearch.and("destroyed", DetachedAccountIdSearch.entity().getDestroyed(), Op.EQ);
|
||||
DetachedAccountIdSearch.and("destroyed", DetachedAccountIdSearch.entity().getState(), Op.NEQ);
|
||||
DetachedAccountIdSearch.and("instanceId", DetachedAccountIdSearch.entity().getInstanceId(), Op.NULL);
|
||||
DetachedAccountIdSearch.done();
|
||||
|
||||
@ -312,11 +294,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
TotalSizeByPoolSearch.and("removed", TotalSizeByPoolSearch.entity().getRemoved(), Op.NULL);
|
||||
TotalSizeByPoolSearch.done();
|
||||
|
||||
DetachedDestroyedSearch = createSearchBuilder();
|
||||
DetachedDestroyedSearch.and("instanceId", DetachedDestroyedSearch.entity().getInstanceId(), Op.NULL);
|
||||
DetachedDestroyedSearch.and("destroyed", DetachedDestroyedSearch.entity().getDestroyed(), Op.EQ);
|
||||
DetachedDestroyedSearch.done();
|
||||
|
||||
ActiveTemplateSearch = createSearchBuilder(Long.class);
|
||||
ActiveTemplateSearch.and("pool", ActiveTemplateSearch.entity().getPoolId(), Op.EQ);
|
||||
ActiveTemplateSearch.and("template", ActiveTemplateSearch.entity().getTemplateId(), Op.EQ);
|
||||
@ -324,11 +301,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
ActiveTemplateSearch.select(null, Func.COUNT, null);
|
||||
ActiveTemplateSearch.done();
|
||||
|
||||
RemovedButNotDestroyedSearch = createSearchBuilder();
|
||||
RemovedButNotDestroyedSearch.and("destroyed", RemovedButNotDestroyedSearch.entity().getDestroyed(), Op.EQ);
|
||||
RemovedButNotDestroyedSearch.and("removed", RemovedButNotDestroyedSearch.entity().getRemoved(), Op.NNULL);
|
||||
RemovedButNotDestroyedSearch.done();
|
||||
|
||||
InstanceStatesSearch = createSearchBuilder();
|
||||
InstanceStatesSearch.and("instance", InstanceStatesSearch.entity().getInstanceId(), Op.EQ);
|
||||
InstanceStatesSearch.and("states", InstanceStatesSearch.entity().getState(), Op.IN);
|
||||
|
||||
@ -100,6 +100,7 @@ import com.cloud.utils.events.SubscriptionMgr;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.utils.net.NfsUtils;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
@ -283,7 +284,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
allowedCidrs.add(cidr);
|
||||
}
|
||||
}
|
||||
String privateCidr = NetUtils.ipAndNetMaskToCidr(secStorageVm.getPrivateIpAddress(), secStorageVm.getPrivateNetmask());
|
||||
Nic privateNic = _networkMgr.getNicForTraffic(secStorageVm.getId(), TrafficType.Management);
|
||||
String privateCidr = NetUtils.ipAndNetMaskToCidr(privateNic.getIp4Address(), privateNic.getNetmask());
|
||||
String publicCidr = NetUtils.ipAndNetMaskToCidr(secStorageVm.getPublicIpAddress(), secStorageVm.getPublicNetmask());
|
||||
if (NetUtils.isNetworkAWithinNetworkB(privateCidr, publicCidr) || NetUtils.isNetworkAWithinNetworkB(publicCidr, privateCidr)) {
|
||||
allowedCidrs.add("0.0.0.0/0");
|
||||
@ -989,7 +991,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
* secondary
|
||||
* storage
|
||||
*/
|
||||
secStorageVm.setPrivateNetmask(cmd.getStorageNetmask());
|
||||
secStorageVm.setPublicIpAddress(cmd.getPublicIpAddress());
|
||||
secStorageVm.setPublicNetmask(cmd.getPublicNetmask());
|
||||
_secStorageVmDao.persist(secStorageVm);
|
||||
@ -1142,7 +1143,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
secVm.setGuestMacAddress(nic.getMacAddress());
|
||||
} else if (network.getTrafficType() == TrafficType.Management) {
|
||||
secVm.setPrivateIpAddress(nic.getIp4Address());
|
||||
secVm.setPrivateNetmask(nic.getNetmask());
|
||||
secVm.setPrivateMacAddress(nic.getMacAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +77,7 @@ import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
@ -178,7 +179,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
}
|
||||
}
|
||||
}
|
||||
if (volume.getDestroyed() || volume.getRemoved() != null) {
|
||||
if (volume.getState() == Volume.State.Destroy || volume.getRemoved() != null) {
|
||||
s_logger.debug("Volume: " + volumeId + " is destroyed/removed. Not taking snapshot");
|
||||
runSnap = false;
|
||||
}
|
||||
@ -352,8 +353,9 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cluster.getId());
|
||||
if (hosts != null && !hosts.isEmpty()) {
|
||||
HostVO host = hosts.get(0);
|
||||
if (!hostSupportSnapsthot(host))
|
||||
throw new CloudRuntimeException("KVM Snapshot is not supported on cluster: " + host.getId());
|
||||
if (!hostSupportSnapsthot(host)) {
|
||||
throw new CloudRuntimeException("KVM Snapshot is not supported on cluster: " + host.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -180,6 +180,7 @@ public class NicVO implements Nic {
|
||||
this.netmask = netmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getIsolationUri() {
|
||||
return isolationUri;
|
||||
}
|
||||
@ -188,6 +189,7 @@ public class NicVO implements Nic {
|
||||
this.isolationUri = isolationUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getBroadcastUri() {
|
||||
return broadcastUri;
|
||||
}
|
||||
@ -200,8 +202,8 @@ public class NicVO implements Nic {
|
||||
this.instanceId = instanceId;
|
||||
}
|
||||
|
||||
public void setNetworkId(long networkConfigurationId) {
|
||||
this.networkId = networkConfigurationId;
|
||||
public void setNetworkId(long networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
@ -273,16 +275,6 @@ public class NicVO implements Nic {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExpectedReservationInterval() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExpectedReleaseInterval() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
|
||||
@ -94,8 +94,6 @@ import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
@ -129,7 +127,6 @@ import com.cloud.network.ovs.OvsTunnelManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.security.SecurityGroupManager;
|
||||
import com.cloud.network.security.SecurityGroupVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -416,7 +413,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
|
||||
// Check that the volume is not destroyed
|
||||
if (volume.getDestroyed()) {
|
||||
if (volume.getState() == Volume.State.Destroy) {
|
||||
throw new InvalidParameterValueException("Please specify a volume that is not destroyed.");
|
||||
}
|
||||
|
||||
@ -2173,8 +2170,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
} else {
|
||||
isoPath = isoPathPair.first();
|
||||
}
|
||||
if (template.isBootable())
|
||||
profile.setBootLoaderType(BootloaderType.CD);
|
||||
if (template.isBootable()) {
|
||||
profile.setBootLoaderType(BootloaderType.CD);
|
||||
}
|
||||
GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId());
|
||||
String displayName = null;
|
||||
if (guestOS != null) {
|
||||
@ -2204,7 +2202,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Guest) {
|
||||
userVm.setPrivateIpAddress(nic.getIp4Address());
|
||||
userVm.setPrivateNetmask(nic.getNetmask());
|
||||
userVm.setPrivateMacAddress(nic.getMacAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,6 @@ import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Journal;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -237,6 +236,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager {
|
||||
return vm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void reserveNics(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
// List<NicVO> nics = _nicsDao.listBy(vmProfile.getId());
|
||||
// for (NicVO nic : nics) {
|
||||
|
||||
@ -11,11 +11,10 @@ import com.cloud.vm.NicVO;
|
||||
public interface NicDao extends GenericDao<NicVO, Long> {
|
||||
List<NicVO> listBy(long instanceId);
|
||||
|
||||
List<String> listIpAddressInNetworkConfiguration(long networkConfigId);
|
||||
List<String> listIpAddressInNetwork(long networkConfigId);
|
||||
|
||||
List<NicVO> listByNetworkId(long networkId);
|
||||
|
||||
List<Long> listNetworksWithNoActiveNics();
|
||||
NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId);
|
||||
|
||||
void removeNicsForInstance(long instanceId);
|
||||
|
||||
@ -17,75 +17,57 @@ import com.cloud.vm.NicVO;
|
||||
|
||||
@Local(value=NicDao.class)
|
||||
public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao {
|
||||
private final SearchBuilder<NicVO> InstanceSearch;
|
||||
private final SearchBuilder<NicVO> AllFieldsSearch;
|
||||
private final GenericSearchBuilder<NicVO, String> IpSearch;
|
||||
private final SearchBuilder<NicVO> NetworkSearch;
|
||||
private final GenericSearchBuilder<NicVO, Long> GarbageCollectSearch;
|
||||
|
||||
protected NicDaoImpl() {
|
||||
super();
|
||||
|
||||
InstanceSearch = createSearchBuilder();
|
||||
InstanceSearch.and("instance", InstanceSearch.entity().getInstanceId(), Op.EQ);
|
||||
InstanceSearch.done();
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("instance", AllFieldsSearch.entity().getInstanceId(), Op.EQ);
|
||||
AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
IpSearch = createSearchBuilder(String.class);
|
||||
IpSearch.select(null, Func.DISTINCT, IpSearch.entity().getIp4Address());
|
||||
IpSearch.and("nc", IpSearch.entity().getNetworkId(), Op.EQ);
|
||||
IpSearch.and("network", IpSearch.entity().getNetworkId(), Op.EQ);
|
||||
IpSearch.and("address", IpSearch.entity().getIp4Address(), Op.NNULL);
|
||||
IpSearch.done();
|
||||
|
||||
NetworkSearch = createSearchBuilder();
|
||||
NetworkSearch.and("networkId", NetworkSearch.entity().getNetworkId(), Op.EQ);
|
||||
NetworkSearch.done();
|
||||
|
||||
GarbageCollectSearch = createSearchBuilder(Long.class);
|
||||
GarbageCollectSearch.select(null, Func.DISTINCT, GarbageCollectSearch.entity().getNetworkId());
|
||||
GarbageCollectSearch.and("reservation", GarbageCollectSearch.entity().getReservationId(), Op.NULL);
|
||||
GarbageCollectSearch.groupBy(GarbageCollectSearch.entity().getNetworkId()).having(Func.COUNT, GarbageCollectSearch.entity().getId(), Op.EQ, null);
|
||||
GarbageCollectSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNicsForInstance(long instanceId) {
|
||||
SearchCriteria<NicVO> sc = InstanceSearch.create();
|
||||
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instance", instanceId);
|
||||
remove(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NicVO> listBy(long instanceId) {
|
||||
SearchCriteria<NicVO> sc = InstanceSearch.create();
|
||||
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instance", instanceId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listIpAddressInNetworkConfiguration(long networkConfigId) {
|
||||
public List<String> listIpAddressInNetwork(long networkId) {
|
||||
SearchCriteria<String> sc = IpSearch.create();
|
||||
sc.setParameters("nc", networkConfigId);
|
||||
sc.setParameters("network", networkId);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NicVO> listByNetworkId(long networkId) {
|
||||
SearchCriteria<NicVO> sc = NetworkSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("network", networkId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listNetworksWithNoActiveNics() {
|
||||
SearchCriteria<Long> sc = GarbageCollectSearch.create();
|
||||
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId) {
|
||||
SearchCriteria<NicVO> sc = createSearchCriteria();
|
||||
sc.addAnd("networkId", SearchCriteria.Op.EQ, networkId);
|
||||
sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId);
|
||||
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("network", networkId);
|
||||
sc.setParameters("instance", instanceId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user