mirror of https://github.com/apache/cloudstack.git
Merge branch '3.0.x' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 3.0.x
This commit is contained in:
commit
d46a4d53fc
|
|
@ -13,7 +13,6 @@
|
|||
package com.cloud.agent.manager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -39,6 +38,7 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
|
|||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
|
|
@ -63,6 +63,8 @@ public interface MockVmManager extends Manager {
|
|||
Answer SetStaticNatRules(SetStaticNatRulesCommand cmd);
|
||||
|
||||
Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd);
|
||||
|
||||
Answer SetFirewallRules(SetFirewallRulesCommand cmd);
|
||||
|
||||
Answer getNetworkUsage(NetworkUsageCommand cmd);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.cloud.agent.api.MigrateAnswer;
|
|||
import com.cloud.agent.api.MigrateCommand;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.RebootAnswer;
|
||||
import com.cloud.agent.api.RebootCommand;
|
||||
import com.cloud.agent.api.SecurityGroupRuleAnswer;
|
||||
import com.cloud.agent.api.SecurityGroupRulesCmd;
|
||||
|
|
@ -53,6 +54,7 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
|
|||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
|
|
@ -272,6 +274,12 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer SetFirewallRules(SetFirewallRulesCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NetworkUsageAnswer getNetworkUsage(NetworkUsageCommand cmd) {
|
||||
return new NetworkUsageAnswer(cmd, null, 100L, 100L);
|
||||
|
|
@ -340,12 +348,12 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||
_mockAgentMgr.handleSystemVMStop(vm.getId());
|
||||
}
|
||||
|
||||
return new StopAnswer(cmd, null, new Integer(0), new Long(100), new Long(200));
|
||||
return new StopAnswer(cmd, null, new Integer(0), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer rebootVM(RebootCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
return new RebootAnswer(cmd, "Rebooted "+cmd.getVmName(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -457,5 +465,5 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
|
|||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
|
|
@ -200,6 +201,8 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||
return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
|
||||
} else if (cmd instanceof SetStaticNatRulesCommand) {
|
||||
return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
|
||||
} else if (cmd instanceof SetFirewallRulesCommand) {
|
||||
return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
|
||||
} else if (cmd instanceof SetPortForwardingRulesCommand) {
|
||||
return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd);
|
||||
} else if (cmd instanceof NetworkUsageCommand) {
|
||||
|
|
|
|||
|
|
@ -229,10 +229,10 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
Answer result = _simMgr.simulate(cmd, hostGuid);
|
||||
|
||||
if (!result.getResult()) {
|
||||
return new StopAnswer(cmd, result.getDetails());
|
||||
return new StopAnswer(cmd, result.getDetails(), false);
|
||||
}
|
||||
|
||||
answer = new StopAnswer(cmd, null, 0, new Long(100), new Long(200));
|
||||
answer = new StopAnswer(cmd, null, 0, true);
|
||||
Pair<Long, Long> data = _runningVms.get(vmName);
|
||||
if (data != null) {
|
||||
this.usedCpu -= data.first();
|
||||
|
|
|
|||
|
|
@ -215,9 +215,6 @@ public class CloudZonesComputingResource extends LibvirtComputingResource {
|
|||
protected Answer execute(StopCommand cmd) {
|
||||
final String vmName = cmd.getVmName();
|
||||
|
||||
Long bytesReceived = new Long(0);
|
||||
Long bytesSent = new Long(0);
|
||||
|
||||
State state = null;
|
||||
synchronized (_vms) {
|
||||
state = _vms.get(vmName);
|
||||
|
|
@ -231,7 +228,7 @@ public class CloudZonesComputingResource extends LibvirtComputingResource {
|
|||
.nameUUIDFromBytes(vmName.getBytes()));
|
||||
} catch (LibvirtException e) {
|
||||
state = State.Stopped;
|
||||
return new StopAnswer(cmd, null, 0, bytesSent, bytesReceived);
|
||||
return new StopAnswer(cmd, null, 0, true);
|
||||
}
|
||||
|
||||
String macAddress = null;
|
||||
|
|
@ -254,9 +251,9 @@ public class CloudZonesComputingResource extends LibvirtComputingResource {
|
|||
}
|
||||
|
||||
state = State.Stopped;
|
||||
return new StopAnswer(cmd, result, 0, bytesSent, bytesReceived);
|
||||
return new StopAnswer(cmd, result, 0, true);
|
||||
} catch (LibvirtException e) {
|
||||
return new StopAnswer(cmd, e.getMessage());
|
||||
return new StopAnswer(cmd, e.getMessage(), false);
|
||||
} finally {
|
||||
synchronized (_vms) {
|
||||
if (state != null) {
|
||||
|
|
|
|||
|
|
@ -439,8 +439,6 @@ public class FakeComputingResource extends ServerResourceBase implements
|
|||
String vmName = cmd.getVmName();
|
||||
|
||||
Integer port = vmMgr.getVncPort(vmName);
|
||||
Long bytesReceived = null;
|
||||
Long bytesSent = null;
|
||||
|
||||
State state = null;
|
||||
synchronized (_vms) {
|
||||
|
|
@ -458,17 +456,16 @@ public class FakeComputingResource extends ServerResourceBase implements
|
|||
s_logger.warn("Couldn't stop " + vmName);
|
||||
|
||||
if (result != null) {
|
||||
return new StopAnswer(cmd, result);
|
||||
return new StopAnswer(cmd, result, false);
|
||||
}
|
||||
}
|
||||
|
||||
answer = new StopAnswer(cmd, null, port, bytesSent, bytesReceived);
|
||||
answer = new StopAnswer(cmd, null, port, true);
|
||||
|
||||
String result2 = vmMgr.cleanupVnet(cmd.getVnet());
|
||||
if (result2 != null) {
|
||||
result = result2 + (result != null ? ("\n" + result) : "");
|
||||
answer = new StopAnswer(cmd, result, port, bytesSent,
|
||||
bytesReceived);
|
||||
answer = new StopAnswer(cmd, result, port, true);
|
||||
}
|
||||
|
||||
_dhcpSnooper.cleanup(vmName, null);
|
||||
|
|
@ -494,7 +491,7 @@ public class FakeComputingResource extends ServerResourceBase implements
|
|||
protected Answer execute(RebootCommand cmd) {
|
||||
VmMgr vmMgr = getVmManager();
|
||||
vmMgr.rebootVM(cmd.getVmName());
|
||||
return new RebootAnswer(cmd, "success", 0L, 0L);
|
||||
return new RebootAnswer(cmd, "success", true);
|
||||
}
|
||||
|
||||
private Answer execute(PingTestCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
private String _createTmplPath;
|
||||
private String _heartBeatPath;
|
||||
private String _securityGroupPath;
|
||||
private String _networkUsagePath;
|
||||
private String _routerProxyPath;
|
||||
private String _host;
|
||||
private String _dcId;
|
||||
private String _pod;
|
||||
|
|
@ -539,11 +539,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
"Unable to find the security_group.py");
|
||||
}
|
||||
|
||||
_networkUsagePath = Script.findScript("scripts/network/domr/",
|
||||
"networkUsage.sh");
|
||||
if (_networkUsagePath == null) {
|
||||
_routerProxyPath = Script.findScript("scripts/network/domr/",
|
||||
"routerProxy.sh");
|
||||
if (_routerProxyPath == null) {
|
||||
throw new ConfigurationException(
|
||||
"Unable to find the networkUsage.sh");
|
||||
"Unable to find the routerProxy.sh");
|
||||
}
|
||||
|
||||
String value = (String) params.get("developer");
|
||||
|
|
@ -2168,7 +2168,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
|
||||
protected String networkUsage(final String privateIpAddress,
|
||||
final String option, final String vif) {
|
||||
Script getUsage = new Script(_networkUsagePath, s_logger);
|
||||
Script getUsage = new Script(_routerProxyPath, s_logger);
|
||||
getUsage.add("netusage.sh");
|
||||
getUsage.add(privateIpAddress);
|
||||
if (option.equals("get")) {
|
||||
getUsage.add("-g");
|
||||
} else if (option.equals("create")) {
|
||||
|
|
@ -2181,7 +2183,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
getUsage.add("-d", vif);
|
||||
}
|
||||
|
||||
getUsage.add("-i", privateIpAddress);
|
||||
|
||||
final OutputInterpreter.OneLineParser usageParser = new OutputInterpreter.OneLineParser();
|
||||
String result = getUsage.execute(usageParser);
|
||||
if (result != null) {
|
||||
|
|
@ -2219,8 +2221,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
}
|
||||
|
||||
private Answer execute(RebootCommand cmd) {
|
||||
Long bytesReceived = null;
|
||||
Long bytesSent = null;
|
||||
|
||||
synchronized (_vms) {
|
||||
_vms.put(cmd.getVmName(), State.Starting);
|
||||
|
|
@ -2237,13 +2237,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
|
||||
}
|
||||
get_rule_logs_for_vms();
|
||||
return new RebootAnswer(cmd, null, bytesSent, bytesReceived,
|
||||
vncPort);
|
||||
return new RebootAnswer(cmd, null, vncPort);
|
||||
} else {
|
||||
return new RebootAnswer(cmd, result);
|
||||
return new RebootAnswer(cmd, result, false);
|
||||
}
|
||||
} catch (LibvirtException e) {
|
||||
return new RebootAnswer(cmd, e.getMessage());
|
||||
return new RebootAnswer(cmd, e.getMessage(), false);
|
||||
} finally {
|
||||
synchronized (_vms) {
|
||||
_vms.put(cmd.getVmName(), State.Running);
|
||||
|
|
@ -2252,16 +2251,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
}
|
||||
|
||||
protected Answer execute(RebootRouterCommand cmd) {
|
||||
Long bytesSent = 0L;
|
||||
Long bytesRcvd = 0L;
|
||||
if (VirtualMachineName.isValidRouterName(cmd.getVmName())) {
|
||||
long[] stats = getNetworkStats(cmd.getPrivateIpAddress());
|
||||
bytesSent = stats[0];
|
||||
bytesRcvd = stats[1];
|
||||
}
|
||||
RebootAnswer answer = (RebootAnswer) execute((RebootCommand) cmd);
|
||||
answer.setBytesSent(bytesSent);
|
||||
answer.setBytesReceived(bytesRcvd);
|
||||
String result = _virtRouterResource.connect(cmd.getPrivateIpAddress());
|
||||
if (result == null) {
|
||||
networkUsage(cmd.getPrivateIpAddress(), "create", null);
|
||||
|
|
@ -2294,9 +2284,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
protected Answer execute(StopCommand cmd) {
|
||||
final String vmName = cmd.getVmName();
|
||||
|
||||
Long bytesReceived = new Long(0);
|
||||
Long bytesSent = new Long(0);
|
||||
|
||||
State state = null;
|
||||
synchronized (_vms) {
|
||||
state = _vms.get(vmName);
|
||||
|
|
@ -2322,9 +2309,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
result = result2 + result;
|
||||
}
|
||||
state = State.Stopped;
|
||||
return new StopAnswer(cmd, result, 0, bytesSent, bytesReceived);
|
||||
return new StopAnswer(cmd, result, 0, true);
|
||||
} catch (LibvirtException e) {
|
||||
return new StopAnswer(cmd, e.getMessage());
|
||||
return new StopAnswer(cmd, e.getMessage(), false);
|
||||
} finally {
|
||||
synchronized (_vms) {
|
||||
if (state != null) {
|
||||
|
|
|
|||
|
|
@ -13,28 +13,35 @@
|
|||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.LogLevel.Log4jLevel;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
|
||||
@LogLevel(Log4jLevel.Trace)
|
||||
public class NetworkUsageCommand extends Command {
|
||||
private String privateIP;
|
||||
private String domRName;
|
||||
private String option;
|
||||
boolean forVpc = false;
|
||||
NicTO guestNic;
|
||||
|
||||
protected NetworkUsageCommand() {
|
||||
|
||||
}
|
||||
|
||||
public NetworkUsageCommand(String privateIP, String domRName)
|
||||
public NetworkUsageCommand(String privateIP, String domRName, boolean forVpc, NicTO guestNic)
|
||||
{
|
||||
this.privateIP = privateIP;
|
||||
this.domRName = domRName;
|
||||
this.forVpc = forVpc;
|
||||
this.guestNic = guestNic;
|
||||
this.option = "get";
|
||||
}
|
||||
|
||||
public NetworkUsageCommand(String privateIP, String domRName, String option)
|
||||
public NetworkUsageCommand(String privateIP, String domRName, String option, boolean forVpc)
|
||||
{
|
||||
this.privateIP = privateIP;
|
||||
this.domRName = domRName;
|
||||
this.option = option;
|
||||
this.forVpc = forVpc;
|
||||
}
|
||||
|
||||
public String getPrivateIP() {
|
||||
|
|
@ -49,6 +56,14 @@ public class NetworkUsageCommand extends Command {
|
|||
return option;
|
||||
}
|
||||
|
||||
public boolean isForVpc() {
|
||||
return forVpc;
|
||||
}
|
||||
|
||||
public NicTO getGuestNic() {
|
||||
return guestNic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class PlugNicAnswer extends Answer{
|
||||
public PlugNicAnswer() {}
|
||||
|
||||
public PlugNicAnswer(PlugNicCommand cmd, boolean success, String result) {
|
||||
super(cmd, success, result);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class PlugNicCommand extends Command {
|
||||
|
||||
VirtualMachineTO vm;
|
||||
NicTO nic;
|
||||
|
||||
public VirtualMachineTO getVirtualMachine() {
|
||||
return vm;
|
||||
}
|
||||
|
||||
public NicTO getNic() {
|
||||
return nic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected PlugNicCommand() {
|
||||
}
|
||||
|
||||
public PlugNicCommand(VirtualMachineTO vm, NicTO nic) {
|
||||
this.vm = vm;
|
||||
this.nic = nic;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,52 +13,25 @@
|
|||
package com.cloud.agent.api;
|
||||
|
||||
public class RebootAnswer extends Answer {
|
||||
Long bytesSent;
|
||||
Long bytesReceived;
|
||||
Integer vncPort;
|
||||
|
||||
protected RebootAnswer() {
|
||||
}
|
||||
|
||||
public RebootAnswer(RebootCommand cmd, String details, Long bytesSent, Long bytesReceived, Integer vncport) {
|
||||
public RebootAnswer(RebootCommand cmd, String details, Integer vncport) {
|
||||
super(cmd, true, details);
|
||||
this.bytesReceived = bytesReceived;
|
||||
this.bytesSent = bytesSent;
|
||||
this.vncPort = vncport;
|
||||
}
|
||||
|
||||
public RebootAnswer(RebootCommand cmd, String details, Long bytesSent, Long bytesReceived) {
|
||||
super(cmd, true, details);
|
||||
this.bytesReceived = bytesReceived;
|
||||
this.bytesSent = bytesSent;
|
||||
public RebootAnswer(RebootCommand cmd, String details, boolean success) {
|
||||
super(cmd, success, details);
|
||||
this.vncPort = null;
|
||||
}
|
||||
|
||||
public RebootAnswer(RebootCommand cmd, String details) {
|
||||
super(cmd, false, details);
|
||||
bytesSent = null;
|
||||
bytesReceived = null;
|
||||
}
|
||||
|
||||
public RebootAnswer(RebootCommand cmd, Exception e) {
|
||||
super(cmd, e);
|
||||
}
|
||||
|
||||
public void setBytesReceived(Long bytesReceived) {
|
||||
this.bytesReceived = bytesReceived;
|
||||
}
|
||||
|
||||
public Long getBytesReceived() {
|
||||
return bytesReceived;
|
||||
}
|
||||
|
||||
public void setBytesSent(Long bytesSent) {
|
||||
this.bytesSent = bytesSent;
|
||||
}
|
||||
|
||||
public Long getBytesSent() {
|
||||
return bytesSent;
|
||||
}
|
||||
public Integer getVncPort() {
|
||||
return vncPort;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.routing.SetSourceNatCommand;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetSourceNatAnswer extends Answer{
|
||||
public SetSourceNatAnswer() {}
|
||||
|
||||
public SetSourceNatAnswer(SetSourceNatCommand cmd, boolean success, String result) {
|
||||
super(cmd, success, result);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetupGuestNetworkAnswer extends Answer{
|
||||
public SetupGuestNetworkAnswer() {}
|
||||
|
||||
public SetupGuestNetworkAnswer(SetupGuestNetworkCommand cmd, boolean success, String result) {
|
||||
super(cmd, success, result);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetupGuestNetworkCommand extends NetworkElementCommand{
|
||||
String dhcpRange;
|
||||
String networkDomain;
|
||||
String defaultDns1 = null;
|
||||
String defaultDns2 = null;
|
||||
boolean isRedundant = false;
|
||||
Integer priority;
|
||||
boolean add = true;
|
||||
NicTO nic;
|
||||
|
||||
public NicTO getNic() {
|
||||
return nic;
|
||||
}
|
||||
|
||||
public String getDefaultDns1() {
|
||||
return defaultDns1;
|
||||
}
|
||||
|
||||
public String getDefaultDns2() {
|
||||
return defaultDns2;
|
||||
}
|
||||
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected SetupGuestNetworkCommand() {
|
||||
}
|
||||
|
||||
|
||||
public SetupGuestNetworkCommand(String dhcpRange, String networkDomain, boolean isRedundant, Integer priority,
|
||||
String defaultDns1, String defaultDns2, boolean add, NicTO nic) {
|
||||
this.dhcpRange = dhcpRange;
|
||||
this.networkDomain = networkDomain;
|
||||
this.defaultDns1 = defaultDns1;
|
||||
this.defaultDns2 = defaultDns2;
|
||||
this.isRedundant = isRedundant;
|
||||
this.priority = priority;
|
||||
this.add = add;
|
||||
this.nic = nic;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,13 +18,13 @@ public class StopAnswer extends RebootAnswer {
|
|||
protected StopAnswer() {
|
||||
}
|
||||
|
||||
public StopAnswer(StopCommand cmd, String details, Integer vncPort, Long bytesSent, Long bytesReceived) {
|
||||
super(cmd, details, bytesSent, bytesReceived);
|
||||
public StopAnswer(StopCommand cmd, String details, Integer vncPort, boolean success) {
|
||||
super(cmd, details, success);
|
||||
this.vncPort = vncPort;
|
||||
}
|
||||
|
||||
public StopAnswer(StopCommand cmd, String details) {
|
||||
super(cmd, details);
|
||||
public StopAnswer(StopCommand cmd, String details, boolean success) {
|
||||
super(cmd, details, success);
|
||||
vncPort = null;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ public class StopCommand extends RebootCommand {
|
|||
private boolean isProxy=false;
|
||||
private String urlPort=null;
|
||||
private String publicConsoleProxyIpAddress=null;
|
||||
private String privateRouterIpAddress=null;
|
||||
|
||||
protected StopCommand() {
|
||||
}
|
||||
|
|
@ -41,12 +40,6 @@ public class StopCommand extends RebootCommand {
|
|||
this.vnet = vnet;
|
||||
}
|
||||
|
||||
public StopCommand(VirtualMachine vm, String vmName, String vnet, String privateRouterIpAddress) {
|
||||
super(vmName);
|
||||
this.vnet = vnet;
|
||||
this.privateRouterIpAddress = privateRouterIpAddress;
|
||||
}
|
||||
|
||||
public StopCommand(String vmName) {
|
||||
super(vmName);
|
||||
}
|
||||
|
|
@ -72,7 +65,4 @@ public class StopCommand extends RebootCommand {
|
|||
return this.publicConsoleProxyIpAddress;
|
||||
}
|
||||
|
||||
public String getPrivateRouterIpAddress() {
|
||||
return privateRouterIpAddress;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class UnPlugNicAnswer extends Answer{
|
||||
public UnPlugNicAnswer() {}
|
||||
|
||||
public UnPlugNicAnswer(UnPlugNicCommand cmd, boolean success, String result) {
|
||||
super(cmd, success, result);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class UnPlugNicCommand extends Command{
|
||||
VirtualMachineTO vm;
|
||||
NicTO nic;
|
||||
|
||||
public VirtualMachineTO getVirtualMachine() {
|
||||
return vm;
|
||||
}
|
||||
|
||||
public NicTO getNic() {
|
||||
return nic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected UnPlugNicCommand() {
|
||||
}
|
||||
|
||||
public UnPlugNicCommand(VirtualMachineTO vm, NicTO nic) {
|
||||
this.vm = vm;
|
||||
this.nic = nic;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class IpAssocVpcCommand extends IpAssocCommand{
|
||||
protected IpAssocVpcCommand() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IpAssocVpcCommand(IpAddressTO[] ips) {
|
||||
super(ips);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
package com.cloud.agent.api.routing;
|
||||
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
|
||||
/**
|
||||
* LoadBalancerConfigCommand sends the load balancer configuration
|
||||
|
|
@ -27,23 +28,35 @@ public class LoadBalancerConfigCommand extends NetworkElementCommand {
|
|||
public String lbStatsSrcCidrs = "0/0" ; /* TODO : currently there is no filtering based on the source ip */
|
||||
public String lbStatsAuth = "admin1:AdMiN123";
|
||||
public String lbStatsUri = "/admin?stats";
|
||||
NicTO nic;
|
||||
Long vpcId;
|
||||
|
||||
protected LoadBalancerConfigCommand() {
|
||||
}
|
||||
|
||||
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers) {
|
||||
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers, Long vpcId) {
|
||||
this.loadBalancers = loadBalancers;
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
|
||||
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp) {
|
||||
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp, NicTO nic, Long vpcId) {
|
||||
this.loadBalancers = loadBalancers;
|
||||
this.lbStatsPublicIP = PublicIp;
|
||||
this.lbStatsPrivateIP = PrivateIp;
|
||||
this.lbStatsGuestIP = GuestIp;
|
||||
this.nic = nic;
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
|
||||
public NicTO getNic() {
|
||||
return nic;
|
||||
}
|
||||
|
||||
public LoadBalancerTO[] getLoadBalancers() {
|
||||
return loadBalancers;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public abstract class NetworkElementCommand extends Command {
|
|||
public static final String ROUTER_IP = "router.ip";
|
||||
public static final String ROUTER_GUEST_IP = "router.guest.ip";
|
||||
public static final String ZONE_NETWORK_TYPE = "zone.network.type";
|
||||
public static final String GUEST_BRIDGE = "guest.bridge";
|
||||
|
||||
protected NetworkElementCommand() {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import com.cloud.agent.api.to.FirewallRuleTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.utils.StringUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
public class SetNetworkACLAnswer extends Answer {
|
||||
String[] results;
|
||||
|
||||
protected SetNetworkACLAnswer() {
|
||||
}
|
||||
|
||||
public SetNetworkACLAnswer(SetNetworkACLCommand cmd, boolean success, String[] results) {
|
||||
super(cmd, success, null);
|
||||
assert (cmd.getRules().length == results.length) : "ACLs and their results should be the same length";
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public String[] getResults() {
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.agent.api.to.NetworkACLTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetNetworkACLCommand extends NetworkElementCommand{
|
||||
NetworkACLTO[] rules;
|
||||
NicTO nic;
|
||||
|
||||
protected SetNetworkACLCommand() {
|
||||
}
|
||||
|
||||
public SetNetworkACLCommand(List<NetworkACLTO> rules, NicTO nic) {
|
||||
this.rules = rules.toArray(new NetworkACLTO[rules.size()]);
|
||||
this.nic = nic;
|
||||
}
|
||||
|
||||
public NetworkACLTO[] getRules() {
|
||||
return rules;
|
||||
}
|
||||
public String[][] generateFwRules() {
|
||||
String [][] result = new String [2][];
|
||||
Set<String> toAdd = new HashSet<String>();
|
||||
|
||||
|
||||
for (NetworkACLTO aclTO: rules) {
|
||||
/* example : Ingress:tcp:80:80:0.0.0.0/0:,Egress:tcp:220:220:0.0.0.0/0:,
|
||||
* each entry format Ingress/Egress:protocol:start port: end port:scidrs:
|
||||
* reverted entry format Ingress/Egress:reverted:0:0:0:
|
||||
*/
|
||||
if (aclTO.revoked() == true)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
/* This entry is added just to make sure atleast there will one entry in the list to get the ipaddress */
|
||||
sb.append(aclTO.getTrafficType().toString()).append(":reverted:0:0:0:");
|
||||
String aclRuleEntry = sb.toString();
|
||||
toAdd.add(aclRuleEntry);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> cidr;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(aclTO.getTrafficType().toString()).append(":").append(aclTO.getProtocol()).append(":");
|
||||
if ("icmp".compareTo(aclTO.getProtocol()) == 0)
|
||||
{
|
||||
sb.append(aclTO.getIcmpType()).append(":").append(aclTO.getIcmpCode()).append(":");
|
||||
} else {
|
||||
sb.append(aclTO.getStringPortRange()).append(":");
|
||||
}
|
||||
cidr = aclTO.getSourceCidrList();
|
||||
if (cidr == null || cidr.isEmpty())
|
||||
{
|
||||
sb.append("0.0.0.0/0");
|
||||
}else{
|
||||
Boolean firstEntry = true;
|
||||
for (String tag : cidr) {
|
||||
if (!firstEntry) sb.append("-");
|
||||
sb.append(tag);
|
||||
firstEntry = false;
|
||||
}
|
||||
}
|
||||
sb.append(":");
|
||||
String aclRuleEntry = sb.toString();
|
||||
|
||||
toAdd.add(aclRuleEntry);
|
||||
|
||||
}
|
||||
result[0] = toAdd.toArray(new String[toAdd.size()]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public NicTO getNic() {
|
||||
return nic;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.PortForwardingRuleTO;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetPortForwardingRulesVpcCommand extends SetPortForwardingRulesCommand{
|
||||
protected SetPortForwardingRulesVpcCommand() {
|
||||
}
|
||||
|
||||
public SetPortForwardingRulesVpcCommand(List<? extends PortForwardingRuleTO> pfRules) {
|
||||
super(pfRules);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetSourceNatCommand extends NetworkElementCommand{
|
||||
IpAddressTO ipAddress;
|
||||
boolean add;
|
||||
|
||||
protected SetSourceNatCommand() {
|
||||
}
|
||||
|
||||
public SetSourceNatCommand(IpAddressTO ip, boolean add) {
|
||||
this.ipAddress = ip;
|
||||
this.add = add;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IpAddressTO getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,20 +19,25 @@ import com.cloud.agent.api.to.StaticNatRuleTO;
|
|||
public class SetStaticNatRulesCommand extends NetworkElementCommand{
|
||||
|
||||
StaticNatRuleTO[] rules;
|
||||
Long vpcId;
|
||||
|
||||
protected SetStaticNatRulesCommand() {
|
||||
}
|
||||
|
||||
public SetStaticNatRulesCommand(List<? extends StaticNatRuleTO> staticNatRules) {
|
||||
public SetStaticNatRulesCommand(List<? extends StaticNatRuleTO> staticNatRules, Long vpcId) {
|
||||
rules = new StaticNatRuleTO[staticNatRules.size()];
|
||||
int i = 0;
|
||||
for (StaticNatRuleTO rule : staticNatRules) {
|
||||
rules[i++] = rule;
|
||||
}
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
|
||||
public StaticNatRuleTO[] getRules() {
|
||||
return rules;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetStaticRouteAnswer extends Answer{
|
||||
String[] results;
|
||||
|
||||
protected SetStaticRouteAnswer() {
|
||||
}
|
||||
|
||||
public SetStaticRouteAnswer(SetStaticRouteCommand cmd, boolean success, String[] results) {
|
||||
super(cmd, success, null);
|
||||
assert (cmd.getStaticRoutes().length == results.length) : "Static routes and their results should be the same length";
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public String[] getResults() {
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api.routing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.vpc.StaticRouteProfile;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public class SetStaticRouteCommand extends NetworkElementCommand{
|
||||
StaticRouteProfile[] staticRoutes;
|
||||
|
||||
protected SetStaticRouteCommand() {
|
||||
}
|
||||
|
||||
public SetStaticRouteCommand(List<StaticRouteProfile> staticRoutes) {
|
||||
this.staticRoutes = staticRoutes.toArray(new StaticRouteProfile[staticRoutes.size()]);
|
||||
}
|
||||
|
||||
public StaticRouteProfile[] getStaticRoutes() {
|
||||
return staticRoutes;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
package com.cloud.agent.api.routing;
|
||||
|
||||
public class Site2SiteVpnCfgCommand extends NetworkElementCommand {
|
||||
|
||||
private boolean create;
|
||||
private String localPublicIp;
|
||||
private String localGuestCidr;
|
||||
private String localPublicGateway;
|
||||
private String peerGatewayIp;
|
||||
private String peerGuestCidrList;
|
||||
private String ipsecPsk;
|
||||
private String ikePolicy;
|
||||
private String espPolicy;
|
||||
private long lifetime;
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Site2SiteVpnCfgCommand () {
|
||||
this.create = false;
|
||||
}
|
||||
|
||||
public Site2SiteVpnCfgCommand (boolean create, String localPublicIp, String localPublicGateway, String localGuestCidr,
|
||||
String peerGatewayIp, String peerGuestCidrList, String ikePolicy, String espPolicy, long lifetime, String ipsecPsk) {
|
||||
this.create = create;
|
||||
this.setLocalPublicIp(localPublicIp);
|
||||
this.setLocalPublicGateway(localPublicGateway);
|
||||
this.setLocalGuestCidr(localGuestCidr);
|
||||
this.setPeerGatewayIp(peerGatewayIp);
|
||||
this.setPeerGuestCidrList(peerGuestCidrList);
|
||||
this.ipsecPsk = ipsecPsk;
|
||||
this.ikePolicy = ikePolicy;
|
||||
this.espPolicy = espPolicy;
|
||||
this.lifetime = lifetime;
|
||||
}
|
||||
|
||||
public boolean isCreate() {
|
||||
return create;
|
||||
}
|
||||
|
||||
public void setCreate(boolean create) {
|
||||
this.create = create;
|
||||
}
|
||||
|
||||
public String getIpsecPsk() {
|
||||
return ipsecPsk;
|
||||
}
|
||||
|
||||
public void setIpsecPsk(String ipsecPsk) {
|
||||
this.ipsecPsk = ipsecPsk;
|
||||
}
|
||||
|
||||
public String getIkePolicy() {
|
||||
return ikePolicy;
|
||||
}
|
||||
|
||||
public void setIkePolicy(String ikePolicy) {
|
||||
this.ikePolicy = ikePolicy;
|
||||
}
|
||||
|
||||
public String getEspPolicy() {
|
||||
return espPolicy;
|
||||
}
|
||||
|
||||
public void setEspPolicy(String espPolicy) {
|
||||
this.espPolicy = espPolicy;
|
||||
}
|
||||
|
||||
public long getLifetime() {
|
||||
return lifetime;
|
||||
}
|
||||
|
||||
public void setLifetime(long lifetime) {
|
||||
this.lifetime = lifetime;
|
||||
}
|
||||
|
||||
public String getLocalPublicIp() {
|
||||
return localPublicIp;
|
||||
}
|
||||
|
||||
public void setLocalPublicIp(String localPublicIp) {
|
||||
this.localPublicIp = localPublicIp;
|
||||
}
|
||||
|
||||
public String getLocalGuestCidr() {
|
||||
return localGuestCidr;
|
||||
}
|
||||
|
||||
public void setLocalGuestCidr(String localGuestCidr) {
|
||||
this.localGuestCidr = localGuestCidr;
|
||||
}
|
||||
|
||||
public String getLocalPublicGateway() {
|
||||
return localPublicGateway;
|
||||
}
|
||||
|
||||
public void setLocalPublicGateway(String localPublicGateway) {
|
||||
this.localPublicGateway = localPublicGateway;
|
||||
}
|
||||
|
||||
public String getPeerGatewayIp() {
|
||||
return peerGatewayIp;
|
||||
}
|
||||
|
||||
public void setPeerGatewayIp(String peerGatewayIp) {
|
||||
this.peerGatewayIp = peerGatewayIp;
|
||||
}
|
||||
|
||||
public String getPeerGuestCidrList() {
|
||||
return peerGuestCidrList;
|
||||
}
|
||||
|
||||
public void setPeerGuestCidrList(String peerGuestCidrList) {
|
||||
this.peerGuestCidrList = peerGuestCidrList;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@ package com.cloud.agent.api.to;
|
|||
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
||||
|
||||
public class IpAddressTO {
|
||||
|
||||
private long accountId;
|
||||
|
|
@ -32,7 +31,8 @@ public class IpAddressTO {
|
|||
private TrafficType trafficType;
|
||||
private String networkName;
|
||||
|
||||
public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String vlanId, String vlanGateway, String vlanNetmask, String vifMacAddress, String guestIp, Integer networkRate, boolean isOneToOneNat) {
|
||||
public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String vlanId,
|
||||
String vlanGateway, String vlanNetmask, String vifMacAddress, String guestIp, Integer networkRate, boolean isOneToOneNat) {
|
||||
this.accountId = accountId;
|
||||
this.publicIp = ipAddress;
|
||||
this.add = add;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
package com.cloud.agent.api.to;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.TrafficType;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
|
||||
public class NetworkACLTO {
|
||||
long id;
|
||||
String vlanTag;
|
||||
String protocol;
|
||||
int[] portRange;
|
||||
boolean revoked;
|
||||
boolean alreadyAdded;
|
||||
private List<String> cidrList;
|
||||
private Integer icmpType;
|
||||
private Integer icmpCode;
|
||||
private FirewallRule.TrafficType trafficType;
|
||||
|
||||
|
||||
protected NetworkACLTO() {
|
||||
}
|
||||
|
||||
|
||||
public NetworkACLTO(long id,String vlanTag, String protocol, Integer portStart, Integer portEnd, boolean revoked,
|
||||
boolean alreadyAdded, List<String> cidrList, Integer icmpType,Integer icmpCode,TrafficType trafficType) {
|
||||
this.vlanTag = vlanTag;
|
||||
this.protocol = protocol;
|
||||
|
||||
if (portStart != null) {
|
||||
List<Integer> range = new ArrayList<Integer>();
|
||||
range.add(portStart);
|
||||
if (portEnd != null) {
|
||||
range.add(portEnd);
|
||||
}
|
||||
|
||||
portRange = new int[range.size()];
|
||||
int i = 0;
|
||||
for (Integer port : range) {
|
||||
portRange[i] = port.intValue();
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
|
||||
this.revoked = revoked;
|
||||
this.alreadyAdded = alreadyAdded;
|
||||
this.cidrList = cidrList;
|
||||
this.icmpType = icmpType;
|
||||
this.icmpCode = icmpCode;
|
||||
this.trafficType = trafficType;
|
||||
}
|
||||
|
||||
public NetworkACLTO(FirewallRule rule, String vlanTag, FirewallRule.TrafficType trafficType ) {
|
||||
this(rule.getId(), vlanTag, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(),
|
||||
rule.getState() == FirewallRule.State.Revoke, rule.getState() == FirewallRule.State.Active,
|
||||
rule.getSourceCidrList() ,rule.getIcmpType(), rule.getIcmpCode(),trafficType);
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getSrcVlanTag() {
|
||||
return vlanTag;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public int[] getSrcPortRange() {
|
||||
return portRange;
|
||||
}
|
||||
|
||||
public Integer getIcmpType(){
|
||||
return icmpType;
|
||||
}
|
||||
|
||||
public Integer getIcmpCode(){
|
||||
return icmpCode;
|
||||
}
|
||||
|
||||
public String getStringPortRange() {
|
||||
if (portRange == null || portRange.length < 2)
|
||||
return "0:0";
|
||||
else
|
||||
return NetUtils.portRangeToString(portRange);
|
||||
}
|
||||
|
||||
public boolean revoked() {
|
||||
return revoked;
|
||||
}
|
||||
|
||||
public List<String> getSourceCidrList() {
|
||||
return cidrList;
|
||||
}
|
||||
|
||||
public boolean isAlreadyAdded() {
|
||||
return alreadyAdded;
|
||||
}
|
||||
|
||||
public FirewallRule.TrafficType getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
}
|
||||
|
|
@ -173,5 +173,4 @@ public class NetworkTO {
|
|||
public boolean isSecurityGroupEnabled() {
|
||||
return this.isSecurityGroupEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,6 +353,24 @@ public class ApiConstants {
|
|||
public static final String VSM_DEVICE_STATE = "vsmdevicestate";
|
||||
public static final String INCL_ZONES = "includezones";
|
||||
public static final String EXCL_ZONES = "excludezones";
|
||||
public static final String RESOURCE_IDS = "resourceids";
|
||||
public static final String RESOURCE_ID = "resourceid";
|
||||
public static final String CUSTOMER = "customer";
|
||||
public static final String VPC_OFF_ID = "vpcofferingid";
|
||||
public static final String NETWORK = "network";
|
||||
public static final String VPC_ID = "vpcid";
|
||||
public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
|
||||
public static final String GATEWAY_ID = "gatewayid";
|
||||
|
||||
|
||||
public static final String S2S_VPN_GATEWAY_ID = "s2svpngatewayid";
|
||||
public static final String S2S_CUSTOMER_GATEWAY_ID = "s2scustomergatewayid";
|
||||
public static final String IPSEC_PSK = "ipsecpsk";
|
||||
public static final String GUEST_IP = "guestip";
|
||||
public static final String REMOVED = "removed";
|
||||
public static final String IKE_POLICY = "ikepolicy";
|
||||
public static final String ESP_POLICY = "esppolicy";
|
||||
public static final String LIFETIME = "lifetime";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import com.cloud.user.UserContext;
|
|||
public abstract class BaseAsyncCmd extends BaseCmd {
|
||||
public static final String ipAddressSyncObject = "ipaddress";
|
||||
public static final String networkSyncObject = "network";
|
||||
public static final String vpcSyncObject = "vpc";
|
||||
|
||||
|
||||
private AsyncJob job;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,14 +37,18 @@ import com.cloud.network.NetworkService;
|
|||
import com.cloud.network.StorageNetworkService;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.firewall.FirewallService;
|
||||
import com.cloud.network.firewall.NetworkACLService;
|
||||
import com.cloud.network.lb.LoadBalancingRulesService;
|
||||
import com.cloud.network.rules.RulesService;
|
||||
import com.cloud.network.security.SecurityGroupService;
|
||||
import com.cloud.network.vpc.VpcService;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnService;
|
||||
import com.cloud.network.vpn.Site2SiteVpnService;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectService;
|
||||
import com.cloud.resource.ResourceService;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.server.TaggedResourceService;
|
||||
import com.cloud.storage.StorageService;
|
||||
import com.cloud.storage.snapshot.SnapshotService;
|
||||
import com.cloud.template.TemplateService;
|
||||
|
|
@ -123,6 +127,10 @@ public abstract class BaseCmd {
|
|||
public static ResourceLimitService _resourceLimitService;
|
||||
public static IdentityService _identityService;
|
||||
public static StorageNetworkService _storageNetworkService;
|
||||
public static TaggedResourceService _taggedResourceService;
|
||||
public static VpcService _vpcService;
|
||||
public static NetworkACLService _networkACLService;
|
||||
public static Site2SiteVpnService _s2sVpnService;
|
||||
|
||||
static void setComponents(ResponseGenerator generator) {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||
|
|
@ -150,6 +158,10 @@ public abstract class BaseCmd {
|
|||
_resourceLimitService = locator.getManager(ResourceLimitService.class);
|
||||
_identityService = locator.getManager(IdentityService.class);
|
||||
_storageNetworkService = locator.getManager(StorageNetworkService.class);
|
||||
_taggedResourceService = locator.getManager(TaggedResourceService.class);
|
||||
_vpcService = locator.getManager(VpcService.class);
|
||||
_networkACLService = locator.getManager(NetworkACLService.class);
|
||||
_s2sVpnService = locator.getManager(Site2SiteVpnService.class);
|
||||
}
|
||||
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||
|
|
@ -483,7 +495,7 @@ public abstract class BaseCmd {
|
|||
if (!enabledOnly || account.getState() == Account.State.enabled) {
|
||||
return account.getId();
|
||||
} else {
|
||||
throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active");
|
||||
throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active");
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain id=" + domainId);
|
||||
|
|
@ -496,10 +508,14 @@ public abstract class BaseCmd {
|
|||
if (!enabledOnly || project.getState() == Project.State.Active) {
|
||||
return project.getProjectAccountId();
|
||||
} else {
|
||||
throw new PermissionDeniedException("Can't add resources to the project id=" + projectId + " in state=" + project.getState() + " as it's no longer active");
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active");
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified projectId");
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.cloud.api.response.BaseResponse;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ TYPE })
|
||||
public @interface Implementation {
|
||||
Class<?> responseObject();
|
||||
Class<? extends BaseResponse> responseObject();
|
||||
|
||||
String description() default "";
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,12 @@ import com.cloud.api.response.LBStickinessResponse;
|
|||
import com.cloud.api.response.LDAPConfigResponse;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.LoadBalancerResponse;
|
||||
import com.cloud.api.response.NetworkACLResponse;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.api.response.NetworkResponse;
|
||||
import com.cloud.api.response.PhysicalNetworkResponse;
|
||||
import com.cloud.api.response.PodResponse;
|
||||
import com.cloud.api.response.PrivateGatewayResponse;
|
||||
import com.cloud.api.response.ProjectAccountResponse;
|
||||
import com.cloud.api.response.ProjectInvitationResponse;
|
||||
import com.cloud.api.response.ProjectResponse;
|
||||
|
|
@ -52,11 +54,16 @@ import com.cloud.api.response.ProviderResponse;
|
|||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.api.response.ResourceCountResponse;
|
||||
import com.cloud.api.response.ResourceLimitResponse;
|
||||
import com.cloud.api.response.ResourceTagResponse;
|
||||
import com.cloud.api.response.SecurityGroupResponse;
|
||||
import com.cloud.api.response.ServiceOfferingResponse;
|
||||
import com.cloud.api.response.ServiceResponse;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.api.response.SnapshotPolicyResponse;
|
||||
import com.cloud.api.response.SnapshotResponse;
|
||||
import com.cloud.api.response.StaticRouteResponse;
|
||||
import com.cloud.api.response.StorageNetworkIpRangeResponse;
|
||||
import com.cloud.api.response.StoragePoolResponse;
|
||||
import com.cloud.api.response.SwiftResponse;
|
||||
|
|
@ -70,6 +77,8 @@ import com.cloud.api.response.UserVmResponse;
|
|||
import com.cloud.api.response.VirtualRouterProviderResponse;
|
||||
import com.cloud.api.response.VlanIpRangeResponse;
|
||||
import com.cloud.api.response.VolumeResponse;
|
||||
import com.cloud.api.response.VpcOfferingResponse;
|
||||
import com.cloud.api.response.VpcResponse;
|
||||
import com.cloud.api.response.VpnUsersResponse;
|
||||
import com.cloud.api.response.ZoneResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
|
|
@ -92,17 +101,25 @@ import com.cloud.network.PhysicalNetwork;
|
|||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkTrafficType;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.NetworkACL;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.network.security.SecurityGroupRules;
|
||||
import com.cloud.network.security.SecurityRule;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.StaticRoute;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
|
@ -110,6 +127,7 @@ import com.cloud.org.Cluster;
|
|||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectAccount;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Swift;
|
||||
|
|
@ -269,11 +287,53 @@ public interface ResponseGenerator {
|
|||
LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String baseSearch, String dn);
|
||||
|
||||
StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(StorageNetworkIpRange result);
|
||||
|
||||
|
||||
/**
|
||||
* @param tableName TODO
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
Long getIdentiyId(String tableName, String token);
|
||||
|
||||
/**
|
||||
* @param resourceTag
|
||||
* @return
|
||||
*/
|
||||
ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag);
|
||||
|
||||
Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVpnGateway result);
|
||||
|
||||
/**
|
||||
* @param offering
|
||||
* @return
|
||||
*/
|
||||
VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering);
|
||||
|
||||
/**
|
||||
* @param vpc
|
||||
* @return
|
||||
*/
|
||||
VpcResponse createVpcResponse(Vpc vpc);
|
||||
|
||||
/**
|
||||
* @param networkACL
|
||||
* @return
|
||||
*/
|
||||
NetworkACLResponse createNetworkACLResponse(NetworkACL networkACL);
|
||||
|
||||
/**
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
PrivateGatewayResponse createPrivateGatewayResponse(PrivateGateway result);
|
||||
|
||||
/**
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
StaticRouteResponse createStaticRouteResponse(StaticRoute result);
|
||||
|
||||
Site2SiteCustomerGatewayResponse createSite2SiteCustomerGatewayResponse(Site2SiteCustomerGateway result);
|
||||
|
||||
Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import com.cloud.event.EventTypes;
|
|||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.AnnotationHelper;
|
||||
|
||||
|
||||
@Implementation(description="Adds acoount to a project", responseObject=SuccessResponse.class, since="3.0.0")
|
||||
public class AddAccountToProjectCmd extends BaseAsyncCmd {
|
||||
|
|
@ -95,7 +97,9 @@ public class AddAccountToProjectCmd extends BaseAsyncCmd {
|
|||
Project project= _projectService.getProject(projectId);
|
||||
//verify input parameters
|
||||
if (project == null) {
|
||||
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _projectService.getProjectOwner(projectId).getId();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
|
|
@ -49,25 +50,35 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account to associate with this IP address")
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING,
|
||||
description="the account to associate with this IP address")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain to associate with this IP address")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG,
|
||||
description="the ID of the domain to associate with this IP address")
|
||||
private Long domainId;
|
||||
|
||||
@IdentityMapper(entityTableName="data_center")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the ID of the availability zone you want to acquire an public IP address from")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG,
|
||||
description="the ID of the availability zone you want to acquire an public IP address from")
|
||||
private Long zoneId;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="The network this ip address should be associated to.")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
|
||||
description="The network this ip address should be associated to.")
|
||||
private Long networkId;
|
||||
|
||||
@IdentityMapper(entityTableName="projects")
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Deploy vm for the project")
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG,
|
||||
description="Deploy vm for the project")
|
||||
private Long projectId;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="the VPC you want the ip address to " +
|
||||
"be associated with")
|
||||
private Long vpcId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -90,26 +101,50 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
return UserContext.current().getCaller().getDomainId();
|
||||
}
|
||||
|
||||
private Long getZoneId() {
|
||||
private long getZoneId() {
|
||||
if (zoneId != null) {
|
||||
return zoneId;
|
||||
} else if (vpcId != null) {
|
||||
Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
|
||||
if (vpc != null) {
|
||||
return vpc.getZoneId();
|
||||
}
|
||||
} else if (networkId != null) {
|
||||
Network ntwk = _entityMgr.findById(Network.class, networkId);
|
||||
if (ntwk != null) {
|
||||
return ntwk.getDataCenterId();
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidParameterValueException("Unable to figure out zone to assign ip to");
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
if (vpcId != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
return networkId;
|
||||
}
|
||||
Long zoneId = getZoneId();
|
||||
|
||||
if (zoneId == null) {
|
||||
throw new InvalidParameterValueException("Either networkId or zoneId has to be specified");
|
||||
return null;
|
||||
}
|
||||
|
||||
DataCenter zone = _configService.getZone(zoneId);
|
||||
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
|
||||
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(),
|
||||
_accountService.getAccount(getEntityOwnerId()));
|
||||
if (networks.size() == 0) {
|
||||
String domain = _domainService.getDomain(getDomainId()).getName();
|
||||
throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
|
||||
throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain +
|
||||
" doesn't have virtual networks in zone=" + zone.getName());
|
||||
}
|
||||
|
||||
if (networks.size() < 1) {
|
||||
|
|
@ -122,7 +157,8 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
} else {
|
||||
Network defaultGuestNetwork = _networkService.getExclusiveGuestNetwork(zoneId);
|
||||
if (defaultGuestNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find a default Guest network for account " + getAccountName() + " in domain id=" + getDomainId());
|
||||
throw new InvalidParameterValueException("Unable to find a default Guest network for account " +
|
||||
getAccountName() + " in domain id=" + getDomainId());
|
||||
} else {
|
||||
return defaultGuestNetwork.getId();
|
||||
}
|
||||
|
|
@ -135,10 +171,18 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
if (accountName != null && domainId != null) {
|
||||
Account account = _accountService.finalizeOwner(caller, accountName, domainId, projectId);
|
||||
return account.getId();
|
||||
} else {
|
||||
} else if (getNetworkId() != null){
|
||||
Network network = _networkService.getNetwork(getNetworkId());
|
||||
return network.getAccountId();
|
||||
} else if (vpcId != null) {
|
||||
Vpc vpc = _vpcService.getVpc(getVpcId());
|
||||
if (vpc == null) {
|
||||
throw new InvalidParameterValueException("Can't find Enabled vpc by id specified");
|
||||
}
|
||||
return vpc.getAccountId();
|
||||
}
|
||||
|
||||
throw new InvalidParameterValueException("Failed to determine ip owner");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -168,7 +212,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
@Override
|
||||
public void create() throws ResourceAllocationException{
|
||||
try {
|
||||
IpAddress ip = _networkService.allocateIP(getNetworkId(), _accountService.getAccount(getEntityOwnerId()));
|
||||
IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), false, getZoneId());
|
||||
if (ip != null) {
|
||||
this.setEntityId(ip.getId());
|
||||
} else {
|
||||
|
|
@ -185,9 +229,14 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
|
||||
public void execute() throws ResourceUnavailableException, ResourceAllocationException,
|
||||
ConcurrentOperationException, InsufficientCapacityException {
|
||||
UserContext.current().setEventDetails("Ip Id: " + getEntityId());
|
||||
IpAddress result = _networkService.associateIP(getEntityId());
|
||||
|
||||
IpAddress result = null;
|
||||
|
||||
result = _networkService.associateIP(getEntityId(), getNetworkId(), getVpcId());
|
||||
|
||||
if (result != null) {
|
||||
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
|
||||
ipResponse.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getSourceIpAddressId() {
|
||||
public Long getSourceIpAddressId() {
|
||||
return ipAddressId;
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +187,18 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
|
|||
|
||||
@Override
|
||||
public long getNetworkId() {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
|
||||
Long ntwkId = null;
|
||||
|
||||
if (ip.getAssociatedWithNetworkId() != null) {
|
||||
ntwkId = ip.getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
if (ntwkId == null) {
|
||||
throw new InvalidParameterValueException("Unable to create firewall rule for the ipAddress id=" + ipAddressId +
|
||||
" as ip is not associated with any network and no networkId is passed in");
|
||||
}
|
||||
return ntwkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getSourceIpAddressId() {
|
||||
public Long getSourceIpAddressId() {
|
||||
return ipAddressId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,9 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
|||
@Parameter(name=ApiConstants.PUBLIC_PORT, type=CommandType.INTEGER, required=true, description="the public port from where the network traffic will be load balanced from")
|
||||
private Integer publicPort;
|
||||
|
||||
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default")
|
||||
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for" +
|
||||
" source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when LB" +
|
||||
" rule is being created for VPC guest network 2) in all other cases defaulted to true")
|
||||
private Boolean openFirewall;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the load balancer. Must be used with the domainId parameter.")
|
||||
|
|
@ -87,7 +89,8 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
|||
private List<String> cidrlist;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="The guest network this rule will be created for")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="The guest network this " +
|
||||
"rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -128,6 +131,19 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
|||
return publicIpId;
|
||||
}
|
||||
|
||||
private Long getVpcId() {
|
||||
if (publicIpId != null) {
|
||||
IpAddress ipAddr = _networkService.getIp(publicIpId);
|
||||
if (ipAddr == null || !ipAddr.readyToUse()) {
|
||||
throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId());
|
||||
} else {
|
||||
return ipAddr.getVpcId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Long getNetworkId() {
|
||||
if (networkId != null) {
|
||||
return networkId;
|
||||
|
|
@ -167,9 +183,12 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
|||
}
|
||||
} else {
|
||||
IpAddress ipAddr = _networkService.getIp(publicIpId);
|
||||
return ipAddr.getAssociatedWithNetworkId();
|
||||
if (ipAddr.getAssociatedWithNetworkId() != null) {
|
||||
return ipAddr.getAssociatedWithNetworkId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Ip address id=" + publicIpId + " is not associated with any network");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Integer getPublicPort() {
|
||||
|
|
@ -181,9 +200,16 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
|||
}
|
||||
|
||||
public Boolean getOpenFirewall() {
|
||||
boolean isVpc = getVpcId() == null ? false : true;
|
||||
if (openFirewall != null) {
|
||||
if (isVpc && openFirewall) {
|
||||
throw new InvalidParameterValueException("Can't have openFirewall=true when IP address belongs to VPC");
|
||||
}
|
||||
return openFirewall;
|
||||
} else {
|
||||
if (isVpc) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,314 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.NetworkACLResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.NetworkACL;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Implementation(description = "Creates a ACL rule the given network (the network has to belong to VPC)",
|
||||
responseObject = NetworkACLResponse.class)
|
||||
public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements NetworkACL {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateNetworkACLCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createnetworkaclresponse";
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ////////////// API parameters /////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, description =
|
||||
"the protocol for the ACL rule. Valid values are TCP/UDP/ICMP.")
|
||||
private String protocol;
|
||||
|
||||
@Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, required=true, description = "the starting port of ACL")
|
||||
private Integer publicStartPort;
|
||||
|
||||
@Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "the ending port of ACL")
|
||||
private Integer publicEndPort;
|
||||
|
||||
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING,
|
||||
description = "the cidr list to allow traffic from/to")
|
||||
private List<String> cidrlist;
|
||||
|
||||
@Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the icmp message being sent")
|
||||
private Integer icmpType;
|
||||
|
||||
@Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this icmp message")
|
||||
private Integer icmpCode;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, required=true,
|
||||
description="The network of the vm the ACL will be created for")
|
||||
private Long networkId;
|
||||
|
||||
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="the traffic type for the ACL," +
|
||||
"can be Ingress or Egress, defaulted to Ingress if not specified")
|
||||
private String trafficType;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "firewall_rules";
|
||||
}
|
||||
|
||||
public Long getIpAddressId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return protocol.trim();
|
||||
}
|
||||
|
||||
public List<String> getSourceCidrList() {
|
||||
if (cidrlist != null) {
|
||||
return cidrlist;
|
||||
} else {
|
||||
List<String> oneCidrList = new ArrayList<String>();
|
||||
oneCidrList.add(NetUtils.ALL_CIDRS);
|
||||
return oneCidrList;
|
||||
}
|
||||
}
|
||||
|
||||
public long getVpcId() {
|
||||
Network network = _networkService.getNetwork(getNetworkId());
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Invalid networkId is given");
|
||||
}
|
||||
|
||||
Long vpcId = network.getVpcId();
|
||||
if (vpcId == null) {
|
||||
throw new InvalidParameterValueException("Can create network ACL only for the network belonging to the VPC");
|
||||
}
|
||||
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule.TrafficType getTrafficType() {
|
||||
if (trafficType == null) {
|
||||
return FirewallRule.TrafficType.Ingress;
|
||||
}
|
||||
for (FirewallRule.TrafficType type : FirewallRule.TrafficType.values()) {
|
||||
if (type.toString().equalsIgnoreCase(trafficType)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new InvalidParameterValueException("Invalid traffic type " + trafficType);
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public void setSourceCidrList(List<String> cidrs){
|
||||
cidrlist = cidrs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException {
|
||||
UserContext callerContext = UserContext.current();
|
||||
boolean success = false;
|
||||
NetworkACL rule = _networkACLService.getNetworkACL(getEntityId());
|
||||
try {
|
||||
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
|
||||
success = _networkACLService.applyNetworkACLs(rule.getNetworkId(), callerContext.getCaller());
|
||||
|
||||
// State is different after the rule is applied, so get new object here
|
||||
NetworkACLResponse aclResponse = new NetworkACLResponse();
|
||||
if (rule != null) {
|
||||
aclResponse = _responseGenerator.createNetworkACLResponse(rule);
|
||||
setResponseObject(aclResponse);
|
||||
}
|
||||
aclResponse.setResponseName(getCommandName());
|
||||
} finally {
|
||||
if (!success || rule == null) {
|
||||
_networkACLService.revokeNetworkACL(getEntityId(), true);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create network ACL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
throw new UnsupportedOperationException("database id can only provided by VO objects");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getXid() {
|
||||
// FIXME: We should allow for end user to specify Xid.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSourceIpAddressId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSourcePortStart() {
|
||||
if (publicStartPort != null) {
|
||||
return publicStartPort.intValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSourcePortEnd() {
|
||||
if (publicEndPort == null) {
|
||||
if (publicStartPort != null) {
|
||||
return publicStartPort.intValue();
|
||||
}
|
||||
} else {
|
||||
return publicEndPort.intValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Purpose getPurpose() {
|
||||
return Purpose.Firewall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
throw new UnsupportedOperationException("Should never call me to find the state");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Vpc vpc = _vpcService.getVpc(getVpcId());
|
||||
if (vpc == null) {
|
||||
throw new InvalidParameterValueException("Invalid vpcId is given");
|
||||
}
|
||||
|
||||
Account account = _accountService.getAccount(vpc.getAccountId());
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDomainId() {
|
||||
Vpc vpc = _vpcService.getVpc(getVpcId());
|
||||
return vpc.getDomainId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
if (getSourceCidrList() != null) {
|
||||
for (String cidr: getSourceCidrList()){
|
||||
if (!NetUtils.isValidCIDR(cidr)){
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Source cidrs formatting error " + cidr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
NetworkACL result = _networkACLService.createNetworkACL(this);
|
||||
setEntityId(result.getId());
|
||||
} catch (NetworkRuleConflictException ex) {
|
||||
s_logger.info("Network rule conflict: " + ex.getMessage());
|
||||
s_logger.trace("Network Rule Conflict: ", ex);
|
||||
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_FIREWALL_OPEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
Network network = _networkService.getNetwork(networkId);
|
||||
return ("Createing Network ACL for Netowrk: " + network + " for protocol:" + this.getProtocol());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Vpc vpc = _vpcService.getVpc(getVpcId());
|
||||
return vpc.getAccountId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return getNetworkId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getIcmpCode() {
|
||||
if (icmpCode != null) {
|
||||
return icmpCode;
|
||||
} else if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
|
||||
return -1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getIcmpType() {
|
||||
if (icmpType != null) {
|
||||
return icmpType;
|
||||
} else if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
|
||||
return -1;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRelated() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRuleType getType() {
|
||||
return FirewallRuleType.User;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.FirewallRule;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -58,16 +58,19 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID the network belongs to")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway of the network")
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway of the network. Required " +
|
||||
"for Shared networks and Isolated networks when it belongs to VPC")
|
||||
private String gateway;
|
||||
|
||||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the network")
|
||||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the network. Required " +
|
||||
"for Shared networks and Isolated networks when it belongs to VPC")
|
||||
private String netmask;
|
||||
|
||||
@Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, description="the beginning IP address in the network IP range")
|
||||
private String startIp;
|
||||
|
||||
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the network IP range. If not specified, will be defaulted to startIP")
|
||||
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the network IP" +
|
||||
" range. If not specified, will be defaulted to startIP")
|
||||
private String endIp;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the network")
|
||||
|
|
@ -76,7 +79,9 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
|
||||
private String networkDomain;
|
||||
|
||||
@Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network")
|
||||
@Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values" +
|
||||
" are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks" +
|
||||
" - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network")
|
||||
private String aclType;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the network")
|
||||
|
|
@ -90,9 +95,13 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.SUBDOMAIN_ACCESS, type=CommandType.BOOLEAN, description="Defines whether to allow subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified")
|
||||
@Parameter(name=ApiConstants.SUBDOMAIN_ACCESS, type=CommandType.BOOLEAN, description="Defines whether to allow" +
|
||||
" subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified")
|
||||
private Boolean subdomainAccess;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="the VPC network belongs to")
|
||||
private Long vpcId;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -154,7 +163,11 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
return subdomainAccess;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
Long physicalNetworkId = getPhysicalNetworkId();
|
||||
|
||||
if (physicalNetworkId == null && zoneId == null) {
|
||||
|
|
@ -204,7 +217,7 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
|
||||
@Override
|
||||
public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
|
||||
Network result = _networkService.createNetwork(this);
|
||||
Network result = _networkService.createGuestNetwork(this);
|
||||
if (result != null) {
|
||||
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -55,13 +55,15 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a physical network")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.BROADCAST_DOMAIN_RANGE, type=CommandType.STRING, description="the broadcast domain range for the physical network[Pod or Zone]. In Acton release it can be Zone only in Advance zone, and Pod in Basic")
|
||||
@Parameter(name=ApiConstants.BROADCAST_DOMAIN_RANGE, type=CommandType.STRING, description="the broadcast domain " +
|
||||
"range for the physical network[Pod or Zone]. In Acton release it can be Zone only in Advance zone, and Pod in Basic")
|
||||
private String broadcastDomainRange;
|
||||
|
||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")
|
||||
private List<String> tags;
|
||||
|
||||
@Parameter(name=ApiConstants.ISOLATION_METHODS, type=CommandType.LIST, collectionType=CommandType.STRING, description="the isolation method for the physical network[VLAN/L3/GRE]")
|
||||
@Parameter(name=ApiConstants.ISOLATION_METHODS, type=CommandType.LIST, collectionType=CommandType.STRING,
|
||||
description="the isolation method for the physical network[VLAN/L3/GRE]")
|
||||
private List<String> isolationMethods;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the physical network")
|
||||
|
|
|
|||
|
|
@ -47,27 +47,42 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
|||
// ///////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName = "user_ip_address")
|
||||
@Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.LONG, required = true, description = "the IP address id of the port forwarding rule")
|
||||
@Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.LONG, required = true,
|
||||
description = "the IP address id of the port forwarding rule")
|
||||
private Long ipAddressId;
|
||||
|
||||
@Parameter(name = ApiConstants.PRIVATE_START_PORT, type = CommandType.INTEGER, required = true, description = "the starting port of port forwarding rule's private port range")
|
||||
@Parameter(name = ApiConstants.PRIVATE_START_PORT, type = CommandType.INTEGER, required = true,
|
||||
description = "the starting port of port forwarding rule's private port range")
|
||||
private Integer privateStartPort;
|
||||
|
||||
@Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, description = "the protocol for the port fowarding rule. Valid values are TCP or UDP.")
|
||||
@Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true,
|
||||
description = "the protocol for the port fowarding rule. Valid values are TCP or UDP.")
|
||||
private String protocol;
|
||||
|
||||
@Parameter(name = ApiConstants.PUBLIC_START_PORT, type = CommandType.INTEGER, required = true, description = "the starting port of port forwarding rule's public port range")
|
||||
@Parameter(name = ApiConstants.PUBLIC_START_PORT, type = CommandType.INTEGER, required = true,
|
||||
description = "the starting port of port forwarding rule's public port range")
|
||||
private Integer publicStartPort;
|
||||
|
||||
@IdentityMapper(entityTableName = "vm_instance")
|
||||
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.LONG, required = true, description = "the ID of the virtual machine for the port forwarding rule")
|
||||
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.LONG, required = true,
|
||||
description = "the ID of the virtual machine for the port forwarding rule")
|
||||
private Long virtualMachineId;
|
||||
|
||||
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from")
|
||||
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING,
|
||||
description = "the cidr list to forward traffic from")
|
||||
private List<String> cidrlist;
|
||||
|
||||
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default")
|
||||
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN,
|
||||
description = "if true, firewall rule for source/end pubic port is automatically created; " +
|
||||
"if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when PF" +
|
||||
" rule is being created for VPC guest network 2) in all other cases defaulted to true")
|
||||
private Boolean openFirewall;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
|
||||
description="The network of the vm the Port Forwarding rule will be created for. " +
|
||||
"Required when public Ip address is not associated with any Guest network yet (VPC case)")
|
||||
private Long networkId;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
|
|
@ -93,18 +108,38 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
|||
|
||||
public List<String> getSourceCidrList() {
|
||||
if (cidrlist != null) {
|
||||
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
|
||||
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall " +
|
||||
"rule for the specific cidr, please refer to createFirewallRule command");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean getOpenFirewall() {
|
||||
boolean isVpc = getVpcId() == null ? false : true;
|
||||
if (openFirewall != null) {
|
||||
if (isVpc && openFirewall) {
|
||||
throw new InvalidParameterValueException("Can't have openFirewall=true when IP address belongs to VPC");
|
||||
}
|
||||
return openFirewall;
|
||||
} else {
|
||||
if (isVpc) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private Long getVpcId() {
|
||||
if (ipAddressId != null) {
|
||||
IpAddress ipAddr = _networkService.getIp(ipAddressId);
|
||||
if (ipAddr == null || !ipAddr.readyToUse()) {
|
||||
throw new InvalidParameterValueException("Unable to create PF rule, invalid IP address id " + ipAddr.getId());
|
||||
} else {
|
||||
return ipAddr.getVpcId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
|
|
@ -163,7 +198,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getSourceIpAddressId() {
|
||||
public Long getSourceIpAddressId() {
|
||||
return ipAddressId;
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +224,19 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
|||
|
||||
@Override
|
||||
public long getNetworkId() {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
|
||||
Long ntwkId = null;
|
||||
|
||||
if (ip.getAssociatedWithNetworkId() != null) {
|
||||
ntwkId = ip.getAssociatedWithNetworkId();
|
||||
} else {
|
||||
ntwkId = networkId;
|
||||
}
|
||||
if (ntwkId == null) {
|
||||
throw new InvalidParameterValueException("Unable to create port forwarding rule for the ipAddress id=" + ipAddressId +
|
||||
" as ip is not associated with any network and no networkId is passed in");
|
||||
}
|
||||
return ntwkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -201,7 +248,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
|||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
|
||||
// tracked
|
||||
// tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -232,7 +279,6 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
|||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
// cidr list parameter is deprecated
|
||||
if (cidrlist != null) {
|
||||
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,181 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.PrivateGatewayResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
@Implementation(description="Creates a private gateway", responseObject=PrivateGatewayResponse.class)
|
||||
public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreatePrivateGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createprivategatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="physical_network")
|
||||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID the network belongs to")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway of the Private gateway")
|
||||
private String gateway;
|
||||
|
||||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask of the Private gateway")
|
||||
private String netmask;
|
||||
|
||||
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, required=true, description="the IP address of the Private gateaway")
|
||||
private String ipAddress;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, required=true, description="the Vlan for the private gateway")
|
||||
private String vlan;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, required=true, description="the VPC network belongs to")
|
||||
private Long vpcId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
}
|
||||
|
||||
public String getStartIp() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
PrivateGateway result = null;
|
||||
try {
|
||||
result = _vpcService.createVpcPrivateGateway(getVpcId(), getPhysicalNetworkId(),
|
||||
getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId());
|
||||
} catch (InsufficientCapacityException ex){
|
||||
s_logger.info(ex);
|
||||
s_logger.trace(ex);
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private gateway");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceAllocationException, ResourceUnavailableException {
|
||||
PrivateGateway result = _vpcService.applyVpcPrivateGateway(getEntityId());
|
||||
if (result != null) {
|
||||
PrivateGatewayResponse response = _responseGenerator.createPrivateGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private gateway");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_PRIVATE_GATEWAY_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating private gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "vpc_gateways";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.vpcSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
Vpc vpc = _vpcService.getVpc(vpcId);
|
||||
if (vpc == null) {
|
||||
throw new InvalidParameterValueException("Invalid id is specified for the vpc");
|
||||
}
|
||||
return vpc.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.PrivateGateway;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.NetworkResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Creates a private network", responseObject=NetworkResponse.class)
|
||||
public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreatePrivateNetworkCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createnetworkresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network")
|
||||
private String name;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network")
|
||||
private String displayText;
|
||||
|
||||
@IdentityMapper(entityTableName="physical_network")
|
||||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID the network belongs to")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway of the network")
|
||||
private String gateway;
|
||||
|
||||
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask of the network")
|
||||
private String netmask;
|
||||
|
||||
@Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, required=true, description="the beginning IP address in the network IP range")
|
||||
private String startIp;
|
||||
|
||||
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the network IP" +
|
||||
" range. If not specified, will be defaulted to startIP")
|
||||
private String endIp;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, required=true, description="the ID or VID of the network")
|
||||
private String vlan;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the network")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="projects")
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project for the ssh key")
|
||||
private Long projectId;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network")
|
||||
private Long domainId;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
}
|
||||
|
||||
public String getStartIp() {
|
||||
return startIp;
|
||||
}
|
||||
|
||||
public String getNetworkName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public Long getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public String getEndIp() {
|
||||
return endIp;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
Network result = null;
|
||||
try {
|
||||
result = _networkService.createPrivateNetwork(getNetworkName(), getDisplayText(), getPhysicalNetworkId(), getVlan(),
|
||||
getStartIp(), getEndIp(), getGateway(), getNetmask(), getEntityOwnerId());
|
||||
} catch (InsufficientCapacityException ex){
|
||||
s_logger.info(ex);
|
||||
s_logger.trace(ex);
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a Private network");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
|
||||
Network result = _networkService.getNetwork(getEntityId());
|
||||
if (result != null) {
|
||||
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private network");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return accountId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_NETWORK_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating private network";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "networks";
|
||||
}
|
||||
}
|
||||
|
|
@ -125,10 +125,25 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
|
|||
return EventTypes.EVENT_REMOTE_ACCESS_VPN_CREATE;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
IpAddress ip = _entityMgr.findById(IpAddress.class, getPublicIpId());
|
||||
Long ntwkId = null;
|
||||
|
||||
if (ip.getAssociatedWithNetworkId() != null) {
|
||||
ntwkId = ip.getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
if (ntwkId == null) {
|
||||
throw new InvalidParameterValueException("Unable to create remote access vpn for the ipAddress id=" + getPublicIpId() +
|
||||
" as ip is not associated with any network and no networkId is passed in");
|
||||
}
|
||||
return ntwkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
try {
|
||||
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall());
|
||||
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall(), getNetworkId());
|
||||
if (vpn != null) {
|
||||
this.setEntityId(vpn.getServerAddressId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ public class CreateSnapshotPolicyCmd extends BaseCmd {
|
|||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
Project project = _projectService.findByProjectAccountId(volume.getAccountId());
|
||||
if (project.getState() != Project.State.Active) {
|
||||
throw new PermissionDeniedException("Can't add resources to the project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active");
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the specified project id in state=" + project.getState() + " as it's no longer active");
|
||||
ex.addProxyObject(project, project.getId(), "projectId");
|
||||
throw ex;
|
||||
}
|
||||
} else if (account.getState() == Account.State.disabled) {
|
||||
throw new PermissionDeniedException("The owner of template is disabled: " + account);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,151 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.StaticRouteResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.StaticRoute;
|
||||
import com.cloud.network.vpc.VpcGateway;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Creates a static route", responseObject=StaticRouteResponse.class)
|
||||
public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{
|
||||
private static final String s_name = "createstaticrouteresponse";
|
||||
public static final Logger s_logger = Logger.getLogger(CreateStaticRouteCmd.class.getName());
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_gateways")
|
||||
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, required=true,
|
||||
description="the gateway id we are creating static route for")
|
||||
private Long gatewayId;
|
||||
|
||||
@Parameter(name = ApiConstants.CIDR, required = true, type = CommandType.STRING, description = "static route cidr")
|
||||
private String cidr;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
public long getGatewayId() {
|
||||
return gatewayId;
|
||||
}
|
||||
|
||||
public String getCidr() {
|
||||
return cidr;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
try {
|
||||
StaticRoute result = _vpcService.createStaticRoute(getGatewayId(), getCidr());
|
||||
setEntityId(result.getId());
|
||||
} catch (NetworkRuleConflictException ex) {
|
||||
s_logger.info("Network rule conflict: " + ex.getMessage());
|
||||
s_logger.trace("Network rule conflict: ", ex);
|
||||
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "static_routes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_STATIC_ROUTE_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating static route";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException {
|
||||
boolean success = false;
|
||||
StaticRoute route = _entityMgr.findById(StaticRoute.class, getEntityId());
|
||||
try {
|
||||
UserContext.current().setEventDetails("Static route Id: " + getEntityId());
|
||||
success = _vpcService.applyStaticRoutes(route.getVpcId());
|
||||
|
||||
// State is different after the route is applied, so get new object here
|
||||
route = _entityMgr.findById(StaticRoute.class, getEntityId());
|
||||
StaticRouteResponse routeResponse = new StaticRouteResponse();
|
||||
if (route != null) {
|
||||
routeResponse = _responseGenerator.createStaticRouteResponse(route);
|
||||
setResponseObject(routeResponse);
|
||||
}
|
||||
routeResponse.setResponseName(getCommandName());
|
||||
} finally {
|
||||
if (!success || route == null) {
|
||||
_vpcService.revokeStaticRoute(getEntityId());
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create static route");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
VpcGateway gateway = _vpcService.getVpcGateway(gatewayId);
|
||||
if (gateway == null) {
|
||||
throw new InvalidParameterValueException("Invalid gateway id is specified");
|
||||
}
|
||||
return _vpcService.getVpc(gateway.getVpcId()).getAccountId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.vpcSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
VpcGateway gateway = _vpcService.getVpcGateway(gatewayId);
|
||||
if (gateway == null) {
|
||||
throw new InvalidParameterValueException("Invalid id is specified for the gateway");
|
||||
}
|
||||
return gateway.getVpcId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.StaticRoute;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description = "Creates resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
|
||||
public class CreateTagsCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(CreateTagsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createtagsresponse";
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ////////////// API parameters /////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, required=true, description = "Map of tags (key/value pairs)")
|
||||
private Map tag;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="type of the resource")
|
||||
private String resourceType;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
|
||||
collectionType=CommandType.STRING, description="list of resources to create the tags for")
|
||||
private List<String> resourceIds;
|
||||
|
||||
@Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="identifies client specific tag. " +
|
||||
"When the value is not null, the tag can't be used by cloudStack code internally")
|
||||
private String customer;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public TaggedResourceType getResourceType(){
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
Map<String, String> tagsMap = null;
|
||||
if (!tag.isEmpty()) {
|
||||
tagsMap = new HashMap<String, String>();
|
||||
Collection<?> servicesCollection = tag.values();
|
||||
Iterator<?> iter = servicesCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||
String key = services.get("key");
|
||||
String value = services.get("value");
|
||||
tagsMap.put(key, value);
|
||||
}
|
||||
}
|
||||
return tagsMap;
|
||||
}
|
||||
|
||||
public List<String> getResourceIds() {
|
||||
return resourceIds;
|
||||
}
|
||||
|
||||
public String getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
//FIXME - validate the owner here
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
List<ResourceTag> tags = _taggedResourceService.createTags(getResourceIds(), getResourceType(), getTags(), getCustomer());
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create tags");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_TAGS_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating tags";
|
||||
}
|
||||
}
|
||||
|
|
@ -204,7 +204,8 @@ import com.cloud.user.UserContext;
|
|||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
Project project = _projectService.findByProjectAccountId(accountId);
|
||||
if (project.getState() != Project.State.Active) {
|
||||
throw new PermissionDeniedException("Can't add resources to the project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active");
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the specified project id in state=" + project.getState() + " as it's no longer active");
|
||||
ex.addProxyObject(project, project.getId(), "projectId");
|
||||
}
|
||||
} else if (account.getState() == Account.State.disabled) {
|
||||
throw new PermissionDeniedException("The owner of template is disabled: " + account);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,184 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.VpcResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Creates a VPC", responseObject=VpcResponse.class)
|
||||
public class CreateVPCCmd extends BaseAsyncCreateCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVPCCmd.class.getName());
|
||||
private static final String s_name = "createvpcresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the VPC. " +
|
||||
"Must be used with the domainId parameter.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the VPC. " +
|
||||
"If used with the account parameter returns the VPC associated with the account for the specified domain.")
|
||||
private Long domainId;
|
||||
|
||||
@IdentityMapper(entityTableName="data_center")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the availability zone")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the VPC")
|
||||
private String vpcName;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of " +
|
||||
"the VPC")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, required=true, description="the cidr of the VPC. All VPC " +
|
||||
"guest networks' cidrs should be within this CIDR")
|
||||
private String cidr;
|
||||
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.LONG, required=true, description="the ID of the VPC offering")
|
||||
private Long vpcOffering;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
|
||||
private String networkDomain;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getVpcName() {
|
||||
return vpcName;
|
||||
}
|
||||
|
||||
public String getCidr() {
|
||||
return cidr;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public Long getVpcOffering() {
|
||||
return vpcOffering;
|
||||
}
|
||||
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(),
|
||||
getCidr(), getNetworkDomain());
|
||||
if (vpc != null) {
|
||||
this.setEntityId(vpc.getId());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a VPC");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Vpc vpc = null;
|
||||
try {
|
||||
if (_vpcService.startVpc(this.getEntityId())) {
|
||||
vpc = _vpcService.getVpc(getEntityId());
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
} catch (InsufficientCapacityException ex) {
|
||||
s_logger.info(ex);
|
||||
s_logger.trace(ex);
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
}
|
||||
|
||||
if (vpc != null) {
|
||||
VpcResponse response = _responseGenerator.createVpcResponse(vpc);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create VPC");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "vpc";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VPC_CREATE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating VPC. Id: " + getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
|
||||
return accountId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.VpcOfferingResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Creates VPC offering", responseObject=VpcOfferingResponse.class)
|
||||
public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVPCOfferingCmd.class.getName());
|
||||
private static final String _name = "createvpcofferingresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the vpc offering")
|
||||
private String vpcOfferingName;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of " +
|
||||
"the vpc offering")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, required=true, collectionType=CommandType.STRING,
|
||||
description="services supported by the vpc offering")
|
||||
private List<String> supportedServices;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getVpcOfferingName() {
|
||||
return vpcOfferingName;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public List<String> getSupportedServices() {
|
||||
return supportedServices;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VpcOffering vpcOff = _vpcService.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices());
|
||||
if (vpcOff != null) {
|
||||
this.setEntityId(vpcOff.getId());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a VPC offering");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
VpcOffering vpc = _vpcService.getVpcOffering(this.getEntityId());
|
||||
if (vpc != null) {
|
||||
VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(vpc);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create VPC offering");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "vpc_offerings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VPC_OFFERING_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating VPC offering. Id: " + getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ import com.cloud.api.response.VirtualRouterProviderResponse;
|
|||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.element.VirtualRouterElementService;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
|
@ -92,7 +93,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VirtualRouterProvider result = _service.addElement(getNspId());
|
||||
VirtualRouterProvider result = _service.addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,144 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Create site to site vpn connection", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVpnConnectionCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createvpnconnectionresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_gateway")
|
||||
@Parameter(name=ApiConstants.S2S_VPN_GATEWAY_ID, type=CommandType.LONG, required=true, description="id of the vpn gateway")
|
||||
private Long vpnGatewayId;
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.S2S_CUSTOMER_GATEWAY_ID, type=CommandType.LONG, required=true, description="id of the customer gateway")
|
||||
private Long customerGatewayId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getVpnGatewayId() {
|
||||
return vpnGatewayId;
|
||||
}
|
||||
|
||||
public Long getCustomerGatewayId() {
|
||||
return customerGatewayId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Create site-to-site VPN connection";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CONNECTION_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
try {
|
||||
Site2SiteVpnConnection conn = _s2sVpnService.createVpnConnection(this);
|
||||
if (conn != null) {
|
||||
this.setEntityId(conn.getId());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create site to site vpn connection");
|
||||
}
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
s_logger.info("Network rule conflict: " + e.getMessage());
|
||||
s_logger.trace("Network Rule Conflict: ", e);
|
||||
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
Site2SiteVpnConnection result = _s2sVpnService.startVpnConnection(this.getEntityId());
|
||||
if (result != null) {
|
||||
Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create site to site vpn connection");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.vpcSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return getIp().getVpcId();
|
||||
}
|
||||
|
||||
private IpAddress getIp() {
|
||||
IpAddress ip = _s2sVpnService.getVpnGatewayIp(vpnGatewayId);
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by vpn gateway id " + vpnGatewayId);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Creates site to site vpn customer gateway", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVpnCustomerGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createvpncustomergatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="public ip address id of the customer gateway")
|
||||
private String gatewayIp;
|
||||
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING, required=true, description="guest cidr list of the customer gateway")
|
||||
private String guestCidrList;
|
||||
|
||||
@Parameter(name=ApiConstants.IPSEC_PSK, type=CommandType.STRING, required=true, description="IPsec Preshared-Key of the customer gateway")
|
||||
private String ipsecPsk;
|
||||
|
||||
@Parameter(name=ApiConstants.IKE_POLICY, type=CommandType.STRING, required=true, description="IKE policy of the customer gateway")
|
||||
private String ikePolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.ESP_POLICY, type=CommandType.STRING, required=true, description="ESP policy of the customer gateway")
|
||||
private String espPolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.LIFETIME, type=CommandType.LONG, required=false, description="Lifetime of vpn connection to the customer gateway, in seconds")
|
||||
private Long lifetime;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public String getIpsecPsk() {
|
||||
return ipsecPsk;
|
||||
}
|
||||
|
||||
public String getGuestCidrList() {
|
||||
return guestCidrList;
|
||||
}
|
||||
|
||||
public String getGatewayIp() {
|
||||
return gatewayIp;
|
||||
}
|
||||
|
||||
public String getIkePolicy() {
|
||||
return ikePolicy;
|
||||
}
|
||||
|
||||
public String getEspPolicy() {
|
||||
return espPolicy;
|
||||
}
|
||||
|
||||
public Long getLifetime() {
|
||||
return lifetime;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Create site-to-site VPN customer gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CUSTOMER_GATEWAY_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteCustomerGateway result = _s2sVpnService.createCustomerGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
|
||||
@Implementation(description="Creates site to site vpn local gateway", responseObject=Site2SiteVpnGatewayResponse.class)
|
||||
public class CreateVpnGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVpnGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createvpngatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="user_ip_address")
|
||||
@Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.LONG, required=true, description="public ip address id of the vpn gateway")
|
||||
private Long publicIpId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "user_ip_address";
|
||||
}
|
||||
|
||||
public Long getPublicIpId() {
|
||||
return publicIpId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
IpAddress ip = _networkService.getIp(publicIpId);
|
||||
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by id=" + publicIpId);
|
||||
}
|
||||
|
||||
return ip.getAccountId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Create site-to-site VPN gateway for account " + getEntityOwnerId() + " using public ip id=" + publicIpId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_VPN_GATEWAY_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteVpnGateway result = _s2sVpnService.createVpnGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create VPN gateway");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.vpcSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return getIp().getVpcId();
|
||||
}
|
||||
|
||||
private IpAddress getIp() {
|
||||
IpAddress ip = _networkService.getIp(publicIpId);
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by id " + publicIpId);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.rules.NetworkACL;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Deletes a Network ACL", responseObject=SuccessResponse.class)
|
||||
public class DeleteNetworkACLCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteNetworkACLCmd.class.getName());
|
||||
private static final String s_name = "deletenetworkaclresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="firewall_rules")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network ACL")
|
||||
private Long id;
|
||||
|
||||
// unexposed parameter needed for events logging
|
||||
@IdentityMapper(entityTableName="account")
|
||||
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
|
||||
private Long ownerId;
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_FIREWALL_CLOSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return ("Deleting Network ACL id=" + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
if (ownerId == null) {
|
||||
NetworkACL rule = _networkACLService.getNetworkACL(id);
|
||||
if (rule == null) {
|
||||
throw new InvalidParameterValueException("Unable to find network ACL by id=" + id);
|
||||
} else {
|
||||
ownerId = rule.getAccountId();
|
||||
}
|
||||
}
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException {
|
||||
UserContext.current().setEventDetails("Network ACL Id: " + id);
|
||||
boolean result = _networkACLService.revokeNetworkACL(id, true);
|
||||
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network ACL");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return _firewallService.getFirewallRule(id).getNetworkId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.FirewallRule;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.VpcGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
@Implementation(description="Deletes a Private gateway", responseObject=SuccessResponse.class)
|
||||
public class DeletePrivateGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeletePrivateGatewayCmd.class.getName());
|
||||
private static final String s_name = "deleteprivategatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_gateways")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the private gateway")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_PRIVATE_GATEWAY_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return ("Deleting private gateway id=" + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
UserContext.current().setEventDetails("Network ACL Id: " + id);
|
||||
boolean result = _vpcService.deleteVpcPrivateGateway(id);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete private gateway");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.vpcSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
VpcGateway gateway = _vpcService.getVpcPrivateGateway(getId());
|
||||
if (gateway == null) {
|
||||
throw new InvalidParameterValueException("Invalid private gateway id");
|
||||
}
|
||||
return gateway.getVpcId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.PrivateGateway;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.StaticRoute;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Deletes a static route", responseObject=SuccessResponse.class)
|
||||
public class DeleteStaticRouteCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteStaticRouteCmd.class.getName());
|
||||
private static final String s_name = "deletestaticrouteresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="static_routes")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the static route")
|
||||
private Long id;
|
||||
|
||||
// unexposed parameter needed for events logging
|
||||
@IdentityMapper(entityTableName="account")
|
||||
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
|
||||
private Long ownerId;
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_STATIC_ROUTE_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return ("Deleting static route id=" + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
if (ownerId == null) {
|
||||
StaticRoute route = _entityMgr.findById(StaticRoute.class, id);
|
||||
if (route == null) {
|
||||
throw new InvalidParameterValueException("Unable to find static route by id=" + id);
|
||||
} else {
|
||||
ownerId = route.getAccountId();
|
||||
}
|
||||
}
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException {
|
||||
UserContext.current().setEventDetails("Route Id: " + id);
|
||||
boolean result = _vpcService.revokeStaticRoute(id);
|
||||
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete static route");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.vpcSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
StaticRoute route = _vpcService.getStaticRoute(id);
|
||||
if (route == null) {
|
||||
throw new InvalidParameterValueException("Invalid id is specified for the static route");
|
||||
}
|
||||
return route.getVpcId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.StaticRoute;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description = "Deleting resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
|
||||
public class DeleteTagsCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteTagsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deleteTagsresponse";
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ////////////// API parameters /////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "Delete tags matching key/value pairs")
|
||||
private Map tag;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="Delete tag by resource type")
|
||||
private String resourceType;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
|
||||
collectionType=CommandType.STRING, description="Delete tags for resource id(s)")
|
||||
private List<String> resourceIds;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public TaggedResourceType getResourceType(){
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
Map<String, String> tagsMap = null;
|
||||
if (tag != null && !tag.isEmpty()) {
|
||||
tagsMap = new HashMap<String, String>();
|
||||
Collection<?> servicesCollection = tag.values();
|
||||
Iterator<?> iter = servicesCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||
String key = services.get("key");
|
||||
String value = services.get("value");
|
||||
tagsMap.put(key, value);
|
||||
}
|
||||
}
|
||||
return tagsMap;
|
||||
}
|
||||
|
||||
public List<String> getResourceIds() {
|
||||
return resourceIds;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
//FIXME - validate the owner here
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
boolean success = _taggedResourceService.deleteTags(getResourceIds(), getResourceType(), getTags());
|
||||
|
||||
if (success) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete tags");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_TAGS_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Deleting tags";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Deletes a VPC", responseObject=SuccessResponse.class)
|
||||
public class DeleteVPCCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVPCCmd.class.getName());
|
||||
private static final String s_name = "deletevpcresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the VPC")
|
||||
private Long id;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VPC_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Deleting VPC id=" + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
boolean result = _vpcService.deleteVpc(getId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete VPC");
|
||||
}
|
||||
}catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Vpc vpc = _entityMgr.findById(Vpc.class, getId());
|
||||
if (vpc != null) {
|
||||
return vpc.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Deletes VPC offering", responseObject=SuccessResponse.class)
|
||||
public class DeleteVPCOfferingCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVPCOfferingCmd.class.getName());
|
||||
private static final String s_name = "deletevpcofferingresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the VPC offering")
|
||||
private Long id;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
boolean result = _vpcService.deleteVpcOffering(getId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete VPC offering");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType(){
|
||||
return EventTypes.EVENT_VPC_OFFERING_DELETE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Deleting VPC offering id=" + getId();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Delete site to site vpn connection", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class DeleteVpnConnectionCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVpnConnectionCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletevpnconnectionresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_connection")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of vpn connection")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for connection. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for connection. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Delete site-to-site VPN connection for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CONNECTION_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
Site2SiteVpnConnection result = _s2sVpnService.deleteVpnConnection(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete site to site VPN connection");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Delete site to site vpn customer gateway", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class DeleteVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVpnCustomerGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletecustomergatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of customer gateway")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for gateway. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId fo: gateway. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Delete site-to-site VPN customer gateway for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CUSTOMER_GATEWAY_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteCustomerGateway result = _s2sVpnService.deleteCustomerGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Delete site to site vpn gateway", responseObject=Site2SiteVpnGatewayResponse.class)
|
||||
public class DeleteVpnGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVpnGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletevpngatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of customer gateway")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for gateway. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId fo: gateway. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_gateway";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Delete site-to-site VPN gateway for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_VPN_GATEWAY_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteVpnGateway result = _s2sVpnService.deleteVpnGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -250,7 +251,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
Map<Long, String> ipToNetworkMap = null;
|
||||
if (ipToNetworkList != null && !ipToNetworkList.isEmpty()) {
|
||||
ipToNetworkMap = new HashMap<Long, String>();
|
||||
ipToNetworkMap = new LinkedHashMap<Long, String>();
|
||||
Collection ipsCollection = ipToNetworkList.values();
|
||||
Iterator iter = ipsCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd {
|
|||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="user_ip_address")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the id of the public ip address to disassociate")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the id of the public ip address" +
|
||||
" to disassociate")
|
||||
private Long id;
|
||||
|
||||
// unexposed parameter needed for events logging
|
||||
|
|
@ -67,8 +68,8 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public void execute() throws InsufficientAddressCapacityException{
|
||||
UserContext.current().setEventDetails("Ip Id: "+getIpAddressId());
|
||||
boolean result = _networkService.disassociateIpAddress(id);
|
||||
UserContext.current().setEventDetails("Ip Id: " + getIpAddressId());
|
||||
boolean result = _networkService.releaseIpAddress(getIpAddressId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
|
|
@ -37,13 +39,21 @@ public class EnableStaticNatCmd extends BaseCmd{
|
|||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="user_ip_address")
|
||||
@Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.LONG, required=true, description="the public IP address id for which static nat feature is being enabled")
|
||||
@Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.LONG, required=true, description="the public IP " +
|
||||
"address id for which static nat feature is being enabled")
|
||||
private Long ipAddressId;
|
||||
|
||||
@IdentityMapper(entityTableName="vm_instance")
|
||||
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=true, description="the ID of the virtual machine for enabling static nat feature")
|
||||
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=true, description="the ID of " +
|
||||
"the virtual machine for enabling static nat feature")
|
||||
private Long virtualMachineId;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
|
||||
description="The network of the vm the static nat will be enabled for." +
|
||||
" Required when public Ip address is not associated with any Guest network yet (VPC case)")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -56,6 +66,22 @@ public class EnableStaticNatCmd extends BaseCmd{
|
|||
return virtualMachineId;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
|
||||
Long ntwkId = null;
|
||||
|
||||
if (ip.getAssociatedWithNetworkId() != null) {
|
||||
ntwkId = ip.getAssociatedWithNetworkId();
|
||||
} else {
|
||||
ntwkId = networkId;
|
||||
}
|
||||
if (ntwkId == null) {
|
||||
throw new InvalidParameterValueException("Unable to enable static nat for the ipAddress id=" + ipAddressId +
|
||||
" as ip is not associated with any network and no networkId is passed in");
|
||||
}
|
||||
return ntwkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -78,7 +104,7 @@ public class EnableStaticNatCmd extends BaseCmd{
|
|||
@Override
|
||||
public void execute() throws ResourceUnavailableException{
|
||||
try {
|
||||
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, false);
|
||||
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), false);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
|
|
@ -30,7 +29,6 @@ import com.cloud.network.rules.FirewallRule;
|
|||
@Implementation(description="Lists all firewall rules for an IP address.", responseObject=FirewallResponse.class)
|
||||
public class ListFirewallRulesCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListFirewallRulesCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listfirewallrulesresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.FirewallResponse;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.NetworkACLResponse;
|
||||
import com.cloud.network.rules.NetworkACL;
|
||||
|
||||
@Implementation(description="Lists all network ACLs", responseObject=NetworkACLResponse.class)
|
||||
public class ListNetworkACLsCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListNetworkACLsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listnetworkaclsresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="firewall_rules")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="Lists network ACL with the specified ID.")
|
||||
private Long id;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="list network ACLs by network Id")
|
||||
private Long networkId;
|
||||
|
||||
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="list network ACLs by traffic type - Ingress or Egress")
|
||||
private String trafficType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends NetworkACL> result = _networkACLService.listNetworkACLs(this);
|
||||
ListResponse<NetworkACLResponse> response = new ListResponse<NetworkACLResponse>();
|
||||
List<NetworkACLResponse> aclResponses = new ArrayList<NetworkACLResponse>();
|
||||
|
||||
for (NetworkACL acl : result) {
|
||||
NetworkACLResponse ruleData = _responseGenerator.createNetworkACLResponse(acl);
|
||||
aclResponses.add(ruleData);
|
||||
}
|
||||
response.setResponses(aclResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,14 +59,21 @@ public class ListNetworksCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="list networks by physical network id")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list network offerings supporting certain services")
|
||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list networks supporting certain services")
|
||||
private List<String> supportedServices;
|
||||
|
||||
@Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list network offerings by restartRequired option")
|
||||
@Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list networks by restartRequired")
|
||||
private Boolean restartRequired;
|
||||
|
||||
@Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if need to list only networks which support specifying ip ranges")
|
||||
private Boolean specifyIpRanges;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List networks by VPC")
|
||||
private Long vpcId;
|
||||
|
||||
@Parameter(name=ApiConstants.CAN_USE_FOR_DEPLOY, type=CommandType.BOOLEAN, description="list networks available for vm deployment")
|
||||
private Boolean canUseForDeploy;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -111,8 +118,16 @@ public class ListNetworksCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
public Boolean getSpecifyIpRanges() {
|
||||
return specifyIpRanges;
|
||||
}
|
||||
|
||||
public Boolean canUseForDeploy() {
|
||||
return canUseForDeploy;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.PrivateGatewayResponse;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
@Implementation(description="List private gateways", responseObject=PrivateGatewayResponse.class)
|
||||
public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(ListPrivateGatewaysCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listprivategatewaysresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="static_routes")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list private gateway by id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="list gateways by ip address")
|
||||
private String ipAddress;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="list gateways by vlan")
|
||||
private String vlan;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list gateways by vpc")
|
||||
private Long vpcId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
List<PrivateGateway> gateways = _vpcService.listPrivateGateway(this);
|
||||
ListResponse<PrivateGatewayResponse> response = new ListResponse<PrivateGatewayResponse>();
|
||||
List<PrivateGatewayResponse> projectResponses = new ArrayList<PrivateGatewayResponse>();
|
||||
for (PrivateGateway gateway : gateways) {
|
||||
PrivateGatewayResponse gatewayResponse = _responseGenerator.createPrivateGatewayResponse(gateway);
|
||||
projectResponses.add(gatewayResponse);
|
||||
}
|
||||
response.setResponses(projectResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,10 @@ public class ListPublicIpAddressesCmd extends BaseListProjectAndAccountResources
|
|||
|
||||
@Parameter(name=ApiConstants.IS_STATIC_NAT, type=CommandType.BOOLEAN, description="list only static nat ip addresses")
|
||||
private Boolean isStaticNat;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List ips belonging to the VPC")
|
||||
private Long vpcId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -118,6 +122,10 @@ public class ListPublicIpAddressesCmd extends BaseListProjectAndAccountResources
|
|||
return isStaticNat;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
|
|
@ -63,6 +62,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="list by network id")
|
||||
private Long networkId;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List networks by VPC")
|
||||
private Long vpcId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -95,6 +98,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.StaticRouteResponse;
|
||||
import com.cloud.network.vpc.StaticRoute;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Lists all static routes", responseObject=StaticRouteResponse.class)
|
||||
public class ListStaticRoutesCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
private static final String s_name = "liststaticroutesresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="static_routes")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list static route by id")
|
||||
private Long id;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list static routes by vpc id")
|
||||
private Long vpcId;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_gateways")
|
||||
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, description="list static routes by gateway id")
|
||||
private Long gatewayId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public Long getGatewayId() {
|
||||
return gatewayId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends StaticRoute> result = _vpcService.listStaticRoutes(this);
|
||||
ListResponse<StaticRouteResponse> response = new ListResponse<StaticRouteResponse>();
|
||||
List<StaticRouteResponse> routeResponses = new ArrayList<StaticRouteResponse>();
|
||||
|
||||
for (StaticRoute route : result) {
|
||||
StaticRouteResponse ruleData = _responseGenerator.createStaticRouteResponse(route);
|
||||
routeResponses.add(ruleData);
|
||||
}
|
||||
response.setResponses(routeResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.ResourceTagResponse;
|
||||
import com.cloud.server.ResourceTag;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "Burbank")
|
||||
public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
|
||||
private static final String s_name = "listtagsresponse";
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, description="list by resource type")
|
||||
private String resourceType;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, description="list by resource id")
|
||||
private String resourceId;
|
||||
|
||||
@Parameter(name=ApiConstants.KEY, type=CommandType.STRING, description="list by key")
|
||||
private String key;
|
||||
|
||||
@Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, description="list by value")
|
||||
private String value;
|
||||
|
||||
@Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="list by customer name")
|
||||
private String customer;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
List<? extends ResourceTag> tags = _taggedResourceService.listTags(this);
|
||||
ListResponse<ResourceTagResponse> response = new ListResponse<ResourceTagResponse>();
|
||||
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
|
||||
for (ResourceTag tag : tags) {
|
||||
ResourceTagResponse tagResponse = _responseGenerator.createResourceTagResponse(tag);
|
||||
tagResponses.add(tagResponse);
|
||||
}
|
||||
response.setResponses(tagResponses);
|
||||
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public String getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.VpcOfferingResponse;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Lists VPC offerings", responseObject=VpcOfferingResponse.class)
|
||||
public class ListVPCOfferingsCmd extends BaseListCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(ListVPCOfferingsCmd.class.getName());
|
||||
private static final String _name = "listvpcofferingsresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list VPC offerings by id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list VPC offerings by name")
|
||||
private String vpcOffName;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="list VPC offerings by display text")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if need to list only default " +
|
||||
"VPC offerings. Default value is false")
|
||||
private Boolean isDefault;
|
||||
|
||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING,
|
||||
description="list VPC offerings supporting certain services")
|
||||
private List<String> supportedServices;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list VPC offerings by state")
|
||||
private String state;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVpcOffName() {
|
||||
return vpcOffName;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public Boolean getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public List<String> getSupportedServices() {
|
||||
return supportedServices;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends VpcOffering> offerings = _vpcService.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(),
|
||||
getSupportedServices(), isDefault, this.getKeyword(), getState(), this.getStartIndex(), this.getPageSizeVal());
|
||||
ListResponse<VpcOfferingResponse> response = new ListResponse<VpcOfferingResponse>();
|
||||
List<VpcOfferingResponse> offeringResponses = new ArrayList<VpcOfferingResponse>();
|
||||
for (VpcOffering offering : offerings) {
|
||||
VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
|
||||
offeringResponses.add(offeringResponse);
|
||||
}
|
||||
|
||||
response.setResponses(offeringResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.VpcResponse;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Lists VPCs", responseObject=VpcResponse.class)
|
||||
public class ListVPCsCmd extends BaseListAccountResourcesCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(ListVPCsCmd.class.getName());
|
||||
private static final String s_name = "listvpcsresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list VPC by id")
|
||||
private Long id;
|
||||
|
||||
@IdentityMapper(entityTableName="data_center")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="list by zone")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list by name of the VPC")
|
||||
private String vpcName;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="List by display text of " +
|
||||
"the VPC")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, description="list by cidr of the VPC. All VPC " +
|
||||
"guest networks' cidrs should be within this CIDR")
|
||||
private String cidr;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.LONG, description="list by ID of the VPC offering")
|
||||
private Long VpcOffId;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="list by account associated with the VPC. " +
|
||||
"Must be used with the domainId parameter.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="list by domain ID associated with the VPC. " +
|
||||
"If used with the account parameter returns the VPC associated with the account for the specified domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING,
|
||||
description="list VPC supporting certain services")
|
||||
private List<String> supportedServices;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list VPCs by state")
|
||||
private String state;
|
||||
|
||||
@Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list VPCs by restartRequired option")
|
||||
private Boolean restartRequired;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getVpcName() {
|
||||
return vpcName;
|
||||
}
|
||||
|
||||
public String getCidr() {
|
||||
return cidr;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public Long getVpcOffId() {
|
||||
return VpcOffId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<String> getSupportedServices() {
|
||||
return supportedServices;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Boolean getRestartRequired() {
|
||||
return restartRequired;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
List<? extends Vpc> vpcs = _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(),
|
||||
getSupportedServices(), getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(),
|
||||
this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getZoneId(), this.isRecursive(),
|
||||
this.listAll(), getRestartRequired());
|
||||
ListResponse<VpcResponse> response = new ListResponse<VpcResponse>();
|
||||
List<VpcResponse> offeringResponses = new ArrayList<VpcResponse>();
|
||||
for (Vpc vpc : vpcs) {
|
||||
VpcResponse offeringResponse = _responseGenerator.createVpcResponse(vpc);
|
||||
offeringResponses.add(offeringResponse);
|
||||
}
|
||||
|
||||
response.setResponses(offeringResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
|
||||
@Implementation(description="Lists site to site vpn connection gateways", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger (ListVpnCustomerGatewaysCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listvpnconnectionsresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_vpn_connection")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="id of the vpn connection")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<Site2SiteVpnConnection> conns = _s2sVpnService.searchForVpnConnections(this);
|
||||
ListResponse<Site2SiteVpnConnectionResponse> response = new ListResponse<Site2SiteVpnConnectionResponse>();
|
||||
List<Site2SiteVpnConnectionResponse> connResponses = new ArrayList<Site2SiteVpnConnectionResponse>();
|
||||
if (conns != null && !conns.isEmpty()) {
|
||||
for (Site2SiteVpnConnection conn : conns) {
|
||||
Site2SiteVpnConnectionResponse site2SiteVpnConnectonRes = _responseGenerator.createSite2SiteVpnConnectionResponse(conn);
|
||||
site2SiteVpnConnectonRes.setObjectName("vpnconnection");
|
||||
connResponses.add(site2SiteVpnConnectonRes);
|
||||
}
|
||||
}
|
||||
response.setResponses(connResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
|
||||
@Implementation(description="Lists site to site vpn customer gateways", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class ListVpnCustomerGatewaysCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger (ListVpnCustomerGatewaysCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listvpncustomergatewaysresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="id of the customer gateway")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<Site2SiteCustomerGateway> gws = _s2sVpnService.searchForCustomerGateways(this);
|
||||
ListResponse<Site2SiteCustomerGatewayResponse> response = new ListResponse<Site2SiteCustomerGatewayResponse>();
|
||||
List<Site2SiteCustomerGatewayResponse> gwResponses = new ArrayList<Site2SiteCustomerGatewayResponse>();
|
||||
if (gws != null && !gws.isEmpty()) {
|
||||
for (Site2SiteCustomerGateway gw : gws) {
|
||||
Site2SiteCustomerGatewayResponse site2SiteCustomerGatewayRes = _responseGenerator.createSite2SiteCustomerGatewayResponse(gw);
|
||||
site2SiteCustomerGatewayRes.setObjectName("vpncustomergateway");
|
||||
gwResponses.add(site2SiteCustomerGatewayRes);
|
||||
}
|
||||
}
|
||||
response.setResponses(gwResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
|
||||
@Implementation(description="Lists site 2 site vpn gateways", responseObject=Site2SiteVpnGatewayResponse.class)
|
||||
public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger (ListVpnGatewaysCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listvpngatewaysresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_vpn_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="id of the vpn gateway")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<Site2SiteVpnGateway> gws = _s2sVpnService.searchForVpnGateways(this);
|
||||
ListResponse<Site2SiteVpnGatewayResponse> response = new ListResponse<Site2SiteVpnGatewayResponse>();
|
||||
List<Site2SiteVpnGatewayResponse> gwResponses = new ArrayList<Site2SiteVpnGatewayResponse>();
|
||||
if (gws != null && !gws.isEmpty()) {
|
||||
for (Site2SiteVpnGateway gw : gws) {
|
||||
Site2SiteVpnGatewayResponse site2SiteVpnGatewayRes = _responseGenerator.createSite2SiteVpnGatewayResponse(gw);
|
||||
site2SiteVpnGatewayRes.setObjectName("vpngateway");
|
||||
gwResponses.add(site2SiteVpnGatewayRes);
|
||||
}
|
||||
}
|
||||
response.setResponses(gwResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Reset site to site vpn connection", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class ResetVpnConnectionCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ResetVpnConnectionCmd.class.getName());
|
||||
|
||||
private static final String s_name = "resetvpnconnectionresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_connection")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of vpn connection")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for connection. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for connection. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Reset site-to-site VPN connection for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CONNECTION_RESET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
Site2SiteVpnConnection result = _s2sVpnService.resetVpnConnection(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reset site to site VPN connection");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.api.response.VpcResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Restarts a VPC", responseObject=VpcResponse.class)
|
||||
public class RestartVPCCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(RestartVPCCmd.class.getName());
|
||||
private static final String _name = "restartvpcresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the VPC")
|
||||
private Long id;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Vpc vpc = _entityMgr.findById(Vpc.class, getId());
|
||||
if (vpc != null) {
|
||||
return vpc.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
boolean result = _vpcService.restartVpc(getId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to restart VPC");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
} catch (InsufficientCapacityException ex) {
|
||||
s_logger.info(ex);
|
||||
s_logger.trace(ex);
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VPC_RESTART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "restarting VPC id=" + getId();
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,8 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the network offering")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering")
|
||||
@Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering." +
|
||||
" Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering")
|
||||
private String availability;
|
||||
|
||||
@Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the network offering, integer")
|
||||
|
|
|
|||
|
|
@ -12,25 +12,26 @@
|
|||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.StorageNetworkIpRangeResponse;
|
||||
import com.cloud.dc.StorageNetworkIpRange;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.StorageNetworkIpRangeResponse;
|
||||
import com.cloud.dc.StorageNetworkIpRange;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Update a Storage network IP range, only allowed when no IPs in this range have been allocated.", responseObject=UpdateStorageNetworkIpRangeCmd.class, since="3.0.0")
|
||||
@Implementation(description="Update a Storage network IP range, only allowed when no IPs in this range have been allocated.",
|
||||
responseObject=StorageNetworkIpRangeResponse.class, since="3.0.0")
|
||||
public class UpdateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateStorageNetworkIpRangeCmd.class);
|
||||
private static final String s_name = "updatestoragenetworkiprangeresponse";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.VpcResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Updates a VPC", responseObject=VpcResponse.class)
|
||||
public class UpdateVPCCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateVPCCmd.class.getName());
|
||||
private static final String _name = "updatevpcresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the VPC")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the VPC")
|
||||
private String vpcName;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the VPC")
|
||||
private String displayText;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getVpcName() {
|
||||
return vpcName;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Vpc vpc = _entityMgr.findById(Vpc.class, getId());
|
||||
if (vpc != null) {
|
||||
return vpc.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText());
|
||||
if (result != null) {
|
||||
VpcResponse response = _responseGenerator.createVpcResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update VPC");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VPC_UPDATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "updating VPC id=" + getId();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.VpcOfferingResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@Implementation(description="Updates VPC offering", responseObject=VpcOfferingResponse.class)
|
||||
public class UpdateVPCOfferingCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateVPCOfferingCmd.class.getName());
|
||||
private static final String _name = "updatevpcofferingresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the VPC offering")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the VPC offering")
|
||||
private String vpcOffName;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the VPC offering")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="update state for the VPC offering; " +
|
||||
"supported states - Enabled/Disabled")
|
||||
private String state;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getVpcOfferingName() {
|
||||
return vpcOffName;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
VpcOffering result = _vpcService.updateVpcOffering(getId(), getVpcOfferingName(), getDisplayText(), getState());
|
||||
if (result != null) {
|
||||
VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update VPC offering");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VPC_OFFERING_UPDATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Updating VPC offering id=" + getId();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Update site to site vpn customer gateway", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateVpnCustomerGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "updatecustomergatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of customer gateway")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="public ip address id of the customer gateway")
|
||||
private String gatewayIp;
|
||||
|
||||
@Parameter(name=ApiConstants.GUEST_IP, type=CommandType.STRING, required=true, description="guest ip of the customer gateway")
|
||||
private String guestIp;
|
||||
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING, required=true, description="guest cidr of the customer gateway")
|
||||
private String guestCidrList;
|
||||
|
||||
@Parameter(name=ApiConstants.IPSEC_PSK, type=CommandType.STRING, required=true, description="IPsec Preshared-Key of the customer gateway")
|
||||
private String ipsecPsk;
|
||||
|
||||
@Parameter(name=ApiConstants.IKE_POLICY, type=CommandType.STRING, required=true, description="IKE policy of the customer gateway")
|
||||
private String ikePolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.ESP_POLICY, type=CommandType.STRING, required=true, description="ESP policy of the customer gateway")
|
||||
private String espPolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.LIFETIME, type=CommandType.STRING, required=false, description="Lifetime of vpn connection to the customer gateway, in seconds")
|
||||
private Long lifetime;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getIpsecPsk() {
|
||||
return ipsecPsk;
|
||||
}
|
||||
|
||||
public String getGuestCidrList() {
|
||||
return guestCidrList;
|
||||
}
|
||||
|
||||
public String getGuestIp() {
|
||||
return guestIp;
|
||||
}
|
||||
|
||||
public String getGatewayIp() {
|
||||
return gatewayIp;
|
||||
}
|
||||
|
||||
public String getIkePolicy() {
|
||||
return ikePolicy;
|
||||
}
|
||||
|
||||
public String getEspPolicy() {
|
||||
return espPolicy;
|
||||
}
|
||||
|
||||
public Long getLifetime() {
|
||||
return lifetime;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Update site-to-site VPN customer gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CUSTOMER_GATEWAY_UPDATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteCustomerGateway result = _s2sVpnService.updateCustomerGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,8 +15,8 @@ package com.cloud.api.response;
|
|||
import java.util.Date;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
|
@ -133,6 +133,9 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
|
|||
@SerializedName("scriptsversion") @Param(description="the version of scripts")
|
||||
private String scriptsVersion;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
|
||||
private IdentityProxy vpcId = new IdentityProxy("vpc");
|
||||
|
||||
@Override
|
||||
public Long getObjectId() {
|
||||
return getId();
|
||||
|
|
@ -301,4 +304,8 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
|
|||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setVpcId(Long vpcId) {
|
||||
this.vpcId.setValue(vpcId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@
|
|||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class FirewallResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of the firewall rule")
|
||||
private IdentityProxy id = new IdentityProxy("firewall_rules");
|
||||
|
|
@ -30,10 +31,10 @@ public class FirewallResponse extends BaseResponse {
|
|||
@SerializedName(ApiConstants.END_PORT) @Param(description = "the ending port of firewall rule's port range")
|
||||
private String endPort;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS_ID) @Param(description="the public ip address id for the port forwarding rule")
|
||||
@SerializedName(ApiConstants.IP_ADDRESS_ID) @Param(description="the public ip address id for the firewall rule")
|
||||
private Long publicIpAddressId;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the public ip address for the port forwarding rule")
|
||||
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the public ip address for the firewall rule")
|
||||
private String publicIpAddress;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="the state of the rule")
|
||||
|
|
@ -87,7 +88,4 @@ public class FirewallResponse extends BaseResponse {
|
|||
public void setIcmpCode(Integer icmpCode) {
|
||||
this.icmpCode = icmpCode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,16 +92,10 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
|
|||
|
||||
@SerializedName(ApiConstants.PURPOSE) @Param(description="purpose of the IP address. In Acton this value is not null for Ips with isSystem=true, and can have either StaticNat or LB value")
|
||||
private String purpose;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the ip belongs to")
|
||||
private IdentityProxy vpcId = new IdentityProxy("vpc");
|
||||
|
||||
/*
|
||||
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
|
||||
private IdentityProxy jobId = new IdentityProxy("async_job");
|
||||
*/
|
||||
|
||||
/*
|
||||
@SerializedName(ApiConstants.JOB_STATUS) @Param(description="shows the current pending asynchronous job status")
|
||||
private Integer jobStatus;
|
||||
*/
|
||||
|
||||
public void setIpAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
|
|
@ -212,4 +206,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
|
|||
public void setPurpose(String purpose) {
|
||||
this.purpose = purpose;
|
||||
}
|
||||
|
||||
public void setVpcId(Long vpcId) {
|
||||
this.vpcId.setValue(vpcId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class NetworkACLResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of the ACL")
|
||||
private IdentityProxy id = new IdentityProxy("firewall_rules");
|
||||
|
||||
@SerializedName(ApiConstants.PROTOCOL) @Param(description="the protocol of the ACL")
|
||||
private String protocol;
|
||||
|
||||
@SerializedName(ApiConstants.START_PORT) @Param(description="the starting port of ACL's port range")
|
||||
private String startPort;
|
||||
|
||||
@SerializedName(ApiConstants.END_PORT) @Param(description = "the ending port of ACL's port range")
|
||||
private String endPort;
|
||||
|
||||
@SerializedName(ApiConstants.TRAFFIC_TYPE) @Param(description="the traffic type for the ACL")
|
||||
private String trafficType;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="the state of the rule")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.CIDR_LIST) @Param(description="the cidr list to forward traffic from")
|
||||
private String cidrList;
|
||||
|
||||
@SerializedName(ApiConstants.ICMP_TYPE) @Param(description= "type of the icmp message being sent")
|
||||
private Integer icmpType;
|
||||
|
||||
@SerializedName(ApiConstants.ICMP_CODE) @Param(description = "error code for this icmp message")
|
||||
private Integer icmpCode;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public void setStartPort(String startPort) {
|
||||
this.startPort = startPort;
|
||||
}
|
||||
|
||||
public void setEndPort(String endPort) {
|
||||
this.endPort = endPort;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setCidrList(String cidrList) {
|
||||
this.cidrList = cidrList;
|
||||
}
|
||||
|
||||
public void setIcmpType(Integer icmpType) {
|
||||
this.icmpType = icmpType;
|
||||
}
|
||||
|
||||
public void setIcmpCode(Integer icmpCode) {
|
||||
this.icmpCode = icmpCode;
|
||||
}
|
||||
|
||||
public void setTrafficType(String trafficType) {
|
||||
this.trafficType = trafficType;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,8 +15,8 @@ package com.cloud.api.response;
|
|||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -127,6 +127,12 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
|||
@SerializedName(ApiConstants.SPECIFY_IP_RANGES) @Param(description="true if network supports specifying ip ranges, false otherwise")
|
||||
private Boolean specifyIpRanges;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
|
||||
private IdentityProxy vpcId = new IdentityProxy("vpc");
|
||||
|
||||
@SerializedName(ApiConstants.CAN_USE_FOR_DEPLOY) @Param(description="list networks available for vm deployment")
|
||||
private Boolean canUseForDeploy;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
|
@ -268,4 +274,12 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
|||
public void setSpecifyIpRanges(Boolean specifyIpRanges) {
|
||||
this.specifyIpRanges = specifyIpRanges;
|
||||
}
|
||||
|
||||
public void setVpcId(Long vpcId) {
|
||||
this.vpcId.setValue(vpcId);
|
||||
}
|
||||
|
||||
public void setCanUseForDeploy(Boolean canUseForDeploy) {
|
||||
this.canUseForDeploy = canUseForDeploy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PrivateGatewayResponse extends BaseResponse implements ControlledEntityResponse{
|
||||
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the id of the private gateway")
|
||||
private IdentityProxy id = new IdentityProxy("vpc_gateways");
|
||||
|
||||
@SerializedName(ApiConstants.GATEWAY) @Param(description="the gateway")
|
||||
private String gateway;
|
||||
|
||||
@SerializedName(ApiConstants.NETMASK) @Param(description="the private gateway's netmask")
|
||||
private String netmask;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the private gateway's ip address")
|
||||
private String address;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the private gateway")
|
||||
private IdentityProxy zoneId = new IdentityProxy("data_center");
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the zone the private gateway belongs to")
|
||||
private String zoneName;
|
||||
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the vlan of the private gateway")
|
||||
private String vlan;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the private gateaway belongs to")
|
||||
private IdentityProxy vpcId = new IdentityProxy("vpc");
|
||||
|
||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network id")
|
||||
private IdentityProxy physicalNetworkId = new IdentityProxy("physical_network");
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
@Param(description = "the account associated with the private gateway")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the private gateway")
|
||||
private IdentityProxy projectId = new IdentityProxy("projects");
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the private gateway")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the ID of the domain associated with the private gateway")
|
||||
private IdentityProxy domainId = new IdentityProxy("domain");
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
@Param(description = "the domain associated with the private gateway")
|
||||
private String domainName;
|
||||
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public void setNetmask(String netmask) {
|
||||
this.netmask = netmask;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId.setValue(zoneId);
|
||||
}
|
||||
|
||||
public void setVlan(String vlan) {
|
||||
this.vlan = vlan;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
public void setVpcId(Long vpcId) {
|
||||
this.vpcId.setValue(vpcId);
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public void setPhysicalNetworkId(Long physicalNetworkId) {
|
||||
this.physicalNetworkId.setValue(physicalNetworkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId.setValue(domainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectId(Long projectId) {
|
||||
this.projectId.setValue(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ResourceTagResponse extends BaseResponse implements ControlledEntityResponse{
|
||||
@SerializedName(ApiConstants.KEY) @Param(description="tag key name")
|
||||
private String key;
|
||||
|
||||
@SerializedName(ApiConstants.VALUE) @Param(description="tag value")
|
||||
private String value;
|
||||
|
||||
@SerializedName(ApiConstants.RESOURCE_TYPE) @Param(description="resource type")
|
||||
private String resourceType;
|
||||
|
||||
@SerializedName(ApiConstants.RESOURCE_ID) @Param(description="id of the resource")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
@Param(description = "the account associated with the tag")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id the tag belongs to")
|
||||
private IdentityProxy projectId = new IdentityProxy("projects");
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name where tag belongs to")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the ID of the domain associated with the tag")
|
||||
private IdentityProxy domainId = new IdentityProxy("domain");
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
@Param(description = "the domain associated with the tag")
|
||||
private String domainName;
|
||||
|
||||
@SerializedName(ApiConstants.CUSTOMER) @Param(description="customer associated with the tag")
|
||||
private String customer;
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId.setValue(domainId);
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectId(Long projectId) {
|
||||
this.projectId.setValue(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setCustomer(String customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Site2SiteCustomerGatewayResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the vpn gateway ID")
|
||||
private IdentityProxy id = new IdentityProxy("s2s_vpn_gateway");
|
||||
|
||||
@SerializedName(ApiConstants.GATEWAY) @Param(description="public ip address id of the customer gateway")
|
||||
private String gatewayIp;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="guest ip of the customer gateway")
|
||||
private String guestIp;
|
||||
|
||||
@SerializedName(ApiConstants.CIDR_LIST) @Param(description="guest cidr list of the customer gateway")
|
||||
private String guestCidrList;
|
||||
|
||||
@SerializedName(ApiConstants.IPSEC_PSK) @Param(description="IPsec preshared-key of customer gateway")
|
||||
private String ipsecPsk;
|
||||
|
||||
@SerializedName(ApiConstants.REMOVED) @Param(description="the date and time the host was removed")
|
||||
private Date removed;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setGatewayIp(String gatewayIp) {
|
||||
this.gatewayIp = gatewayIp;
|
||||
}
|
||||
|
||||
public void setGuestIp(String guestIp) {
|
||||
this.guestIp = guestIp;
|
||||
}
|
||||
|
||||
public void setGuestCidrList(String guestCidrList) {
|
||||
this.guestCidrList = guestCidrList;
|
||||
}
|
||||
|
||||
public void setIpsecPsk(String ipsecPsk) {
|
||||
this.ipsecPsk = ipsecPsk;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue