Skip to content

Commit cfad797

Browse files
committed
2 parents 47e346a + c02e802 commit cfad797

220 files changed

Lines changed: 4534 additions & 3881 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎api/src/com/cloud/agent/api/to/S3TO.java‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@
1818

1919
import java.util.Date;
2020

21+
import com.cloud.agent.api.LogLevel;
22+
import com.cloud.agent.api.LogLevel.Log4jLevel;
2123
import com.cloud.storage.DataStoreRole;
2224
import com.cloud.utils.S3Utils;
2325

2426
public final class S3TO implements S3Utils.ClientOptions, DataStoreTO {
2527

2628
private Long id;
2729
private String uuid;
30+
@LogLevel(Log4jLevel.Off)
2831
private String accessKey;
32+
@LogLevel(Log4jLevel.Off)
2933
private String secretKey;
3034
private String endPoint;
3135
private String bucketName;
@@ -68,10 +72,12 @@ public S3TO(final Long id, final String uuid, final String accessKey,
6872
@Override
6973
public boolean equals(final Object thatObject) {
7074

71-
if (this == thatObject)
75+
if (this == thatObject) {
7276
return true;
73-
if (thatObject == null || getClass() != thatObject.getClass())
77+
}
78+
if (thatObject == null || getClass() != thatObject.getClass()) {
7479
return false;
80+
}
7581

7682
final S3TO thatS3TO = (S3TO) thatObject;
7783

‎api/src/com/cloud/agent/manager/allocator/HostAllocator.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public interface HostAllocator extends Adapter {
4747
* @return List<Host> List of hosts that are suitable for VM allocation
4848
**/
4949

50-
public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
50+
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
5151

5252
/**
5353
* Determines which physical hosts are suitable to
@@ -62,7 +62,7 @@ public interface HostAllocator extends Adapter {
6262
* @return List<Host> List of hosts that are suitable for VM allocation
6363
**/
6464

65-
public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
65+
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
6666

6767
/**
6868
* Determines which physical hosts are suitable to
@@ -77,7 +77,7 @@ public interface HostAllocator extends Adapter {
7777
* @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
7878
* @return List<Host> List of hosts that are suitable for VM allocation
7979
**/
80-
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts,
80+
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts,
8181
int returnUpTo, boolean considerReservedCapacity);
8282

8383
public static int RETURN_UPTO_ALL = -1;

‎api/src/com/cloud/deploy/DeploymentClusterPlanner.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
import java.util.List;
2020

21-
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
2221
import com.cloud.exception.InsufficientServerCapacityException;
23-
import com.cloud.vm.VirtualMachine;
2422
import com.cloud.vm.VirtualMachineProfile;
2523

2624
/**
@@ -38,10 +36,10 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner {
3836
* avoid these data centers, pods, clusters, or hosts.
3937
* @return DeployDestination for that virtual machine.
4038
*/
41-
List<Long> orderClusters(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid)
39+
List<Long> orderClusters(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid)
4240
throws InsufficientServerCapacityException;
4341

44-
PlannerResourceUsage getResourceUsage(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
42+
PlannerResourceUsage getResourceUsage(VirtualMachineProfile vmProfile,
4543
DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
4644

4745
}

‎api/src/com/cloud/deploy/DeploymentPlanner.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.cloud.org.Cluster;
3030
import com.cloud.storage.StoragePool;
3131
import com.cloud.utils.component.Adapter;
32-
import com.cloud.vm.VirtualMachine;
3332
import com.cloud.vm.VirtualMachineProfile;
3433

3534
/**
@@ -48,7 +47,7 @@ public interface DeploymentPlanner extends Adapter {
4847
* @return DeployDestination for that virtual machine.
4948
*/
5049
@Deprecated
51-
DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
50+
DeployDestination plan(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
5251

5352
/**
5453
* check() is called right before the virtual machine starts to make sure
@@ -65,7 +64,7 @@ public interface DeploymentPlanner extends Adapter {
6564
* @return true if it's okay to start; false if not. If false, the exclude list will include what should be
6665
* excluded.
6766
*/
68-
boolean check(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, DeployDestination dest, ExcludeList exclude);
67+
boolean check(VirtualMachineProfile vm, DeploymentPlan plan, DeployDestination dest, ExcludeList exclude);
6968

7069
/**
7170
* canHandle is called before plan to determine if the plan can do the allocation. Planers should be exclusive so
@@ -80,7 +79,7 @@ public interface DeploymentPlanner extends Adapter {
8079
* avoid these data centers, pods, clusters, or hosts.
8180
* @return true if it's okay to allocate; false or not
8281
*/
83-
boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid);
82+
boolean canHandle(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid);
8483

8584
public enum AllocationAlgorithm {
8685
random,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// under the License.
1717
package com.cloud.ha;
1818

19-
import com.cloud.host.HostVO;
19+
import com.cloud.host.Host;
2020
import com.cloud.utils.component.Adapter;
21-
import com.cloud.vm.VMInstanceVO;
21+
import com.cloud.vm.VirtualMachine;
2222

2323
public interface FenceBuilder extends Adapter {
2424
/**
@@ -27,5 +27,5 @@ public interface FenceBuilder extends Adapter {
2727
* @param vm vm
2828
* @param host host where the vm was running on.
2929
*/
30-
public Boolean fenceOff(VMInstanceVO vm, HostVO host);
30+
public Boolean fenceOff(VirtualMachine vm, Host host);
3131
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
// under the License.
1717
package com.cloud.ha;
1818

19-
import com.cloud.host.HostVO;
19+
import com.cloud.host.Host;
2020
import com.cloud.host.Status;
2121
import com.cloud.utils.component.Adapter;
22-
import com.cloud.vm.VMInstanceVO;
22+
import com.cloud.vm.VirtualMachine;
2323

2424
public interface Investigator extends Adapter {
2525
/**
2626
* Returns if the vm is still alive.
2727
*
2828
* @param vm to work on.
2929
*/
30-
public Boolean isVmAlive(VMInstanceVO vm, HostVO host);
30+
public Boolean isVmAlive(VirtualMachine vm, Host host);
3131

32-
public Status isAgentAlive(HostVO agent);
32+
public Status isAgentAlive(Host agent);
3333
}

‎api/src/com/cloud/hypervisor/HypervisorGuru.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface HypervisorGuru extends Adapter {
3636
* @param vm
3737
* @return
3838
*/
39-
<T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm);
39+
VirtualMachineTO implement(VirtualMachineProfile vm);
4040

4141
/**
4242
* Give hypervisor guru opportunity to decide if certain command needs to be delegated to other host, mainly to secondary storage VM host

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface NetworkMigrationResponder {
3838
* @param context
3939
* @return true when operation was successful.
4040
*/
41-
public boolean prepareMigration(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context);
41+
public boolean prepareMigration(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context);
4242

4343
/**
4444
* Cancel for migration preparation.
@@ -52,7 +52,7 @@ public interface NetworkMigrationResponder {
5252
* @param src The context nic migrates from.
5353
* @param dst The context nic migrates to.
5454
*/
55-
public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext src, ReservationContext dst);
55+
public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst);
5656

5757
/**
5858
* Commit the migration resource.
@@ -66,5 +66,5 @@ public interface NetworkMigrationResponder {
6666
* @param src the context nic migrates from.
6767
* @param dst the context nic migrates to.
6868
*/
69-
public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext src, ReservationContext dst);
69+
public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst);
7070
}

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

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* Network includes all of the enums used within networking.
26-
*
26+
*
2727
*/
2828
public class Networks {
2929

@@ -66,33 +66,82 @@ public enum BroadcastDomainType {
6666
Pvlan("pvlan", String.class),
6767
UnDecided(null, null);
6868

69-
private String scheme;
70-
private Class<?> type;
69+
private final String scheme;
70+
private final Class<?> type;
7171

7272
private BroadcastDomainType(String scheme, Class<?> type) {
7373
this.scheme = scheme;
7474
this.type = type;
7575
}
7676

7777
/**
78-
* @return scheme to be used in broadcast uri. Null indicates that this type does not have broadcast tags.
78+
* @return scheme to be used in broadcast uri. Null indicates that this
79+
* type does not have broadcast tags.
7980
*/
8081
public String scheme() {
8182
return scheme;
8283
}
8384

8485
/**
85-
* @return type of the value in the broadcast uri. Null indicates that this type does not have broadcast tags.
86+
* @return type of the value in the broadcast uri. Null indicates that
87+
* this type does not have broadcast tags.
8688
*/
8789
public Class<?> type() {
8890
return type;
8991
}
9092

9193
public <T> URI toUri(T value) {
9294
try {
93-
return new URI(scheme + "://" + value);
95+
// do we need to check that value does not contain a scheme
96+
// part?
97+
if (value.toString().contains(":"))
98+
return new URI(value.toString());
99+
else
100+
return new URI(scheme, value.toString(), null);
94101
} catch (URISyntaxException e) {
95-
throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value);
102+
throw new CloudRuntimeException(
103+
"Unable to convert to broadcast URI: " + value);
104+
}
105+
}
106+
107+
public static BroadcastDomainType getTypeOf(URI uri) {
108+
return getType(uri.getScheme());
109+
}
110+
111+
public static BroadcastDomainType getTypeOf(String str)
112+
throws URISyntaxException {
113+
return getTypeOf(new URI(str));
114+
}
115+
116+
public static BroadcastDomainType getType(String scheme) {
117+
if (scheme == null) {
118+
return UnDecided;
119+
}
120+
for (BroadcastDomainType type : values()) {
121+
if (scheme.equalsIgnoreCase(type.scheme())) {
122+
return type;
123+
}
124+
}
125+
return UnDecided;
126+
}
127+
128+
public static String getValue(String uriString)
129+
throws URISyntaxException {
130+
return getValue(new URI(uriString));
131+
}
132+
133+
public static String getValue(URI uri) {
134+
BroadcastDomainType type = getTypeOf(uri);
135+
if (type == Vlan) {
136+
// do complicated stuff for backward compatibility
137+
try {
138+
Long.parseLong(uri.getSchemeSpecificPart());
139+
return uri.getSchemeSpecificPart();
140+
} catch (NumberFormatException e) {
141+
return uri.getHost();
142+
}
143+
} else {
144+
return uri.getSchemeSpecificPart();
96145
}
97146
}
98147
};
@@ -110,8 +159,7 @@ public enum TrafficType {
110159
Vpn;
111160

112161
public static boolean isSystemNetwork(TrafficType trafficType) {
113-
if (Storage.equals(trafficType)
114-
|| Management.equals(trafficType)
162+
if (Storage.equals(trafficType) || Management.equals(trafficType)
115163
|| Control.equals(trafficType)) {
116164
return true;
117165
}
@@ -163,11 +211,18 @@ public Class<?> type() {
163211

164212
public <T> URI toUri(T value) {
165213
try {
166-
// assert(this!=Vlan || value.getClass().isAssignableFrom(Integer.class)) :
214+
// assert(this!=Vlan ||
215+
// value.getClass().isAssignableFrom(Integer.class)) :
216+
// do we need to check that value does not contain a scheme
217+
// part?
167218
// "Why are you putting non integer into vlan url";
168-
return new URI(scheme + "://" + value.toString());
219+
if (value.toString().contains(":"))
220+
return new URI(value.toString());
221+
else
222+
return new URI(scheme, value.toString(), null);
169223
} catch (URISyntaxException e) {
170-
throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value);
224+
throw new CloudRuntimeException(
225+
"Unable to convert to isolation type URI: " + value);
171226
}
172227
}
173228
}
@@ -176,7 +231,7 @@ public enum BroadcastScheme {
176231
Vlan("vlan"),
177232
VSwitch("vswitch");
178233

179-
private String scheme;
234+
private final String scheme;
180235

181236
private BroadcastScheme(String scheme) {
182237
this.scheme = scheme;

‎api/src/com/cloud/network/element/DhcpServiceProvider.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.cloud.vm.VirtualMachineProfile;
2828

2929
public interface DhcpServiceProvider extends NetworkElement {
30-
boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
31-
boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
30+
boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
31+
boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
3232
boolean removeDhcpSupportForSubnet(Network network) throws ResourceUnavailableException;
3333
}

0 commit comments

Comments
 (0)