Skip to content

Commit f580639

Browse files
author
Alex Huang
committed
deploy vm completed
1 parent 9401ec1 commit f580639

27 files changed

Lines changed: 548 additions & 271 deletions

‎api/src/com/cloud/acl/SecurityChecker.java‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
*/
44
package com.cloud.acl;
55

6-
import java.security.acl.NotOwnerException;
7-
8-
import com.cloud.domain.PartOf;
6+
import com.cloud.domain.Domain;
97
import com.cloud.exception.PermissionDeniedException;
108
import com.cloud.user.Account;
11-
import com.cloud.user.OwnedBy;
129
import com.cloud.user.User;
1310
import com.cloud.utils.component.Adapter;
1411

@@ -25,7 +22,7 @@ public interface SecurityChecker extends Adapter {
2522
* @return true if access allowed. false if this adapter cannot authenticate ownership.
2623
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
2724
*/
28-
boolean checkOwnership(Account account, OwnedBy object) throws NotOwnerException;
25+
boolean checkAccess(Account account, Domain domain) throws PermissionDeniedException;
2926

3027
/**
3128
* Checks if the user belongs to an account that owns the object.
@@ -35,27 +32,27 @@ public interface SecurityChecker extends Adapter {
3532
* @return true if access allowed. false if this adapter cannot authenticate ownership.
3633
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
3734
*/
38-
boolean checkOwnership(User user, OwnedBy object) throws NotOwnerException;
35+
boolean checkAccess(User user, Domain domain) throws PermissionDeniedException;
3936

4037
/**
4138
* Checks if the account can access the object.
4239
*
4340
* @param account account to check against.
44-
* @param object object that the account is trying to access.
41+
* @param entity object that the account is trying to access.
4542
* @return true if access allowed. false if this adapter cannot provide permission.
4643
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
4744
*/
48-
boolean checkAccess(Account account, PartOf object) throws PermissionDeniedException;
45+
boolean checkAccess(Account account, ControlledEntity entity) throws PermissionDeniedException;
4946

5047
/**
5148
* Checks if the user belongs to an account that can access the object.
5249
*
5350
* @param user user to check against.
54-
* @param object object that the account is trying to access.
51+
* @param entity object that the account is trying to access.
5552
* @return true if access allowed. false if this adapter cannot authenticate ownership.
5653
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
5754
*/
58-
boolean checkAccess(User user, PartOf object) throws PermissionDeniedException;
55+
boolean checkAccess(User user, ControlledEntity entity) throws PermissionDeniedException;
5956

6057
// We should be able to use this method to check against commands. For example, we can
6158
// annotate the command with access annotations and this method can use it to extract

‎api/src/com/cloud/network/NetworkConfiguration.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,8 @@ private State(String description) {
9292
State getState();
9393

9494
long getRelated();
95+
96+
String getBroadcastUri();
97+
98+
String getDns();
9599
}

‎api/src/com/cloud/storage/Volume.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
import java.util.List;
2222
import java.util.Set;
2323

24-
import com.cloud.domain.PartOf;
24+
import com.cloud.acl.ControlledEntity;
2525
import com.cloud.template.BasedOn;
26-
import com.cloud.user.OwnedBy;
2726
import com.cloud.utils.fsm.FiniteState;
2827
import com.cloud.utils.fsm.StateMachine;
2928

3029

31-
public interface Volume extends PartOf, OwnedBy, BasedOn {
30+
public interface Volume extends ControlledEntity, BasedOn {
3231
enum VolumeType {UNKNOWN, ROOT, SWAP, DATADISK, ISO};
3332

3433
enum MirrorState {NOT_MIRRORED, ACTIVE, DEFUNCT};

‎api/src/com/cloud/template/VirtualMachineTemplate.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*/
1818
package com.cloud.template;
1919

20-
import com.cloud.storage.Storage.FileSystem;
20+
import com.cloud.acl.ControlledEntity;
2121

22-
public interface VirtualMachineTemplate {
22+
public interface VirtualMachineTemplate extends ControlledEntity {
2323

2424
public static enum BootloaderType { PyGrub, HVM, External, CD };
2525

‎api/src/com/cloud/user/Account.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ public enum State {
5353
public short getType();
5454
public String getState();
5555
public void setState(String state);
56+
@Override
5657
public long getDomainId();
5758
public Date getRemoved();
5859
public String getNetworkDomain();
5960
public void setNetworkDomain(String networkDomain);
61+
6062
}

‎api/src/com/cloud/vm/VirtualMachine.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919

2020
import java.util.Date;
2121

22-
import com.cloud.domain.PartOf;
23-
import com.cloud.user.OwnedBy;
22+
import com.cloud.acl.ControlledEntity;
2423

2524
/**
2625
* VirtualMachine describes the properties held by a virtual machine
2726
*
2827
*/
29-
public interface VirtualMachine extends RunningOn, OwnedBy, PartOf {
28+
public interface VirtualMachine extends RunningOn, ControlledEntity {
3029
public enum Event {
3130
CreateRequested,
3231
StartRequested,

‎client/tomcatconf/commands.properties.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3
3333
listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15
3434

3535
#### VM commands
36-
deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11
36+
deployVirtualMachine=com.cloud.api.commands.DeployVm2Cmd;11
3737
destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15
3838
rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15
3939
startVirtualMachine=com.cloud.api.commands.StartVMCmd;15

‎core/src/com/cloud/domain/DomainVO.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ public DomainVO(String name, long owner, Long parentId) {
7171
this.level = 0;
7272
}
7373

74+
@Override
7475
public long getId() {
7576
return id;
7677
}
7778

79+
@Override
7880
public Long getParent() {
7981
return parent;
8082
}
8183

84+
@Override
8285
public void setParent(Long parent) {
8386
if(parent == null) {
8487
this.parent = DomainVO.ROOT_DOMAIN;
@@ -90,30 +93,37 @@ public void setParent(Long parent) {
9093
}
9194
}
9295

96+
@Override
9397
public String getName() {
9498
return name;
9599
}
96100

101+
@Override
97102
public void setName(String name) {
98103
this.name = name;
99104
}
100105

106+
@Override
101107
public long getAccountId() {
102108
return accountId;
103109
}
104110

111+
@Override
105112
public Date getRemoved() {
106113
return removed;
107114
}
108115

116+
@Override
109117
public String getPath() {
110118
return path;
111119
}
112120

121+
@Override
113122
public void setPath(String path) {
114123
this.path = path;
115124
}
116125

126+
@Override
117127
public int getLevel() {
118128
return level;
119129
}
@@ -122,6 +132,7 @@ public void setLevel(int level) {
122132
this.level = level;
123133
}
124134

135+
@Override
125136
public int getChildCount() {
126137
return childCount;
127138
}
@@ -130,12 +141,18 @@ public void setChildCount(int count) {
130141
childCount = count;
131142
}
132143

144+
@Override
133145
public long getNextChildSeq() {
134146
return nextChildSeq;
135147
}
136148

137149
public void setNextChildSeq(long seq) {
138150
nextChildSeq = seq;
151+
}
152+
153+
@Override
154+
public String toString() {
155+
return new StringBuilder("Domain:").append(id).append(path).toString();
139156
}
140157
}
141158

‎core/src/com/cloud/offerings/NetworkOfferingVO.java‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import com.cloud.network.Network.TrafficType;
3232
import com.cloud.offering.NetworkOffering;
33+
import com.cloud.service.ServiceOfferingVO;
3334
import com.cloud.utils.db.GenericDao;
3435

3536
@Entity
@@ -72,6 +73,9 @@ public class NetworkOfferingVO implements NetworkOffering {
7273
@Column(name="system_only")
7374
boolean systemOnly;
7475

76+
@Column(name="service_offering_id")
77+
Long serviceOfferingId;
78+
7579
@Column(name="tags")
7680
String tags;
7781

@@ -128,6 +132,14 @@ public Date getRemoved() {
128132
return removed;
129133
}
130134

135+
public Long getServiceOfferingId() {
136+
return serviceOfferingId;
137+
}
138+
139+
public void setServiceOfferingId(long serviceOfferingId) {
140+
this.serviceOfferingId = serviceOfferingId;
141+
}
142+
131143
@Override
132144
public Integer getConcurrentConnections() {
133145
return concurrentConnections;
@@ -144,6 +156,50 @@ public void setTags(String tags) {
144156
public NetworkOfferingVO() {
145157
}
146158

159+
public void setName(String name) {
160+
this.name = name;
161+
}
162+
163+
public void setDisplayText(String displayText) {
164+
this.displayText = displayText;
165+
}
166+
167+
public void setRateMbps(Integer rateMbps) {
168+
this.rateMbps = rateMbps;
169+
}
170+
171+
public void setMulticastRateMbps(Integer multicastRateMbps) {
172+
this.multicastRateMbps = multicastRateMbps;
173+
}
174+
175+
public void setConcurrentConnections(Integer concurrentConnections) {
176+
this.concurrentConnections = concurrentConnections;
177+
}
178+
179+
public void setGuestIpType(GuestIpType guestIpType) {
180+
this.guestIpType = guestIpType;
181+
}
182+
183+
public void setTrafficType(TrafficType trafficType) {
184+
this.trafficType = trafficType;
185+
}
186+
187+
public void setSystemOnly(boolean systemOnly) {
188+
this.systemOnly = systemOnly;
189+
}
190+
191+
public void setServiceOfferingId(Long serviceOfferingId) {
192+
this.serviceOfferingId = serviceOfferingId;
193+
}
194+
195+
public void setRemoved(Date removed) {
196+
this.removed = removed;
197+
}
198+
199+
public void setCreated(Date created) {
200+
this.created = created;
201+
}
202+
147203
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) {
148204
this.name = name;
149205
this.displayText = displayText;
@@ -155,6 +211,11 @@ public NetworkOfferingVO(String name, String displayText, TrafficType trafficTyp
155211
this.systemOnly = systemOnly;
156212
}
157213

214+
public NetworkOfferingVO(ServiceOfferingVO offering) {
215+
this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, offering.getRateMbps(), offering.getMulticastRateMbps(), null);
216+
this.serviceOfferingId = offering.getId();
217+
}
218+
158219
/**
159220
* Network Offering for all system vms.
160221
* @param name

‎core/src/com/cloud/storage/VMTemplateVO.java‎

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,23 @@
1818

1919
package com.cloud.storage;
2020

21-
import java.util.Date;
22-
import java.util.UUID;
23-
24-
import javax.persistence.Column;
25-
import javax.persistence.Entity;
26-
import javax.persistence.EnumType;
27-
import javax.persistence.Enumerated;
28-
import javax.persistence.Id;
29-
import javax.persistence.Table;
30-
import javax.persistence.TableGenerator;
31-
import javax.persistence.Temporal;
32-
import javax.persistence.TemporalType;
33-
34-
import com.cloud.async.AsyncInstanceCreateStatus;
21+
import java.util.Date;
22+
import java.util.UUID;
23+
24+
import javax.persistence.Column;
25+
import javax.persistence.Entity;
26+
import javax.persistence.Id;
27+
import javax.persistence.Table;
28+
import javax.persistence.TableGenerator;
29+
import javax.persistence.Temporal;
30+
import javax.persistence.TemporalType;
31+
import javax.persistence.Transient;
32+
3533
import com.cloud.hypervisor.Hypervisor.HypervisorType;
36-
import com.cloud.storage.Storage.FileSystem;
3734
import com.cloud.storage.Storage.ImageFormat;
3835
import com.cloud.storage.Storage.TemplateType;
39-
import com.cloud.utils.db.GenericDao;
40-
import com.google.gson.annotations.Expose;
41-
import com.cloud.storage.Storage;
4236
import com.cloud.template.VirtualMachineTemplate;
37+
import com.cloud.utils.db.GenericDao;
4338

4439
@Entity
4540
@Table(name="vm_template")
@@ -248,7 +243,8 @@ public void setRequiresHvm(boolean value) {
248243
requiresHvm = value;
249244
}
250245

251-
public long getAccountId() {
246+
@Override
247+
public long getAccountId() {
252248
return accountId;
253249
}
254250

@@ -303,6 +299,11 @@ public HypervisorType getHypervisorType() {
303299
public void setHypervisorType(HypervisorType hyperType) {
304300
hypervisorType = hyperType.toString();
305301
}
302+
303+
@Override
304+
public long getDomainId() {
305+
return -1;
306+
}
306307

307308
@Override
308309
public boolean equals(Object that) {
@@ -320,5 +321,15 @@ public boolean equals(Object that) {
320321
public int hashCode() {
321322
return uniqueName.hashCode();
322323
}
324+
325+
@Transient
326+
String toString;
327+
@Override
328+
public String toString() {
329+
if (toString == null) {
330+
toString = new StringBuilder("Template:").append(id).append(":").append(format).append(":").append(uniqueName).toString();
331+
}
332+
return toString;
333+
}
323334

324335
}

0 commit comments

Comments
 (0)