From 5331e13bacfa4d0c4108cc2deca0b285600116af Mon Sep 17 00:00:00 2001 From: nitin Date: Wed, 18 Aug 2010 12:44:27 +0530 Subject: [PATCH 01/11] 5844 - adding more tags to updateTemplate API --- .../cloud/api/commands/UpdateTemplateCmd.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/api/commands/UpdateTemplateCmd.java b/server/src/com/cloud/api/commands/UpdateTemplateCmd.java index 752a43f8a14..a9095eae749 100644 --- a/server/src/com/cloud/api/commands/UpdateTemplateCmd.java +++ b/server/src/com/cloud/api/commands/UpdateTemplateCmd.java @@ -26,6 +26,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; +import com.cloud.storage.GuestOS; import com.cloud.storage.VMTemplateVO; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -104,9 +105,25 @@ public class UpdateTemplateCmd extends BaseCmd { templateData.add(new Pair(BaseCmd.Properties.IS_PUBLIC.getName(), Boolean.valueOf(updatedTemplate.isPublicTemplate()).toString())); templateData.add(new Pair(BaseCmd.Properties.CREATED.getName(), getDateString(updatedTemplate.getCreated()))); templateData.add(new Pair(BaseCmd.Properties.FORMAT.getName(), updatedTemplate.getFormat())); - templateData.add(new Pair(BaseCmd.Properties.OS_TYPE_ID.getName(), updatedTemplate.getGuestOSId())); + GuestOS os = getManagementServer().findGuestOSById(updatedTemplate.getGuestOSId()); + if (os != null) { + templateData.add(new Pair(BaseCmd.Properties.OS_TYPE_ID.getName(), os.getId())); + templateData.add(new Pair(BaseCmd.Properties.OS_TYPE_NAME.getName(), os.getDisplayName())); + } else { + templateData.add(new Pair(BaseCmd.Properties.OS_TYPE_ID.getName(), -1)); + templateData.add(new Pair(BaseCmd.Properties.OS_TYPE_NAME.getName(), "")); + } templateData.add(new Pair(BaseCmd.Properties.PASSWORD_ENABLED.getName(), updatedTemplate.getEnablePassword())); - templateData.add(new Pair(BaseCmd.Properties.CROSS_ZONES.getName(), Boolean.valueOf(updatedTemplate.isCrossZones()).toString())); + templateData.add(new Pair(BaseCmd.Properties.CROSS_ZONES.getName(), Boolean.valueOf(updatedTemplate.isCrossZones()).toString())); + templateData.add(new Pair(BaseCmd.Properties.IS_FEATURED.getName(), Boolean.valueOf(updatedTemplate.isFeatured()).toString())); + + // add account ID and name + Account owner = getManagementServer().findAccountById(updatedTemplate.getAccountId()); + if (owner != null) { + templateData.add(new Pair(BaseCmd.Properties.ACCOUNT.getName(), owner.getAccountName())); + templateData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), owner.getDomainId())); + templateData.add(new Pair(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(owner.getDomainId()).getName())); + } return templateData; } else { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "internal error updating template"); From 467a4356598608d9949e4d370cdddc5ce25350b5 Mon Sep 17 00:00:00 2001 From: "Manuel Amador (Rudd-O)" Date: Wed, 18 Aug 2010 00:35:38 -0700 Subject: [PATCH 02/11] Revert "Correct name of cloud-qemu package" This reverts commit b3cf83c94eef6540198009b65af3b4cf48fac78e. --- cloud.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud.spec b/cloud.spec index e4cb4d16367..7e8281fcacd 100644 --- a/cloud.spec +++ b/cloud.spec @@ -233,7 +233,7 @@ Requires: /sbin/service Requires: /sbin/chkconfig Requires: kvm %if "%{fedora}" != "" -Requires: cloud-qemu-system-x86 +Requires: cloud-qemu-system-x86_64 %endif Requires: libcgroup Requires: /usr/bin/uuidgen From b70307eb1aad88d0e0e47d7f0055e7071abdc694 Mon Sep 17 00:00:00 2001 From: "Manuel Amador (Rudd-O)" Date: Wed, 18 Aug 2010 00:35:49 -0700 Subject: [PATCH 03/11] Revert "Added cloud-qemu-system dependency on packages" This reverts commit f8e7b3ff5ff767bfcfd9b8004a4916a9350da953. --- cloud.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/cloud.spec b/cloud.spec index 7e8281fcacd..b164ab03b7e 100644 --- a/cloud.spec +++ b/cloud.spec @@ -232,9 +232,6 @@ Requires: %{name}-daemonize Requires: /sbin/service Requires: /sbin/chkconfig Requires: kvm -%if "%{fedora}" != "" -Requires: cloud-qemu-system-x86_64 -%endif Requires: libcgroup Requires: /usr/bin/uuidgen Requires: augeas >= 0.7.1 From ef41ebc9eceeaaca2f600a1f50130b8834106a95 Mon Sep 17 00:00:00 2001 From: kishan Date: Wed, 18 Aug 2010 13:54:53 +0530 Subject: [PATCH 04/11] Check for null vnet when allocation fails --- server/src/com/cloud/network/NetworkManagerImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) mode change 100755 => 100644 server/src/com/cloud/network/NetworkManagerImpl.java diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java old mode 100755 new mode 100644 index a37b3376cb6..8a1ea05b800 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -880,7 +880,9 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager vnet = _dcDao.allocateVnet(router.getDataCenterId(), router.getAccountId()); } vnetAllocated = true; - routerMacAddress = getRouterMacForVnet(dc, vnet); + if(vnet != null){ + routerMacAddress = getRouterMacForVnet(dc, vnet); + } } else if (router.getRole() == Role.DHCP_USERDATA) { if (!Vlan.UNTAGGED.equals(router.getVlanId())) { vnet = router.getVlanId().trim(); From d202ce4c7aba3744bb69364c7c14ee8a7822a513 Mon Sep 17 00:00:00 2001 From: kishan Date: Wed, 18 Aug 2010 19:43:16 +0530 Subject: [PATCH 05/11] Issue #: 5775 Release vnet and private IP allocation when domR fails to start --- .../com/cloud/network/NetworkManagerImpl.java | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 8a1ea05b800..64d1179a2cd 100644 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -794,6 +794,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager s_logger.debug("Lock on router " + routerId + " is acquired"); boolean started = false; + String vnet = null; + boolean vnetAllocated = false; try { final State state = router.getState(); if (state == State.Running) { @@ -847,8 +849,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager throw new ConcurrentOperationException("Someone else is starting the router: " + router.toString()); } - String vnet = null; - boolean vnetAllocated = false; final boolean mirroredVols = router.isMirroredVols(); try { event = new EventVO(); @@ -862,6 +862,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager for (final UserVmVO vm : vms) { if (vm.getVnet() != null) { vnet = vm.getVnet(); + break; } } } @@ -1002,28 +1003,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager return _routerDao.findById(routerId); } catch (final Throwable th) { - Transaction txn = Transaction.currentTxn(); - if (!started) { - txn.start(); - if (vnetAllocated == true && vnet != null) { - _dcDao.releaseVnet(vnet, router.getDataCenterId(), router.getAccountId()); - } - - router.setVnet(null); - String privateIpAddress = router.getPrivateIpAddress(); - - router.setPrivateIpAddress(null); - - if (privateIpAddress != null) { - _dcDao.releasePrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId()); - } - - - if (_routerDao.updateIf(router, Event.OperationFailed, null)) { - txn.commit(); - } - } - if (th instanceof ExecutionException) { s_logger.error("Error while starting router due to " + th.getMessage()); } else if (th instanceof ConcurrentOperationException) { @@ -1036,13 +1015,28 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager return null; } } finally { - if (router != null) { - - if(s_logger.isDebugEnabled()) - s_logger.debug("Releasing lock on router " + routerId); - _routerDao.release(routerId); - } - if (!started){ + + if (!started){ + Transaction txn = Transaction.currentTxn(); + txn.start(); + if (vnetAllocated == true && vnet != null) { + _dcDao.releaseVnet(vnet, router.getDataCenterId(), router.getAccountId()); + } + + router.setVnet(null); + String privateIpAddress = router.getPrivateIpAddress(); + + router.setPrivateIpAddress(null); + + if (privateIpAddress != null) { + _dcDao.releasePrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId()); + } + + + if (_routerDao.updateIf(router, Event.OperationFailed, null)) { + txn.commit(); + } + EventVO event = new EventVO(); event.setUserId(1L); event.setAccountId(router.getAccountId()); @@ -1051,7 +1045,14 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager event.setLevel(EventVO.LEVEL_ERROR); event.setStartId(startEventId); _eventDao.persist(event); + } + + if (router != null) { + if(s_logger.isDebugEnabled()) + s_logger.debug("Releasing lock on router " + routerId); + _routerDao.release(routerId); } + } } From 275785404ce18eb30d3b03bd45a8b57d0e759c7d Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 18 Aug 2010 11:30:01 -0700 Subject: [PATCH 06/11] Add Host - vlidate cluster section only if xenserver is xenserver --- ui/scripts/cloud.core.hosts.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/scripts/cloud.core.hosts.js b/ui/scripts/cloud.core.hosts.js index 9d32c417c07..3316b5b19b8 100644 --- a/ui/scripts/cloud.core.hosts.js +++ b/ui/scripts/cloud.core.hosts.js @@ -594,8 +594,11 @@ function showHostsTab() { isValid &= validateString("Host name", dialogBox.find("#host_hostname"), dialogBox.find("#host_hostname_errormsg")); isValid &= validateString("User name", dialogBox.find("#host_username"), dialogBox.find("#host_username_errormsg")); isValid &= validateString("Password", dialogBox.find("#host_password"), dialogBox.find("#host_password_errormsg")); - if(clusterRadio == "new_cluster_radio") - isValid &= validateString("Cluster name", dialogBox.find("#new_cluster_name"), dialogBox.find("#new_cluster_name_errormsg")); + //xenserver supports cluster. kvm doesn't support cluster. + if (getHypervisorType() != "kvm") { + if(clusterRadio == "new_cluster_radio") + isValid &= validateString("Cluster name", dialogBox.find("#new_cluster_name"), dialogBox.find("#new_cluster_name_errormsg")); + } if (!isValid) return; var array1 = []; From b250b985ecd5cdaceaa896e6fefef18be5a214d8 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 18 Aug 2010 12:19:22 -0700 Subject: [PATCH 07/11] changes --- .../resource/storage/IscsiMountPreparer.java | 2 +- .../cloud/deploy/DataCenterDeployment.java | 3 +- ...ymentStrategy.java => DeploymentPlan.java} | 3 +- api/src/com/cloud/storage/Volume.java | 16 +++---- .../template}/VirtualMachineTemplate.java | 5 +-- {core => api}/src/com/cloud/user/Account.java | 23 +++++++--- api/src/com/cloud/uservm/UserVm.java | 9 ++-- .../com/cloud/vm/NetworkCharacteristics.java | 34 ++++---------- .../src/com/cloud/vm}/NetworkTO.java | 3 +- api/src/com/cloud/vm/Nic.java | 3 ++ api/src/com/cloud/vm/VirtualMachine.java | 7 +-- build/build.number | 4 +- core/src/com/cloud/agent/AgentManager.java | 2 +- .../cloud/agent/api/AbstractStartCommand.java | 2 +- core/src/com/cloud/agent/api/to/HostTO.java | 1 + core/src/com/cloud/agent/api/to/VmTO.java | 1 + core/src/com/cloud/dc/AccountVlanMapVO.java | 7 ++- core/src/com/cloud/domain/DomainVO.java | 42 +++++++++-------- .../com/cloud/domain/dao/DomainDaoImpl.java | 2 +- .../com/cloud/network/SecurityGroupVO.java | 35 ++++++++------- .../network/security/NetworkGroupVO.java | 33 +++++++------- core/src/com/cloud/resource/DiskPreparer.java | 2 +- .../com/cloud/server/ManagementServer.java | 19 ++++---- core/src/com/cloud/storage/VMTemplateVO.java | 1 + .../cloud/storage/dao/VMTemplateDaoImpl.java | 2 +- core/src/com/cloud/user/AccountVO.java | 36 ++++++++------- core/src/com/cloud/user/User.java | 6 +-- .../com/cloud/user/dao/AccountDaoImpl.java | 4 +- .../cloud/agent/manager/AgentManagerImpl.java | 2 +- .../agent/manager/allocator/PodAllocator.java | 2 +- .../impl/UserConcentratedAllocator.java | 2 +- server/src/com/cloud/api/ApiServer.java | 7 +-- server/src/com/cloud/api/BaseCmd.java | 2 +- .../AssignPortForwardingServiceCmd.java | 16 +++---- .../commands/AssignToLoadBalancerRuleCmd.java | 16 +++---- .../com/cloud/api/commands/AttachIsoCmd.java | 4 +- .../cloud/api/commands/AttachVolumeCmd.java | 4 +- .../cloud/api/commands/CreateDomainCmd.java | 22 ++++----- .../commands/CreateIPForwardingRuleCmd.java | 2 +- .../commands/CreateLoadBalancerRuleCmd.java | 4 +- .../api/commands/CreateNetworkGroupCmd.java | 2 +- .../CreatePortForwardingServiceCmd.java | 14 +++--- .../CreatePortForwardingServiceRuleCmd.java | 4 +- .../cloud/api/commands/CreateTemplateCmd.java | 4 +- .../cloud/api/commands/CreateVolumeCmd.java | 2 +- .../cloud/api/commands/DeleteDomainCmd.java | 18 ++++---- .../commands/DeleteIPForwardingRuleCmd.java | 36 +++++++-------- .../com/cloud/api/commands/DeleteIsoCmd.java | 14 +++--- .../commands/DeleteLoadBalancerRuleCmd.java | 14 +++--- .../DeletePortForwardingServiceCmd.java | 2 +- .../com/cloud/api/commands/DestroyVMCmd.java | 14 +++--- .../com/cloud/api/commands/DetachIsoCmd.java | 14 +++--- .../cloud/api/commands/DisableAccountCmd.java | 16 +++---- .../cloud/api/commands/DisableUserCmd.java | 14 +++--- .../api/commands/DisassociateIPAddrCmd.java | 14 +++--- .../cloud/api/commands/EnableAccountCmd.java | 16 +++---- .../cloud/api/commands/ListAccountsCmd.java | 8 ++-- .../api/commands/ListDomainChildrenCmd.java | 8 ++-- .../cloud/api/commands/ListDomainsCmd.java | 8 ++-- .../com/cloud/api/commands/ListEventsCmd.java | 16 +++---- .../com/cloud/api/commands/ListIsosCmd.java | 4 +- .../ListLoadBalancerRuleInstancesCmd.java | 2 +- .../api/commands/ListNetworkGroupsCmd.java | 2 +- .../commands/ListPortForwardingRulesCmd.java | 2 +- .../ListPortForwardingServiceRulesCmd.java | 2 +- .../ListRecurringSnapshotScheduleCmd.java | 10 ++--- .../api/commands/ListServiceOfferingsCmd.java | 2 +- .../cloud/api/commands/ListSnapshotsCmd.java | 4 +- .../ListTemplateOrIsoPermissionsCmd.java | 6 +-- .../cloud/api/commands/ListTemplatesCmd.java | 4 +- .../com/cloud/api/commands/ListVMsCmd.java | 2 +- .../cloud/api/commands/ListZonesByCmd.java | 14 +++--- .../cloud/api/commands/LockAccountCmd.java | 24 +++++----- .../com/cloud/api/commands/RebootVMCmd.java | 14 +++--- .../cloud/api/commands/RegisterIsoCmd.java | 6 +-- .../api/commands/RegisterTemplateCmd.java | 2 +- .../RemoveFromLoadBalancerRuleCmd.java | 16 +++---- .../RemovePortForwardingServiceCmd.java | 18 ++++---- .../api/commands/ResetVMPasswordCmd.java | 14 +++--- .../com/cloud/api/commands/StartVMCmd.java | 14 +++--- .../src/com/cloud/api/commands/StopVMCmd.java | 14 +++--- .../cloud/api/commands/UpdateAccountCmd.java | 14 +++--- .../cloud/api/commands/UpdateDomainCmd.java | 4 +- .../commands/UpdateIPForwardingRuleCmd.java | 2 +- .../com/cloud/api/commands/UpdateIsoCmd.java | 14 +++--- .../commands/UpdateLoadBalancerRuleCmd.java | 2 +- .../com/cloud/api/commands/UpdateVMCmd.java | 14 +++--- .../com/cloud/api/commands/UpgradeVMCmd.java | 15 +++---- .../async/executor/CopyTemplateExecutor.java | 11 +++-- .../com/cloud/network/NetworkManagerImpl.java | 8 ++-- .../com/cloud/network/NetworkProfileVO.java | 4 +- .../security/NetworkGroupManagerImpl.java | 2 +- .../cloud/server/ManagementServerImpl.java | 45 ++++++++++--------- .../cloud/servlet/ConsoleProxyServlet.java | 20 ++++----- .../com/cloud/storage/StorageManagerImpl.java | 8 ++-- server/src/com/cloud/user/AccountManager.java | 2 + server/src/com/cloud/vm/MauriceMoss.java | 25 ++++++++--- server/src/com/cloud/vm/NicVO.java | 34 ++++++++++++++ .../src/com/cloud/vm/UserVmManagerImpl.java | 10 ++--- server/src/com/cloud/vm/VmManager.java | 20 +++++++-- setup/db/create-schema.sql | 7 ++- 101 files changed, 561 insertions(+), 504 deletions(-) rename api/src/com/cloud/deploy/{DeploymentStrategy.java => DeploymentPlan.java} (92%) rename {core/src/com/cloud/storage => api/src/com/cloud/template}/VirtualMachineTemplate.java (91%) rename {core => api}/src/com/cloud/user/Account.java (82%) rename {core/src/com/cloud/agent/api/to => api/src/com/cloud/vm}/NetworkTO.java (98%) diff --git a/agent/src/com/cloud/agent/resource/storage/IscsiMountPreparer.java b/agent/src/com/cloud/agent/resource/storage/IscsiMountPreparer.java index 97198e77c7c..2def1977824 100644 --- a/agent/src/com/cloud/agent/resource/storage/IscsiMountPreparer.java +++ b/agent/src/com/cloud/agent/resource/storage/IscsiMountPreparer.java @@ -28,8 +28,8 @@ import org.apache.log4j.Logger; import com.cloud.resource.DiskPreparer; import com.cloud.storage.Volume; import com.cloud.storage.VolumeVO; -import com.cloud.storage.VirtualMachineTemplate.BootloaderType; import com.cloud.storage.Volume.VolumeType; +import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.NumbersUtil; import com.cloud.utils.script.Script; diff --git a/api/src/com/cloud/deploy/DataCenterDeployment.java b/api/src/com/cloud/deploy/DataCenterDeployment.java index ba8b227c179..7e3be074503 100644 --- a/api/src/com/cloud/deploy/DataCenterDeployment.java +++ b/api/src/com/cloud/deploy/DataCenterDeployment.java @@ -17,12 +17,13 @@ */ package com.cloud.deploy; -public class DataCenterDeployment implements DeploymentStrategy { +public class DataCenterDeployment implements DeploymentPlan { long _dcId; public DataCenterDeployment(long dataCenterId) { _dcId = dataCenterId; } + @Override public long getDataCenterId() { return _dcId; } diff --git a/api/src/com/cloud/deploy/DeploymentStrategy.java b/api/src/com/cloud/deploy/DeploymentPlan.java similarity index 92% rename from api/src/com/cloud/deploy/DeploymentStrategy.java rename to api/src/com/cloud/deploy/DeploymentPlan.java index 57bdeca6188..e619fc6a1e2 100644 --- a/api/src/com/cloud/deploy/DeploymentStrategy.java +++ b/api/src/com/cloud/deploy/DeploymentPlan.java @@ -21,6 +21,7 @@ package com.cloud.deploy; * Describes how a VM should be deployed. * */ -public interface DeploymentStrategy { +public interface DeploymentPlan { + public long getDataCenterId(); } diff --git a/api/src/com/cloud/storage/Volume.java b/api/src/com/cloud/storage/Volume.java index eaddb7c8195..3f6d9b1013e 100755 --- a/api/src/com/cloud/storage/Volume.java +++ b/api/src/com/cloud/storage/Volume.java @@ -17,8 +17,12 @@ */ 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 MirrorState {NOT_MIRRORED, ACTIVE, DEFUNCT}; @@ -38,16 +42,6 @@ public interface Volume { */ 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 */ diff --git a/core/src/com/cloud/storage/VirtualMachineTemplate.java b/api/src/com/cloud/template/VirtualMachineTemplate.java similarity index 91% rename from core/src/com/cloud/storage/VirtualMachineTemplate.java rename to api/src/com/cloud/template/VirtualMachineTemplate.java index 7a56a2c9477..8259206f52c 100755 --- a/core/src/com/cloud/storage/VirtualMachineTemplate.java +++ b/api/src/com/cloud/template/VirtualMachineTemplate.java @@ -15,12 +15,11 @@ * along with this program. If not, see . * */ -package com.cloud.storage; +package com.cloud.template; -import com.cloud.async.AsyncInstanceCreateStatus; import com.cloud.storage.Storage.FileSystem; -public interface VirtualMachineTemplate { +public interface VirtualMachineTemplate { public static enum BootloaderType { PyGrub, HVM, External }; diff --git a/core/src/com/cloud/user/Account.java b/api/src/com/cloud/user/Account.java similarity index 82% rename from core/src/com/cloud/user/Account.java rename to api/src/com/cloud/user/Account.java index bb419b1007a..aebd92ab134 100644 --- a/core/src/com/cloud/user/Account.java +++ b/api/src/com/cloud/user/Account.java @@ -20,7 +20,22 @@ package com.cloud.user; 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_ADMIN = 1; 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 Long getId(); + public long getId(); public String getAccountName(); public void setAccountName(String accountId); public short getType(); - public void setType(short type); public String getState(); public void setState(String state); - public Long getDomainId(); - public void setDomainId(Long domainId); + public long getDomainId(); public Date getRemoved(); } diff --git a/api/src/com/cloud/uservm/UserVm.java b/api/src/com/cloud/uservm/UserVm.java index c4a9d2c923e..a0bd2bc08a5 100755 --- a/api/src/com/cloud/uservm/UserVm.java +++ b/api/src/com/cloud/uservm/UserVm.java @@ -17,12 +17,14 @@ */ package com.cloud.uservm; +import com.cloud.domain.PartOf; +import com.cloud.user.OwnedBy; import com.cloud.vm.VirtualMachine; /** * This represents one running virtual machine instance. */ -public interface UserVm extends VirtualMachine { +public interface UserVm extends VirtualMachine, OwnedBy, PartOf { /** * @return service offering id @@ -39,11 +41,6 @@ public interface UserVm extends VirtualMachine { */ String getVnet(); - /** - * @return the account this vm instance belongs to. - */ - long getAccountId(); - /** * @return the domain this vm instance belongs to. */ diff --git a/api/src/com/cloud/vm/NetworkCharacteristics.java b/api/src/com/cloud/vm/NetworkCharacteristics.java index 9d97e02e6a4..7b8c3482797 100644 --- a/api/src/com/cloud/vm/NetworkCharacteristics.java +++ b/api/src/com/cloud/vm/NetworkCharacteristics.java @@ -9,32 +9,14 @@ import com.cloud.network.Network.Mode; public class NetworkCharacteristics { long id; BroadcastDomainType type; - String ip4Address; - String netmask; - String gateway; + String cidr; Mode mode; - String[] dns; + long vmId; public BroadcastDomainType getType() { 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() { return mode; } @@ -42,17 +24,19 @@ public class NetworkCharacteristics { public long getNetworkId() { return id; } + + public long getVirtualMachineId() { + return vmId; + } 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.type = type; - this.ip4Address = ip4Address; - this.netmask = netmask; - this.gateway = gateway; + this.cidr = cidr; this.mode = mode; - this.dns = dns; + this.vmId = vmId; } } diff --git a/core/src/com/cloud/agent/api/to/NetworkTO.java b/api/src/com/cloud/vm/NetworkTO.java similarity index 98% rename from core/src/com/cloud/agent/api/to/NetworkTO.java rename to api/src/com/cloud/vm/NetworkTO.java index 50cb1cd034c..844b1943e12 100644 --- a/core/src/com/cloud/agent/api/to/NetworkTO.java +++ b/api/src/com/cloud/vm/NetworkTO.java @@ -15,12 +15,13 @@ * along with this program. If not, see . * */ -package com.cloud.agent.api.to; +package com.cloud.vm; /** * Transfer object to transfer network settings. */ public class NetworkTO { + private String uuid; private String ip; private String netmask; private String gateway; diff --git a/api/src/com/cloud/vm/Nic.java b/api/src/com/cloud/vm/Nic.java index b477170ed11..3dfd7bb942a 100644 --- a/api/src/com/cloud/vm/Nic.java +++ b/api/src/com/cloud/vm/Nic.java @@ -23,6 +23,7 @@ package com.cloud.vm; */ public interface Nic { enum State { + Allocated, AcquireIp, IpAcquired, } @@ -47,4 +48,6 @@ public interface Nic { * @return the vm instance id that this nic belongs to. */ long getInstanceId(); + + long getDeviceId(); } diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java index b8a7646a8d9..6594f9a2d38 100755 --- a/api/src/com/cloud/vm/VirtualMachine.java +++ b/api/src/com/cloud/vm/VirtualMachine.java @@ -23,7 +23,7 @@ import java.util.Date; * VirtualMachine describes the properties held by a virtual machine * */ -public interface VirtualMachine { +public interface VirtualMachine extends RunningOn { public enum Event { CreateRequested, StartRequested, @@ -100,11 +100,6 @@ public interface VirtualMachine { */ 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. */ diff --git a/build/build.number b/build/build.number index 6360d93adb4..30f89d5f59b 100644 --- a/build/build.number +++ b/build/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Mon Aug 16 18:14:16 PDT 2010 -build.number=32 +#Wed Aug 18 11:29:13 PDT 2010 +build.number=64 diff --git a/core/src/com/cloud/agent/AgentManager.java b/core/src/com/cloud/agent/AgentManager.java index 08e9a30a4ee..fac5b8be354 100755 --- a/core/src/com/cloud/agent/AgentManager.java +++ b/core/src/com/cloud/agent/AgentManager.java @@ -39,7 +39,7 @@ import com.cloud.offering.ServiceOffering; import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.StoragePoolVO; import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.VirtualMachineTemplate; +import com.cloud.template.VirtualMachineTemplate; import com.cloud.uservm.UserVm; import com.cloud.utils.Pair; import com.cloud.utils.component.Manager; diff --git a/core/src/com/cloud/agent/api/AbstractStartCommand.java b/core/src/com/cloud/agent/api/AbstractStartCommand.java index b2a943ad5f0..e9f31204d15 100644 --- a/core/src/com/cloud/agent/api/AbstractStartCommand.java +++ b/core/src/com/cloud/agent/api/AbstractStartCommand.java @@ -21,7 +21,7 @@ package com.cloud.agent.api; import java.util.List; import com.cloud.storage.VolumeVO; -import com.cloud.storage.VirtualMachineTemplate.BootloaderType; +import com.cloud.template.VirtualMachineTemplate.BootloaderType; public abstract class AbstractStartCommand extends Command { diff --git a/core/src/com/cloud/agent/api/to/HostTO.java b/core/src/com/cloud/agent/api/to/HostTO.java index 91cfa65437e..717412f4c1e 100644 --- a/core/src/com/cloud/agent/api/to/HostTO.java +++ b/core/src/com/cloud/agent/api/to/HostTO.java @@ -18,6 +18,7 @@ package com.cloud.agent.api.to; import com.cloud.host.HostVO; +import com.cloud.vm.NetworkTO; public class HostTO { private String guid; diff --git a/core/src/com/cloud/agent/api/to/VmTO.java b/core/src/com/cloud/agent/api/to/VmTO.java index 7df5041def4..5cacc391a1c 100644 --- a/core/src/com/cloud/agent/api/to/VmTO.java +++ b/core/src/com/cloud/agent/api/to/VmTO.java @@ -17,6 +17,7 @@ */ package com.cloud.agent.api.to; +import com.cloud.vm.NetworkTO; import com.cloud.vm.VMInstanceVO; public class VmTO { diff --git a/core/src/com/cloud/dc/AccountVlanMapVO.java b/core/src/com/cloud/dc/AccountVlanMapVO.java index a5fbb105e1d..b4d6969c7ca 100644 --- a/core/src/com/cloud/dc/AccountVlanMapVO.java +++ b/core/src/com/cloud/dc/AccountVlanMapVO.java @@ -25,9 +25,11 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import com.cloud.user.OwnedBy; + @Entity @Table(name="account_vlan_map") -public class AccountVlanMapVO { +public class AccountVlanMapVO implements OwnedBy { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @@ -52,7 +54,8 @@ public class AccountVlanMapVO { public Long getId() { return id; } - + + @Override public long getAccountId() { return accountId; } diff --git a/core/src/com/cloud/domain/DomainVO.java b/core/src/com/cloud/domain/DomainVO.java index 90ee26b5976..9b97065723c 100644 --- a/core/src/com/cloud/domain/DomainVO.java +++ b/core/src/com/cloud/domain/DomainVO.java @@ -18,26 +18,24 @@ package com.cloud.domain; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + import com.cloud.utils.db.GenericDao; @Entity @Table(name="domain") -public class DomainVO { - public static final long ROOT_DOMAIN = 1L; - +public class DomainVO implements Domain { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") - private Long id = null; + private long id; @Column(name="parent") private Long parent = null; @@ -46,13 +44,13 @@ public class DomainVO { private String name = null; @Column(name="owner") - private Long owner = null; + private long accountId; @Column(name="path") private String path = null; @Column(name="level") - private Integer level = null; + private int level; @Column(name=GenericDao.REMOVED_COLUMN) private Date removed; @@ -65,15 +63,15 @@ public class DomainVO { public DomainVO() {} - public DomainVO(String name, Long owner, Long parentId) { + public DomainVO(String name, long owner, Long parentId) { this.parent = parentId; this.name = name; - this.owner = owner; + this.accountId = owner; this.path =""; this.level = 0; } - public Long getId() { + public long getId() { return id; } @@ -100,8 +98,8 @@ public class DomainVO { this.name = name; } - public Long getOwner() { - return owner; + public long getAccountId() { + return accountId; } public Date getRemoved() { @@ -116,11 +114,11 @@ public class DomainVO { this.path = path; } - public Integer getLevel() { + public int getLevel() { return level; } - public void setLevel(Integer level) { + public void setLevel(int level) { this.level = level; } diff --git a/core/src/com/cloud/domain/dao/DomainDaoImpl.java b/core/src/com/cloud/domain/dao/DomainDaoImpl.java index dc2633cdd6f..118c4c853dc 100644 --- a/core/src/com/cloud/domain/dao/DomainDaoImpl.java +++ b/core/src/com/cloud/domain/dao/DomainDaoImpl.java @@ -211,7 +211,7 @@ public class DomainDaoImpl extends GenericDaoBase implements Dom DomainVO d1 = domainPair.get(0); DomainVO d2 = domainPair.get(1); - if (d1.getId().equals(parentId)) { + if (d1.getId() == parentId) { result = d2.getPath().startsWith(d1.getPath()); } else { result = d1.getPath().startsWith(d2.getPath()); diff --git a/core/src/com/cloud/network/SecurityGroupVO.java b/core/src/com/cloud/network/SecurityGroupVO.java index 8ea991e01a9..691963775da 100644 --- a/core/src/com/cloud/network/SecurityGroupVO.java +++ b/core/src/com/cloud/network/SecurityGroupVO.java @@ -18,24 +18,27 @@ package com.cloud.network; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.PrimaryKeyJoinColumn; -import javax.persistence.SecondaryTable; -import javax.persistence.Table; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.SecondaryTable; +import javax.persistence.Table; + +import com.cloud.domain.PartOf; +import com.cloud.user.OwnedBy; @Entity @Table(name=("security_group")) @SecondaryTable(name="account", pkJoinColumns={@PrimaryKeyJoinColumn(name="account_id", referencedColumnName="id")}) -public class SecurityGroupVO { +public class SecurityGroupVO implements PartOf, OwnedBy { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") - private Long id; + private long id; @Column(name="name") private String name; @@ -44,24 +47,24 @@ public class SecurityGroupVO { private String description; @Column(name="domain_id") - private Long domainId; + private long domainId; @Column(name="account_id") - private Long accountId; + private long accountId; @Column(name="account_name", table="account", insertable=false, updatable=false) private String accountName = null; 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.description = description; this.domainId = domainId; this.accountId = accountId; } - public Long getId() { + public long getId() { return id; } @@ -73,11 +76,11 @@ public class SecurityGroupVO { return description; } - public Long getDomainId() { + public long getDomainId() { return domainId; } - public Long getAccountId() { + public long getAccountId() { return accountId; } diff --git a/core/src/com/cloud/network/security/NetworkGroupVO.java b/core/src/com/cloud/network/security/NetworkGroupVO.java index d20823bb035..7aa736d070d 100644 --- a/core/src/com/cloud/network/security/NetworkGroupVO.java +++ b/core/src/com/cloud/network/security/NetworkGroupVO.java @@ -18,22 +18,23 @@ package com.cloud.network.security; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.PrimaryKeyJoinColumn; -import javax.persistence.SecondaryTable; -import javax.persistence.Table; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import com.cloud.domain.PartOf; +import com.cloud.user.OwnedBy; @Entity @Table(name=("network_group")) -public class NetworkGroupVO { +public class NetworkGroupVO implements PartOf, OwnedBy { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") - private Long id; + private long id; @Column(name="name") private String name; @@ -42,17 +43,17 @@ public class NetworkGroupVO { private String description; @Column(name="domain_id") - private Long domainId; + private long domainId; @Column(name="account_id") - private Long accountId; + private long accountId; @Column(name="account_name") private String accountName = null; 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.description = description; this.domainId = domainId; @@ -60,7 +61,7 @@ public class NetworkGroupVO { this.accountName = accountName; } - public Long getId() { + public long getId() { return id; } @@ -72,11 +73,11 @@ public class NetworkGroupVO { return description; } - public Long getDomainId() { + public long getDomainId() { return domainId; } - public Long getAccountId() { + public long getAccountId() { return accountId; } diff --git a/core/src/com/cloud/resource/DiskPreparer.java b/core/src/com/cloud/resource/DiskPreparer.java index c24813d66d9..05ffa78465f 100644 --- a/core/src/com/cloud/resource/DiskPreparer.java +++ b/core/src/com/cloud/resource/DiskPreparer.java @@ -18,7 +18,7 @@ package com.cloud.resource; import com.cloud.storage.VolumeVO; -import com.cloud.storage.VirtualMachineTemplate.BootloaderType; +import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.component.Adapter; /** diff --git a/core/src/com/cloud/server/ManagementServer.java b/core/src/com/cloud/server/ManagementServer.java index be62fb62109..840d9343ca6 100644 --- a/core/src/com/cloud/server/ManagementServer.java +++ b/core/src/com/cloud/server/ManagementServer.java @@ -29,15 +29,15 @@ import com.cloud.async.AsyncJobResult; import com.cloud.async.AsyncJobVO; import com.cloud.capacity.CapacityVO; import com.cloud.configuration.ConfigurationVO; -import com.cloud.configuration.ResourceLimitVO; import com.cloud.configuration.ResourceCount.ResourceType; +import com.cloud.configuration.ResourceLimitVO; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterIpAddressVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; -import com.cloud.dc.VlanVO; 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.exception.ConcurrentOperationException; import com.cloud.exception.DiscoveryException; @@ -72,7 +72,6 @@ import com.cloud.storage.Snapshot; import com.cloud.storage.SnapshotPolicyVO; import com.cloud.storage.SnapshotScheduleVO; import com.cloud.storage.SnapshotVO; -import com.cloud.storage.StoragePoolHostVO; import com.cloud.storage.StoragePoolVO; import com.cloud.storage.StorageStats; import com.cloud.storage.VMTemplateHostVO; @@ -1521,9 +1520,9 @@ public interface ManagementServer { * in a Criteria object. * @return list of domains owned by the given user */ - List searchForDomains(Criteria c); + List searchForDomains(Criteria c); - List searchForDomainChildren(Criteria c); + List searchForDomainChildren(Criteria c); /** * create a new domain @@ -1533,7 +1532,7 @@ public interface ManagementServer { * @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 @@ -1560,14 +1559,14 @@ public interface ManagementServer { * find the domain by id * @param domainId the id of the domainId */ - DomainVO findDomainIdById(Long domainId); + Domain findDomainIdById(Long domainId); /** * find the domain by its path * @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 diff --git a/core/src/com/cloud/storage/VMTemplateVO.java b/core/src/com/cloud/storage/VMTemplateVO.java index 43213545f8f..e46a3bcc66e 100644 --- a/core/src/com/cloud/storage/VMTemplateVO.java +++ b/core/src/com/cloud/storage/VMTemplateVO.java @@ -37,6 +37,7 @@ import com.cloud.storage.Storage.ImageFormat; import com.cloud.utils.db.GenericDao; import com.google.gson.annotations.Expose; import com.cloud.storage.Storage; +import com.cloud.template.VirtualMachineTemplate; @Entity @Table(name="vm_template") diff --git a/core/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/core/src/com/cloud/storage/dao/VMTemplateDaoImpl.java index a02d33bdb53..aee78a8e79b 100644 --- a/core/src/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/core/src/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -185,7 +185,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem String accountId = null; if (account != null) { accountType = account.getType(); - accountId = account.getId().toString(); + accountId = Long.toString(account.getId()); } else { accountType = Account.ACCOUNT_TYPE_ADMIN; } diff --git a/core/src/com/cloud/user/AccountVO.java b/core/src/com/cloud/user/AccountVO.java index 42c30ee7ca3..58f0c89b3e8 100644 --- a/core/src/com/cloud/user/AccountVO.java +++ b/core/src/com/cloud/user/AccountVO.java @@ -18,15 +18,15 @@ package com.cloud.user; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + import com.cloud.utils.db.GenericDao; @Entity @@ -35,7 +35,7 @@ public class AccountVO implements Account { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") - private Long id = null; + private long id; @Column(name="account_name") private String accountName = null; @@ -44,7 +44,7 @@ public class AccountVO implements Account { private short type = ACCOUNT_TYPE_NORMAL; @Column(name="domain_id") - private Long domainId = null; + private long domainId; @Column(name="state") private String state; @@ -56,7 +56,7 @@ public class AccountVO implements Account { private boolean needsCleanup = false; public AccountVO() {} - public AccountVO(Long id) { + public AccountVO(long id) { this.id = id; } @@ -67,8 +67,9 @@ public class AccountVO implements Account { public boolean getNeedsCleanup() { return needsCleanup; } - - public Long getId() { + + @Override + public long getId() { return id; } @@ -85,10 +86,11 @@ public class AccountVO implements Account { this.type = type; } - public Long getDomainId() { + public long getDomainId() { return domainId; - } - public void setDomainId(Long domainId) { + } + + public void setDomainId(long domainId) { this.domainId = domainId; } diff --git a/core/src/com/cloud/user/User.java b/core/src/com/cloud/user/User.java index f5e5adc34c3..2859e24697d 100644 --- a/core/src/com/cloud/user/User.java +++ b/core/src/com/cloud/user/User.java @@ -18,9 +18,9 @@ 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 Long getId(); @@ -45,8 +45,6 @@ public interface User { public void setLastname(String lastname); - public long getAccountId(); - public void setAccountId(long accountId); public String getEmail(); diff --git a/core/src/com/cloud/user/dao/AccountDaoImpl.java b/core/src/com/cloud/user/dao/AccountDaoImpl.java index c9dd9c0b401..603ea80fe59 100644 --- a/core/src/com/cloud/user/dao/AccountDaoImpl.java +++ b/core/src/com/cloud/user/dao/AccountDaoImpl.java @@ -36,8 +36,8 @@ import com.cloud.utils.db.Filter; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.Transaction; import com.cloud.utils.db.SearchCriteria.Op; +import com.cloud.utils.db.Transaction; @Local(value={AccountDao.class}) public class AccountDaoImpl extends GenericDaoBase implements AccountDao { @@ -94,7 +94,7 @@ public class AccountDaoImpl extends GenericDaoBase implements A u.setSecretKey(rs.getString(4)); 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.setType(rs.getShort(8)); a.setDomainId(rs.getLong(9)); diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 509aef1a3c1..498b6c26a0e 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -116,7 +116,6 @@ import com.cloud.storage.Storage.StorageResourceType; import com.cloud.storage.StoragePoolVO; import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.VirtualMachineTemplate; import com.cloud.storage.dao.GuestOSCategoryDao; import com.cloud.storage.dao.StoragePoolDao; 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.VolumeDao; import com.cloud.storage.resource.DummySecondaryStorageResource; +import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.dao.UserStatisticsDao; import com.cloud.uservm.UserVm; import com.cloud.utils.ActionDelegate; diff --git a/server/src/com/cloud/agent/manager/allocator/PodAllocator.java b/server/src/com/cloud/agent/manager/allocator/PodAllocator.java index ab567aab85f..403360beb3c 100755 --- a/server/src/com/cloud/agent/manager/allocator/PodAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/PodAllocator.java @@ -22,7 +22,7 @@ import java.util.Set; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.service.ServiceOfferingVO; -import com.cloud.storage.VirtualMachineTemplate; +import com.cloud.template.VirtualMachineTemplate; import com.cloud.utils.Pair; import com.cloud.utils.component.Adapter; diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java index 9d5d50442f5..29ba8bc511c 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java @@ -40,11 +40,11 @@ import com.cloud.offering.ServiceOffering; import com.cloud.offering.ServiceOffering.GuestIpType; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; -import com.cloud.storage.VirtualMachineTemplate; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.dao.VMTemplatePoolDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.template.VirtualMachineTemplate; import com.cloud.utils.DateUtil; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index f8b4f06a734..5c29f8dada8 100644 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -76,6 +76,7 @@ import org.apache.log4j.Logger; import com.cloud.configuration.ConfigurationVO; import com.cloud.configuration.dao.ConfigurationDao; +import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.maid.StackMaid; import com.cloud.server.ManagementServer; @@ -402,7 +403,7 @@ public class ApiServer implements HttpRequestHandler { if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) { 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.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 }); } else { 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) { domainId = DomainVO.ROOT_DOMAIN; } else { - DomainVO domainObj = _ms.findDomainByPath(domainPath); + Domain domainObj = _ms.findDomainByPath(domainPath); if (domainObj != null) { domainId = domainObj.getId(); } 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(BaseCmd.Properties.LASTNAME.getName(), userAcct.getLastname())); loginParams.add(new Pair(BaseCmd.Properties.ACCOUNT_OBJ.getName(), account)); loginParams.add(new Pair(BaseCmd.Properties.ACCOUNT.getName(), account.getAccountName())); - loginParams.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), account.getDomainId().toString())); + loginParams.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(account.getDomainId()))); loginParams.add(new Pair(BaseCmd.Properties.TYPE.getName(), Short.valueOf(account.getType()).toString())); loginParams.add(new Pair(BaseCmd.Properties.NETWORK_TYPE.getName(), networkType)); loginParams.add(new Pair(BaseCmd.Properties.HYPERVISOR_TYPE.getName(), hypervisorType)); diff --git a/server/src/com/cloud/api/BaseCmd.java b/server/src/com/cloud/api/BaseCmd.java index 0698671be76..e9072b732b4 100644 --- a/server/src/com/cloud/api/BaseCmd.java +++ b/server/src/com/cloud/api/BaseCmd.java @@ -877,7 +877,7 @@ public abstract class BaseCmd { Account account = getAccount(params); if (account != null) { 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"); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), targetDomainId)) { diff --git a/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java b/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java index 2bd6d34f467..3cd05ade7c5 100644 --- a/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java +++ b/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java @@ -18,13 +18,13 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; 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."); } 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 + "."); } else { Account validatedAccount = getManagementServer().findAccountById(validatedAccountId); diff --git a/server/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java b/server/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java index 5d50a94632d..fa76554bf2d 100644 --- a/server/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java +++ b/server/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java @@ -18,13 +18,13 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.network.LoadBalancerVO; @@ -97,7 +97,7 @@ public class AssignToLoadBalancerRuleCmd extends BaseCmd { if (loadBalancer == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule, with id " + loadBalancerId); } 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() + " (id:" + loadBalancer.getId() + ")"); } else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/AttachIsoCmd.java b/server/src/com/cloud/api/commands/AttachIsoCmd.java index 0cfd57b2e86..e96b9a1cd41 100644 --- a/server/src/com/cloud/api/commands/AttachIsoCmd.java +++ b/server/src/com/cloud/api/commands/AttachIsoCmd.java @@ -73,10 +73,10 @@ public class AttachIsoCmd extends BaseCmd { if (account != null) { 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"); } - 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"); } } else { diff --git a/server/src/com/cloud/api/commands/AttachVolumeCmd.java b/server/src/com/cloud/api/commands/AttachVolumeCmd.java index 53f0d5582bb..629c6b03443 100644 --- a/server/src/com/cloud/api/commands/AttachVolumeCmd.java +++ b/server/src/com/cloud/api/commands/AttachVolumeCmd.java @@ -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 (account != null) { 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()); - 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()); } else { if (!getManagementServer().isChildDomain(account.getDomainId(), volume.getDomainId()) || diff --git a/server/src/com/cloud/api/commands/CreateDomainCmd.java b/server/src/com/cloud/api/commands/CreateDomainCmd.java index ff4cb1ccfd5..3ec5be14837 100644 --- a/server/src/com/cloud/api/commands/CreateDomainCmd.java +++ b/server/src/com/cloud/api/commands/CreateDomainCmd.java @@ -18,15 +18,15 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -63,9 +63,9 @@ public class CreateDomainCmd extends BaseCmd { } if (parentDomainId == null){ - parentDomainId = DomainVO.ROOT_DOMAIN; + parentDomainId = Domain.ROOT_DOMAIN; } else { - DomainVO parentDomain = null; + Domain parentDomain = null; parentDomain = getManagementServer().findDomainIdById(parentDomainId); if (parentDomain == null) { 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); } - DomainVO domain = null; + Domain domain = null; try { domain = getManagementServer().createDomain(name, account.getId(), parentDomainId); } catch (IllegalArgumentException illArgEx) { @@ -96,7 +96,7 @@ public class CreateDomainCmd extends BaseCmd { } else { returnValues.add(new Pair(BaseCmd.Properties.ID.getName(), domain.getId())); returnValues.add(new Pair(BaseCmd.Properties.NAME.getName(), domain.getName())); - returnValues.add(new Pair(BaseCmd.Properties.LEVEL.getName(), domain.getLevel().toString())); + returnValues.add(new Pair(BaseCmd.Properties.LEVEL.getName(), Integer.toString(domain.getLevel()))); returnValues.add(new Pair(BaseCmd.Properties.PARENT_DOMAIN_ID.getName(), domain.getParent().toString())); returnValues.add(new Pair(BaseCmd.Properties.PARENT_DOMAIN_NAME.getName(), getManagementServer().findDomainIdById(domain.getParent()).getName())); diff --git a/server/src/com/cloud/api/commands/CreateIPForwardingRuleCmd.java b/server/src/com/cloud/api/commands/CreateIPForwardingRuleCmd.java index 797029adec2..0d3c22843b9 100644 --- a/server/src/com/cloud/api/commands/CreateIPForwardingRuleCmd.java +++ b/server/src/com/cloud/api/commands/CreateIPForwardingRuleCmd.java @@ -98,7 +98,7 @@ public class CreateIPForwardingRuleCmd extends BaseCmd { 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."); } - } 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."); } } diff --git a/server/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java b/server/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java index 5be0f45ae66..557cac553f0 100644 --- a/server/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java +++ b/server/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java @@ -26,8 +26,8 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.dc.VlanVO; import com.cloud.dc.Vlan.VlanType; +import com.cloud.dc.VlanVO; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.PermissionDeniedException; import com.cloud.network.IPAddressVO; @@ -102,7 +102,7 @@ public class CreateLoadBalancerRuleCmd extends BaseCmd { Long accountId = accountByIp.getId(); if (account != null) { 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); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), accountByIp.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/CreateNetworkGroupCmd.java b/server/src/com/cloud/api/commands/CreateNetworkGroupCmd.java index 4b7712b64f8..7f87a565644 100644 --- a/server/src/com/cloud/api/commands/CreateNetworkGroupCmd.java +++ b/server/src/com/cloud/api/commands/CreateNetworkGroupCmd.java @@ -110,7 +110,7 @@ public class CreateNetworkGroupCmd extends BaseCmd { List> embeddedObject = new ArrayList>(); List> returnValues = new ArrayList>(); - returnValues.add(new Pair(BaseCmd.Properties.ID.getName(), networkGroup.getId().toString())); + returnValues.add(new Pair(BaseCmd.Properties.ID.getName(), Long.toString(networkGroup.getId()))); returnValues.add(new Pair(BaseCmd.Properties.NAME.getName(), networkGroup.getName())); returnValues.add(new Pair(BaseCmd.Properties.DESCRIPTION.getName(), networkGroup.getDescription())); diff --git a/server/src/com/cloud/api/commands/CreatePortForwardingServiceCmd.java b/server/src/com/cloud/api/commands/CreatePortForwardingServiceCmd.java index 285255f4d11..99561bf6b0e 100644 --- a/server/src/com/cloud/api/commands/CreatePortForwardingServiceCmd.java +++ b/server/src/com/cloud/api/commands/CreatePortForwardingServiceCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.network.SecurityGroupVO; @@ -107,7 +107,7 @@ public class CreatePortForwardingServiceCmd extends BaseCmd { List> embeddedObject = new ArrayList>(); List> returnValues = new ArrayList>(); - returnValues.add(new Pair(BaseCmd.Properties.ID.getName(), securityGroup.getId().toString())); + returnValues.add(new Pair(BaseCmd.Properties.ID.getName(), Long.toString(securityGroup.getId()))); returnValues.add(new Pair(BaseCmd.Properties.NAME.getName(), securityGroup.getName())); returnValues.add(new Pair(BaseCmd.Properties.DESCRIPTION.getName(), securityGroup.getDescription())); diff --git a/server/src/com/cloud/api/commands/CreatePortForwardingServiceRuleCmd.java b/server/src/com/cloud/api/commands/CreatePortForwardingServiceRuleCmd.java index f28221f8707..4e67053d1dc 100644 --- a/server/src/com/cloud/api/commands/CreatePortForwardingServiceRuleCmd.java +++ b/server/src/com/cloud/api/commands/CreatePortForwardingServiceRuleCmd.java @@ -78,7 +78,7 @@ public class CreatePortForwardingServiceRuleCmd extends BaseCmd { 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."); } - } 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."); } } @@ -88,7 +88,7 @@ public class CreatePortForwardingServiceRuleCmd extends BaseCmd { 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; if (jobId == 0) { diff --git a/server/src/com/cloud/api/commands/CreateTemplateCmd.java b/server/src/com/cloud/api/commands/CreateTemplateCmd.java index fdc5dad6195..a1606477cc6 100644 --- a/server/src/com/cloud/api/commands/CreateTemplateCmd.java +++ b/server/src/com/cloud/api/commands/CreateTemplateCmd.java @@ -26,8 +26,6 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.async.AsyncInstanceCreateStatus; -import com.cloud.async.AsyncJobResult; import com.cloud.async.executor.CreatePrivateTemplateResultObject; import com.cloud.serializer.SerializerHelper; import com.cloud.server.Criteria; @@ -111,7 +109,7 @@ public class CreateTemplateCmd extends BaseCmd { boolean isAdmin = ((account == null) || isAdmin(account.getType())); 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"); } } else if ((account != null) && !getManagementServer().isChildDomain(account.getDomainId(), volume.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/CreateVolumeCmd.java b/server/src/com/cloud/api/commands/CreateVolumeCmd.java index d9426d61852..2733228d4e4 100644 --- a/server/src/com/cloud/api/commands/CreateVolumeCmd.java +++ b/server/src/com/cloud/api/commands/CreateVolumeCmd.java @@ -165,7 +165,7 @@ public class CreateVolumeCmd extends BaseCmd { if (!getManagementServer().isChildDomain(account.getDomainId(), snapshotOwner.getDomainId())) { 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"); } } diff --git a/server/src/com/cloud/api/commands/DeleteDomainCmd.java b/server/src/com/cloud/api/commands/DeleteDomainCmd.java index 7ff5f1691e1..ffd5b9b470d 100644 --- a/server/src/com/cloud/api/commands/DeleteDomainCmd.java +++ b/server/src/com/cloud/api/commands/DeleteDomainCmd.java @@ -18,15 +18,15 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -61,12 +61,12 @@ public class DeleteDomainCmd extends BaseCmd{ 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."); } // check if domain exists in the system - DomainVO domain = getManagementServer().findDomainIdById(domainId); + Domain domain = getManagementServer().findDomainIdById(domainId); if (domain == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find domain " + domainId); } diff --git a/server/src/com/cloud/api/commands/DeleteIPForwardingRuleCmd.java b/server/src/com/cloud/api/commands/DeleteIPForwardingRuleCmd.java index 9b9af0c6c82..d5e3079da0e 100644 --- a/server/src/com/cloud/api/commands/DeleteIPForwardingRuleCmd.java +++ b/server/src/com/cloud/api/commands/DeleteIPForwardingRuleCmd.java @@ -18,22 +18,22 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - -import com.cloud.api.BaseCmd; -import com.cloud.api.ServerApiException; -import com.cloud.exception.InternalErrorException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.PermissionDeniedException; -import com.cloud.network.FirewallRuleVO; -import com.cloud.network.IPAddressVO; -import com.cloud.user.Account; -import com.cloud.user.User; -import com.cloud.utils.Pair; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.cloud.api.BaseCmd; +import com.cloud.api.ServerApiException; +import com.cloud.exception.InternalErrorException; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.exception.PermissionDeniedException; +import com.cloud.network.FirewallRuleVO; +import com.cloud.network.IPAddressVO; +import com.cloud.user.Account; +import com.cloud.user.User; +import com.cloud.utils.Pair; public class DeleteIPForwardingRuleCmd extends BaseCmd { 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())) { 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."); } } try { - getManagementServer().deleteRule(ruleId.longValue(), userId.longValue(), ruleOwner.getId().longValue()); + getManagementServer().deleteRule(ruleId.longValue(), userId.longValue(), ruleOwner.getId()); } catch (InvalidParameterValueException ex1) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to delete port forwarding rule " + ruleId + ", internal error."); } catch (PermissionDeniedException ex2) { diff --git a/server/src/com/cloud/api/commands/DeleteIsoCmd.java b/server/src/com/cloud/api/commands/DeleteIsoCmd.java index de376b2be5a..1ad54de6a95 100644 --- a/server/src/com/cloud/api/commands/DeleteIsoCmd.java +++ b/server/src/com/cloud/api/commands/DeleteIsoCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.storage.VMTemplateVO; @@ -74,7 +74,7 @@ public class DeleteIsoCmd extends BaseCmd { if (account != null) { 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); } } else { diff --git a/server/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java b/server/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java index 3330d3d9278..76deabc42e3 100644 --- a/server/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java +++ b/server/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; 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); } else if (account != null) { 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 + ")"); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/DeletePortForwardingServiceCmd.java b/server/src/com/cloud/api/commands/DeletePortForwardingServiceCmd.java index 72d92be15d5..72c161bcd1f 100644 --- a/server/src/com/cloud/api/commands/DeletePortForwardingServiceCmd.java +++ b/server/src/com/cloud/api/commands/DeletePortForwardingServiceCmd.java @@ -68,7 +68,7 @@ public class DeletePortForwardingServiceCmd extends BaseCmd { if (account != null) { 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"); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), sg.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/DestroyVMCmd.java b/server/src/com/cloud/api/commands/DestroyVMCmd.java index 7cd4414b9d5..e987c57236e 100644 --- a/server/src/com/cloud/api/commands/DestroyVMCmd.java +++ b/server/src/com/cloud/api/commands/DestroyVMCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -64,7 +64,7 @@ public class DestroyVMCmd extends BaseCmd { if (account != null) { 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"); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/DetachIsoCmd.java b/server/src/com/cloud/api/commands/DetachIsoCmd.java index 0b443a98a4f..ec5324d504d 100644 --- a/server/src/com/cloud/api/commands/DetachIsoCmd.java +++ b/server/src/com/cloud/api/commands/DetachIsoCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -66,7 +66,7 @@ public class DetachIsoCmd extends BaseCmd { if (account != null) { 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"); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstanceCheck.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/DisableAccountCmd.java b/server/src/com/cloud/api/commands/DisableAccountCmd.java index 8b3b63478eb..75fed4bcdfe 100644 --- a/server/src/com/cloud/api/commands/DisableAccountCmd.java +++ b/server/src/com/cloud/api/commands/DisableAccountCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -66,11 +66,11 @@ public class DisableAccountCmd extends BaseCmd { } // 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"); } - long jobId = getManagementServer().disableAccountAsync(account.getId().longValue()); + long jobId = getManagementServer().disableAccountAsync(account.getId()); if (jobId == 0) { s_logger.warn("Unable to schedule async-job for DisableAccount comamnd"); } else { diff --git a/server/src/com/cloud/api/commands/DisableUserCmd.java b/server/src/com/cloud/api/commands/DisableUserCmd.java index b16c360c1c5..c16872a735e 100644 --- a/server/src/com/cloud/api/commands/DisableUserCmd.java +++ b/server/src/com/cloud/api/commands/DisableUserCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; 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 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"); } diff --git a/server/src/com/cloud/api/commands/DisassociateIPAddrCmd.java b/server/src/com/cloud/api/commands/DisassociateIPAddrCmd.java index 678f8f73068..56a651dfeb4 100644 --- a/server/src/com/cloud/api/commands/DisassociateIPAddrCmd.java +++ b/server/src/com/cloud/api/commands/DisassociateIPAddrCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.exception.PermissionDeniedException; @@ -66,7 +66,7 @@ public class DisassociateIPAddrCmd extends BaseCmd { Long accountId = accountByIp.getId(); if (account != null) { 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); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), accountByIp.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/EnableAccountCmd.java b/server/src/com/cloud/api/commands/EnableAccountCmd.java index 2d718e2f35f..4b3b933a79d 100644 --- a/server/src/com/cloud/api/commands/EnableAccountCmd.java +++ b/server/src/com/cloud/api/commands/EnableAccountCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -67,13 +67,13 @@ public class EnableAccountCmd extends BaseCmd { } // 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"); } boolean success = true; try { - success = getManagementServer().enableAccount(account.getId().longValue()); + success = getManagementServer().enableAccount(account.getId()); } catch (Exception 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); diff --git a/server/src/com/cloud/api/commands/ListAccountsCmd.java b/server/src/com/cloud/api/commands/ListAccountsCmd.java index 46d6dc0cb17..294248fabd0 100644 --- a/server/src/com/cloud/api/commands/ListAccountsCmd.java +++ b/server/src/com/cloud/api/commands/ListAccountsCmd.java @@ -28,7 +28,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.configuration.ResourceCount.ResourceType; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.server.Criteria; import com.cloud.user.Account; import com.cloud.user.AccountVO; @@ -84,7 +84,7 @@ public class ListAccountsCmd extends BaseCmd{ isAdmin = true; if (domainId == null) { // 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) { if (!getManagementServer().isChildDomain(account.getDomainId(), domainId)) { 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(BaseCmd.Properties.ID.getName(), Long.valueOf(accountO.getId()).toString())); accountData.add(new Pair(BaseCmd.Properties.NAME.getName(), accountO.getAccountName())); accountData.add(new Pair(BaseCmd.Properties.ACCOUNT_TYPE.getName(), Short.valueOf(accountO.getType()).toString())); - DomainVO domain = getManagementServer().findDomainIdById(accountO.getDomainId()); - accountData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), domain.getId().toString())); + Domain domain = getManagementServer().findDomainIdById(accountO.getDomainId()); + accountData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(domain.getId()))); accountData.add(new Pair(BaseCmd.Properties.DOMAIN.getName(), domain.getName())); //get network stat diff --git a/server/src/com/cloud/api/commands/ListDomainChildrenCmd.java b/server/src/com/cloud/api/commands/ListDomainChildrenCmd.java index 3e3150f56b4..6e17f9a862a 100644 --- a/server/src/com/cloud/api/commands/ListDomainChildrenCmd.java +++ b/server/src/com/cloud/api/commands/ListDomainChildrenCmd.java @@ -26,7 +26,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.server.Criteria; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -101,16 +101,16 @@ public class ListDomainChildrenCmd extends BaseCmd { } // TODO : Recursive listing is not supported yet - List domains = getManagementServer().searchForDomainChildren(c); + List domains = getManagementServer().searchForDomainChildren(c); List> domainTags = new ArrayList>(); Object[] dTag = new Object[domains.size()]; int i = 0; - for (DomainVO domain : domains) { + for (Domain domain : domains) { List> domainData = new ArrayList>(); domainData.add(new Pair(BaseCmd.Properties.ID.getName(), Long.valueOf(domain.getId()).toString())); domainData.add(new Pair(BaseCmd.Properties.NAME.getName(), domain.getName())); - domainData.add(new Pair(BaseCmd.Properties.LEVEL.getName(), domain.getLevel().toString())); + domainData.add(new Pair(BaseCmd.Properties.LEVEL.getName(), Integer.toString(domain.getLevel()))); domainData.add(new Pair(BaseCmd.Properties.HAS_CHILD.getName(), (domain.getChildCount()) > 0 ? "true" : "false")); diff --git a/server/src/com/cloud/api/commands/ListDomainsCmd.java b/server/src/com/cloud/api/commands/ListDomainsCmd.java index 42c0576fb9c..6b503a14fee 100644 --- a/server/src/com/cloud/api/commands/ListDomainsCmd.java +++ b/server/src/com/cloud/api/commands/ListDomainsCmd.java @@ -26,7 +26,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.server.Criteria; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -95,16 +95,16 @@ public class ListDomainsCmd extends BaseCmd { c.addCriteria(Criteria.LEVEL, level); } - List domains = getManagementServer().searchForDomains(c); + List domains = getManagementServer().searchForDomains(c); List> domainTags = new ArrayList>(); Object[] dTag = new Object[domains.size()]; int i = 0; - for (DomainVO domain : domains) { + for (Domain domain : domains) { List> domainData = new ArrayList>(); domainData.add(new Pair(BaseCmd.Properties.ID.getName(), Long.valueOf(domain.getId()).toString())); domainData.add(new Pair(BaseCmd.Properties.NAME.getName(), domain.getName())); - domainData.add(new Pair(BaseCmd.Properties.LEVEL.getName(), domain.getLevel().toString())); + domainData.add(new Pair(BaseCmd.Properties.LEVEL.getName(), Integer.toString(domain.getLevel()))); if (domain.getParent() != null){ domainData.add(new Pair(BaseCmd.Properties.PARENT_DOMAIN_ID.getName(), domain.getParent().toString())); diff --git a/server/src/com/cloud/api/commands/ListEventsCmd.java b/server/src/com/cloud/api/commands/ListEventsCmd.java index 7cefef97c4a..8b8e0b14a43 100644 --- a/server/src/com/cloud/api/commands/ListEventsCmd.java +++ b/server/src/com/cloud/api/commands/ListEventsCmd.java @@ -18,13 +18,13 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.domain.DomainVO; @@ -165,7 +165,7 @@ public class ListEventsCmd extends BaseCmd { Account acct = getManagementServer().findAccountById(Long.valueOf(event.getAccountId())); if (acct != null) { eventData.add(new Pair(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName())); - eventData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString())); + eventData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(acct.getDomainId()))); eventData.add(new Pair(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName())); } if (event.getCreateDate() != null) { diff --git a/server/src/com/cloud/api/commands/ListIsosCmd.java b/server/src/com/cloud/api/commands/ListIsosCmd.java index 939525a1a3a..26c3fdbd1ec 100644 --- a/server/src/com/cloud/api/commands/ListIsosCmd.java +++ b/server/src/com/cloud/api/commands/ListIsosCmd.java @@ -33,8 +33,8 @@ import com.cloud.domain.DomainVO; import com.cloud.host.HostVO; import com.cloud.storage.GuestOS; import com.cloud.storage.VMTemplateHostVO; -import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; +import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao.TemplateFilter; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -216,7 +216,7 @@ public class ListIsosCmd extends BaseCmd { isoData.add(new Pair(BaseCmd.Properties.ZONE_NAME.getName(), datacenter.getName())); // 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 if (isoHost.getDownloadState()!=Status.DOWNLOADED) { String isoStatus = "Processing"; diff --git a/server/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java b/server/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java index 3bc40f0827d..420fbe29b63 100644 --- a/server/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java +++ b/server/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java @@ -74,7 +74,7 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseCmd { if (!getManagementServer().isChildDomain(account.getDomainId(), userAccount.getDomainId())) { 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()); } } diff --git a/server/src/com/cloud/api/commands/ListNetworkGroupsCmd.java b/server/src/com/cloud/api/commands/ListNetworkGroupsCmd.java index f1668d98e8f..fe2ba276ab1 100644 --- a/server/src/com/cloud/api/commands/ListNetworkGroupsCmd.java +++ b/server/src/com/cloud/api/commands/ListNetworkGroupsCmd.java @@ -95,7 +95,7 @@ public class ListNetworkGroupsCmd extends BaseCmd { if (account != null) { // 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."); } } diff --git a/server/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java b/server/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java index 68aa5407757..f16c870f2cc 100644 --- a/server/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java +++ b/server/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java @@ -77,7 +77,7 @@ public class ListPortForwardingRulesCmd extends BaseCmd { } } else { 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()); } addrOwner = account; diff --git a/server/src/com/cloud/api/commands/ListPortForwardingServiceRulesCmd.java b/server/src/com/cloud/api/commands/ListPortForwardingServiceRulesCmd.java index 3addbf14a22..2e3b1787b6d 100644 --- a/server/src/com/cloud/api/commands/ListPortForwardingServiceRulesCmd.java +++ b/server/src/com/cloud/api/commands/ListPortForwardingServiceRulesCmd.java @@ -85,7 +85,7 @@ public class ListPortForwardingServiceRulesCmd extends BaseCmd { if ((groupId != null) && (accountId != null)) { SecurityGroupVO sg = getManagementServer().findSecurityGroupById(groupId); 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); } } else { diff --git a/server/src/com/cloud/api/commands/ListRecurringSnapshotScheduleCmd.java b/server/src/com/cloud/api/commands/ListRecurringSnapshotScheduleCmd.java index f3a11ab6037..23c92148768 100644 --- a/server/src/com/cloud/api/commands/ListRecurringSnapshotScheduleCmd.java +++ b/server/src/com/cloud/api/commands/ListRecurringSnapshotScheduleCmd.java @@ -18,10 +18,10 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.storage.SnapshotScheduleVO; @@ -65,7 +65,7 @@ public class ListRecurringSnapshotScheduleCmd extends BaseCmd { if (!getManagementServer().isChildDomain(account.getDomainId(), userAccount.getDomainId())) { 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); } } diff --git a/server/src/com/cloud/api/commands/ListServiceOfferingsCmd.java b/server/src/com/cloud/api/commands/ListServiceOfferingsCmd.java index 8a690c60809..e7d97615452 100644 --- a/server/src/com/cloud/api/commands/ListServiceOfferingsCmd.java +++ b/server/src/com/cloud/api/commands/ListServiceOfferingsCmd.java @@ -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); } 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"); } } diff --git a/server/src/com/cloud/api/commands/ListSnapshotsCmd.java b/server/src/com/cloud/api/commands/ListSnapshotsCmd.java index a71e5b7b36c..99f674276f3 100644 --- a/server/src/com/cloud/api/commands/ListSnapshotsCmd.java +++ b/server/src/com/cloud/api/commands/ListSnapshotsCmd.java @@ -30,9 +30,9 @@ import com.cloud.async.AsyncJobVO; import com.cloud.exception.InvalidParameterValueException; import com.cloud.server.Criteria; import com.cloud.storage.Snapshot; +import com.cloud.storage.Snapshot.SnapshotType; import com.cloud.storage.SnapshotVO; import com.cloud.storage.VolumeVO; -import com.cloud.storage.Snapshot.SnapshotType; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -141,7 +141,7 @@ public class ListSnapshotsCmd extends BaseCmd { Account acct = getManagementServer().findAccountById(Long.valueOf(snapshot.getAccountId())); if (acct != null) { snapshotData.add(new Pair(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName())); - snapshotData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString())); + snapshotData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(acct.getDomainId()))); snapshotData.add(new Pair(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName())); } volumeId = snapshot.getVolumeId(); diff --git a/server/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java b/server/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java index 438236efa00..474f1541eb1 100644 --- a/server/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java +++ b/server/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java @@ -8,7 +8,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.storage.VMTemplateVO; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -86,9 +86,9 @@ public class ListTemplateOrIsoPermissionsCmd extends BaseCmd { 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); } 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()); - DomainVO templateDomain = getManagementServer().findDomainIdById(templateAccount.getDomainId()); + Domain templateDomain = getManagementServer().findDomainIdById(templateAccount.getDomainId()); if (!templateDomain.getPath().contains(accountDomain.getPath())) { throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "unable to list permissions for " + getMediaType() + " with id " + id); } diff --git a/server/src/com/cloud/api/commands/ListTemplatesCmd.java b/server/src/com/cloud/api/commands/ListTemplatesCmd.java index a3067e05fc9..b55fe57ce0d 100644 --- a/server/src/com/cloud/api/commands/ListTemplatesCmd.java +++ b/server/src/com/cloud/api/commands/ListTemplatesCmd.java @@ -31,8 +31,8 @@ import com.cloud.dc.DataCenterVO; import com.cloud.host.HostVO; import com.cloud.storage.GuestOS; import com.cloud.storage.VMTemplateHostVO; -import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; +import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao.TemplateFilter; import com.cloud.storage.template.TemplateConstants; import com.cloud.user.Account; @@ -196,7 +196,7 @@ public class ListTemplatesCmd extends BaseCmd { templateData.add(new Pair(BaseCmd.Properties.ZONE_NAME.getName(), datacenter.getName())); // 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 if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) { String templateStatus = "Processing"; diff --git a/server/src/com/cloud/api/commands/ListVMsCmd.java b/server/src/com/cloud/api/commands/ListVMsCmd.java index 1f87433f8fa..e8d3bc2eee5 100644 --- a/server/src/com/cloud/api/commands/ListVMsCmd.java +++ b/server/src/com/cloud/api/commands/ListVMsCmd.java @@ -185,7 +185,7 @@ public class ListVMsCmd extends BaseCmd { Account acct = getManagementServer().findAccountById(Long.valueOf(vmInstance.getAccountId())); if (acct != null) { vmData.add(new Pair(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName())); - vmData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString())); + vmData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), Long.toString(acct.getDomainId()))); vmData.add(new Pair(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName())); } vmData.add(new Pair(BaseCmd.Properties.HA_ENABLE.getName(), Boolean.valueOf(vmInstance.isHaEnabled()).toString())); diff --git a/server/src/com/cloud/api/commands/ListZonesByCmd.java b/server/src/com/cloud/api/commands/ListZonesByCmd.java index e15687ea88d..72acbac152a 100644 --- a/server/src/com/cloud/api/commands/ListZonesByCmd.java +++ b/server/src/com/cloud/api/commands/ListZonesByCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.dc.DataCenterVO; @@ -62,7 +62,7 @@ public class ListZonesByCmd extends BaseCmd { if (available != null && available) { dataCenters = getManagementServer().listDataCenters(); } else { - dataCenters = getManagementServer().listDataCentersBy(account.getId().longValue()); + dataCenters = getManagementServer().listDataCentersBy(account.getId()); } } else { // available is kinda useless in this case because we can't exactly list by diff --git a/server/src/com/cloud/api/commands/LockAccountCmd.java b/server/src/com/cloud/api/commands/LockAccountCmd.java index 397ec3d8eca..b1d8d3f89f0 100644 --- a/server/src/com/cloud/api/commands/LockAccountCmd.java +++ b/server/src/com/cloud/api/commands/LockAccountCmd.java @@ -17,16 +17,16 @@ */ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - -import com.cloud.api.BaseCmd; -import com.cloud.api.ServerApiException; -import com.cloud.user.Account; -import com.cloud.utils.Pair; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.cloud.api.BaseCmd; +import com.cloud.api.ServerApiException; +import com.cloud.user.Account; +import com.cloud.utils.Pair; public class LockAccountCmd extends BaseCmd { 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 - 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"); } - boolean success = getManagementServer().lockAccount(account.getId().longValue()); + boolean success = getManagementServer().lockAccount(account.getId()); List> returnValues = new ArrayList>(); returnValues.add(new Pair(BaseCmd.Properties.SUCCESS.getName(), Boolean.valueOf(success).toString())); return returnValues; diff --git a/server/src/com/cloud/api/commands/RebootVMCmd.java b/server/src/com/cloud/api/commands/RebootVMCmd.java index 37595f62d2b..05c304a4faa 100644 --- a/server/src/com/cloud/api/commands/RebootVMCmd.java +++ b/server/src/com/cloud/api/commands/RebootVMCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -62,7 +62,7 @@ public class RebootVMCmd extends BaseCmd { } 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"); } else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) { // the domain in which the VM lives is not in the admin's domain tree diff --git a/server/src/com/cloud/api/commands/RegisterIsoCmd.java b/server/src/com/cloud/api/commands/RegisterIsoCmd.java index 076b729a34a..f6de4345ccd 100644 --- a/server/src/com/cloud/api/commands/RegisterIsoCmd.java +++ b/server/src/com/cloud/api/commands/RegisterIsoCmd.java @@ -27,11 +27,11 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; 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.ImageFormat; +import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; +import com.cloud.storage.VMTemplateVO; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -86,7 +86,7 @@ public class RegisterIsoCmd extends BaseCmd { long accountId = 1L; // default to system account if (account != null) { - accountId = account.getId().longValue(); + accountId = account.getId(); } Account accountObj; diff --git a/server/src/com/cloud/api/commands/RegisterTemplateCmd.java b/server/src/com/cloud/api/commands/RegisterTemplateCmd.java index a7ed60f51a3..c3a8439ec13 100644 --- a/server/src/com/cloud/api/commands/RegisterTemplateCmd.java +++ b/server/src/com/cloud/api/commands/RegisterTemplateCmd.java @@ -105,7 +105,7 @@ public class RegisterTemplateCmd extends BaseCmd { long accountId = 1L; // default to system account if (account != null) { - accountId = account.getId().longValue(); + accountId = account.getId(); } Account accountObj; diff --git a/server/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java b/server/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java index b2fb11392dc..2052eb72c89 100644 --- a/server/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java +++ b/server/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java @@ -18,13 +18,13 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.network.LoadBalancerVO; @@ -92,7 +92,7 @@ public class RemoveFromLoadBalancerRuleCmd extends BaseCmd { if (loadBalancer == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find load balancer rule with id " + loadBalancerId); } 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() + " (id:" + loadBalancer.getId() + ")"); } else if (!getManagementServer().isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/RemovePortForwardingServiceCmd.java b/server/src/com/cloud/api/commands/RemovePortForwardingServiceCmd.java index 0f3929afd14..4ceb43e8eb5 100644 --- a/server/src/com/cloud/api/commands/RemovePortForwardingServiceCmd.java +++ b/server/src/com/cloud/api/commands/RemovePortForwardingServiceCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.network.SecurityGroupVO; @@ -66,7 +66,7 @@ public class RemovePortForwardingServiceCmd extends BaseCmd { if (securityG == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a port forwarding service with id " + securityGroupId); } 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"); } 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."); @@ -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); } 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"); } 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."); @@ -96,7 +96,7 @@ public class RemovePortForwardingServiceCmd extends BaseCmd { Long accountId = ipAddrAccount.getId(); 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); } } diff --git a/server/src/com/cloud/api/commands/ResetVMPasswordCmd.java b/server/src/com/cloud/api/commands/ResetVMPasswordCmd.java index 8e458e59904..4d4e0bd939d 100644 --- a/server/src/com/cloud/api/commands/ResetVMPasswordCmd.java +++ b/server/src/com/cloud/api/commands/ResetVMPasswordCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.storage.VMTemplateVO; @@ -65,7 +65,7 @@ public class ResetVMPasswordCmd extends BaseCmd { } 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"); } else if (!getManagementServer().isChildDomain(account.getDomainId(), vmInstance.getDomainId())) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + vmId + ") given, unable to reset password."); diff --git a/server/src/com/cloud/api/commands/StartVMCmd.java b/server/src/com/cloud/api/commands/StartVMCmd.java index 33a97a78280..6c70304d573 100644 --- a/server/src/com/cloud/api/commands/StartVMCmd.java +++ b/server/src/com/cloud/api/commands/StartVMCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -72,7 +72,7 @@ public class StartVMCmd extends BaseCmd { } 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"); } 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."); diff --git a/server/src/com/cloud/api/commands/StopVMCmd.java b/server/src/com/cloud/api/commands/StopVMCmd.java index 254c510da83..e49c13fa23a 100644 --- a/server/src/com/cloud/api/commands/StopVMCmd.java +++ b/server/src/com/cloud/api/commands/StopVMCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -63,7 +63,7 @@ public class StopVMCmd extends BaseCmd { } 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"); } 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."); diff --git a/server/src/com/cloud/api/commands/UpdateAccountCmd.java b/server/src/com/cloud/api/commands/UpdateAccountCmd.java index 8960475be0a..f4684de5cfa 100644 --- a/server/src/com/cloud/api/commands/UpdateAccountCmd.java +++ b/server/src/com/cloud/api/commands/UpdateAccountCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -70,7 +70,7 @@ public class UpdateAccountCmd extends BaseCmd{ } // 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"); } diff --git a/server/src/com/cloud/api/commands/UpdateDomainCmd.java b/server/src/com/cloud/api/commands/UpdateDomainCmd.java index 05c6d7ae063..97bc78dd744 100644 --- a/server/src/com/cloud/api/commands/UpdateDomainCmd.java +++ b/server/src/com/cloud/api/commands/UpdateDomainCmd.java @@ -26,7 +26,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.user.Account; import com.cloud.utils.Pair; @@ -58,7 +58,7 @@ public class UpdateDomainCmd extends BaseCmd{ Boolean editDomainResult = false; //check if domain exists in the system - DomainVO domain = getManagementServer().findDomainIdById(domainId); + Domain domain = getManagementServer().findDomainIdById(domainId); if (domain == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find domain " + domainId); } else if (domain.getParent() == null) { diff --git a/server/src/com/cloud/api/commands/UpdateIPForwardingRuleCmd.java b/server/src/com/cloud/api/commands/UpdateIPForwardingRuleCmd.java index 41f5cd55069..f810b3e9a85 100644 --- a/server/src/com/cloud/api/commands/UpdateIPForwardingRuleCmd.java +++ b/server/src/com/cloud/api/commands/UpdateIPForwardingRuleCmd.java @@ -103,7 +103,7 @@ public class UpdateIPForwardingRuleCmd extends BaseCmd { 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."); } - } 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."); } } diff --git a/server/src/com/cloud/api/commands/UpdateIsoCmd.java b/server/src/com/cloud/api/commands/UpdateIsoCmd.java index 887e593cd77..b85b4f495e9 100644 --- a/server/src/com/cloud/api/commands/UpdateIsoCmd.java +++ b/server/src/com/cloud/api/commands/UpdateIsoCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.storage.Storage; @@ -73,7 +73,7 @@ public class UpdateIsoCmd extends BaseCmd { if (account != null) { Long isoOwner = iso.getAccountId(); 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); } } else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) { diff --git a/server/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java b/server/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java index 586d28d4fa6..1e4d0720d74 100644 --- a/server/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java +++ b/server/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java @@ -63,7 +63,7 @@ public class UpdateLoadBalancerRuleCmd extends BaseCmd { Long accountId = lbOwner.getId(); if (account != null) { 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"); } } else if (!getManagementServer().isChildDomain(account.getDomainId(), lbOwner.getDomainId())) { diff --git a/server/src/com/cloud/api/commands/UpdateVMCmd.java b/server/src/com/cloud/api/commands/UpdateVMCmd.java index 3f31927911b..6269e453fea 100644 --- a/server/src/com/cloud/api/commands/UpdateVMCmd.java +++ b/server/src/com/cloud/api/commands/UpdateVMCmd.java @@ -18,12 +18,12 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.user.Account; @@ -80,7 +80,7 @@ public class UpdateVMCmd extends BaseCmd{ } 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"); } 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."); diff --git a/server/src/com/cloud/api/commands/UpgradeVMCmd.java b/server/src/com/cloud/api/commands/UpgradeVMCmd.java index b1a5d6ee643..115a6122e92 100644 --- a/server/src/com/cloud/api/commands/UpgradeVMCmd.java +++ b/server/src/com/cloud/api/commands/UpgradeVMCmd.java @@ -18,16 +18,15 @@ package com.cloud.api.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.exception.InvalidParameterValueException; -import com.cloud.service.ServiceOfferingVO; import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.utils.Pair; @@ -71,7 +70,7 @@ public class UpgradeVMCmd extends BaseCmd { } 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"); } 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."); diff --git a/server/src/com/cloud/async/executor/CopyTemplateExecutor.java b/server/src/com/cloud/async/executor/CopyTemplateExecutor.java index 044041e0763..ba65f105610 100644 --- a/server/src/com/cloud/async/executor/CopyTemplateExecutor.java +++ b/server/src/com/cloud/async/executor/CopyTemplateExecutor.java @@ -27,14 +27,13 @@ import com.cloud.async.AsyncJobResult; import com.cloud.async.AsyncJobVO; import com.cloud.async.BaseAsyncJobExecutor; import com.cloud.dc.DataCenterVO; -import com.cloud.domain.DomainVO; +import com.cloud.domain.Domain; import com.cloud.serializer.GsonHelper; import com.cloud.server.ManagementServer; import com.cloud.storage.VMTemplateHostVO; -import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; +import com.cloud.storage.VMTemplateVO; import com.cloud.user.Account; -import com.cloud.utils.Pair; import com.google.gson.Gson; public class CopyTemplateExecutor extends BaseAsyncJobExecutor { @@ -58,7 +57,7 @@ public class CopyTemplateExecutor extends BaseAsyncJobExecutor { VMTemplateHostVO templateHostRef = managementServer.findTemplateHostRef(param.getTemplateId(), destZone.getId()); long guestOsId = template.getGuestOSId(); Account owner = managementServer.findAccountById(template.getAccountId()); - DomainVO domain = managementServer.findDomainIdById(owner.getDomainId()); + Domain domain = managementServer.findDomainIdById(owner.getDomainId()); String guestOSName = managementServer.findGuestOSById(guestOsId).getName(); asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, composeResultObject(template, templateHostRef, destZone,guestOSName, owner, domain)); } else { @@ -82,7 +81,7 @@ public class CopyTemplateExecutor extends BaseAsyncJobExecutor { 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(); @@ -92,7 +91,7 @@ public class CopyTemplateExecutor extends BaseAsyncJobExecutor { if(owner.getType() == Account.ACCOUNT_TYPE_ADMIN) isAdmin = true; - if (isAdmin || owner.getId().longValue() == template.getAccountId()) { + if (isAdmin || owner.getId() == template.getAccountId()) { // add download status if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) { String templateStatus = "Processing"; diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 64d1179a2cd..80ad3568233 100644 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -72,8 +72,8 @@ import com.cloud.configuration.dao.ResourceLimitDao; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.dc.Vlan; -import com.cloud.dc.VlanVO; import com.cloud.dc.Vlan.VlanType; +import com.cloud.dc.VlanVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.HostPodDao; 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.net.NetUtils; import com.cloud.vm.DomainRouter; +import com.cloud.vm.DomainRouter.Role; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.State; import com.cloud.vm.UserVmVO; import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachine.Event; import com.cloud.vm.VirtualMachineManager; 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.UserVmDao; @@ -588,7 +588,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager guestIpAddress, guestNetmask, accountId, - account.getDomainId().longValue(), + account.getDomainId(), publicMacAddress, publicIpAddress, vlanNetmask, diff --git a/server/src/com/cloud/network/NetworkProfileVO.java b/server/src/com/cloud/network/NetworkProfileVO.java index 9956014b8e2..081803e8c63 100644 --- a/server/src/com/cloud/network/NetworkProfileVO.java +++ b/server/src/com/cloud/network/NetworkProfileVO.java @@ -29,6 +29,7 @@ import javax.persistence.Table; import com.cloud.network.Network.BroadcastDomainType; import com.cloud.network.Network.Mode; import com.cloud.network.Network.TrafficType; +import com.cloud.user.OwnedBy; /** * NetworkProfileVO contains information about a specific network. @@ -36,7 +37,7 @@ import com.cloud.network.Network.TrafficType; */ @Entity @Table(name="network_profile") -public class NetworkProfileVO { +public class NetworkProfileVO implements OwnedBy { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) long id; @@ -81,6 +82,7 @@ public class NetworkProfileVO { this.mode = mode; } + @Override public long getAccountId() { return accountId; } diff --git a/server/src/com/cloud/network/security/NetworkGroupManagerImpl.java b/server/src/com/cloud/network/security/NetworkGroupManagerImpl.java index 96ad145c1b6..afc5bab16a3 100644 --- a/server/src/com/cloud/network/security/NetworkGroupManagerImpl.java +++ b/server/src/com/cloud/network/security/NetworkGroupManagerImpl.java @@ -105,7 +105,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager { Comparator { @Override 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; } } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 25c49f3ba68..54883bb42a6 100644 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -101,15 +101,15 @@ import com.cloud.async.executor.SecurityGroupParam; import com.cloud.async.executor.UpdateLoadBalancerParam; import com.cloud.async.executor.UpgradeVMParam; import com.cloud.async.executor.VMOperationParam; -import com.cloud.async.executor.VolumeOperationParam; import com.cloud.async.executor.VMOperationParam.VmOp; +import com.cloud.async.executor.VolumeOperationParam; import com.cloud.async.executor.VolumeOperationParam.VolumeOp; import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationVO; -import com.cloud.configuration.ResourceLimitVO; import com.cloud.configuration.ResourceCount.ResourceType; +import com.cloud.configuration.ResourceLimitVO; import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.configuration.dao.ResourceLimitDao; import com.cloud.consoleproxy.ConsoleProxyManager; @@ -119,8 +119,8 @@ import com.cloud.dc.DataCenterIpAddressVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.dc.PodVlanMapVO; -import com.cloud.dc.VlanVO; import com.cloud.dc.Vlan.VlanType; +import com.cloud.dc.VlanVO; import com.cloud.dc.dao.AccountVlanMapDao; import com.cloud.dc.dao.ClusterDao; 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.PodVlanMapDao; import com.cloud.dc.dao.VlanDao; +import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; import com.cloud.event.EventState; @@ -186,10 +187,13 @@ import com.cloud.storage.GuestOSCategoryVO; import com.cloud.storage.GuestOSVO; import com.cloud.storage.LaunchPermissionVO; import com.cloud.storage.Snapshot; +import com.cloud.storage.Snapshot.SnapshotType; import com.cloud.storage.SnapshotPolicyVO; import com.cloud.storage.SnapshotScheduleVO; import com.cloud.storage.SnapshotVO; 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.StoragePoolHostVO; import com.cloud.storage.StoragePoolVO; @@ -197,12 +201,9 @@ import com.cloud.storage.StorageStats; import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateStorageResourceAssoc; import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.Volume.VolumeType; import com.cloud.storage.VolumeStats; 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.DiskTemplateDao; 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.StoragePoolHostDao; import com.cloud.storage.dao.VMTemplateDao; +import com.cloud.storage.dao.VMTemplateDao.TemplateFilter; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.dao.VolumeDao; -import com.cloud.storage.dao.VMTemplateDao.TemplateFilter; import com.cloud.storage.preallocatedlun.PreallocatedLunVO; import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDao; 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.uservm.UserVm; import com.cloud.utils.DateUtil; +import com.cloud.utils.DateUtil.IntervalType; import com.cloud.utils.EnumUtils; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.PasswordGenerator; import com.cloud.utils.StringUtils; -import com.cloud.utils.DateUtil.IntervalType; import com.cloud.utils.component.Adapters; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.concurrency.NamedThreadFactory; @@ -979,7 +980,7 @@ public class ManagementServerImpl implements ManagementServer { _securityGroupVMMapDao.delete(sc); // now clean the network rules and security groups themselves - _networkRuleConfigDao.deleteBySecurityGroup(securityGroup.getId().longValue()); + _networkRuleConfigDao.deleteBySecurityGroup(securityGroup.getId()); _securityGroupDao.remove(securityGroup.getId()); } } @@ -1450,7 +1451,7 @@ public class ManagementServerImpl implements ManagementServer { txn.start(); List ipAddrsList = new ArrayList(); 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(); _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))) { // 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 - LaunchPermissionVO permission = _launchPermissionDao.findByTemplateAndAccount(templateId, account.getId().longValue()); + LaunchPermissionVO permission = _launchPermissionDao.findByTemplateAndAccount(templateId, account.getId()); if (permission == null) { 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()); if (account != null) { 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"); } } else if (!isChildDomain(account.getDomainId(), sg.getDomainId())) { @@ -3578,7 +3579,7 @@ public class ManagementServerImpl implements ManagementServer { } } if (sg != null) { - accountId = sg.getAccountId().longValue(); + accountId = sg.getAccountId(); } } else { return 0L; // failed to delete due to netRule not found @@ -6183,7 +6184,7 @@ public class ManagementServerImpl implements ManagementServer { return _consoleProxyDao.findById(instanceId); } - public List searchForDomains(Criteria c) { + public List searchForDomains(Criteria c) { Filter searchFilter = new Filter(DomainVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit()); Long domainId = (Long) c.getCriteria(Criteria.ID); String domainName = (String) c.getCriteria(Criteria.NAME); @@ -6222,7 +6223,7 @@ public class ManagementServerImpl implements ManagementServer { return _domainDao.search(sc, searchFilter); } - public List searchForDomainChildren(Criteria c) { + public List searchForDomainChildren(Criteria c) { Filter searchFilter = new Filter(DomainVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit()); Long domainId = (Long) c.getCriteria(Criteria.ID); String domainName = (String) c.getCriteria(Criteria.NAME); @@ -6323,7 +6324,7 @@ public class ManagementServerImpl implements ManagementServer { // cleanup sub-domains first 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()) { _domainDao.update(domainId, domainName); 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 { 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) { Account permittedAccount = _accountDao.findActiveAccount(accountName, domainId); 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 } - LaunchPermissionVO existingPermission = _launchPermissionDao.findByTemplateAndAccount(templateId, permittedAccount.getId().longValue()); + LaunchPermissionVO existingPermission = _launchPermissionDao.findByTemplateAndAccount(templateId, permittedAccount.getId()); if (existingPermission == null) { - LaunchPermissionVO launchPermission = new LaunchPermissionVO(templateId, permittedAccount.getId().longValue()); + LaunchPermissionVO launchPermission = new LaunchPermissionVO(templateId, permittedAccount.getId()); _launchPermissionDao.persist(launchPermission); } } else { diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java index 18bba6c7603..851860f8a04 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java +++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java @@ -18,23 +18,23 @@ package com.cloud.servlet; -import java.io.IOException; +import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; - + import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; - -import org.apache.log4j.Logger; - + +import org.apache.log4j.Logger; + import com.cloud.api.BaseCmd; import com.cloud.host.HostVO; import com.cloud.server.ManagementServer; @@ -297,7 +297,7 @@ public class ConsoleProxyServlet extends HttpServlet { { case User : 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()) s_logger.debug("VM access is denied. VM owner account " + userVm.getAccountId() + " 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) { 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.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 }); } else { requestParameters.put(BaseCmd.Properties.USER_ID.getName(), new String[] { user.getId().toString() }); diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 339ba196377..76091274ccd 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -489,7 +489,7 @@ public class StorageManagerImpl implements StorageManager { volume.setDataCenterId(dc.getId()); volume.setPodId(null); volume.setAccountId(accountId); - volume.setDomainId(account.getDomainId().longValue()); + volume.setDomainId(account.getDomainId()); volume.setMirrorState(MirrorState.NOT_MIRRORED); if (diskOffering != null) { volume.setDiskOfferingId(diskOffering.getId()); @@ -573,7 +573,7 @@ public class StorageManagerImpl implements StorageManager { createdVolume.setPoolType(pool.getPoolType()); createdVolume.setFolder(volumeFolder); createdVolume.setPath(volumeUUID); - createdVolume.setDomainId(account.getDomainId().longValue()); + createdVolume.setDomainId(account.getDomainId()); } else { createdVolume.setStatus(AsyncInstanceCreateStatus.Corrupted); createdVolume.setDestroyed(true); @@ -1577,14 +1577,14 @@ public class StorageManagerImpl implements StorageManager { volume.setDataCenterId(dc.getId()); volume.setPodId(null); volume.setAccountId(accountId); - volume.setDomainId(account.getDomainId().longValue()); + volume.setDomainId(account.getDomainId()); volume.setMirrorState(MirrorState.NOT_MIRRORED); volume.setDiskOfferingId(diskOffering.getId()); volume.setStorageResourceType(Storage.StorageResourceType.STORAGE_POOL); volume.setInstanceId(null); volume.setUpdated(new Date()); volume.setStatus(AsyncInstanceCreateStatus.Creating); - volume.setDomainId(account.getDomainId().longValue()); + volume.setDomainId(account.getDomainId()); volume = _volsDao.persist(volume); AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor(); diff --git a/server/src/com/cloud/user/AccountManager.java b/server/src/com/cloud/user/AccountManager.java index c0392d12aad..e6ac4062236 100644 --- a/server/src/com/cloud/user/AccountManager.java +++ b/server/src/com/cloud/user/AccountManager.java @@ -102,4 +102,6 @@ public interface AccountManager extends Manager { AccountVO getSystemAccount(); + + } diff --git a/server/src/com/cloud/vm/MauriceMoss.java b/server/src/com/cloud/vm/MauriceMoss.java index 2b54c1b90cd..a082aed3fc7 100644 --- a/server/src/com/cloud/vm/MauriceMoss.java +++ b/server/src/com/cloud/vm/MauriceMoss.java @@ -18,6 +18,7 @@ package com.cloud.vm; import java.util.List; +import java.util.Map; import javax.ejb.Local; @@ -35,15 +36,25 @@ public class MauriceMoss implements VmManager { @Inject private StorageManager _storageMgr; @Inject private NetworkManager _networkMgr; - @Override public VMInstanceVO allocate(VMInstanceVO vm, - ServiceOfferingVO serviceOffering, - NetworkOfferingVO[] networkOfferings, - DiskOfferingVO[] diskOffering, + ServiceOfferingVO serviceOffering, + Long rootSize, + List networkOfferings, + Map diskOfferings, DataCenterVO dc, - AccountVO account) { - - return null; + AccountVO owner) { + return null; + } + + public VMInstanceVO allocate(VMInstanceVO vm, + ServiceOfferingVO serviceOffering, + Long rootSize, + List networkOfferings, + DiskOfferingVO dataOffering, + Long dataSize, + DataCenterVO dc, + AccountVO owner) { + return null; } @Override diff --git a/server/src/com/cloud/vm/NicVO.java b/server/src/com/cloud/vm/NicVO.java index 8d6c69a2569..8ff88a2b34b 100644 --- a/server/src/com/cloud/vm/NicVO.java +++ b/server/src/com/cloud/vm/NicVO.java @@ -69,6 +69,15 @@ public class NicVO implements Nic { @Column(name="state") @Enumerated(value=EnumType.STRING) State state; + + @Column(name="name") + String conciergeName; + + @Column(name="reservation_id") + String reservationId; + + @Column(name="device_id") + int deviceId; @Override public String getIp4Address() { @@ -103,4 +112,29 @@ public class NicVO implements Nic { public long getNetworkProfileId() { 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; + } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 14b6a32c94d..283deb48f64 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -137,7 +137,6 @@ import com.cloud.storage.StoragePoolVO; import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.VirtualMachineTemplate.BootloaderType; import com.cloud.storage.Volume; import com.cloud.storage.Volume.VolumeType; 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.VMTemplateHostDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; 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) { 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(), null,null,null, routerId, pod.first().getId(), dataCenterId, @@ -2651,7 +2651,7 @@ public class UserVmManagerImpl implements UserVmManager { } 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) { s_logger.debug("No guest IP available in pod id=" + pod.first().getId()); avoids.add(pod.first().getId()); @@ -2662,7 +2662,7 @@ public class UserVmManagerImpl implements UserVmManager { String externalMacAddress = macAddresses[1]; 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(), null, externalMacAddress, externalVlanDbId, routerId, pod.first().getId(), dataCenterId, @@ -2820,7 +2820,7 @@ public class UserVmManagerImpl implements UserVmManager { publicIpAddr = publicIp.ipaddr; 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, null, externalMacAddress, null, routerId, pod.first().getId(), dataCenterId, diff --git a/server/src/com/cloud/vm/VmManager.java b/server/src/com/cloud/vm/VmManager.java index 59cbbe33ad7..068da4e084d 100644 --- a/server/src/com/cloud/vm/VmManager.java +++ b/server/src/com/cloud/vm/VmManager.java @@ -18,6 +18,7 @@ package com.cloud.vm; import java.util.List; +import java.util.Map; import com.cloud.dc.DataCenterVO; import com.cloud.offerings.NetworkOfferingVO; @@ -31,11 +32,22 @@ import com.cloud.user.AccountVO; public interface VmManager { VMInstanceVO allocate(VMInstanceVO vm, - ServiceOfferingVO serviceOffering, - NetworkOfferingVO[] networkOfferings, - DiskOfferingVO[] diskOffering, + ServiceOfferingVO serviceOffering, + Long rootSize, + List networkOfferings, + Map diskOfferings, + DataCenterVO dc, + AccountVO owner); + + VMInstanceVO allocate(VMInstanceVO vm, + ServiceOfferingVO serviceOffering, + Long rootSize, + List networkOfferings, + DiskOfferingVO dataOffering, + Long dataSize, DataCenterVO dc, - AccountVO account); + AccountVO owner); + void create(VmCharacteristics vm, List disks, List networks); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 8281af4ca75..51a2aa4d9c2 100644 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -97,6 +97,9 @@ CREATE TABLE `cloud`.`nics` ( `network_profile_id` bigint unsigned NOT NULL COMMENT 'network id', `vlan` varchar(64) COMMENT 'Virtualized network identifier', `state` varchar(32) NOT NULL COMMENT 'state of the creation', + `name` varchar(64) COMMENT 'Name of the component that reserved the ip address', + `reservation_id` varchar(64) COMMENT 'id for the reservation', + `device_id` int(10) COMMENT 'device id for the network when plugged into the virtual machine', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -836,8 +839,8 @@ CREATE TABLE `cloud`.`security_group` ( `id` bigint unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, `description` varchar(4096) NULL, - `domain_id` bigint unsigned NULL, - `account_id` bigint unsigned NULL, + `domain_id` bigint unsigned NOT NULL, + `account_id` bigint unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 20ffe6f13dced8d1b6ffa26549d6bfc33be358ba Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 18 Aug 2010 12:28:30 -0700 Subject: [PATCH 08/11] more changes --- api/src/com/cloud/domain/Domain.java | 37 ++++++++++++++++++++++ api/src/com/cloud/domain/PartOf.java | 15 +++++++++ api/src/com/cloud/template/BasedOn.java | 16 ++++++++++ api/src/com/cloud/user/OwnedBy.java | 14 ++++++++ api/src/com/cloud/vm/NetworkConcierge.java | 23 ++++++++++++++ api/src/com/cloud/vm/NetworkProfiler.java | 18 +++++++++++ api/src/com/cloud/vm/RunningOn.java | 14 ++++++++ 7 files changed, 137 insertions(+) create mode 100644 api/src/com/cloud/domain/Domain.java create mode 100644 api/src/com/cloud/domain/PartOf.java create mode 100644 api/src/com/cloud/template/BasedOn.java create mode 100644 api/src/com/cloud/user/OwnedBy.java create mode 100644 api/src/com/cloud/vm/NetworkConcierge.java create mode 100644 api/src/com/cloud/vm/NetworkProfiler.java create mode 100644 api/src/com/cloud/vm/RunningOn.java diff --git a/api/src/com/cloud/domain/Domain.java b/api/src/com/cloud/domain/Domain.java new file mode 100644 index 00000000000..5cbfb39b4dc --- /dev/null +++ b/api/src/com/cloud/domain/Domain.java @@ -0,0 +1,37 @@ +/** + * + */ +package com.cloud.domain; + +import java.util.Date; + +import com.cloud.user.OwnedBy; + +/** + * Domain defines the Domain object. + */ +public interface Domain extends OwnedBy { + public static final long ROOT_DOMAIN = 1L; + + long getId(); + + Long getParent(); + + void setParent(Long parent); + + String getName(); + + void setName(String name); + + Date getRemoved(); + + String getPath(); + + void setPath(String path); + + int getLevel(); + + int getChildCount(); + + long getNextChildSeq(); +} diff --git a/api/src/com/cloud/domain/PartOf.java b/api/src/com/cloud/domain/PartOf.java new file mode 100644 index 00000000000..98b8b2ad6dd --- /dev/null +++ b/api/src/com/cloud/domain/PartOf.java @@ -0,0 +1,15 @@ +/** + * + */ +package com.cloud.domain; + +/** + * PartOf must be implemented by all objects that belongs + * in a domain. + */ +public interface PartOf { + /** + * @return domain id that the object belongs to. + */ + long getDomainId(); +} diff --git a/api/src/com/cloud/template/BasedOn.java b/api/src/com/cloud/template/BasedOn.java new file mode 100644 index 00000000000..4424cbdb520 --- /dev/null +++ b/api/src/com/cloud/template/BasedOn.java @@ -0,0 +1,16 @@ +/** + * + */ +package com.cloud.template; + +/** + * BasedOn is implemented by all objects that are based on a certain template. + */ +public interface BasedOn { + + /** + * @return the template id that the volume is based on. + */ + Long getTemplateId(); + +} diff --git a/api/src/com/cloud/user/OwnedBy.java b/api/src/com/cloud/user/OwnedBy.java new file mode 100644 index 00000000000..78edbc33bd2 --- /dev/null +++ b/api/src/com/cloud/user/OwnedBy.java @@ -0,0 +1,14 @@ +/** + * + */ +package com.cloud.user; + +/** + * OwnedBy must be inheritted by all objects that can be owned by an account. + */ +public interface OwnedBy { + /** + * @return account id that owns this object. + */ + long getAccountId(); +} diff --git a/api/src/com/cloud/vm/NetworkConcierge.java b/api/src/com/cloud/vm/NetworkConcierge.java new file mode 100644 index 00000000000..03ab6fae6df --- /dev/null +++ b/api/src/com/cloud/vm/NetworkConcierge.java @@ -0,0 +1,23 @@ +/** + * + */ +package com.cloud.vm; + +import com.cloud.exception.InsufficientVirtualNetworkCapcityException; +import com.cloud.utils.Pair; +import com.cloud.utils.component.Adapter; + +/** + * NetworkConcierge reserves network settings for a VM based + * on the NetworkCharacteristics given. A Concierge must + * return a unique name so we know to call it to release + * the reservation. + * + */ +public interface NetworkConcierge extends Adapter { + String getUniqueName(); + + Pair reserve(long vmId, NetworkCharacteristics ch) throws InsufficientVirtualNetworkCapcityException; + + boolean release(String uniqueName, String uniqueId); +} diff --git a/api/src/com/cloud/vm/NetworkProfiler.java b/api/src/com/cloud/vm/NetworkProfiler.java new file mode 100644 index 00000000000..b3afdd47c59 --- /dev/null +++ b/api/src/com/cloud/vm/NetworkProfiler.java @@ -0,0 +1,18 @@ +/** + * + */ +package com.cloud.vm; + +import java.util.Collection; +import java.util.List; + +import com.cloud.offering.DiskOffering; +import com.cloud.offering.NetworkOffering; +import com.cloud.offering.ServiceOffering; +import com.cloud.user.Account; +import com.cloud.utils.Ternary; +import com.cloud.utils.component.Adapter; + +public interface NetworkProfiler extends Adapter { + Ternary, List> convert(VirtualMachine vm, ServiceOffering serviceOffering, List networkOfferings, Collection diskOfferings, Account owner); +} diff --git a/api/src/com/cloud/vm/RunningOn.java b/api/src/com/cloud/vm/RunningOn.java new file mode 100644 index 00000000000..f491825dad1 --- /dev/null +++ b/api/src/com/cloud/vm/RunningOn.java @@ -0,0 +1,14 @@ +/** + * + */ +package com.cloud.vm; + +/** + * RunningOn must be implemented by objects that runs on hosts. + * + */ +public interface RunningOn { + + Long getHostId(); + +} From 09680d80a76661a87c21ad58ade8a950c6a55c76 Mon Sep 17 00:00:00 2001 From: Anthony Xu Date: Mon, 16 Aug 2010 18:35:39 -0700 Subject: [PATCH 09/11] bug 5939: add the new script to patch status 5939: assigned --- scripts/vm/hypervisor/xenserver/xenserver56/patch | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch index fe414c79b6f..15b8908ddb5 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch @@ -20,6 +20,7 @@ vmops=..,0755,/etc/xapi.d/plugins vmopsSnapshot=..,0755,/etc/xapi.d/plugins systemvm-premium.zip=../../../../../vms,0755,/opt/xensource/bin hostvmstats.py=..,0755,/opt/xensource/sm +xs_cleanup.sh=..,0755,/opt/xensource/bin network_info.sh=..,0755,/opt/xensource/bin prepsystemvm.sh=..,0755,/opt/xensource/bin setupxenserver.sh=..,0755,/opt/xensource/bin From 41f7c745bdb54aedd18982072b4361583613e9a5 Mon Sep 17 00:00:00 2001 From: Anthony Xu Date: Wed, 18 Aug 2010 17:33:25 -0700 Subject: [PATCH 10/11] bug 5934: if it is standalone, give cluser name as Standalone-ip/name status 5934: resolved fixed Conflicts: server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java --- .../com/cloud/api/commands/AddHostCmd.java | 7 +++++++ .../xen/discoverer/XcpServerDiscoverer.java | 19 +------------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/server/src/com/cloud/api/commands/AddHostCmd.java b/server/src/com/cloud/api/commands/AddHostCmd.java index 76271fb5311..faf3aa70f5c 100644 --- a/server/src/com/cloud/api/commands/AddHostCmd.java +++ b/server/src/com/cloud/api/commands/AddHostCmd.java @@ -75,6 +75,13 @@ public class AddHostCmd extends BaseCmd { throw new ServerApiException(BaseCmd.PARAM_ERROR, "Can't specify cluster by both id and name"); } + if (clusterName == null && clusterId == null) { + // Stand alone, assign a name to it + String[] stringarray = url.split("//"); + String address = stringarray[stringarray.length - 1]; + clusterName = "Standalone-" + address; + } + if ((clusterName != null || clusterId != null) && podId == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "Can't specify cluster without specifying the pod"); } diff --git a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index 8b0e7bd280f..e7017710f9e 100644 --- a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -81,7 +81,6 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L protected String _privateNic; protected String _storageNic1; protected String _storageNic2; - protected boolean _formPoolsInPod; protected int _wait; protected XenServerConnectionPool _connPool; protected String _increase; @@ -132,19 +131,6 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L String cluster = null; if (clusterId != null) { cluster = Long.toString(clusterId); - } else if (_formPoolsInPod) { - if (podId != null) { - List clusters = _clusterDao.listByPodId(podId); - if (clusters.size() > 1) { - throw new DiscoveryException("There are more than one cluster in the pod and we don't know which to add to."); - } else if (clusters.size() == 1) { - clusterId = clusters.get(0).getId(); - cluster = Long.toString(clusterId); - } else { - Map pools = Pool.getAllRecords(conn); - cluster = pools.values().iterator().next().uuid; - } - } } Map hosts = Host.getAllRecords(conn); @@ -300,7 +286,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L if ( resources.size() == 0 ) { return false; } - if (clusterId == null && !_formPoolsInPod) { + if (clusterId == null ) { if (resources.size() > 1) { s_logger.warn("There's no cluster specified but we found a pool of xenservers " + resources.size()); throw new DiscoveryException("There's no cluster specified but we found a pool of xenservers " + resources.size()); @@ -439,9 +425,6 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L value = _params.get("xen.check.hvm"); _checkHvm = value == null ? true : Boolean.parseBoolean(value); - value = _params.get(Config.CreatePoolsInPod.key()); - _formPoolsInPod = Boolean.parseBoolean(value); - _connPool = XenServerConnectionPool.getInstance(); _agentMgr.registerForHostEvents(this, true, false, true); From 3106c2ae3feaad73a451aa2e3e69fc21fc007f64 Mon Sep 17 00:00:00 2001 From: edison Date: Wed, 18 Aug 2010 17:39:22 -0700 Subject: [PATCH 11/11] Issue #: 5954 Status 5954: resolved fixed exclude link local gateway --- .../dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java | 2 ++ utils/src/com/cloud/utils/net/NetUtils.java | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java b/core/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java index 359cd6d0958..33474614d77 100644 --- a/core/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java +++ b/core/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java @@ -52,6 +52,7 @@ public class DataCenterLinkLocalIpAddressDaoImpl extends GenericDaoBase sc = FreeIpSearch.create(); sc.setParameters("dc", dcId); sc.setParameters("pod", podId); + sc.setParameters("ipAddr", NetUtils.getLinkLocalGateway()); /*explicitly removing the gateway*/ Transaction txn = Transaction.currentTxn(); try { @@ -141,6 +142,7 @@ public class DataCenterLinkLocalIpAddressDaoImpl extends GenericDaoBase