Skip to content

Commit c607e03

Browse files
author
Kishan Kavala
committed
Merge branch 'master' into regions
2 parents e734131 + cae89c6 commit c607e03

145 files changed

Lines changed: 11746 additions & 2103 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/FirewallRuleTO.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class FirewallRuleTO implements InternalIdentity {
5050
FirewallRule.Purpose purpose;
5151
private Integer icmpType;
5252
private Integer icmpCode;
53-
53+
private FirewallRule.TrafficType trafficType;
5454

5555
protected FirewallRuleTO() {
5656
}
@@ -85,6 +85,7 @@ public FirewallRuleTO(long id,String srcVlanTag, String srcIp, String protocol,
8585
this.sourceCidrList = sourceCidr;
8686
this.icmpType = icmpType;
8787
this.icmpCode = icmpCode;
88+
this.trafficType = null;
8889
}
8990
public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp) {
9091
this(rule.getId(),srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, rule.getPurpose(),rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
@@ -93,6 +94,23 @@ public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp) {
9394
public FirewallRuleTO(FirewallRule rule, String srcIp) {
9495
this(rule.getId(),null, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, rule.getPurpose(),rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
9596
}
97+
98+
public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose) {
99+
this(rule.getId(),srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, purpose,rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
100+
}
101+
102+
public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose, FirewallRule.TrafficType trafficType) {
103+
this(rule.getId(),srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, purpose,rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
104+
this.trafficType = trafficType;
105+
}
106+
107+
public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose, boolean revokeState, boolean alreadyAdded) {
108+
this(rule.getId(),srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), revokeState, alreadyAdded, purpose,rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
109+
}
110+
111+
public FirewallRule.TrafficType getTrafficType(){
112+
return trafficType;
113+
}
96114

97115
public long getId() {
98116
return id;

api/src/com/cloud/event/EventTypes.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class EventTypes {
2626
public static final String EVENT_VM_UPDATE = "VM.UPDATE";
2727
public static final String EVENT_VM_UPGRADE = "VM.UPGRADE";
2828
public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD";
29+
public static final String EVENT_VM_RESETSSHKEY = "VM.RESETSSHKEY";
2930
public static final String EVENT_VM_MIGRATE = "VM.MIGRATE";
3031
public static final String EVENT_VM_MOVE = "VM.MOVE";
3132
public static final String EVENT_VM_RESTORE = "VM.RESTORE";
@@ -63,6 +64,11 @@ public class EventTypes {
6364
public static final String EVENT_FIREWALL_OPEN = "FIREWALL.OPEN";
6465
public static final String EVENT_FIREWALL_CLOSE = "FIREWALL.CLOSE";
6566

67+
//NIC Events
68+
public static final String EVENT_NIC_CREATE = "NIC.CREATE";
69+
public static final String EVENT_NIC_DELETE = "NIC.DELETE";
70+
public static final String EVENT_NIC_UPDATE = "NIC.UPDATE";
71+
6672
// Load Balancers
6773
public static final String EVENT_ASSIGN_TO_LOAD_BALANCER_RULE = "LB.ASSIGN.TO.RULE";
6874
public static final String EVENT_REMOVE_FROM_LOAD_BALANCER_RULE = "LB.REMOVE.FROM.RULE";
@@ -313,4 +319,10 @@ public class EventTypes {
313319
public static final String EVENT_AUTOSCALEVMGROUP_UPDATE = "AUTOSCALEVMGROUP.UPDATE";
314320
public static final String EVENT_AUTOSCALEVMGROUP_ENABLE = "AUTOSCALEVMGROUP.ENABLE";
315321
public static final String EVENT_AUTOSCALEVMGROUP_DISABLE = "AUTOSCALEVMGROUP.DISABLE";
322+
323+
public static final String EVENT_BAREMETAL_DHCP_SERVER_ADD = "PHYSICAL.DHCP.ADD";
324+
public static final String EVENT_BAREMETAL_DHCP_SERVER_DELETE = "PHYSICAL.DHCP.DELETE";
325+
326+
public static final String EVENT_BAREMETAL_PXE_SERVER_ADD = "PHYSICAL.PXE.ADD";
327+
public static final String EVENT_BAREMETAL_PXE_SERVER_DELETE = "PHYSICAL.PXE.DELETE";
316328
}

api/src/com/cloud/host/Host.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public enum Type {
3939
ExternalLoadBalancer(false),
4040
ExternalVirtualSwitchSupervisor(false),
4141
PxeServer(false),
42+
BaremetalPxe(false),
43+
BaremetalDhcp(false),
4244
TrafficMonitor(false),
4345

4446
ExternalDhcp(false),

api/src/com/cloud/network/Network.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public static class Service {
4747
public static final Service Dhcp = new Service("Dhcp");
4848
public static final Service Dns = new Service("Dns", Capability.AllowDnsSuffixModification);
4949
public static final Service Gateway = new Service("Gateway");
50-
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols,
51-
Capability.MultipleIps, Capability.TrafficStatistics);
50+
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols,
51+
Capability.MultipleIps, Capability.TrafficStatistics, Capability.SupportedTrafficDirection, Capability.SupportedEgressProtocols);
5252
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation,
5353
Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps,
5454
Capability.SupportedStickinessMethods, Capability.ElasticLb);
@@ -173,6 +173,8 @@ public static class Capability {
173173
public static final Capability ElasticLb = new Capability("ElasticLb");
174174
public static final Capability AutoScaleCounters = new Capability("AutoScaleCounters");
175175
public static final Capability InlineMode = new Capability("InlineMode");
176+
public static final Capability SupportedTrafficDirection = new Capability("SupportedTrafficDirection");
177+
public static final Capability SupportedEgressProtocols = new Capability("SupportedEgressProtocols");
176178

177179
private String name;
178180

@@ -287,6 +289,8 @@ private State(String description) {
287289

288290
void setPhysicalNetworkId(Long physicalNetworkId);
289291

292+
public void setTrafficType(TrafficType type);
293+
290294
ACLType getAclType();
291295

292296
boolean isRestartRequired();

api/src/com/cloud/network/NetworkProfile.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,8 @@ public Long getVpcId() {
226226
return vpcId;
227227
}
228228

229+
@Override
230+
public void setTrafficType(TrafficType type) {
231+
this.trafficType = type;
232+
}
229233
}

api/src/com/cloud/network/element/UserDataServiceProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ public interface UserDataServiceProvider extends NetworkElement {
3030
public boolean addPasswordAndUserdata(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
3131
boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws ResourceUnavailableException;
3232
boolean saveUserData(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws ResourceUnavailableException;
33+
boolean saveSSHKey(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String SSHPublicKey) throws ResourceUnavailableException;
3334
}

api/src/com/cloud/network/firewall/FirewallService.java

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

2929
public interface FirewallService {
30-
FirewallRule createFirewallRule(FirewallRule rule) throws NetworkRuleConflictException;
30+
FirewallRule createIngressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException;
31+
FirewallRule createEgressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException;
3132

3233
Pair<List<? extends FirewallRule>, Integer> listFirewallRules(ListFirewallRulesCmd cmd);
3334

@@ -40,7 +41,8 @@ public interface FirewallService {
4041
*/
4142
boolean revokeFirewallRule(long ruleId, boolean apply);
4243

43-
boolean applyFirewallRules(long ipId, Account caller) throws ResourceUnavailableException;
44+
boolean applyEgressFirewallRules (FirewallRule rule, Account caller) throws ResourceUnavailableException;
45+
boolean applyIngressFirewallRules(long Ipid , Account caller) throws ResourceUnavailableException;
4446

4547
FirewallRule getFirewallRule(long ruleId);
4648

api/src/com/cloud/vm/UserVmService.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.cloudstack.api.command.user.vm.RebootVMCmd;
3434
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
3535
import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
36+
import org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd;
3637
import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
3738
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
3839

@@ -88,6 +89,15 @@ public interface UserVmService {
8889
*/
8990
UserVm resetVMPassword(ResetVMPasswordCmd cmd, String password) throws ResourceUnavailableException, InsufficientCapacityException;
9091

92+
/**
93+
* Resets the SSH Key of a virtual machine.
94+
*
95+
* @param cmd
96+
* - the command specifying vmId, Keypair name
97+
* @return the VM if reset worked successfully, null otherwise
98+
*/
99+
UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
100+
91101
/**
92102
* Attaches the specified volume to the specified VM
93103
*
@@ -113,6 +123,27 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
113123

114124
UserVm updateVirtualMachine(UpdateVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
115125

126+
/**
127+
* Adds a NIC on the given network to the virtual machine
128+
* @param cmd the command object that defines the vm and the given network
129+
* @return the vm object if successful, null otherwise
130+
*/
131+
UserVm addNicToVirtualMachine(AddNicToVMCmd cmd);
132+
133+
/**
134+
* Removes a NIC on the given network from the virtual machine
135+
* @param cmd the command object that defines the vm and the given network
136+
* @return the vm object if successful, null otherwise
137+
*/
138+
UserVm removeNicFromVirtualMachine(RemoveNicFromVMCmd cmd);
139+
140+
/**
141+
* Updates default Nic to the given network for given virtual machine
142+
* @param cmd the command object that defines the vm and the given network
143+
* @return the vm object if successful, null otherwise
144+
*/
145+
UserVm updateDefaultNicForVirtualMachine(UpdateDefaultNicForVMCmd cmd);
146+
116147
UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException;
117148

118149
/**

api/src/org/apache/cloudstack/api/ApiConstants.java

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public class ApiConstants {
224224
public static final String NETWORK_OFFERING_ID = "networkofferingid";
225225
public static final String NETWORK_IDS = "networkids";
226226
public static final String NETWORK_ID = "networkid";
227+
public static final String NIC_ID = "nicid";
227228
public static final String SPECIFY_VLAN = "specifyvlan";
228229
public static final String IS_DEFAULT = "isdefault";
229230
public static final String IS_SYSTEM = "issystem";
@@ -430,6 +431,7 @@ public class ApiConstants {
430431
public static final String CONDITION_IDS = "conditionids";
431432
public static final String COUNTERPARAM_LIST = "counterparam";
432433
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
434+
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
433435

434436
public enum HostDetails {
435437
all, capacity, events, stats, min;

api/src/org/apache/cloudstack/api/BaseCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,14 @@ public String buildResponse(ServerApiException apiException, String responseType
292292
StringBuffer sb = new StringBuffer();
293293
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
294294
// JSON response
295-
sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloudstack-version\":\"" + _mgr.getVersion() + "\"},");
295+
sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
296296
sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }");
297297
} else {
298298
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
299299
sb.append("<" + getCommandName() + ">");
300300
sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
301301
sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
302-
sb.append("</" + getCommandName() + " cloudstack-version=\"" + _mgr.getVersion() + "\">");
302+
sb.append("</" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
303303
}
304304
return sb.toString();
305305
}
@@ -310,10 +310,10 @@ public String buildResponse(List<Pair<String, Object>> tagList, String responseT
310310

311311
// set up the return value with the name of the response
312312
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
313-
prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloudstack-version\":\"" + _mgr.getVersion() + "\"},");
313+
prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
314314
} else {
315315
prefixSb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
316-
prefixSb.append("<" + getCommandName() + " cloudstack-version=\"" + _mgr.getVersion() + "\">");
316+
prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
317317
}
318318

319319
int i = 0;

0 commit comments

Comments
 (0)