From 06b7d80fec6d7913e09a74d464152d19dabb6b0d Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Thu, 13 Sep 2012 11:31:54 -0700 Subject: [PATCH] latest changes --- api/src/com/cloud/vm/VirtualMachine.java | 1 - core/src/com/cloud/vm/DomainRouterVO.java | 156 ++++--- core/src/com/cloud/vm/VMInstanceVO.java | 394 +++++++++--------- .../service/api/OrchestrationService.java | 29 +- platform/orchestration/.classpath | 20 +- platform/orchestration/.project | 6 + .../.settings/org.eclipse.jdt.core.prefs | 7 +- .../.settings/org.eclipse.m2e.core.prefs | 4 + platform/orchestration/pom.xml | 6 + .../orchestration/CloudOrchestrator.java | 110 +---- .../cloud/upgrade/DatabaseUpgradeChecker.java | 6 +- 11 files changed, 332 insertions(+), 407 deletions(-) create mode 100755 platform/orchestration/.settings/org.eclipse.m2e.core.prefs create mode 100755 platform/orchestration/pom.xml diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java index 9214fa4f31b..b3c40a32662 100755 --- a/api/src/com/cloud/vm/VirtualMachine.java +++ b/api/src/com/cloud/vm/VirtualMachine.java @@ -293,5 +293,4 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S public Map getDetails(); - boolean canPlugNics(); } diff --git a/core/src/com/cloud/vm/DomainRouterVO.java b/core/src/com/cloud/vm/DomainRouterVO.java index 052d2054f6c..0082d749831 100755 --- a/core/src/com/cloud/vm/DomainRouterVO.java +++ b/core/src/com/cloud/vm/DomainRouterVO.java @@ -36,45 +36,45 @@ import com.cloud.network.router.VirtualRouter; public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { @Column(name="element_id") private long elementId; - + @Column(name="public_ip_address") private String publicIpAddress; - + @Column(name="public_mac_address") private String publicMacAddress; - + @Column(name="public_netmask") private String publicNetmask; @Column(name="is_redundant_router") boolean isRedundantRouter; - + @Column(name="priority") int priority; - + @Column(name="is_priority_bumpup") boolean isPriorityBumpUp; - + @Column(name="redundant_state") @Enumerated(EnumType.STRING) private RedundantState redundantState; - + @Column(name="stop_pending") boolean stopPending; - + @Column(name="role") @Enumerated(EnumType.STRING) private Role role = Role.VIRTUAL_ROUTER; - + @Column(name="template_version") private String templateVersion; - + @Column(name="scripts_version") private String scriptsVersion; - + @Column(name="vpc_id") private Long vpcId; - + public DomainRouterVO(long id, long serviceOfferingId, long elementId, @@ -99,7 +99,7 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { this.stopPending = stopPending; this.vpcId = vpcId; } - + public DomainRouterVO(long id, long serviceOfferingId, long elementId, @@ -146,94 +146,94 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { public long getDataCenterIdToDeployIn() { return dataCenterIdToDeployIn; } - + public String getPublicNetmask() { return publicNetmask; } - + public String getPublicMacAddress() { return publicMacAddress; } - + protected DomainRouterVO() { super(); } - + @Override public String getPublicIpAddress() { return publicIpAddress; } - - @Override - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } - - @Override - public boolean getIsRedundantRouter() { - return this.isRedundantRouter; - } - - public void setIsRedundantRouter(boolean isRedundantRouter) { - this.isRedundantRouter = isRedundantRouter; - } - - @Override - public long getServiceOfferingId() { - return serviceOfferingId; - } - - public int getPriority() { - return this.priority; - } - - public void setPriority(int priority) { - this.priority = priority; - } - - @Override - public RedundantState getRedundantState() { - return this.redundantState; - } - - public void setRedundantState(RedundantState redundantState) { - this.redundantState = redundantState; - } - - public boolean getIsPriorityBumpUp() { - return this.isPriorityBumpUp; - } - - public void setIsPriorityBumpUp(boolean isPriorityBumpUp) { - this.isPriorityBumpUp = isPriorityBumpUp; - } @Override - public boolean isStopPending() { - return this.stopPending; - } + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } @Override - public void setStopPending(boolean stopPending) { - this.stopPending = stopPending; - } - + public boolean getIsRedundantRouter() { + return this.isRedundantRouter; + } + + public void setIsRedundantRouter(boolean isRedundantRouter) { + this.isRedundantRouter = isRedundantRouter; + } + + @Override + public long getServiceOfferingId() { + return serviceOfferingId; + } + + public int getPriority() { + return this.priority; + } + + public void setPriority(int priority) { + this.priority = priority; + } + + @Override + public RedundantState getRedundantState() { + return this.redundantState; + } + + public void setRedundantState(RedundantState redundantState) { + this.redundantState = redundantState; + } + + public boolean getIsPriorityBumpUp() { + return this.isPriorityBumpUp; + } + + public void setIsPriorityBumpUp(boolean isPriorityBumpUp) { + this.isPriorityBumpUp = isPriorityBumpUp; + } + + @Override + public boolean isStopPending() { + return this.stopPending; + } + + @Override + public void setStopPending(boolean stopPending) { + this.stopPending = stopPending; + } + public String getTemplateVersion() { return this.templateVersion; } - + public void setTemplateVersion(String templateVersion) { this.templateVersion = templateVersion; } - + public String getScriptsVersion() { return this.scriptsVersion; } - + public void setScriptsVersion(String scriptsVersion) { this.scriptsVersion = scriptsVersion; } @@ -242,9 +242,5 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { public Long getVpcId() { return vpcId; } - - @Override - public boolean canPlugNics() { - return true; - } + } diff --git a/core/src/com/cloud/vm/VMInstanceVO.java b/core/src/com/cloud/vm/VMInstanceVO.java index 8cb5816724d..986c4218ccf 100644 --- a/core/src/com/cloud/vm/VMInstanceVO.java +++ b/core/src/com/cloud/vm/VMInstanceVO.java @@ -48,21 +48,21 @@ import com.cloud.vm.VirtualMachine.State; @Inheritance(strategy=InheritanceType.JOINED) @DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32) public class VMInstanceVO implements VirtualMachine, FiniteStateObject { - @Id + @Id @TableGenerator(name="vm_instance_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="vm_instance_seq", allocationSize=1) @Column(name="id", updatable=false, nullable = false) - protected long id; + protected long id; @Column(name="name", updatable=false, nullable=false, length=255) - protected String hostName = null; + protected String hostName = null; @Encrypt @Column(name="vnc_password", updatable=true, nullable=false, length=255) protected String vncPassword; - + @Column(name="proxy_id", updatable=true, nullable=true) protected Long proxyId; - + @Temporal(TemporalType.TIMESTAMP) @Column(name="proxy_assign_time", updatable=true, nullable=true) protected Date proxyAssignTime; @@ -78,20 +78,20 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject details; @Column(name="uuid") protected String uuid = UUID.randomUUID().toString(); ; - + public VMInstanceVO(long id, - long serviceOfferingId, - String name, - String instanceName, - Type type, - Long vmTemplateId, - HypervisorType hypervisorType, - long guestOSId, - long domainId, - long accountId, - boolean haEnabled) { + long serviceOfferingId, + String name, + String instanceName, + Type type, + Long vmTemplateId, + HypervisorType hypervisorType, + long guestOSId, + long domainId, + long accountId, + boolean haEnabled) { this.id = id; this.hostName = name != null ? name : this.uuid; if (vmTemplateId != null) { @@ -191,177 +200,177 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject getDetails() { return details; } - + public void setDetail(String name, String value) { assert (details != null) : "Did you forget to load the details?"; - + details.put(name, value); } - + public void setDetails(Map details) { this.details = details; } - transient String toString; + transient String toString; @Override - public String toString() { + public String toString() { if (toString == null) { toString = new StringBuilder("VM[").append(type.toString()).append("|").append(hostName).append("]").toString(); } return toString; } - + @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - return result; - } + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VMInstanceVO other = (VMInstanceVO) obj; + if (id != other.id) + return false; + return true; + } + - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VMInstanceVO other = (VMInstanceVO) obj; - if (id != other.id) - return false; - return true; - } - - public void setServiceOfferingId(long serviceOfferingId) { this.serviceOfferingId = serviceOfferingId; } - - @Override - public boolean canPlugNics() { - return false; - } - + } diff --git a/platform/api/src/org/apache/cloudstack/platform/service/api/OrchestrationService.java b/platform/api/src/org/apache/cloudstack/platform/service/api/OrchestrationService.java index 13133e200cc..aa0a9f73588 100755 --- a/platform/api/src/org/apache/cloudstack/platform/service/api/OrchestrationService.java +++ b/platform/api/src/org/apache/cloudstack/platform/service/api/OrchestrationService.java @@ -22,10 +22,11 @@ import java.net.URL; import java.util.List; import java.util.Map; +import org.apache.cloudstack.platform.cloud.entity.api.VirtualMachineEntity; +import org.apache.cloudstack.platform.cloud.entity.api.VolumeEntity; + import com.cloud.exception.InsufficientCapacityException; import com.cloud.hypervisor.Hypervisor; -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.vm.VirtualMachine; public interface OrchestrationService { /** @@ -43,7 +44,7 @@ public interface OrchestrationService { * @param details extra details to store for the VM * @return VirtualMachine */ - VirtualMachine create(String name, + VirtualMachineEntity create(String name, String template, String hostName, int cpu, @@ -55,7 +56,7 @@ public interface OrchestrationService { Map details, String owner); - VirtualMachine createFromScratch(String uuid, + VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String hypervisor, @@ -77,8 +78,6 @@ public interface OrchestrationService { */ String reserve(String vm, String planner, Long until) throws InsufficientCapacityException; - String cancel(String reservationId); - /** * Deploy the reservation * @param reservationId reservation id during the deployment @@ -87,29 +86,13 @@ public interface OrchestrationService { */ String deploy(String reservationId); - /** - * Stops the vm - * @param vm vm - * @throws CloudRuntimeException if error - */ - String stop(String vm); - - /** - * destroys the vm - * @param vm vm - * @throws CloudRuntimeException if error - */ - void destroy(String vm); - void joinNetwork(String network1, String network2); - void attachVolume(String vm, String vol); - void createNetwork(); void destroyNetwork(); - void createVolume(); + VolumeEntity createVolume(); void registerTemplate(String name, URL path, String os, Hypervisor hypervisor); } diff --git a/platform/orchestration/.classpath b/platform/orchestration/.classpath index 3028798ad9a..54b5d825325 100755 --- a/platform/orchestration/.classpath +++ b/platform/orchestration/.classpath @@ -1,10 +1,18 @@ - - + - - - - + + + + + + + + + + + + + diff --git a/platform/orchestration/.project b/platform/orchestration/.project index fe968bce1d7..5963e0bd676 100755 --- a/platform/orchestration/.project +++ b/platform/orchestration/.project @@ -10,8 +10,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature diff --git a/platform/orchestration/.settings/org.eclipse.jdt.core.prefs b/platform/orchestration/.settings/org.eclipse.jdt.core.prefs index 7341ab1683c..8e4055a6fa8 100755 --- a/platform/orchestration/.settings/org.eclipse.jdt.core.prefs +++ b/platform/orchestration/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/platform/orchestration/.settings/org.eclipse.m2e.core.prefs b/platform/orchestration/.settings/org.eclipse.m2e.core.prefs new file mode 100755 index 00000000000..f897a7f1cb2 --- /dev/null +++ b/platform/orchestration/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/platform/orchestration/pom.xml b/platform/orchestration/pom.xml new file mode 100755 index 00000000000..70abde4c4b9 --- /dev/null +++ b/platform/orchestration/pom.xml @@ -0,0 +1,6 @@ + + 4.0.0 + org.apache.cloudstack + cloud-platform-orchestration + 0.0.1-SNAPSHOT + \ No newline at end of file diff --git a/platform/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java b/platform/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java index 405289dbc8c..34154ad3b7c 100755 --- a/platform/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java +++ b/platform/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java @@ -22,140 +22,58 @@ import java.net.URL; import java.util.List; import java.util.Map; -import org.apache.cloudstack.framework.ipc.Publisher; -import org.apache.cloudstack.platform.planning.Concierge; +import org.apache.cloudstack.platform.cloud.entity.api.VirtualMachineEntity; +import org.apache.cloudstack.platform.cloud.entity.api.VolumeEntity; import org.apache.cloudstack.platform.service.api.OrchestrationService; import com.cloud.exception.InsufficientCapacityException; import com.cloud.hypervisor.Hypervisor; -import com.cloud.vm.VirtualMachine; + public class CloudOrchestrator implements OrchestrationService { - int _retryCount = 5; - Concierge _concierge = null; // These are injected - Publisher _publisher = null; - @Override - public VirtualMachine create(String uuid, String template, String hostName, int cpu, int speed, long memory, List networks, List rootDiskTags, List computeTags, Map details, - String owner) { - // creates a virtual machine and relevant work in database - return null; - } - - @Override - public VirtualMachine createFromScratch(String uuid, String iso, String os, String hypervisor, String hostName, int cpu, int speed, long memory, List networks, List computeTags, + public VirtualMachineEntity create(String name, String template, String hostName, int cpu, int speed, long memory, List networks, List rootDiskTags, List computeTags, Map details, String owner) { - // creates a virtual machine and relevant work in database + // TODO Auto-generated method stub + return null; + } + + public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String hypervisor, String hostName, int cpu, int speed, long memory, List networks, List computeTags, + Map details, String owner) { + // TODO Auto-generated method stub return null; } - @Override public String reserve(String vm, String planner, Long until) throws InsufficientCapacityException { - return _concierge.reserve(vm, planner); - } - - @Override - public String cancel(String reservationId) { // TODO Auto-generated method stub return null; } - @Override - public String deploy(String reservationId, String callback) { - for (int i = 0; i < _retryCount; i++) { - try { - // Retrieves the reservation - // Signals Network and Storage to prepare - // Signals Compute - _concierge.claim(reservationId); - } catch (Exception e) { - // Cancel reservations. - } - _concierge.reserveAnother(reservationId); - } - return null; - } - - @Override - public String stop(String vm) { - + public String deploy(String reservationId) { // TODO Auto-generated method stub return null; } - @Override - public void destroy(String vm) { - // TODO Auto-generated method stub - - } - - @Override public void joinNetwork(String network1, String network2) { // TODO Auto-generated method stub } - @Override - public void attachNetwork(String network, String vm) { - // TODO Auto-generated method stub - - } - - @Override - public void detachNetwork(String network, String vm) { - // TODO Auto-generated method stub - - } - - @Override - public void attachVolume(String vm, String vol) { - // TODO Auto-generated method stub - - } - - @Override public void createNetwork() { // TODO Auto-generated method stub } - @Override public void destroyNetwork() { // TODO Auto-generated method stub } - @Override - public void createVolume() { + public VolumeEntity createVolume() { // TODO Auto-generated method stub - + return null; } - @Override - public void destroyVolume() { - // TODO Auto-generated method stub - - } - - @Override - public void snapshotVirtualMachine(String vm) { - // TODO Auto-generated method stub - - } - - @Override - public void snapshotVolume(String volume) { - // TODO Auto-generated method stub - - } - - @Override - public void backup(String snapshot) { - // TODO Auto-generated method stub - - } - - @Override public void registerTemplate(String name, URL path, String os, Hypervisor hypervisor) { // TODO Auto-generated method stub diff --git a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java index 047bb3eec21..cfa1bcd6cb3 100755 --- a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -131,7 +131,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { _upgradeMap.put("2.2.8", new DbUpgrade[] { new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30() - , new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + , new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); _upgradeMap.put("2.2.9", new DbUpgrade[] { new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), @@ -335,8 +335,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { } if ( currentVersion == null ) - return; - + return; + s_logger.info("DB version = " + dbVersion + " Code Version = " + currentVersion); if (Version.compare(Version.trimToPatch(dbVersion), Version.trimToPatch(currentVersion)) > 0) {