mirror of https://github.com/apache/cloudstack.git
changes
This commit is contained in:
parent
d202ce4c7a
commit
b250b985ec
|
|
@ -28,8 +28,8 @@ import org.apache.log4j.Logger;
|
||||||
import com.cloud.resource.DiskPreparer;
|
import com.cloud.resource.DiskPreparer;
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.VirtualMachineTemplate.BootloaderType;
|
|
||||||
import com.cloud.storage.Volume.VolumeType;
|
import com.cloud.storage.Volume.VolumeType;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.script.Script;
|
import com.cloud.utils.script.Script;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,13 @@
|
||||||
*/
|
*/
|
||||||
package com.cloud.deploy;
|
package com.cloud.deploy;
|
||||||
|
|
||||||
public class DataCenterDeployment implements DeploymentStrategy {
|
public class DataCenterDeployment implements DeploymentPlan {
|
||||||
long _dcId;
|
long _dcId;
|
||||||
public DataCenterDeployment(long dataCenterId) {
|
public DataCenterDeployment(long dataCenterId) {
|
||||||
_dcId = dataCenterId;
|
_dcId = dataCenterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long getDataCenterId() {
|
public long getDataCenterId() {
|
||||||
return _dcId;
|
return _dcId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package com.cloud.deploy;
|
||||||
* Describes how a VM should be deployed.
|
* Describes how a VM should be deployed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface DeploymentStrategy {
|
public interface DeploymentPlan {
|
||||||
|
public long getDataCenterId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -17,8 +17,12 @@
|
||||||
*/
|
*/
|
||||||
package com.cloud.storage;
|
package com.cloud.storage;
|
||||||
|
|
||||||
|
import com.cloud.domain.PartOf;
|
||||||
|
import com.cloud.template.BasedOn;
|
||||||
|
import com.cloud.user.OwnedBy;
|
||||||
|
|
||||||
public interface Volume {
|
|
||||||
|
public interface Volume extends PartOf, OwnedBy, BasedOn {
|
||||||
enum VolumeType {UNKNOWN, ROOT, SWAP, DATADISK};
|
enum VolumeType {UNKNOWN, ROOT, SWAP, DATADISK};
|
||||||
|
|
||||||
enum MirrorState {NOT_MIRRORED, ACTIVE, DEFUNCT};
|
enum MirrorState {NOT_MIRRORED, ACTIVE, DEFUNCT};
|
||||||
|
|
@ -38,16 +42,6 @@ public interface Volume {
|
||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return owner's account id
|
|
||||||
*/
|
|
||||||
long getAccountId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return id of the owning account's domain
|
|
||||||
*/
|
|
||||||
long getDomainId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return total size of the partition
|
* @return total size of the partition
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.cloud.storage;
|
package com.cloud.template;
|
||||||
|
|
||||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
|
||||||
import com.cloud.storage.Storage.FileSystem;
|
import com.cloud.storage.Storage.FileSystem;
|
||||||
|
|
||||||
public interface VirtualMachineTemplate {
|
public interface VirtualMachineTemplate {
|
||||||
|
|
||||||
public static enum BootloaderType { PyGrub, HVM, External };
|
public static enum BootloaderType { PyGrub, HVM, External };
|
||||||
|
|
||||||
|
|
@ -20,7 +20,22 @@ package com.cloud.user;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public interface Account {
|
import com.cloud.domain.PartOf;
|
||||||
|
|
||||||
|
public interface Account extends PartOf {
|
||||||
|
public enum Type {
|
||||||
|
Normal,
|
||||||
|
Admin,
|
||||||
|
DomainAdmin,
|
||||||
|
CustomerCare
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum State {
|
||||||
|
Disabled,
|
||||||
|
Enabled,
|
||||||
|
Locked
|
||||||
|
}
|
||||||
|
|
||||||
public static final short ACCOUNT_TYPE_NORMAL = 0;
|
public static final short ACCOUNT_TYPE_NORMAL = 0;
|
||||||
public static final short ACCOUNT_TYPE_ADMIN = 1;
|
public static final short ACCOUNT_TYPE_ADMIN = 1;
|
||||||
public static final short ACCOUNT_TYPE_DOMAIN_ADMIN = 2;
|
public static final short ACCOUNT_TYPE_DOMAIN_ADMIN = 2;
|
||||||
|
|
@ -32,14 +47,12 @@ public interface Account {
|
||||||
|
|
||||||
public static final long ACCOUNT_ID_SYSTEM = 1;
|
public static final long ACCOUNT_ID_SYSTEM = 1;
|
||||||
|
|
||||||
public Long getId();
|
public long getId();
|
||||||
public String getAccountName();
|
public String getAccountName();
|
||||||
public void setAccountName(String accountId);
|
public void setAccountName(String accountId);
|
||||||
public short getType();
|
public short getType();
|
||||||
public void setType(short type);
|
|
||||||
public String getState();
|
public String getState();
|
||||||
public void setState(String state);
|
public void setState(String state);
|
||||||
public Long getDomainId();
|
public long getDomainId();
|
||||||
public void setDomainId(Long domainId);
|
|
||||||
public Date getRemoved();
|
public Date getRemoved();
|
||||||
}
|
}
|
||||||
|
|
@ -17,12 +17,14 @@
|
||||||
*/
|
*/
|
||||||
package com.cloud.uservm;
|
package com.cloud.uservm;
|
||||||
|
|
||||||
|
import com.cloud.domain.PartOf;
|
||||||
|
import com.cloud.user.OwnedBy;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This represents one running virtual machine instance.
|
* This represents one running virtual machine instance.
|
||||||
*/
|
*/
|
||||||
public interface UserVm extends VirtualMachine {
|
public interface UserVm extends VirtualMachine, OwnedBy, PartOf {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return service offering id
|
* @return service offering id
|
||||||
|
|
@ -39,11 +41,6 @@ public interface UserVm extends VirtualMachine {
|
||||||
*/
|
*/
|
||||||
String getVnet();
|
String getVnet();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the account this vm instance belongs to.
|
|
||||||
*/
|
|
||||||
long getAccountId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the domain this vm instance belongs to.
|
* @return the domain this vm instance belongs to.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -9,32 +9,14 @@ import com.cloud.network.Network.Mode;
|
||||||
public class NetworkCharacteristics {
|
public class NetworkCharacteristics {
|
||||||
long id;
|
long id;
|
||||||
BroadcastDomainType type;
|
BroadcastDomainType type;
|
||||||
String ip4Address;
|
String cidr;
|
||||||
String netmask;
|
|
||||||
String gateway;
|
|
||||||
Mode mode;
|
Mode mode;
|
||||||
String[] dns;
|
long vmId;
|
||||||
|
|
||||||
public BroadcastDomainType getType() {
|
public BroadcastDomainType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getDns() {
|
|
||||||
return dns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIp4Address() {
|
|
||||||
return ip4Address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNetmask() {
|
|
||||||
return netmask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGateway() {
|
|
||||||
return gateway;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mode getMode() {
|
public Mode getMode() {
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
@ -42,17 +24,19 @@ public class NetworkCharacteristics {
|
||||||
public long getNetworkId() {
|
public long getNetworkId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getVirtualMachineId() {
|
||||||
|
return vmId;
|
||||||
|
}
|
||||||
|
|
||||||
public NetworkCharacteristics() {
|
public NetworkCharacteristics() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkCharacteristics(long id, BroadcastDomainType type, String ip4Address, String netmask, String gateway, Mode mode, String[] dns) {
|
public NetworkCharacteristics(long id, BroadcastDomainType type, String cidr, Mode mode, long vmId) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.ip4Address = ip4Address;
|
this.cidr = cidr;
|
||||||
this.netmask = netmask;
|
|
||||||
this.gateway = gateway;
|
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
this.dns = dns;
|
this.vmId = vmId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.cloud.agent.api.to;
|
package com.cloud.vm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer object to transfer network settings.
|
* Transfer object to transfer network settings.
|
||||||
*/
|
*/
|
||||||
public class NetworkTO {
|
public class NetworkTO {
|
||||||
|
private String uuid;
|
||||||
private String ip;
|
private String ip;
|
||||||
private String netmask;
|
private String netmask;
|
||||||
private String gateway;
|
private String gateway;
|
||||||
|
|
@ -23,6 +23,7 @@ package com.cloud.vm;
|
||||||
*/
|
*/
|
||||||
public interface Nic {
|
public interface Nic {
|
||||||
enum State {
|
enum State {
|
||||||
|
Allocated,
|
||||||
AcquireIp,
|
AcquireIp,
|
||||||
IpAcquired,
|
IpAcquired,
|
||||||
}
|
}
|
||||||
|
|
@ -47,4 +48,6 @@ public interface Nic {
|
||||||
* @return the vm instance id that this nic belongs to.
|
* @return the vm instance id that this nic belongs to.
|
||||||
*/
|
*/
|
||||||
long getInstanceId();
|
long getInstanceId();
|
||||||
|
|
||||||
|
long getDeviceId();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import java.util.Date;
|
||||||
* VirtualMachine describes the properties held by a virtual machine
|
* VirtualMachine describes the properties held by a virtual machine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface VirtualMachine {
|
public interface VirtualMachine extends RunningOn {
|
||||||
public enum Event {
|
public enum Event {
|
||||||
CreateRequested,
|
CreateRequested,
|
||||||
StartRequested,
|
StartRequested,
|
||||||
|
|
@ -100,11 +100,6 @@ public interface VirtualMachine {
|
||||||
*/
|
*/
|
||||||
public long getDataCenterId();
|
public long getDataCenterId();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return id of the host it is running on. If not running, returns null.
|
|
||||||
*/
|
|
||||||
public Long getHostId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return id of the host it was assigned last time.
|
* @return id of the host it was assigned last time.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Mon Aug 16 18:14:16 PDT 2010
|
#Wed Aug 18 11:29:13 PDT 2010
|
||||||
build.number=32
|
build.number=64
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.storage.StoragePoolVO;
|
import com.cloud.storage.StoragePoolVO;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.VirtualMachineTemplate;
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ package com.cloud.agent.api;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.VirtualMachineTemplate.BootloaderType;
|
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||||
|
|
||||||
public abstract class AbstractStartCommand extends Command {
|
public abstract class AbstractStartCommand extends Command {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package com.cloud.agent.api.to;
|
package com.cloud.agent.api.to;
|
||||||
|
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
|
import com.cloud.vm.NetworkTO;
|
||||||
|
|
||||||
public class HostTO {
|
public class HostTO {
|
||||||
private String guid;
|
private String guid;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package com.cloud.agent.api.to;
|
package com.cloud.agent.api.to;
|
||||||
|
|
||||||
|
import com.cloud.vm.NetworkTO;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
|
|
||||||
public class VmTO {
|
public class VmTO {
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,11 @@ import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import com.cloud.user.OwnedBy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="account_vlan_map")
|
@Table(name="account_vlan_map")
|
||||||
public class AccountVlanMapVO {
|
public class AccountVlanMapVO implements OwnedBy {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
|
@ -52,7 +54,8 @@ public class AccountVlanMapVO {
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long getAccountId() {
|
public long getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,26 +18,24 @@
|
||||||
|
|
||||||
package com.cloud.domain;
|
package com.cloud.domain;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="domain")
|
@Table(name="domain")
|
||||||
public class DomainVO {
|
public class DomainVO implements Domain {
|
||||||
public static final long ROOT_DOMAIN = 1L;
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
@Column(name="id")
|
@Column(name="id")
|
||||||
private Long id = null;
|
private long id;
|
||||||
|
|
||||||
@Column(name="parent")
|
@Column(name="parent")
|
||||||
private Long parent = null;
|
private Long parent = null;
|
||||||
|
|
@ -46,13 +44,13 @@ public class DomainVO {
|
||||||
private String name = null;
|
private String name = null;
|
||||||
|
|
||||||
@Column(name="owner")
|
@Column(name="owner")
|
||||||
private Long owner = null;
|
private long accountId;
|
||||||
|
|
||||||
@Column(name="path")
|
@Column(name="path")
|
||||||
private String path = null;
|
private String path = null;
|
||||||
|
|
||||||
@Column(name="level")
|
@Column(name="level")
|
||||||
private Integer level = null;
|
private int level;
|
||||||
|
|
||||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||||
private Date removed;
|
private Date removed;
|
||||||
|
|
@ -65,15 +63,15 @@ public class DomainVO {
|
||||||
|
|
||||||
public DomainVO() {}
|
public DomainVO() {}
|
||||||
|
|
||||||
public DomainVO(String name, Long owner, Long parentId) {
|
public DomainVO(String name, long owner, Long parentId) {
|
||||||
this.parent = parentId;
|
this.parent = parentId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.owner = owner;
|
this.accountId = owner;
|
||||||
this.path ="";
|
this.path ="";
|
||||||
this.level = 0;
|
this.level = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,8 +98,8 @@ public class DomainVO {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getOwner() {
|
public long getAccountId() {
|
||||||
return owner;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getRemoved() {
|
public Date getRemoved() {
|
||||||
|
|
@ -116,11 +114,11 @@ public class DomainVO {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getLevel() {
|
public int getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(Integer level) {
|
public void setLevel(int level) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
||||||
DomainVO d1 = domainPair.get(0);
|
DomainVO d1 = domainPair.get(0);
|
||||||
DomainVO d2 = domainPair.get(1);
|
DomainVO d2 = domainPair.get(1);
|
||||||
|
|
||||||
if (d1.getId().equals(parentId)) {
|
if (d1.getId() == parentId) {
|
||||||
result = d2.getPath().startsWith(d1.getPath());
|
result = d2.getPath().startsWith(d1.getPath());
|
||||||
} else {
|
} else {
|
||||||
result = d1.getPath().startsWith(d2.getPath());
|
result = d1.getPath().startsWith(d2.getPath());
|
||||||
|
|
|
||||||
|
|
@ -18,24 +18,27 @@
|
||||||
|
|
||||||
package com.cloud.network;
|
package com.cloud.network;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.PrimaryKeyJoinColumn;
|
import javax.persistence.PrimaryKeyJoinColumn;
|
||||||
import javax.persistence.SecondaryTable;
|
import javax.persistence.SecondaryTable;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import com.cloud.domain.PartOf;
|
||||||
|
import com.cloud.user.OwnedBy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name=("security_group"))
|
@Table(name=("security_group"))
|
||||||
@SecondaryTable(name="account",
|
@SecondaryTable(name="account",
|
||||||
pkJoinColumns={@PrimaryKeyJoinColumn(name="account_id", referencedColumnName="id")})
|
pkJoinColumns={@PrimaryKeyJoinColumn(name="account_id", referencedColumnName="id")})
|
||||||
public class SecurityGroupVO {
|
public class SecurityGroupVO implements PartOf, OwnedBy {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
@Column(name="id")
|
@Column(name="id")
|
||||||
private Long id;
|
private long id;
|
||||||
|
|
||||||
@Column(name="name")
|
@Column(name="name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
@ -44,24 +47,24 @@ public class SecurityGroupVO {
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Column(name="domain_id")
|
@Column(name="domain_id")
|
||||||
private Long domainId;
|
private long domainId;
|
||||||
|
|
||||||
@Column(name="account_id")
|
@Column(name="account_id")
|
||||||
private Long accountId;
|
private long accountId;
|
||||||
|
|
||||||
@Column(name="account_name", table="account", insertable=false, updatable=false)
|
@Column(name="account_name", table="account", insertable=false, updatable=false)
|
||||||
private String accountName = null;
|
private String accountName = null;
|
||||||
|
|
||||||
public SecurityGroupVO() {}
|
public SecurityGroupVO() {}
|
||||||
|
|
||||||
public SecurityGroupVO(String name, String description, Long domainId, Long accountId) {
|
public SecurityGroupVO(String name, String description, long domainId, long accountId) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.domainId = domainId;
|
this.domainId = domainId;
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,11 +76,11 @@ public class SecurityGroupVO {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDomainId() {
|
public long getDomainId() {
|
||||||
return domainId;
|
return domainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getAccountId() {
|
public long getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,22 +18,23 @@
|
||||||
|
|
||||||
package com.cloud.network.security;
|
package com.cloud.network.security;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.PrimaryKeyJoinColumn;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.SecondaryTable;
|
|
||||||
import javax.persistence.Table;
|
import com.cloud.domain.PartOf;
|
||||||
|
import com.cloud.user.OwnedBy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name=("network_group"))
|
@Table(name=("network_group"))
|
||||||
public class NetworkGroupVO {
|
public class NetworkGroupVO implements PartOf, OwnedBy {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
@Column(name="id")
|
@Column(name="id")
|
||||||
private Long id;
|
private long id;
|
||||||
|
|
||||||
@Column(name="name")
|
@Column(name="name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
@ -42,17 +43,17 @@ public class NetworkGroupVO {
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Column(name="domain_id")
|
@Column(name="domain_id")
|
||||||
private Long domainId;
|
private long domainId;
|
||||||
|
|
||||||
@Column(name="account_id")
|
@Column(name="account_id")
|
||||||
private Long accountId;
|
private long accountId;
|
||||||
|
|
||||||
@Column(name="account_name")
|
@Column(name="account_name")
|
||||||
private String accountName = null;
|
private String accountName = null;
|
||||||
|
|
||||||
public NetworkGroupVO() {}
|
public NetworkGroupVO() {}
|
||||||
|
|
||||||
public NetworkGroupVO(String name, String description, Long domainId, Long accountId, String accountName) {
|
public NetworkGroupVO(String name, String description, long domainId, long accountId, String accountName) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.domainId = domainId;
|
this.domainId = domainId;
|
||||||
|
|
@ -60,7 +61,7 @@ public class NetworkGroupVO {
|
||||||
this.accountName = accountName;
|
this.accountName = accountName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,11 +73,11 @@ public class NetworkGroupVO {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDomainId() {
|
public long getDomainId() {
|
||||||
return domainId;
|
return domainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getAccountId() {
|
public long getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
package com.cloud.resource;
|
package com.cloud.resource;
|
||||||
|
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.VirtualMachineTemplate.BootloaderType;
|
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||||
import com.cloud.utils.component.Adapter;
|
import com.cloud.utils.component.Adapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,15 @@ import com.cloud.async.AsyncJobResult;
|
||||||
import com.cloud.async.AsyncJobVO;
|
import com.cloud.async.AsyncJobVO;
|
||||||
import com.cloud.capacity.CapacityVO;
|
import com.cloud.capacity.CapacityVO;
|
||||||
import com.cloud.configuration.ConfigurationVO;
|
import com.cloud.configuration.ConfigurationVO;
|
||||||
import com.cloud.configuration.ResourceLimitVO;
|
|
||||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||||
|
import com.cloud.configuration.ResourceLimitVO;
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
import com.cloud.dc.DataCenterIpAddressVO;
|
import com.cloud.dc.DataCenterIpAddressVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.dc.Vlan.VlanType;
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.dc.VlanVO;
|
||||||
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.event.EventVO;
|
import com.cloud.event.EventVO;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
|
|
@ -72,7 +72,6 @@ import com.cloud.storage.Snapshot;
|
||||||
import com.cloud.storage.SnapshotPolicyVO;
|
import com.cloud.storage.SnapshotPolicyVO;
|
||||||
import com.cloud.storage.SnapshotScheduleVO;
|
import com.cloud.storage.SnapshotScheduleVO;
|
||||||
import com.cloud.storage.SnapshotVO;
|
import com.cloud.storage.SnapshotVO;
|
||||||
import com.cloud.storage.StoragePoolHostVO;
|
|
||||||
import com.cloud.storage.StoragePoolVO;
|
import com.cloud.storage.StoragePoolVO;
|
||||||
import com.cloud.storage.StorageStats;
|
import com.cloud.storage.StorageStats;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
|
|
@ -1521,9 +1520,9 @@ public interface ManagementServer {
|
||||||
* in a Criteria object.
|
* in a Criteria object.
|
||||||
* @return list of domains owned by the given user
|
* @return list of domains owned by the given user
|
||||||
*/
|
*/
|
||||||
List<DomainVO> searchForDomains(Criteria c);
|
List<? extends Domain> searchForDomains(Criteria c);
|
||||||
|
|
||||||
List<DomainVO> searchForDomainChildren(Criteria c);
|
List<? extends Domain> searchForDomainChildren(Criteria c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a new domain
|
* create a new domain
|
||||||
|
|
@ -1533,7 +1532,7 @@ public interface ManagementServer {
|
||||||
* @param parentId
|
* @param parentId
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DomainVO createDomain(String name, Long ownerId, Long parentId);
|
Domain createDomain(String name, Long ownerId, Long parentId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete a domain with the given domainId
|
* delete a domain with the given domainId
|
||||||
|
|
@ -1560,14 +1559,14 @@ public interface ManagementServer {
|
||||||
* find the domain by id
|
* find the domain by id
|
||||||
* @param domainId the id of the domainId
|
* @param domainId the id of the domainId
|
||||||
*/
|
*/
|
||||||
DomainVO findDomainIdById(Long domainId);
|
Domain findDomainIdById(Long domainId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find the domain by its path
|
* find the domain by its path
|
||||||
* @param domainPath the path to use to lookup a domain
|
* @param domainPath the path to use to lookup a domain
|
||||||
* @return domainVO the domain with the matching path, or null if no domain with the given path exists
|
* @return Domain the domain with the matching path, or null if no domain with the given path exists
|
||||||
*/
|
*/
|
||||||
DomainVO findDomainByPath(String domainPath);
|
Domain findDomainByPath(String domainPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds accounts with account identifiers similar to the parameter
|
* Finds accounts with account identifiers similar to the parameter
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="vm_template")
|
@Table(name="vm_template")
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||||
String accountId = null;
|
String accountId = null;
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
accountType = account.getType();
|
accountType = account.getType();
|
||||||
accountId = account.getId().toString();
|
accountId = Long.toString(account.getId());
|
||||||
} else {
|
} else {
|
||||||
accountType = Account.ACCOUNT_TYPE_ADMIN;
|
accountType = Account.ACCOUNT_TYPE_ADMIN;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,15 @@
|
||||||
|
|
||||||
package com.cloud.user;
|
package com.cloud.user;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
|
@ -35,7 +35,7 @@ public class AccountVO implements Account {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
@Column(name="id")
|
@Column(name="id")
|
||||||
private Long id = null;
|
private long id;
|
||||||
|
|
||||||
@Column(name="account_name")
|
@Column(name="account_name")
|
||||||
private String accountName = null;
|
private String accountName = null;
|
||||||
|
|
@ -44,7 +44,7 @@ public class AccountVO implements Account {
|
||||||
private short type = ACCOUNT_TYPE_NORMAL;
|
private short type = ACCOUNT_TYPE_NORMAL;
|
||||||
|
|
||||||
@Column(name="domain_id")
|
@Column(name="domain_id")
|
||||||
private Long domainId = null;
|
private long domainId;
|
||||||
|
|
||||||
@Column(name="state")
|
@Column(name="state")
|
||||||
private String state;
|
private String state;
|
||||||
|
|
@ -56,7 +56,7 @@ public class AccountVO implements Account {
|
||||||
private boolean needsCleanup = false;
|
private boolean needsCleanup = false;
|
||||||
|
|
||||||
public AccountVO() {}
|
public AccountVO() {}
|
||||||
public AccountVO(Long id) {
|
public AccountVO(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,8 +67,9 @@ public class AccountVO implements Account {
|
||||||
public boolean getNeedsCleanup() {
|
public boolean getNeedsCleanup() {
|
||||||
return needsCleanup;
|
return needsCleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
@Override
|
||||||
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,10 +86,11 @@ public class AccountVO implements Account {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDomainId() {
|
public long getDomainId() {
|
||||||
return domainId;
|
return domainId;
|
||||||
}
|
}
|
||||||
public void setDomainId(Long domainId) {
|
|
||||||
|
public void setDomainId(long domainId) {
|
||||||
this.domainId = domainId;
|
this.domainId = domainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
|
|
||||||
package com.cloud.user;
|
package com.cloud.user;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public interface User {
|
public interface User extends OwnedBy {
|
||||||
public static final long UID_SYSTEM = 1;
|
public static final long UID_SYSTEM = 1;
|
||||||
|
|
||||||
public Long getId();
|
public Long getId();
|
||||||
|
|
@ -45,8 +45,6 @@ public interface User {
|
||||||
|
|
||||||
public void setLastname(String lastname);
|
public void setLastname(String lastname);
|
||||||
|
|
||||||
public long getAccountId();
|
|
||||||
|
|
||||||
public void setAccountId(long accountId);
|
public void setAccountId(long accountId);
|
||||||
|
|
||||||
public String getEmail();
|
public String getEmail();
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ import com.cloud.utils.db.Filter;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.Transaction;
|
|
||||||
import com.cloud.utils.db.SearchCriteria.Op;
|
import com.cloud.utils.db.SearchCriteria.Op;
|
||||||
|
import com.cloud.utils.db.Transaction;
|
||||||
|
|
||||||
@Local(value={AccountDao.class})
|
@Local(value={AccountDao.class})
|
||||||
public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements AccountDao {
|
public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements AccountDao {
|
||||||
|
|
@ -94,7 +94,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
||||||
u.setSecretKey(rs.getString(4));
|
u.setSecretKey(rs.getString(4));
|
||||||
u.setState(rs.getString(5));
|
u.setState(rs.getString(5));
|
||||||
|
|
||||||
Account a = new AccountVO(rs.getLong(6));
|
AccountVO a = new AccountVO(rs.getLong(6));
|
||||||
a.setAccountName(rs.getString(7));
|
a.setAccountName(rs.getString(7));
|
||||||
a.setType(rs.getShort(8));
|
a.setType(rs.getShort(8));
|
||||||
a.setDomainId(rs.getLong(9));
|
a.setDomainId(rs.getLong(9));
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,6 @@ import com.cloud.storage.Storage.StorageResourceType;
|
||||||
import com.cloud.storage.StoragePoolVO;
|
import com.cloud.storage.StoragePoolVO;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.VirtualMachineTemplate;
|
|
||||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||||
import com.cloud.storage.dao.StoragePoolDao;
|
import com.cloud.storage.dao.StoragePoolDao;
|
||||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||||
|
|
@ -124,6 +123,7 @@ import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
import com.cloud.storage.resource.DummySecondaryStorageResource;
|
import com.cloud.storage.resource.DummySecondaryStorageResource;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
import com.cloud.user.dao.UserStatisticsDao;
|
import com.cloud.user.dao.UserStatisticsDao;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.utils.ActionDelegate;
|
import com.cloud.utils.ActionDelegate;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import java.util.Set;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.storage.VirtualMachineTemplate;
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Adapter;
|
import com.cloud.utils.component.Adapter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
import com.cloud.storage.VirtualMachineTemplate;
|
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.configuration.ConfigurationVO;
|
import com.cloud.configuration.ConfigurationVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.DomainVO;
|
||||||
import com.cloud.maid.StackMaid;
|
import com.cloud.maid.StackMaid;
|
||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
|
|
@ -402,7 +403,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
|
if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
|
||||||
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
||||||
requestParameters.put(BaseCmd.Properties.ACCOUNT.getName(), new String[] { account.getAccountName() });
|
requestParameters.put(BaseCmd.Properties.ACCOUNT.getName(), new String[] { account.getAccountName() });
|
||||||
requestParameters.put(BaseCmd.Properties.DOMAIN_ID.getName(), new String[] { account.getDomainId().toString() });
|
requestParameters.put(BaseCmd.Properties.DOMAIN_ID.getName(), new String[] { Long.toString(account.getDomainId()) });
|
||||||
requestParameters.put(BaseCmd.Properties.ACCOUNT_OBJ.getName(), new Object[] { account });
|
requestParameters.put(BaseCmd.Properties.ACCOUNT_OBJ.getName(), new Object[] { account });
|
||||||
} else {
|
} else {
|
||||||
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
||||||
|
|
@ -446,7 +447,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||||
if (domainPath == null || domainPath.trim().length() == 0) {
|
if (domainPath == null || domainPath.trim().length() == 0) {
|
||||||
domainId = DomainVO.ROOT_DOMAIN;
|
domainId = DomainVO.ROOT_DOMAIN;
|
||||||
} else {
|
} else {
|
||||||
DomainVO domainObj = _ms.findDomainByPath(domainPath);
|
Domain domainObj = _ms.findDomainByPath(domainPath);
|
||||||
if (domainObj != null) {
|
if (domainObj != null) {
|
||||||
domainId = domainObj.getId();
|
domainId = domainObj.getId();
|
||||||
} else { // if an unknown path is passed in, fail the login call
|
} else { // if an unknown path is passed in, fail the login call
|
||||||
|
|
@ -501,7 +502,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||||
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.LASTNAME.getName(), userAcct.getLastname()));
|
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.LASTNAME.getName(), userAcct.getLastname()));
|
||||||
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT_OBJ.getName(), account));
|
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT_OBJ.getName(), account));
|
||||||
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), account.getAccountName()));
|
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), account.getAccountName()));
|
||||||
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), account.getDomainId().toString()));
|
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(account.getDomainId())));
|
||||||
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.TYPE.getName(), Short.valueOf(account.getType()).toString()));
|
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.TYPE.getName(), Short.valueOf(account.getType()).toString()));
|
||||||
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.NETWORK_TYPE.getName(), networkType));
|
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.NETWORK_TYPE.getName(), networkType));
|
||||||
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.HYPERVISOR_TYPE.getName(), hypervisorType));
|
loginParams.add(new Pair<String, Object>(BaseCmd.Properties.HYPERVISOR_TYPE.getName(), hypervisorType));
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,7 @@ public abstract class BaseCmd {
|
||||||
Account account = getAccount(params);
|
Account account = getAccount(params);
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != targetAccountId) {
|
if (account.getId() != targetAccountId) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find a " + targetDesc + " with id " + targetId + " for this account");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find a " + targetDesc + " with id " + targetId + " for this account");
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), targetDomainId)) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), targetDomainId)) {
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -98,7 +98,7 @@ public class AssignPortForwardingServiceCmd extends BaseCmd {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to apply port forwarding services " + StringUtils.join(sgIdList, ",") + " to instance " + vmId + ". Invalid list of port forwarding services for the given instance.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to apply port forwarding services " + StringUtils.join(sgIdList, ",") + " to instance " + vmId + ". Invalid list of port forwarding services for the given instance.");
|
||||||
}
|
}
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != validatedAccountId.longValue())) {
|
if (!isAdmin(account.getType()) && (account.getId() != validatedAccountId.longValue())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Permission denied applying port forwarding services " + StringUtils.join(sgIdList, ",") + " to instance " + vmId + ".");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Permission denied applying port forwarding services " + StringUtils.join(sgIdList, ",") + " to instance " + vmId + ".");
|
||||||
} else {
|
} else {
|
||||||
Account validatedAccount = getManagementServer().findAccountById(validatedAccountId);
|
Account validatedAccount = getManagementServer().findAccountById(validatedAccountId);
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.network.LoadBalancerVO;
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
|
@ -97,7 +97,7 @@ public class AssignToLoadBalancerRuleCmd extends BaseCmd {
|
||||||
if (loadBalancer == null) {
|
if (loadBalancer == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule, with id " + loadBalancerId);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule, with id " + loadBalancerId);
|
||||||
} else if (account != null) {
|
} else if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (loadBalancer.getAccountId() != account.getId().longValue())) {
|
if (!isAdmin(account.getType()) && (loadBalancer.getAccountId() != account.getId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName() +
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName() +
|
||||||
" (id:" + loadBalancer.getId() + ")");
|
" (id:" + loadBalancer.getId() + ")");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,10 @@ public class AttachIsoCmd extends BaseCmd {
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != vmInstanceCheck.getAccountId()) {
|
if (account.getId() != vmInstanceCheck.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to attach ISO " + iso.getName() + " to virtual machine " + vmInstanceCheck.getName() + " for this account");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to attach ISO " + iso.getName() + " to virtual machine " + vmInstanceCheck.getName() + " for this account");
|
||||||
}
|
}
|
||||||
if (!iso.isPublicTemplate() && (account.getId().longValue() != iso.getAccountId()) && (!iso.getName().startsWith("xs-tools"))) {
|
if (!iso.isPublicTemplate() && (account.getId() != iso.getAccountId()) && (!iso.getName().startsWith("xs-tools"))) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to attach ISO " + iso.getName() + " to virtual machine " + vmInstanceCheck.getName() + " for this account");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to attach ISO " + iso.getName() + " to virtual machine " + vmInstanceCheck.getName() + " for this account");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,10 @@ public class AttachVolumeCmd extends BaseCmd {
|
||||||
// If the account is not an admin, check that the volume and the virtual machine are owned by the account that was passed in
|
// If the account is not an admin, check that the volume and the virtual machine are owned by the account that was passed in
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != volume.getAccountId())
|
if (account.getId() != volume.getAccountId())
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find volume with ID: " + volumeId + " for account: " + account.getAccountName());
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find volume with ID: " + volumeId + " for account: " + account.getAccountName());
|
||||||
|
|
||||||
if (account.getId().longValue() != vm.getAccountId())
|
if (account.getId() != vm.getAccountId())
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find VM with ID: " + vmId + " for account: " + account.getAccountName());
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find VM with ID: " + vmId + " for account: " + account.getAccountName());
|
||||||
} else {
|
} else {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), volume.getDomainId()) ||
|
if (!getManagementServer().isChildDomain(account.getDomainId(), volume.getDomainId()) ||
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,15 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
|
|
@ -63,9 +63,9 @@ public class CreateDomainCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentDomainId == null){
|
if (parentDomainId == null){
|
||||||
parentDomainId = DomainVO.ROOT_DOMAIN;
|
parentDomainId = Domain.ROOT_DOMAIN;
|
||||||
} else {
|
} else {
|
||||||
DomainVO parentDomain = null;
|
Domain parentDomain = null;
|
||||||
parentDomain = getManagementServer().findDomainIdById(parentDomainId);
|
parentDomain = getManagementServer().findDomainIdById(parentDomainId);
|
||||||
if (parentDomain == null) {
|
if (parentDomain == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find parent domain " + parentDomainId);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find parent domain " + parentDomainId);
|
||||||
|
|
@ -76,7 +76,7 @@ public class CreateDomainCmd extends BaseCmd {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Invalid parent domain " + parentDomainId + ", unable to create domain " + name);
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Invalid parent domain " + parentDomainId + ", unable to create domain " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
DomainVO domain = null;
|
Domain domain = null;
|
||||||
try {
|
try {
|
||||||
domain = getManagementServer().createDomain(name, account.getId(), parentDomainId);
|
domain = getManagementServer().createDomain(name, account.getId(), parentDomainId);
|
||||||
} catch (IllegalArgumentException illArgEx) {
|
} catch (IllegalArgumentException illArgEx) {
|
||||||
|
|
@ -96,7 +96,7 @@ public class CreateDomainCmd extends BaseCmd {
|
||||||
} else {
|
} else {
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), domain.getId()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), domain.getId()));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), domain.getName()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), domain.getName()));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.LEVEL.getName(), domain.getLevel().toString()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.LEVEL.getName(), Integer.toString(domain.getLevel())));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.PARENT_DOMAIN_ID.getName(), domain.getParent().toString()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.PARENT_DOMAIN_ID.getName(), domain.getParent().toString()));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.PARENT_DOMAIN_NAME.getName(),
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.PARENT_DOMAIN_NAME.getName(),
|
||||||
getManagementServer().findDomainIdById(domain.getParent()).getName()));
|
getManagementServer().findDomainIdById(domain.getParent()).getName()));
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public class CreateIPForwardingRuleCmd extends BaseCmd {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), vmOwner.getDomainId())) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), vmOwner.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to create port forwarding rule, IP address " + ipAddress + " to virtual machine " + vmId + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to create port forwarding rule, IP address " + ipAddress + " to virtual machine " + vmId + ", permission denied.");
|
||||||
}
|
}
|
||||||
} else if (account.getId().longValue() != userVM.getAccountId()) {
|
} else if (account.getId() != userVM.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to create port forwarding rule, IP address " + ipAddress + " to virtual machine " + vmId + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to create port forwarding rule, IP address " + ipAddress + " to virtual machine " + vmId + ", permission denied.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.dc.Vlan.VlanType;
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
|
import com.cloud.dc.VlanVO;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.exception.PermissionDeniedException;
|
import com.cloud.exception.PermissionDeniedException;
|
||||||
import com.cloud.network.IPAddressVO;
|
import com.cloud.network.IPAddressVO;
|
||||||
|
|
@ -102,7 +102,7 @@ public class CreateLoadBalancerRuleCmd extends BaseCmd {
|
||||||
Long accountId = accountByIp.getId();
|
Long accountId = accountByIp.getId();
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != accountId.longValue()) {
|
if (account.getId() != accountId.longValue()) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to create load balancer rule, account " + account.getAccountName() + " doesn't own ip address " + publicIP);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to create load balancer rule, account " + account.getAccountName() + " doesn't own ip address " + publicIP);
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), accountByIp.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), accountByIp.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ public class CreateNetworkGroupCmd extends BaseCmd {
|
||||||
List<Pair<String, Object>> embeddedObject = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> embeddedObject = new ArrayList<Pair<String, Object>>();
|
||||||
|
|
||||||
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), networkGroup.getId().toString()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.toString(networkGroup.getId())));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), networkGroup.getName()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), networkGroup.getName()));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DESCRIPTION.getName(), networkGroup.getDescription()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DESCRIPTION.getName(), networkGroup.getDescription()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.network.SecurityGroupVO;
|
import com.cloud.network.SecurityGroupVO;
|
||||||
|
|
@ -107,7 +107,7 @@ public class CreatePortForwardingServiceCmd extends BaseCmd {
|
||||||
List<Pair<String, Object>> embeddedObject = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> embeddedObject = new ArrayList<Pair<String, Object>>();
|
||||||
|
|
||||||
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), securityGroup.getId().toString()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.toString(securityGroup.getId())));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), securityGroup.getName()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), securityGroup.getName()));
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DESCRIPTION.getName(), securityGroup.getDescription()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DESCRIPTION.getName(), securityGroup.getDescription()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class CreatePortForwardingServiceRuleCmd extends BaseCmd {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), sg.getDomainId())) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), sg.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to find rules for port forwarding service id = " + securityGroupId + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to find rules for port forwarding service id = " + securityGroupId + ", permission denied.");
|
||||||
}
|
}
|
||||||
} else if (account.getId().longValue() != sg.getAccountId().longValue()) {
|
} else if (account.getId() != sg.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Invalid port forwarding service (" + securityGroupId + ") given, unable to create rule.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Invalid port forwarding service (" + securityGroupId + ") given, unable to create rule.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +88,7 @@ public class CreatePortForwardingServiceRuleCmd extends BaseCmd {
|
||||||
userId = Long.valueOf(1);
|
userId = Long.valueOf(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
long jobId = getManagementServer().createOrUpdateRuleAsync(true, userId.longValue(), sg.getAccountId().longValue(), null, securityGroupId, null, publicPort, null, privatePort, protocol, null);
|
long jobId = getManagementServer().createOrUpdateRuleAsync(true, userId.longValue(), sg.getAccountId(), null, securityGroupId, null, publicPort, null, privatePort, protocol, null);
|
||||||
long ruleId = 0;
|
long ruleId = 0;
|
||||||
|
|
||||||
if (jobId == 0) {
|
if (jobId == 0) {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
|
||||||
import com.cloud.async.AsyncJobResult;
|
|
||||||
import com.cloud.async.executor.CreatePrivateTemplateResultObject;
|
import com.cloud.async.executor.CreatePrivateTemplateResultObject;
|
||||||
import com.cloud.serializer.SerializerHelper;
|
import com.cloud.serializer.SerializerHelper;
|
||||||
import com.cloud.server.Criteria;
|
import com.cloud.server.Criteria;
|
||||||
|
|
@ -111,7 +109,7 @@ public class CreateTemplateCmd extends BaseCmd {
|
||||||
|
|
||||||
boolean isAdmin = ((account == null) || isAdmin(account.getType()));
|
boolean isAdmin = ((account == null) || isAdmin(account.getType()));
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
if (account.getId().longValue() != volume.getAccountId()) {
|
if (account.getId() != volume.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to find a volume with id " + volumeId + " for this account");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to find a volume with id " + volumeId + " for this account");
|
||||||
}
|
}
|
||||||
} else if ((account != null) && !getManagementServer().isChildDomain(account.getDomainId(), volume.getDomainId())) {
|
} else if ((account != null) && !getManagementServer().isChildDomain(account.getDomainId(), volume.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ public class CreateVolumeCmd extends BaseCmd {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), snapshotOwner.getDomainId())) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), snapshotOwner.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to create volume from snapshot with id " + snapshotId + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to create volume from snapshot with id " + snapshotId + ", permission denied.");
|
||||||
}
|
}
|
||||||
} else if (account.getId().longValue() != snapshotCheck.getAccountId()) {
|
} else if (account.getId() != snapshotCheck.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR, "unable to find a snapshot with id " + snapshotId + " for this account");
|
throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR, "unable to find a snapshot with id " + snapshotId + " for this account");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,15 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
|
|
@ -61,12 +61,12 @@ public class DeleteDomainCmd extends BaseCmd{
|
||||||
account = getManagementServer().findAccountById(Long.valueOf(1L));
|
account = getManagementServer().findAccountById(Long.valueOf(1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((domainId.longValue() == DomainVO.ROOT_DOMAIN) || !getManagementServer().isChildDomain(account.getDomainId(), domainId)) {
|
if ((domainId.longValue() == Domain.ROOT_DOMAIN) || !getManagementServer().isChildDomain(account.getDomainId(), domainId)) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete domain " + domainId + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete domain " + domainId + ", permission denied.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if domain exists in the system
|
// check if domain exists in the system
|
||||||
DomainVO domain = getManagementServer().findDomainIdById(domainId);
|
Domain domain = getManagementServer().findDomainIdById(domainId);
|
||||||
if (domain == null) {
|
if (domain == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find domain " + domainId);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find domain " + domainId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,22 +18,22 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.exception.InternalErrorException;
|
import com.cloud.exception.InternalErrorException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.exception.PermissionDeniedException;
|
import com.cloud.exception.PermissionDeniedException;
|
||||||
import com.cloud.network.FirewallRuleVO;
|
import com.cloud.network.FirewallRuleVO;
|
||||||
import com.cloud.network.IPAddressVO;
|
import com.cloud.network.IPAddressVO;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.User;
|
import com.cloud.user.User;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
public class DeleteIPForwardingRuleCmd extends BaseCmd {
|
public class DeleteIPForwardingRuleCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(DeleteIPForwardingRuleCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(DeleteIPForwardingRuleCmd.class.getName());
|
||||||
|
|
@ -85,13 +85,13 @@ public class DeleteIPForwardingRuleCmd extends BaseCmd {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), ruleOwner.getDomainId())) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), ruleOwner.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete port forwarding rule " + ruleId + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete port forwarding rule " + ruleId + ", permission denied.");
|
||||||
}
|
}
|
||||||
} else if (account.getId().longValue() != ruleOwner.getId().longValue()) {
|
} else if (account.getId() != ruleOwner.getId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete port forwarding rule " + ruleId + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete port forwarding rule " + ruleId + ", permission denied.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getManagementServer().deleteRule(ruleId.longValue(), userId.longValue(), ruleOwner.getId().longValue());
|
getManagementServer().deleteRule(ruleId.longValue(), userId.longValue(), ruleOwner.getId());
|
||||||
} catch (InvalidParameterValueException ex1) {
|
} catch (InvalidParameterValueException ex1) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to delete port forwarding rule " + ruleId + ", internal error.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to delete port forwarding rule " + ruleId + ", internal error.");
|
||||||
} catch (PermissionDeniedException ex2) {
|
} catch (PermissionDeniedException ex2) {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
|
@ -74,7 +74,7 @@ public class DeleteIsoCmd extends BaseCmd {
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (iso.getAccountId() != account.getId().longValue()) {
|
if (iso.getAccountId() != account.getId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete ISO with id " + isoId);
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to delete ISO with id " + isoId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.network.LoadBalancerVO;
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
|
@ -64,7 +64,7 @@ public class DeleteLoadBalancerRuleCmd extends BaseCmd {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule, with id " + loadBalancerId);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule, with id " + loadBalancerId);
|
||||||
} else if (account != null) {
|
} else if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (loadBalancer.getAccountId() != account.getId().longValue()) {
|
if (loadBalancer.getAccountId() != account.getId()) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName() + " (id:" + loadBalancerId + ")");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName() + " (id:" + loadBalancerId + ")");
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public class DeletePortForwardingServiceCmd extends BaseCmd {
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != sg.getAccountId()) {
|
if (account.getId() != sg.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to find a port forwarding service with id " + id + " for this account");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to find a port forwarding service with id " + id + " for this account");
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), sg.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), sg.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -64,7 +64,7 @@ public class DestroyVMCmd extends BaseCmd {
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != vmInstance.getAccountId()) {
|
if (account.getId() != vmInstance.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + "for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + "for this account");
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -66,7 +66,7 @@ public class DetachIsoCmd extends BaseCmd {
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != vmInstanceCheck.getAccountId()) {
|
if (account.getId() != vmInstanceCheck.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to detach ISO from virtual machine " + vmInstanceCheck.getName() + " for this account");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to detach ISO from virtual machine " + vmInstanceCheck.getName() + " for this account");
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstanceCheck.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstanceCheck.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -66,11 +66,11 @@ public class DisableAccountCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't allow modify system account
|
// don't allow modify system account
|
||||||
if (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM) {
|
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not disable system account");
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not disable system account");
|
||||||
}
|
}
|
||||||
|
|
||||||
long jobId = getManagementServer().disableAccountAsync(account.getId().longValue());
|
long jobId = getManagementServer().disableAccountAsync(account.getId());
|
||||||
if (jobId == 0) {
|
if (jobId == 0) {
|
||||||
s_logger.warn("Unable to schedule async-job for DisableAccount comamnd");
|
s_logger.warn("Unable to schedule async-job for DisableAccount comamnd");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -65,7 +65,7 @@ public class DisableUserCmd extends BaseCmd {
|
||||||
|
|
||||||
// If the user is a System user, return an error. We do not allow this
|
// If the user is a System user, return an error. We do not allow this
|
||||||
Account account = getManagementServer().findAccountById(user.getAccountId());
|
Account account = getManagementServer().findAccountById(user.getAccountId());
|
||||||
if ((account != null) && (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM)) {
|
if ((account != null) && (account.getId() == Account.ACCOUNT_ID_SYSTEM)) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "user id : " + id + " is a system user, disabling is not allowed");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "user id : " + id + " is a system user, disabling is not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.exception.PermissionDeniedException;
|
import com.cloud.exception.PermissionDeniedException;
|
||||||
|
|
@ -66,7 +66,7 @@ public class DisassociateIPAddrCmd extends BaseCmd {
|
||||||
Long accountId = accountByIp.getId();
|
Long accountId = accountByIp.getId();
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != accountId.longValue()) {
|
if (account.getId() != accountId.longValue()) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "account " + account.getAccountName() + " doesn't own ip address " + ipAddress);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "account " + account.getAccountName() + " doesn't own ip address " + ipAddress);
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), accountByIp.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), accountByIp.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -67,13 +67,13 @@ public class EnableAccountCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't allow modify system account
|
// don't allow modify system account
|
||||||
if (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM) {
|
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not enable system account");
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not enable system account");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
try {
|
try {
|
||||||
success = getManagementServer().enableAccount(account.getId().longValue());
|
success = getManagementServer().enableAccount(account.getId());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
s_logger.error("error enabling account " + accountName + " in domain " + domainId, ex);
|
s_logger.error("error enabling account " + accountName + " in domain " + domainId, ex);
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Internal error enabling account " + accountName + " in domain " + domainId);
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Internal error enabling account " + accountName + " in domain " + domainId);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import org.apache.log4j.Logger;
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.server.Criteria;
|
import com.cloud.server.Criteria;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.AccountVO;
|
import com.cloud.user.AccountVO;
|
||||||
|
|
@ -84,7 +84,7 @@ public class ListAccountsCmd extends BaseCmd{
|
||||||
isAdmin = true;
|
isAdmin = true;
|
||||||
if (domainId == null) {
|
if (domainId == null) {
|
||||||
// default domainId to the admin's domain
|
// default domainId to the admin's domain
|
||||||
domainId = ((account == null) ? DomainVO.ROOT_DOMAIN : account.getDomainId());
|
domainId = ((account == null) ? Domain.ROOT_DOMAIN : account.getDomainId());
|
||||||
} else if (account != null) {
|
} else if (account != null) {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), domainId)) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), domainId)) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid domain id (" + domainId + ") given, unable to list accounts");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid domain id (" + domainId + ") given, unable to list accounts");
|
||||||
|
|
@ -135,8 +135,8 @@ public class ListAccountsCmd extends BaseCmd{
|
||||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(accountO.getId()).toString()));
|
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(accountO.getId()).toString()));
|
||||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), accountO.getAccountName()));
|
accountData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), accountO.getAccountName()));
|
||||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT_TYPE.getName(), Short.valueOf(accountO.getType()).toString()));
|
accountData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT_TYPE.getName(), Short.valueOf(accountO.getType()).toString()));
|
||||||
DomainVO domain = getManagementServer().findDomainIdById(accountO.getDomainId());
|
Domain domain = getManagementServer().findDomainIdById(accountO.getDomainId());
|
||||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), domain.getId().toString()));
|
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(domain.getId())));
|
||||||
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), domain.getName()));
|
accountData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), domain.getName()));
|
||||||
|
|
||||||
//get network stat
|
//get network stat
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.server.Criteria;
|
import com.cloud.server.Criteria;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
@ -101,16 +101,16 @@ public class ListDomainChildrenCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : Recursive listing is not supported yet
|
// TODO : Recursive listing is not supported yet
|
||||||
List<DomainVO> domains = getManagementServer().searchForDomainChildren(c);
|
List<? extends Domain> domains = getManagementServer().searchForDomainChildren(c);
|
||||||
|
|
||||||
List<Pair<String, Object>> domainTags = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> domainTags = new ArrayList<Pair<String, Object>>();
|
||||||
Object[] dTag = new Object[domains.size()];
|
Object[] dTag = new Object[domains.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (DomainVO domain : domains) {
|
for (Domain domain : domains) {
|
||||||
List<Pair<String, Object>> domainData = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> domainData = new ArrayList<Pair<String, Object>>();
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(domain.getId()).toString()));
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(domain.getId()).toString()));
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), domain.getName()));
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), domain.getName()));
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.LEVEL.getName(), domain.getLevel().toString()));
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.LEVEL.getName(), Integer.toString(domain.getLevel())));
|
||||||
|
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.HAS_CHILD.getName(),
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.HAS_CHILD.getName(),
|
||||||
(domain.getChildCount()) > 0 ? "true" : "false"));
|
(domain.getChildCount()) > 0 ? "true" : "false"));
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.server.Criteria;
|
import com.cloud.server.Criteria;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
@ -95,16 +95,16 @@ public class ListDomainsCmd extends BaseCmd {
|
||||||
c.addCriteria(Criteria.LEVEL, level);
|
c.addCriteria(Criteria.LEVEL, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DomainVO> domains = getManagementServer().searchForDomains(c);
|
List<? extends Domain> domains = getManagementServer().searchForDomains(c);
|
||||||
|
|
||||||
List<Pair<String, Object>> domainTags = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> domainTags = new ArrayList<Pair<String, Object>>();
|
||||||
Object[] dTag = new Object[domains.size()];
|
Object[] dTag = new Object[domains.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (DomainVO domain : domains) {
|
for (Domain domain : domains) {
|
||||||
List<Pair<String, Object>> domainData = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> domainData = new ArrayList<Pair<String, Object>>();
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(domain.getId()).toString()));
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.valueOf(domain.getId()).toString()));
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), domain.getName()));
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), domain.getName()));
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.LEVEL.getName(), domain.getLevel().toString()));
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.LEVEL.getName(), Integer.toString(domain.getLevel())));
|
||||||
|
|
||||||
if (domain.getParent() != null){
|
if (domain.getParent() != null){
|
||||||
domainData.add(new Pair<String, Object>(BaseCmd.Properties.PARENT_DOMAIN_ID.getName(), domain.getParent().toString()));
|
domainData.add(new Pair<String, Object>(BaseCmd.Properties.PARENT_DOMAIN_ID.getName(), domain.getParent().toString()));
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.DomainVO;
|
||||||
|
|
@ -165,7 +165,7 @@ public class ListEventsCmd extends BaseCmd {
|
||||||
Account acct = getManagementServer().findAccountById(Long.valueOf(event.getAccountId()));
|
Account acct = getManagementServer().findAccountById(Long.valueOf(event.getAccountId()));
|
||||||
if (acct != null) {
|
if (acct != null) {
|
||||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName()));
|
eventData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName()));
|
||||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString()));
|
eventData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(acct.getDomainId())));
|
||||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
eventData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
||||||
}
|
}
|
||||||
if (event.getCreateDate() != null) {
|
if (event.getCreateDate() != null) {
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ import com.cloud.domain.DomainVO;
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.storage.GuestOS;
|
import com.cloud.storage.GuestOS;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
|
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
@ -216,7 +216,7 @@ public class ListIsosCmd extends BaseCmd {
|
||||||
isoData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), datacenter.getName()));
|
isoData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), datacenter.getName()));
|
||||||
|
|
||||||
// If the user is an admin, add the template download status
|
// If the user is an admin, add the template download status
|
||||||
if (isAdmin || account.getId().longValue() == iso.getAccountId()) {
|
if (isAdmin || account.getId() == iso.getAccountId()) {
|
||||||
// add download status
|
// add download status
|
||||||
if (isoHost.getDownloadState()!=Status.DOWNLOADED) {
|
if (isoHost.getDownloadState()!=Status.DOWNLOADED) {
|
||||||
String isoStatus = "Processing";
|
String isoStatus = "Processing";
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseCmd {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), userAccount.getDomainId())) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), userAccount.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid load balancer rule id (" + loadBalancerId + ") given, unable to list instances.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid load balancer rule id (" + loadBalancerId + ") given, unable to list instances.");
|
||||||
}
|
}
|
||||||
} else if (account.getId().longValue() != lbAcctId) {
|
} else if (account.getId() != lbAcctId) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName());
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class ListNetworkGroupsCmd extends BaseCmd {
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
// check that the user is the owner of the VM (admin case was already verified
|
// check that the user is the owner of the VM (admin case was already verified
|
||||||
if (account.getId().longValue() != userVM.getAccountId()) {
|
if (account.getId() != userVM.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to list network groups for virtual machine instance " + vmId + "; permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to list network groups for virtual machine instance " + vmId + "; permission denied.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class ListPortForwardingRulesCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if ((ipAddressVO.getAccountId() == null) || (account.getId().longValue() != ipAddressVO.getAccountId().longValue())) {
|
if ((ipAddressVO.getAccountId() == null) || (account.getId() != ipAddressVO.getAccountId().longValue())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to list port forwarding rules for address " + ipAddress + ", permission denied for account " + account.getId());
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to list port forwarding rules for address " + ipAddress + ", permission denied for account " + account.getId());
|
||||||
}
|
}
|
||||||
addrOwner = account;
|
addrOwner = account;
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ public class ListPortForwardingServiceRulesCmd extends BaseCmd {
|
||||||
if ((groupId != null) && (accountId != null)) {
|
if ((groupId != null) && (accountId != null)) {
|
||||||
SecurityGroupVO sg = getManagementServer().findSecurityGroupById(groupId);
|
SecurityGroupVO sg = getManagementServer().findSecurityGroupById(groupId);
|
||||||
if (sg != null) {
|
if (sg != null) {
|
||||||
if ((sg.getAccountId() != null) && sg.getAccountId().longValue() != accountId.longValue()) {
|
if (sg.getAccountId() != accountId.longValue()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to list port forwarding service rules, account " + accountId + " does not own port forwarding service " + groupId);
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to list port forwarding service rules, account " + accountId + " does not own port forwarding service " + groupId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.storage.SnapshotScheduleVO;
|
import com.cloud.storage.SnapshotScheduleVO;
|
||||||
|
|
@ -65,7 +65,7 @@ public class ListRecurringSnapshotScheduleCmd extends BaseCmd {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), userAccount.getDomainId())) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), userAccount.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid volume id (" + volumeId + ") given, unable to list snapshots.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid volume id (" + volumeId + ") given, unable to list snapshots.");
|
||||||
}
|
}
|
||||||
} else if (account.getId().longValue() != volAcctId) {
|
} else if (account.getId() != volAcctId) {
|
||||||
throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR, "account " + account.getAccountName() + " does not own volume id " + volAcctId);
|
throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR, "account " + account.getAccountName() + " does not own volume id " + volAcctId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class ListServiceOfferingsCmd extends BaseCmd {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId);
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId);
|
||||||
}
|
}
|
||||||
if ((account != null) && !isAdmin(account.getType())) {
|
if ((account != null) && !isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != vmInstance.getAccountId()) {
|
if (account.getId() != vmInstance.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ import com.cloud.async.AsyncJobVO;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.server.Criteria;
|
import com.cloud.server.Criteria;
|
||||||
import com.cloud.storage.Snapshot;
|
import com.cloud.storage.Snapshot;
|
||||||
|
import com.cloud.storage.Snapshot.SnapshotType;
|
||||||
import com.cloud.storage.SnapshotVO;
|
import com.cloud.storage.SnapshotVO;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.Snapshot.SnapshotType;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ public class ListSnapshotsCmd extends BaseCmd {
|
||||||
Account acct = getManagementServer().findAccountById(Long.valueOf(snapshot.getAccountId()));
|
Account acct = getManagementServer().findAccountById(Long.valueOf(snapshot.getAccountId()));
|
||||||
if (acct != null) {
|
if (acct != null) {
|
||||||
snapshotData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName()));
|
snapshotData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName()));
|
||||||
snapshotData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString()));
|
snapshotData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(acct.getDomainId())));
|
||||||
snapshotData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
snapshotData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
||||||
}
|
}
|
||||||
volumeId = snapshot.getVolumeId();
|
volumeId = snapshot.getVolumeId();
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
@ -86,9 +86,9 @@ public class ListTemplateOrIsoPermissionsCmd extends BaseCmd {
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_NORMAL && template.getAccountId() != accountId) {
|
if (account.getType() == Account.ACCOUNT_TYPE_NORMAL && template.getAccountId() != accountId) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to list permissions for " + getMediaType() + " with id " + id);
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to list permissions for " + getMediaType() + " with id " + id);
|
||||||
} else if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
} else if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
||||||
DomainVO accountDomain = getManagementServer().findDomainIdById(account.getDomainId());
|
Domain accountDomain = getManagementServer().findDomainIdById(account.getDomainId());
|
||||||
Account templateAccount = getManagementServer().findAccountById(template.getAccountId());
|
Account templateAccount = getManagementServer().findAccountById(template.getAccountId());
|
||||||
DomainVO templateDomain = getManagementServer().findDomainIdById(templateAccount.getDomainId());
|
Domain templateDomain = getManagementServer().findDomainIdById(templateAccount.getDomainId());
|
||||||
if (!templateDomain.getPath().contains(accountDomain.getPath())) {
|
if (!templateDomain.getPath().contains(accountDomain.getPath())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to list permissions for " + getMediaType() + " with id " + id);
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to list permissions for " + getMediaType() + " with id " + id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.storage.GuestOS;
|
import com.cloud.storage.GuestOS;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
|
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
|
||||||
import com.cloud.storage.template.TemplateConstants;
|
import com.cloud.storage.template.TemplateConstants;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -196,7 +196,7 @@ public class ListTemplatesCmd extends BaseCmd {
|
||||||
templateData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), datacenter.getName()));
|
templateData.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), datacenter.getName()));
|
||||||
|
|
||||||
// If the user is an admin, add the template download status
|
// If the user is an admin, add the template download status
|
||||||
if (isAdmin || account.getId().longValue() == template.getAccountId()) {
|
if (isAdmin || account.getId() == template.getAccountId()) {
|
||||||
// add download status
|
// add download status
|
||||||
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
|
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
|
||||||
String templateStatus = "Processing";
|
String templateStatus = "Processing";
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ public class ListVMsCmd extends BaseCmd {
|
||||||
Account acct = getManagementServer().findAccountById(Long.valueOf(vmInstance.getAccountId()));
|
Account acct = getManagementServer().findAccountById(Long.valueOf(vmInstance.getAccountId()));
|
||||||
if (acct != null) {
|
if (acct != null) {
|
||||||
vmData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName()));
|
vmData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName()));
|
||||||
vmData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString()));
|
vmData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(acct.getDomainId())));
|
||||||
vmData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
vmData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
||||||
}
|
}
|
||||||
vmData.add(new Pair<String, Object>(BaseCmd.Properties.HA_ENABLE.getName(), Boolean.valueOf(vmInstance.isHaEnabled()).toString()));
|
vmData.add(new Pair<String, Object>(BaseCmd.Properties.HA_ENABLE.getName(), Boolean.valueOf(vmInstance.isHaEnabled()).toString()));
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
|
|
@ -62,7 +62,7 @@ public class ListZonesByCmd extends BaseCmd {
|
||||||
if (available != null && available) {
|
if (available != null && available) {
|
||||||
dataCenters = getManagementServer().listDataCenters();
|
dataCenters = getManagementServer().listDataCenters();
|
||||||
} else {
|
} else {
|
||||||
dataCenters = getManagementServer().listDataCentersBy(account.getId().longValue());
|
dataCenters = getManagementServer().listDataCentersBy(account.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// available is kinda useless in this case because we can't exactly list by
|
// available is kinda useless in this case because we can't exactly list by
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,16 @@
|
||||||
*/
|
*/
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
public class LockAccountCmd extends BaseCmd {
|
public class LockAccountCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(LockAccountCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(LockAccountCmd.class.getName());
|
||||||
|
|
@ -63,11 +63,11 @@ public class LockAccountCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't allow modify system account
|
// don't allow modify system account
|
||||||
if (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM) {
|
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not lock system account");
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not lock system account");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = getManagementServer().lockAccount(account.getId().longValue());
|
boolean success = getManagementServer().lockAccount(account.getId());
|
||||||
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.SUCCESS.getName(), Boolean.valueOf(success).toString()));
|
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.SUCCESS.getName(), Boolean.valueOf(success).toString()));
|
||||||
return returnValues;
|
return returnValues;
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -62,7 +62,7 @@ public class RebootVMCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != vmInstance.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
||||||
// the domain in which the VM lives is not in the admin's domain tree
|
// the domain in which the VM lives is not in the admin's domain tree
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ import org.apache.log4j.Logger;
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.storage.Storage.FileSystem;
|
import com.cloud.storage.Storage.FileSystem;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class RegisterIsoCmd extends BaseCmd {
|
||||||
|
|
||||||
long accountId = 1L; // default to system account
|
long accountId = 1L; // default to system account
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
accountId = account.getId().longValue();
|
accountId = account.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
Account accountObj;
|
Account accountObj;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ public class RegisterTemplateCmd extends BaseCmd {
|
||||||
|
|
||||||
long accountId = 1L; // default to system account
|
long accountId = 1L; // default to system account
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
accountId = account.getId().longValue();
|
accountId = account.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
Account accountObj;
|
Account accountObj;
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.network.LoadBalancerVO;
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
|
@ -92,7 +92,7 @@ public class RemoveFromLoadBalancerRuleCmd extends BaseCmd {
|
||||||
if (loadBalancer == null) {
|
if (loadBalancer == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule with id " + loadBalancerId);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule with id " + loadBalancerId);
|
||||||
} else if (account != null) {
|
} else if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (loadBalancer.getAccountId() != account.getId().longValue())) {
|
if (!isAdmin(account.getType()) && (loadBalancer.getAccountId() != account.getId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName() +
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Account " + account.getAccountName() + " does not own load balancer rule " + loadBalancer.getName() +
|
||||||
" (id:" + loadBalancer.getId() + ")");
|
" (id:" + loadBalancer.getId() + ")");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.network.SecurityGroupVO;
|
import com.cloud.network.SecurityGroupVO;
|
||||||
|
|
@ -66,7 +66,7 @@ public class RemovePortForwardingServiceCmd extends BaseCmd {
|
||||||
if (securityG == null) {
|
if (securityG == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a port forwarding service with id " + securityGroupId);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a port forwarding service with id " + securityGroupId);
|
||||||
} else if (account != null) {
|
} else if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != securityG.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != securityG.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a port forwarding service with id " + securityGroupId + " for this account");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a port forwarding service with id " + securityGroupId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), securityG.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), securityG.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid port forwarding service id (" + securityGroupId + ") given, unable to remove port forwarding service.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid port forwarding service id (" + securityGroupId + ") given, unable to remove port forwarding service.");
|
||||||
|
|
@ -78,7 +78,7 @@ public class RemovePortForwardingServiceCmd extends BaseCmd {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId);
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId);
|
||||||
}
|
}
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != vmInstance.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to remove port forwarding service.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to remove port forwarding service.");
|
||||||
|
|
@ -96,7 +96,7 @@ public class RemovePortForwardingServiceCmd extends BaseCmd {
|
||||||
|
|
||||||
Long accountId = ipAddrAccount.getId();
|
Long accountId = ipAddrAccount.getId();
|
||||||
if ((account != null) && !isAdmin(account.getType())) {
|
if ((account != null) && !isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != accountId) {
|
if (account.getId() != accountId) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "account " + account.getAccountName() + " doesn't own ip address " + publicIp);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "account " + account.getAccountName() + " doesn't own ip address " + publicIp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
|
@ -65,7 +65,7 @@ public class ResetVMPasswordCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != vmInstance.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to reset password.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to reset password.");
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -72,7 +72,7 @@ public class StartVMCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstanceCheck.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != vmInstanceCheck.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstanceCheck.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstanceCheck.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to start virtual machine.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to start virtual machine.");
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -63,7 +63,7 @@ public class StopVMCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != vmInstance.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to sop virtual machine.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to sop virtual machine.");
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -70,7 +70,7 @@ public class UpdateAccountCmd extends BaseCmd{
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't allow modify system account
|
// don't allow modify system account
|
||||||
if (account.getId().longValue() == Account.ACCOUNT_ID_SYSTEM) {
|
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not modify system account");
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "can not modify system account");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class UpdateDomainCmd extends BaseCmd{
|
||||||
Boolean editDomainResult = false;
|
Boolean editDomainResult = false;
|
||||||
|
|
||||||
//check if domain exists in the system
|
//check if domain exists in the system
|
||||||
DomainVO domain = getManagementServer().findDomainIdById(domainId);
|
Domain domain = getManagementServer().findDomainIdById(domainId);
|
||||||
if (domain == null) {
|
if (domain == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find domain " + domainId);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find domain " + domainId);
|
||||||
} else if (domain.getParent() == null) {
|
} else if (domain.getParent() == null) {
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ public class UpdateIPForwardingRuleCmd extends BaseCmd {
|
||||||
if (!getManagementServer().isChildDomain(account.getDomainId(), ipAddressVO.getDomainId())) {
|
if (!getManagementServer().isChildDomain(account.getDomainId(), ipAddressVO.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to update port forwarding rule on IP address " + publicIp + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to update port forwarding rule on IP address " + publicIp + ", permission denied.");
|
||||||
}
|
}
|
||||||
} else if (account.getId().longValue() != ipAddressVO.getAccountId()) {
|
} else if (account.getId() != ipAddressVO.getAccountId()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to update port forwarding rule on IP address " + publicIp + ", permission denied.");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to update port forwarding rule on IP address " + publicIp + ", permission denied.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
|
|
@ -73,7 +73,7 @@ public class UpdateIsoCmd extends BaseCmd {
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
Long isoOwner = iso.getAccountId();
|
Long isoOwner = iso.getAccountId();
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if ((isoOwner == null) || (account.getId().longValue() != isoOwner.longValue())) {
|
if ((isoOwner == null) || (account.getId() != isoOwner.longValue())) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to modify ISO with id " + isoId);
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to modify ISO with id " + isoId);
|
||||||
}
|
}
|
||||||
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class UpdateLoadBalancerRuleCmd extends BaseCmd {
|
||||||
Long accountId = lbOwner.getId();
|
Long accountId = lbOwner.getId();
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (!isAdmin(account.getType())) {
|
||||||
if (account.getId().longValue() != accountId.longValue()) {
|
if (account.getId() != accountId.longValue()) {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to update load balancer rule, permission denied");
|
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to update load balancer rule, permission denied");
|
||||||
}
|
}
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), lbOwner.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), lbOwner.getDomainId())) {
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -80,7 +80,7 @@ public class UpdateVMCmd extends BaseCmd{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != vmInstance.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to update virtual machine.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to update virtual machine.");
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,15 @@
|
||||||
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.User;
|
import com.cloud.user.User;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
|
@ -71,7 +70,7 @@ public class UpgradeVMCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) {
|
if (!isAdmin(account.getType()) && (account.getId() != vmInstance.getAccountId())) {
|
||||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + virtualMachineId + " for this account");
|
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + virtualMachineId + " for this account");
|
||||||
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
} else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + virtualMachineId + ") given, unable to upgrade virtual machine.");
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + virtualMachineId + ") given, unable to upgrade virtual machine.");
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,13 @@ import com.cloud.async.AsyncJobResult;
|
||||||
import com.cloud.async.AsyncJobVO;
|
import com.cloud.async.AsyncJobVO;
|
||||||
import com.cloud.async.BaseAsyncJobExecutor;
|
import com.cloud.async.BaseAsyncJobExecutor;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.serializer.GsonHelper;
|
import com.cloud.serializer.GsonHelper;
|
||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
public class CopyTemplateExecutor extends BaseAsyncJobExecutor {
|
public class CopyTemplateExecutor extends BaseAsyncJobExecutor {
|
||||||
|
|
@ -58,7 +57,7 @@ public class CopyTemplateExecutor extends BaseAsyncJobExecutor {
|
||||||
VMTemplateHostVO templateHostRef = managementServer.findTemplateHostRef(param.getTemplateId(), destZone.getId());
|
VMTemplateHostVO templateHostRef = managementServer.findTemplateHostRef(param.getTemplateId(), destZone.getId());
|
||||||
long guestOsId = template.getGuestOSId();
|
long guestOsId = template.getGuestOSId();
|
||||||
Account owner = managementServer.findAccountById(template.getAccountId());
|
Account owner = managementServer.findAccountById(template.getAccountId());
|
||||||
DomainVO domain = managementServer.findDomainIdById(owner.getDomainId());
|
Domain domain = managementServer.findDomainIdById(owner.getDomainId());
|
||||||
String guestOSName = managementServer.findGuestOSById(guestOsId).getName();
|
String guestOSName = managementServer.findGuestOSById(guestOsId).getName();
|
||||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(template, templateHostRef, destZone,guestOSName, owner, domain));
|
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(template, templateHostRef, destZone,guestOSName, owner, domain));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -82,7 +81,7 @@ public class CopyTemplateExecutor extends BaseAsyncJobExecutor {
|
||||||
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private CopyTemplateResultObject composeResultObject(VMTemplateVO template, VMTemplateHostVO templateHostRef, DataCenterVO destZone, String guestOSName, Account owner, DomainVO domain) {
|
private CopyTemplateResultObject composeResultObject(VMTemplateVO template, VMTemplateHostVO templateHostRef, DataCenterVO destZone, String guestOSName, Account owner, Domain domain) {
|
||||||
CopyTemplateResultObject resultObject = new CopyTemplateResultObject();
|
CopyTemplateResultObject resultObject = new CopyTemplateResultObject();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -92,7 +91,7 @@ public class CopyTemplateExecutor extends BaseAsyncJobExecutor {
|
||||||
if(owner.getType() == Account.ACCOUNT_TYPE_ADMIN)
|
if(owner.getType() == Account.ACCOUNT_TYPE_ADMIN)
|
||||||
isAdmin = true;
|
isAdmin = true;
|
||||||
|
|
||||||
if (isAdmin || owner.getId().longValue() == template.getAccountId()) {
|
if (isAdmin || owner.getId() == template.getAccountId()) {
|
||||||
// add download status
|
// add download status
|
||||||
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
|
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
|
||||||
String templateStatus = "Processing";
|
String templateStatus = "Processing";
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ import com.cloud.configuration.dao.ResourceLimitDao;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.Vlan;
|
import com.cloud.dc.Vlan;
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.dc.Vlan.VlanType;
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
|
import com.cloud.dc.VlanVO;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
|
|
@ -136,14 +136,14 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.exception.ExecutionException;
|
import com.cloud.utils.exception.ExecutionException;
|
||||||
import com.cloud.utils.net.NetUtils;
|
import com.cloud.utils.net.NetUtils;
|
||||||
import com.cloud.vm.DomainRouter;
|
import com.cloud.vm.DomainRouter;
|
||||||
|
import com.cloud.vm.DomainRouter.Role;
|
||||||
import com.cloud.vm.DomainRouterVO;
|
import com.cloud.vm.DomainRouterVO;
|
||||||
import com.cloud.vm.State;
|
import com.cloud.vm.State;
|
||||||
import com.cloud.vm.UserVmVO;
|
import com.cloud.vm.UserVmVO;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
import com.cloud.vm.VirtualMachine.Event;
|
||||||
import com.cloud.vm.VirtualMachineManager;
|
import com.cloud.vm.VirtualMachineManager;
|
||||||
import com.cloud.vm.VirtualMachineName;
|
import com.cloud.vm.VirtualMachineName;
|
||||||
import com.cloud.vm.DomainRouter.Role;
|
|
||||||
import com.cloud.vm.VirtualMachine.Event;
|
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
import com.cloud.vm.dao.DomainRouterDao;
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
import com.cloud.vm.dao.UserVmDao;
|
||||||
|
|
||||||
|
|
@ -588,7 +588,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||||
guestIpAddress,
|
guestIpAddress,
|
||||||
guestNetmask,
|
guestNetmask,
|
||||||
accountId,
|
accountId,
|
||||||
account.getDomainId().longValue(),
|
account.getDomainId(),
|
||||||
publicMacAddress,
|
publicMacAddress,
|
||||||
publicIpAddress,
|
publicIpAddress,
|
||||||
vlanNetmask,
|
vlanNetmask,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import javax.persistence.Table;
|
||||||
import com.cloud.network.Network.BroadcastDomainType;
|
import com.cloud.network.Network.BroadcastDomainType;
|
||||||
import com.cloud.network.Network.Mode;
|
import com.cloud.network.Network.Mode;
|
||||||
import com.cloud.network.Network.TrafficType;
|
import com.cloud.network.Network.TrafficType;
|
||||||
|
import com.cloud.user.OwnedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NetworkProfileVO contains information about a specific network.
|
* NetworkProfileVO contains information about a specific network.
|
||||||
|
|
@ -36,7 +37,7 @@ import com.cloud.network.Network.TrafficType;
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="network_profile")
|
@Table(name="network_profile")
|
||||||
public class NetworkProfileVO {
|
public class NetworkProfileVO implements OwnedBy {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
long id;
|
long id;
|
||||||
|
|
@ -81,6 +82,7 @@ public class NetworkProfileVO {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long getAccountId() {
|
public long getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
||||||
Comparator<NetworkGroupVO> {
|
Comparator<NetworkGroupVO> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(NetworkGroupVO o1, NetworkGroupVO o2) {
|
public int compare(NetworkGroupVO o1, NetworkGroupVO o2) {
|
||||||
return o1.getId().compareTo(o2.getId());
|
return o1.getId() == o2.getId() ? 0 : o1.getId() < o2.getId() ? -1 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,15 +101,15 @@ import com.cloud.async.executor.SecurityGroupParam;
|
||||||
import com.cloud.async.executor.UpdateLoadBalancerParam;
|
import com.cloud.async.executor.UpdateLoadBalancerParam;
|
||||||
import com.cloud.async.executor.UpgradeVMParam;
|
import com.cloud.async.executor.UpgradeVMParam;
|
||||||
import com.cloud.async.executor.VMOperationParam;
|
import com.cloud.async.executor.VMOperationParam;
|
||||||
import com.cloud.async.executor.VolumeOperationParam;
|
|
||||||
import com.cloud.async.executor.VMOperationParam.VmOp;
|
import com.cloud.async.executor.VMOperationParam.VmOp;
|
||||||
|
import com.cloud.async.executor.VolumeOperationParam;
|
||||||
import com.cloud.async.executor.VolumeOperationParam.VolumeOp;
|
import com.cloud.async.executor.VolumeOperationParam.VolumeOp;
|
||||||
import com.cloud.capacity.CapacityVO;
|
import com.cloud.capacity.CapacityVO;
|
||||||
import com.cloud.capacity.dao.CapacityDao;
|
import com.cloud.capacity.dao.CapacityDao;
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.ConfigurationVO;
|
import com.cloud.configuration.ConfigurationVO;
|
||||||
import com.cloud.configuration.ResourceLimitVO;
|
|
||||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||||
|
import com.cloud.configuration.ResourceLimitVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.configuration.dao.ResourceLimitDao;
|
import com.cloud.configuration.dao.ResourceLimitDao;
|
||||||
import com.cloud.consoleproxy.ConsoleProxyManager;
|
import com.cloud.consoleproxy.ConsoleProxyManager;
|
||||||
|
|
@ -119,8 +119,8 @@ import com.cloud.dc.DataCenterIpAddressVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.PodVlanMapVO;
|
import com.cloud.dc.PodVlanMapVO;
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.dc.Vlan.VlanType;
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
|
import com.cloud.dc.VlanVO;
|
||||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
|
|
@ -128,6 +128,7 @@ import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
import com.cloud.dc.dao.PodVlanMapDao;
|
import com.cloud.dc.dao.PodVlanMapDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.DomainVO;
|
||||||
import com.cloud.domain.dao.DomainDao;
|
import com.cloud.domain.dao.DomainDao;
|
||||||
import com.cloud.event.EventState;
|
import com.cloud.event.EventState;
|
||||||
|
|
@ -186,10 +187,13 @@ import com.cloud.storage.GuestOSCategoryVO;
|
||||||
import com.cloud.storage.GuestOSVO;
|
import com.cloud.storage.GuestOSVO;
|
||||||
import com.cloud.storage.LaunchPermissionVO;
|
import com.cloud.storage.LaunchPermissionVO;
|
||||||
import com.cloud.storage.Snapshot;
|
import com.cloud.storage.Snapshot;
|
||||||
|
import com.cloud.storage.Snapshot.SnapshotType;
|
||||||
import com.cloud.storage.SnapshotPolicyVO;
|
import com.cloud.storage.SnapshotPolicyVO;
|
||||||
import com.cloud.storage.SnapshotScheduleVO;
|
import com.cloud.storage.SnapshotScheduleVO;
|
||||||
import com.cloud.storage.SnapshotVO;
|
import com.cloud.storage.SnapshotVO;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
|
import com.cloud.storage.Storage.FileSystem;
|
||||||
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.StorageManager;
|
import com.cloud.storage.StorageManager;
|
||||||
import com.cloud.storage.StoragePoolHostVO;
|
import com.cloud.storage.StoragePoolHostVO;
|
||||||
import com.cloud.storage.StoragePoolVO;
|
import com.cloud.storage.StoragePoolVO;
|
||||||
|
|
@ -197,12 +201,9 @@ import com.cloud.storage.StorageStats;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
import com.cloud.storage.Volume.VolumeType;
|
||||||
import com.cloud.storage.VolumeStats;
|
import com.cloud.storage.VolumeStats;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.Snapshot.SnapshotType;
|
|
||||||
import com.cloud.storage.Storage.FileSystem;
|
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
|
||||||
import com.cloud.storage.Volume.VolumeType;
|
|
||||||
import com.cloud.storage.dao.DiskOfferingDao;
|
import com.cloud.storage.dao.DiskOfferingDao;
|
||||||
import com.cloud.storage.dao.DiskTemplateDao;
|
import com.cloud.storage.dao.DiskTemplateDao;
|
||||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||||
|
|
@ -213,9 +214,9 @@ import com.cloud.storage.dao.SnapshotPolicyDao;
|
||||||
import com.cloud.storage.dao.StoragePoolDao;
|
import com.cloud.storage.dao.StoragePoolDao;
|
||||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
|
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
|
||||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
|
|
||||||
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
|
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
|
||||||
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDao;
|
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDao;
|
||||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||||
|
|
@ -237,12 +238,12 @@ import com.cloud.user.dao.UserDao;
|
||||||
import com.cloud.user.dao.UserStatisticsDao;
|
import com.cloud.user.dao.UserStatisticsDao;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
|
import com.cloud.utils.DateUtil.IntervalType;
|
||||||
import com.cloud.utils.EnumUtils;
|
import com.cloud.utils.EnumUtils;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.PasswordGenerator;
|
import com.cloud.utils.PasswordGenerator;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.utils.StringUtils;
|
||||||
import com.cloud.utils.DateUtil.IntervalType;
|
|
||||||
import com.cloud.utils.component.Adapters;
|
import com.cloud.utils.component.Adapters;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
|
|
@ -979,7 +980,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
_securityGroupVMMapDao.delete(sc);
|
_securityGroupVMMapDao.delete(sc);
|
||||||
|
|
||||||
// now clean the network rules and security groups themselves
|
// now clean the network rules and security groups themselves
|
||||||
_networkRuleConfigDao.deleteBySecurityGroup(securityGroup.getId().longValue());
|
_networkRuleConfigDao.deleteBySecurityGroup(securityGroup.getId());
|
||||||
_securityGroupDao.remove(securityGroup.getId());
|
_securityGroupDao.remove(securityGroup.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1450,7 +1451,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
txn.start();
|
txn.start();
|
||||||
List<String> ipAddrsList = new ArrayList<String>();
|
List<String> ipAddrsList = new ArrayList<String>();
|
||||||
for (VlanVO vlan : vlansForAccount){
|
for (VlanVO vlan : vlansForAccount){
|
||||||
ipAddrsList.addAll(_publicIpAddressDao.assignAcccountSpecificIps(accountId, account.getDomainId().longValue(), vlan.getId(), false));
|
ipAddrsList.addAll(_publicIpAddressDao.assignAcccountSpecificIps(accountId, account.getDomainId(), vlan.getId(), false));
|
||||||
|
|
||||||
long size = ipAddrsList.size();
|
long size = ipAddrsList.size();
|
||||||
_accountMgr.incrementResourceCount(accountId, ResourceType.public_ip, size);
|
_accountMgr.incrementResourceCount(accountId, ResourceType.public_ip, size);
|
||||||
|
|
@ -2472,7 +2473,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
if (!BaseCmd.isAdmin(account.getType()) && ((templateOwner == null) || (templateOwner.longValue() != accountId))) {
|
if (!BaseCmd.isAdmin(account.getType()) && ((templateOwner == null) || (templateOwner.longValue() != accountId))) {
|
||||||
// since the current account is not the owner of the template, check the launch permissions table to see if the
|
// since the current account is not the owner of the template, check the launch permissions table to see if the
|
||||||
// account can launch a VM from this template
|
// account can launch a VM from this template
|
||||||
LaunchPermissionVO permission = _launchPermissionDao.findByTemplateAndAccount(templateId, account.getId().longValue());
|
LaunchPermissionVO permission = _launchPermissionDao.findByTemplateAndAccount(templateId, account.getId());
|
||||||
if (permission == null) {
|
if (permission == null) {
|
||||||
throw new PermissionDeniedException("Account " + account.getAccountName() + " does not have permission to launch instances from template " + template.getName());
|
throw new PermissionDeniedException("Account " + account.getAccountName() + " does not have permission to launch instances from template " + template.getName());
|
||||||
}
|
}
|
||||||
|
|
@ -3570,7 +3571,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
SecurityGroupVO sg = _securityGroupDao.findById(netRule.getSecurityGroupId());
|
SecurityGroupVO sg = _securityGroupDao.findById(netRule.getSecurityGroupId());
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (!BaseCmd.isAdmin(account.getType())) {
|
if (!BaseCmd.isAdmin(account.getType())) {
|
||||||
if ((sg.getAccountId() == null) || (sg.getAccountId().longValue() != account.getId().longValue())) {
|
if ((sg.getAccountId() != account.getId())) {
|
||||||
throw new PermissionDeniedException("Unable to delete port forwarding service rule " + networkRuleId + "; account: " + account.getAccountName() + " is not the owner");
|
throw new PermissionDeniedException("Unable to delete port forwarding service rule " + networkRuleId + "; account: " + account.getAccountName() + " is not the owner");
|
||||||
}
|
}
|
||||||
} else if (!isChildDomain(account.getDomainId(), sg.getDomainId())) {
|
} else if (!isChildDomain(account.getDomainId(), sg.getDomainId())) {
|
||||||
|
|
@ -3578,7 +3579,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sg != null) {
|
if (sg != null) {
|
||||||
accountId = sg.getAccountId().longValue();
|
accountId = sg.getAccountId();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 0L; // failed to delete due to netRule not found
|
return 0L; // failed to delete due to netRule not found
|
||||||
|
|
@ -6183,7 +6184,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
return _consoleProxyDao.findById(instanceId);
|
return _consoleProxyDao.findById(instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DomainVO> searchForDomains(Criteria c) {
|
public List<? extends Domain> searchForDomains(Criteria c) {
|
||||||
Filter searchFilter = new Filter(DomainVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
Filter searchFilter = new Filter(DomainVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
||||||
Long domainId = (Long) c.getCriteria(Criteria.ID);
|
Long domainId = (Long) c.getCriteria(Criteria.ID);
|
||||||
String domainName = (String) c.getCriteria(Criteria.NAME);
|
String domainName = (String) c.getCriteria(Criteria.NAME);
|
||||||
|
|
@ -6222,7 +6223,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
return _domainDao.search(sc, searchFilter);
|
return _domainDao.search(sc, searchFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DomainVO> searchForDomainChildren(Criteria c) {
|
public List<? extends Domain> searchForDomainChildren(Criteria c) {
|
||||||
Filter searchFilter = new Filter(DomainVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
Filter searchFilter = new Filter(DomainVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
||||||
Long domainId = (Long) c.getCriteria(Criteria.ID);
|
Long domainId = (Long) c.getCriteria(Criteria.ID);
|
||||||
String domainName = (String) c.getCriteria(Criteria.NAME);
|
String domainName = (String) c.getCriteria(Criteria.NAME);
|
||||||
|
|
@ -6323,7 +6324,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
|
|
||||||
// cleanup sub-domains first
|
// cleanup sub-domains first
|
||||||
for (DomainVO domain : domains) {
|
for (DomainVO domain : domains) {
|
||||||
success = (success && cleanupDomain(domain.getId(), domain.getOwner()));
|
success = (success && cleanupDomain(domain.getId(), domain.getAccountId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6360,10 +6361,10 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
if ((domains == null) || domains.isEmpty()) {
|
if ((domains == null) || domains.isEmpty()) {
|
||||||
_domainDao.update(domainId, domainName);
|
_domainDao.update(domainId, domainName);
|
||||||
DomainVO domain = _domainDao.findById(domainId);
|
DomainVO domain = _domainDao.findById(domainId);
|
||||||
saveEvent(new Long(1), domain.getOwner(), EventVO.LEVEL_INFO, EventTypes.EVENT_DOMAIN_UPDATE, "Domain, " + domainName + " was updated");
|
saveEvent(new Long(1), domain.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_DOMAIN_UPDATE, "Domain, " + domainName + " was updated");
|
||||||
} else {
|
} else {
|
||||||
DomainVO domain = _domainDao.findById(domainId);
|
DomainVO domain = _domainDao.findById(domainId);
|
||||||
saveEvent(new Long(1), domain.getOwner(), EventVO.LEVEL_ERROR, EventTypes.EVENT_DOMAIN_UPDATE, "Failed to update domain " + domain.getName() + " with name " + domainName + ", name in use.");
|
saveEvent(new Long(1), domain.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_DOMAIN_UPDATE, "Failed to update domain " + domain.getName() + " with name " + domainName + ", name in use.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6705,12 +6706,12 @@ public class ManagementServerImpl implements ManagementServer {
|
||||||
for (String accountName : accountNames) {
|
for (String accountName : accountNames) {
|
||||||
Account permittedAccount = _accountDao.findActiveAccount(accountName, domainId);
|
Account permittedAccount = _accountDao.findActiveAccount(accountName, domainId);
|
||||||
if (permittedAccount != null) {
|
if (permittedAccount != null) {
|
||||||
if (permittedAccount.getId().longValue() == account.getId().longValue()) {
|
if (permittedAccount.getId() == account.getId()) {
|
||||||
continue; // don't grant permission to the template owner, they implicitly have permission
|
continue; // don't grant permission to the template owner, they implicitly have permission
|
||||||
}
|
}
|
||||||
LaunchPermissionVO existingPermission = _launchPermissionDao.findByTemplateAndAccount(templateId, permittedAccount.getId().longValue());
|
LaunchPermissionVO existingPermission = _launchPermissionDao.findByTemplateAndAccount(templateId, permittedAccount.getId());
|
||||||
if (existingPermission == null) {
|
if (existingPermission == null) {
|
||||||
LaunchPermissionVO launchPermission = new LaunchPermissionVO(templateId, permittedAccount.getId().longValue());
|
LaunchPermissionVO launchPermission = new LaunchPermissionVO(templateId, permittedAccount.getId());
|
||||||
_launchPermissionDao.persist(launchPermission);
|
_launchPermissionDao.persist(launchPermission);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -18,23 +18,23 @@
|
||||||
|
|
||||||
package com.cloud.servlet;
|
package com.cloud.servlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.crypto.Mac;
|
import javax.crypto.Mac;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
|
|
@ -297,7 +297,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||||
{
|
{
|
||||||
case User :
|
case User :
|
||||||
userVm = _ms.findUserVMInstanceById(vmId);
|
userVm = _ms.findUserVMInstanceById(vmId);
|
||||||
if(userVm.getAccountId() != accountObj.getId().longValue() && accountObj.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
if(userVm.getAccountId() != accountObj.getId() && accountObj.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled())
|
||||||
s_logger.debug("VM access is denied. VM owner account " + userVm.getAccountId()
|
s_logger.debug("VM access is denied. VM owner account " + userVm.getAccountId()
|
||||||
+ " does not match the account id in session " + accountObj.getId());
|
+ " does not match the account id in session " + accountObj.getId());
|
||||||
|
|
@ -411,7 +411,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
|
if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
|
||||||
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
||||||
requestParameters.put(BaseCmd.Properties.ACCOUNT.getName(), new String[] { account.getAccountName() });
|
requestParameters.put(BaseCmd.Properties.ACCOUNT.getName(), new String[] { account.getAccountName() });
|
||||||
requestParameters.put(BaseCmd.Properties.DOMAIN_ID.getName(), new String[] { account.getDomainId().toString() });
|
requestParameters.put(BaseCmd.Properties.DOMAIN_ID.getName(), new String[] { Long.toString(account.getDomainId()) });
|
||||||
requestParameters.put(BaseCmd.Properties.ACCOUNT_OBJ.getName(), new Object[] { account });
|
requestParameters.put(BaseCmd.Properties.ACCOUNT_OBJ.getName(), new Object[] { account });
|
||||||
} else {
|
} else {
|
||||||
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() });
|
||||||
|
|
|
||||||
|
|
@ -489,7 +489,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||||
volume.setDataCenterId(dc.getId());
|
volume.setDataCenterId(dc.getId());
|
||||||
volume.setPodId(null);
|
volume.setPodId(null);
|
||||||
volume.setAccountId(accountId);
|
volume.setAccountId(accountId);
|
||||||
volume.setDomainId(account.getDomainId().longValue());
|
volume.setDomainId(account.getDomainId());
|
||||||
volume.setMirrorState(MirrorState.NOT_MIRRORED);
|
volume.setMirrorState(MirrorState.NOT_MIRRORED);
|
||||||
if (diskOffering != null) {
|
if (diskOffering != null) {
|
||||||
volume.setDiskOfferingId(diskOffering.getId());
|
volume.setDiskOfferingId(diskOffering.getId());
|
||||||
|
|
@ -573,7 +573,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||||
createdVolume.setPoolType(pool.getPoolType());
|
createdVolume.setPoolType(pool.getPoolType());
|
||||||
createdVolume.setFolder(volumeFolder);
|
createdVolume.setFolder(volumeFolder);
|
||||||
createdVolume.setPath(volumeUUID);
|
createdVolume.setPath(volumeUUID);
|
||||||
createdVolume.setDomainId(account.getDomainId().longValue());
|
createdVolume.setDomainId(account.getDomainId());
|
||||||
} else {
|
} else {
|
||||||
createdVolume.setStatus(AsyncInstanceCreateStatus.Corrupted);
|
createdVolume.setStatus(AsyncInstanceCreateStatus.Corrupted);
|
||||||
createdVolume.setDestroyed(true);
|
createdVolume.setDestroyed(true);
|
||||||
|
|
@ -1577,14 +1577,14 @@ public class StorageManagerImpl implements StorageManager {
|
||||||
volume.setDataCenterId(dc.getId());
|
volume.setDataCenterId(dc.getId());
|
||||||
volume.setPodId(null);
|
volume.setPodId(null);
|
||||||
volume.setAccountId(accountId);
|
volume.setAccountId(accountId);
|
||||||
volume.setDomainId(account.getDomainId().longValue());
|
volume.setDomainId(account.getDomainId());
|
||||||
volume.setMirrorState(MirrorState.NOT_MIRRORED);
|
volume.setMirrorState(MirrorState.NOT_MIRRORED);
|
||||||
volume.setDiskOfferingId(diskOffering.getId());
|
volume.setDiskOfferingId(diskOffering.getId());
|
||||||
volume.setStorageResourceType(Storage.StorageResourceType.STORAGE_POOL);
|
volume.setStorageResourceType(Storage.StorageResourceType.STORAGE_POOL);
|
||||||
volume.setInstanceId(null);
|
volume.setInstanceId(null);
|
||||||
volume.setUpdated(new Date());
|
volume.setUpdated(new Date());
|
||||||
volume.setStatus(AsyncInstanceCreateStatus.Creating);
|
volume.setStatus(AsyncInstanceCreateStatus.Creating);
|
||||||
volume.setDomainId(account.getDomainId().longValue());
|
volume.setDomainId(account.getDomainId());
|
||||||
volume = _volsDao.persist(volume);
|
volume = _volsDao.persist(volume);
|
||||||
|
|
||||||
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||||
|
|
|
||||||
|
|
@ -102,4 +102,6 @@ public interface AccountManager extends Manager {
|
||||||
|
|
||||||
AccountVO getSystemAccount();
|
AccountVO getSystemAccount();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package com.cloud.vm;
|
package com.cloud.vm;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
|
|
@ -35,15 +36,25 @@ public class MauriceMoss implements VmManager {
|
||||||
@Inject private StorageManager _storageMgr;
|
@Inject private StorageManager _storageMgr;
|
||||||
@Inject private NetworkManager _networkMgr;
|
@Inject private NetworkManager _networkMgr;
|
||||||
|
|
||||||
@Override
|
|
||||||
public VMInstanceVO allocate(VMInstanceVO vm,
|
public VMInstanceVO allocate(VMInstanceVO vm,
|
||||||
ServiceOfferingVO serviceOffering,
|
ServiceOfferingVO serviceOffering,
|
||||||
NetworkOfferingVO[] networkOfferings,
|
Long rootSize,
|
||||||
DiskOfferingVO[] diskOffering,
|
List<NetworkOfferingVO> networkOfferings,
|
||||||
|
Map<DiskOfferingVO, Long> diskOfferings,
|
||||||
DataCenterVO dc,
|
DataCenterVO dc,
|
||||||
AccountVO account) {
|
AccountVO owner) {
|
||||||
|
return null;
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
public VMInstanceVO allocate(VMInstanceVO vm,
|
||||||
|
ServiceOfferingVO serviceOffering,
|
||||||
|
Long rootSize,
|
||||||
|
List<NetworkOfferingVO> networkOfferings,
|
||||||
|
DiskOfferingVO dataOffering,
|
||||||
|
Long dataSize,
|
||||||
|
DataCenterVO dc,
|
||||||
|
AccountVO owner) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,15 @@ public class NicVO implements Nic {
|
||||||
@Column(name="state")
|
@Column(name="state")
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
State state;
|
State state;
|
||||||
|
|
||||||
|
@Column(name="name")
|
||||||
|
String conciergeName;
|
||||||
|
|
||||||
|
@Column(name="reservation_id")
|
||||||
|
String reservationId;
|
||||||
|
|
||||||
|
@Column(name="device_id")
|
||||||
|
int deviceId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIp4Address() {
|
public String getIp4Address() {
|
||||||
|
|
@ -103,4 +112,29 @@ public class NicVO implements Nic {
|
||||||
public long getNetworkProfileId() {
|
public long getNetworkProfileId() {
|
||||||
return networkProfileId;
|
return networkProfileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConciergeName() {
|
||||||
|
return conciergeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReservationId() {
|
||||||
|
return reservationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReservationId(String id) {
|
||||||
|
this.reservationId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConciergeName(String conciergeName) {
|
||||||
|
this.conciergeName = conciergeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(int deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,6 @@ import com.cloud.storage.StoragePoolVO;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.VirtualMachineTemplate.BootloaderType;
|
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.storage.Volume.VolumeType;
|
import com.cloud.storage.Volume.VolumeType;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
|
|
@ -151,6 +150,7 @@ import com.cloud.storage.dao.StoragePoolHostDao;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import com.cloud.user.AccountVO;
|
import com.cloud.user.AccountVO;
|
||||||
import com.cloud.user.User;
|
import com.cloud.user.User;
|
||||||
|
|
@ -1444,7 +1444,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||||
|
|
||||||
while ((pod = _agentMgr.findPod(template, offering, dc, account.getId(), podsToAvoid)) != null) {
|
while ((pod = _agentMgr.findPod(template, offering, dc, account.getId(), podsToAvoid)) != null) {
|
||||||
if (vm == null) {
|
if (vm == null) {
|
||||||
vm = new UserVmVO(vmId, name, template.getId(), guestOSId, accountId, account.getDomainId().longValue(),
|
vm = new UserVmVO(vmId, name, template.getId(), guestOSId, accountId, account.getDomainId(),
|
||||||
serviceOfferingId, null, null, router.getGuestNetmask(),
|
serviceOfferingId, null, null, router.getGuestNetmask(),
|
||||||
null,null,null,
|
null,null,null,
|
||||||
routerId, pod.first().getId(), dataCenterId,
|
routerId, pod.first().getId(), dataCenterId,
|
||||||
|
|
@ -2651,7 +2651,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||||
}
|
}
|
||||||
routerId = router.getId();
|
routerId = router.getId();
|
||||||
}
|
}
|
||||||
String guestIp = _ipAddressDao.assignIpAddress(accountId, account.getDomainId().longValue(), guestVlan.getId(), false);
|
String guestIp = _ipAddressDao.assignIpAddress(accountId, account.getDomainId(), guestVlan.getId(), false);
|
||||||
if (guestIp == null) {
|
if (guestIp == null) {
|
||||||
s_logger.debug("No guest IP available in pod id=" + pod.first().getId());
|
s_logger.debug("No guest IP available in pod id=" + pod.first().getId());
|
||||||
avoids.add(pod.first().getId());
|
avoids.add(pod.first().getId());
|
||||||
|
|
@ -2662,7 +2662,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||||
String externalMacAddress = macAddresses[1];
|
String externalMacAddress = macAddresses[1];
|
||||||
Long externalVlanDbId = null;
|
Long externalVlanDbId = null;
|
||||||
|
|
||||||
vm = new UserVmVO(vmId, name, templateId, guestOSId, accountId, account.getDomainId().longValue(),
|
vm = new UserVmVO(vmId, name, templateId, guestOSId, accountId, account.getDomainId(),
|
||||||
serviceOfferingId, guestMacAddress, guestIp, guestVlan.getVlanNetmask(),
|
serviceOfferingId, guestMacAddress, guestIp, guestVlan.getVlanNetmask(),
|
||||||
null, externalMacAddress, externalVlanDbId,
|
null, externalMacAddress, externalVlanDbId,
|
||||||
routerId, pod.first().getId(), dataCenterId,
|
routerId, pod.first().getId(), dataCenterId,
|
||||||
|
|
@ -2820,7 +2820,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||||
publicIpAddr = publicIp.ipaddr;
|
publicIpAddr = publicIp.ipaddr;
|
||||||
publicIpNetMask = publicIp.netMask;
|
publicIpNetMask = publicIp.netMask;
|
||||||
}
|
}
|
||||||
vm = new UserVmVO(vmId, name, templateId, guestOSId, accountId, account.getDomainId().longValue(),
|
vm = new UserVmVO(vmId, name, templateId, guestOSId, accountId, account.getDomainId(),
|
||||||
serviceOfferingId, guestMacAddress, publicIpAddr, publicIpNetMask,
|
serviceOfferingId, guestMacAddress, publicIpAddr, publicIpNetMask,
|
||||||
null, externalMacAddress, null,
|
null, externalMacAddress, null,
|
||||||
routerId, pod.first().getId(), dataCenterId,
|
routerId, pod.first().getId(), dataCenterId,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package com.cloud.vm;
|
package com.cloud.vm;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
|
|
@ -31,11 +32,22 @@ import com.cloud.user.AccountVO;
|
||||||
public interface VmManager {
|
public interface VmManager {
|
||||||
|
|
||||||
VMInstanceVO allocate(VMInstanceVO vm,
|
VMInstanceVO allocate(VMInstanceVO vm,
|
||||||
ServiceOfferingVO serviceOffering,
|
ServiceOfferingVO serviceOffering,
|
||||||
NetworkOfferingVO[] networkOfferings,
|
Long rootSize,
|
||||||
DiskOfferingVO[] diskOffering,
|
List<NetworkOfferingVO> networkOfferings,
|
||||||
|
Map<DiskOfferingVO, Long> diskOfferings,
|
||||||
|
DataCenterVO dc,
|
||||||
|
AccountVO owner);
|
||||||
|
|
||||||
|
VMInstanceVO allocate(VMInstanceVO vm,
|
||||||
|
ServiceOfferingVO serviceOffering,
|
||||||
|
Long rootSize,
|
||||||
|
List<NetworkOfferingVO> networkOfferings,
|
||||||
|
DiskOfferingVO dataOffering,
|
||||||
|
Long dataSize,
|
||||||
DataCenterVO dc,
|
DataCenterVO dc,
|
||||||
AccountVO account);
|
AccountVO owner);
|
||||||
|
|
||||||
|
|
||||||
void create(VmCharacteristics vm, List<DiskCharacteristics> disks, List<NetworkCharacteristics> networks);
|
void create(VmCharacteristics vm, List<DiskCharacteristics> disks, List<NetworkCharacteristics> networks);
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue