mirror of https://github.com/apache/cloudstack.git
Merge branch 'vpc-3.0.x' into 3.0.x
Conflicts: api/src/com/cloud/api/ApiConstants.java api/src/com/cloud/api/BaseCmd.java api/src/com/cloud/api/ResponseGenerator.java api/src/com/cloud/api/commands/AssociateIPAddrCmd.java api/src/com/cloud/api/commands/EnableStaticNatCmd.java api/src/com/cloud/event/EventTypes.java api/src/com/cloud/network/NetworkService.java api/src/com/cloud/network/rules/RulesService.java client/tomcatconf/commands.properties.in core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java scripts/vm/hypervisor/xenserver/xenserver56fp1/patch server/src/com/cloud/api/ApiDBUtils.java server/src/com/cloud/api/ApiResponseHelper.java server/src/com/cloud/configuration/DefaultComponentLibrary.java server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java server/src/com/cloud/network/NetworkManagerImpl.java server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java server/src/com/cloud/network/rules/RulesManagerImpl.java server/src/com/cloud/server/ManagementServerImpl.java server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java server/src/com/cloud/upgrade/dao/Upgrade2214to30.java server/test/com/cloud/network/MockNetworkManagerImpl.java server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java setup/db/create-schema.sql wscript
This commit is contained in:
commit
aaf0d24a83
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,46 @@
|
|||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 SetSourceNatAnswer extends Answer{
|
||||
public SetSourceNatAnswer() {}
|
||||
|
||||
public SetSourceNatAnswer(PlugNicCommand 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -32,7 +32,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;
|
||||
|
|
|
|||
|
|
@ -173,5 +173,4 @@ public class NetworkTO {
|
|||
public boolean isSecurityGroupEnabled() {
|
||||
return this.isSecurityGroupEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,6 +356,9 @@ public class ApiConstants {
|
|||
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 enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import com.cloud.network.firewall.FirewallService;
|
|||
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.projects.Project;
|
||||
import com.cloud.projects.ProjectService;
|
||||
|
|
@ -125,6 +126,7 @@ public abstract class BaseCmd {
|
|||
public static IdentityService _identityService;
|
||||
public static StorageNetworkService _storageNetworkService;
|
||||
public static TaggedResourceService _taggedResourceService;
|
||||
public static VpcService _vpcService;
|
||||
|
||||
static void setComponents(ResponseGenerator generator) {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||
|
|
@ -153,6 +155,7 @@ public abstract class BaseCmd {
|
|||
_identityService = locator.getManager(IdentityService.class);
|
||||
_storageNetworkService = locator.getManager(StorageNetworkService.class);
|
||||
_taggedResourceService = locator.getManager(TaggedResourceService.class);
|
||||
_vpcService = locator.getManager(VpcService.class);
|
||||
}
|
||||
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,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;
|
||||
|
|
@ -104,6 +106,8 @@ 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.Vpc;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
|
@ -286,4 +290,15 @@ public interface ResponseGenerator {
|
|||
ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag);
|
||||
|
||||
|
||||
/**
|
||||
* @param offering
|
||||
* @return
|
||||
*/
|
||||
VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering);
|
||||
|
||||
/**
|
||||
* @param vpc
|
||||
* @return
|
||||
*/
|
||||
VpcResponse createVpcResponse(Vpc vpc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -168,7 +204,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 +221,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());
|
||||
|
|
|
|||
|
|
@ -72,6 +72,11 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
|
|||
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "type of firewallrule: system/user")
|
||||
private String type;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
|
||||
description="The network of the vm the Firewall rule will be created for")
|
||||
private Long networkId;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
@ -187,7 +192,19 @@ 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();
|
||||
} else {
|
||||
ntwkId = networkId;
|
||||
}
|
||||
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
|
||||
|
|
|
|||
|
|
@ -167,9 +167,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() {
|
||||
|
|
|
|||
|
|
@ -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,40 @@ 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. Has value true by default")
|
||||
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")
|
||||
private Long networkId;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
|
|
@ -93,7 +106,8 @@ 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;
|
||||
}
|
||||
|
|
@ -189,7 +203,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 +227,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 +258,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,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";
|
||||
}
|
||||
}
|
||||
|
|
@ -58,6 +58,11 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
|
|||
@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")
|
||||
private Boolean openFirewall;
|
||||
|
||||
@IdentityMapper(entityTableName="networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
|
||||
description="The network of the ip the VPN be created for")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -125,10 +130,26 @@ 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();
|
||||
} else {
|
||||
ntwkId = networkId;
|
||||
}
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -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.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
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
|
||||
*/
|
||||
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,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.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.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
|
||||
*/
|
||||
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,104 @@
|
|||
// 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.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.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
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,89 @@
|
|||
// 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.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
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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,20 @@ 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.")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -56,6 +65,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 +103,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);
|
||||
|
|
|
|||
|
|
@ -62,11 +62,15 @@ public class ListNetworksCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list network offerings 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;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -112,7 +116,11 @@ public class ListNetworksCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
return specifyIpRanges;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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,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 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.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.VpcOfferingResponse;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
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,155 @@
|
|||
// 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.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.VpcResponse;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
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,95 @@
|
|||
// 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.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.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
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")
|
||||
|
|
|
|||
|
|
@ -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.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
|
||||
*/
|
||||
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,108 @@
|
|||
// 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.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
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,6 +127,9 @@ 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");
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
|
@ -268,4 +271,8 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
|||
public void setSpecifyIpRanges(Boolean specifyIpRanges) {
|
||||
this.specifyIpRanges = specifyIpRanges;
|
||||
}
|
||||
|
||||
public void setVpcId(Long vpcId) {
|
||||
this.vpcId.setValue(vpcId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
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 VpcOfferingResponse extends BaseResponse{
|
||||
@SerializedName("id") @Param(description="the id of the vpc offering")
|
||||
private final IdentityProxy id = new IdentityProxy("vpc_offerings");
|
||||
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="the name of the vpc offering")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.DISPLAY_TEXT) @Param(description="an alternate display text of the vpc offering.")
|
||||
private String displayText;
|
||||
|
||||
@SerializedName(ApiConstants.CREATED) @Param(description="the date this vpc offering was created")
|
||||
private Date created;
|
||||
|
||||
@SerializedName(ApiConstants.IS_DEFAULT) @Param(description="true if vpc offering is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="state of the vpc offering. Can be Disabled/Enabled")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.SERVICE) @Param(description="the list of supported services", responseObject = ServiceResponse.class)
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDisplayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public void setIsDefault(Boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public void setServices(List<ServiceResponse> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
// 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 java.util.List;
|
||||
|
||||
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 VpcResponse extends BaseResponse implements ControlledEntityResponse{
|
||||
@SerializedName("id") @Param(description="the id of the VPC")
|
||||
private final IdentityProxy id = new IdentityProxy("vpc");
|
||||
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="the name of the VPC")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.DISPLAY_TEXT) @Param(description="an alternate display text of the VPC.")
|
||||
private String displayText;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="state of the VPC. Can be Disabled/Enabled")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the vpc")
|
||||
private IdentityProxy zoneId = new IdentityProxy("data_center");
|
||||
|
||||
@SerializedName(ApiConstants.SERVICE) @Param(description="the list of supported services", responseObject = ServiceResponse.class)
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
@SerializedName(ApiConstants.CIDR) @Param(description="the cidr the VPC")
|
||||
private String cidr;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_OFF_ID) @Param(description="vpc offering id the VPC is created from")
|
||||
private IdentityProxy vpcOfferingId = new IdentityProxy("vpc_offerings");
|
||||
|
||||
@SerializedName(ApiConstants.CREATED) @Param(description="the date this VPC was created")
|
||||
private Date created;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the owner of the VPC")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the VPC")
|
||||
private IdentityProxy projectId = new IdentityProxy("projects");
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the VPC")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the VPC owner")
|
||||
private IdentityProxy domainId = new IdentityProxy("domain");
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the owner")
|
||||
private String domain;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK) @Param(description="the list of networks belongign to the VPC", responseObject = NetworkResponse.class)
|
||||
private List<NetworkResponse> networks;
|
||||
|
||||
@SerializedName(ApiConstants.RESTART_REQUIRED) @Param(description="true network requires restart")
|
||||
private Boolean restartRequired;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_DOMAIN) @Param(description="the network domain")
|
||||
private String networkDomain;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDisplayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public void setServices(List<ServiceResponse> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectId(Long projectId) {
|
||||
this.projectId.setValue(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId.setValue(domainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainName(String domainName) {
|
||||
this.domain = domainName;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId.setValue(zoneId);
|
||||
}
|
||||
|
||||
public void setCidr(String cidr) {
|
||||
this.cidr = cidr;
|
||||
}
|
||||
|
||||
public void setVpcOfferingId(Long vpcOfferingId) {
|
||||
this.vpcOfferingId.setValue(vpcOfferingId);
|
||||
}
|
||||
|
||||
public List<NetworkResponse> getNetworks() {
|
||||
return networks;
|
||||
}
|
||||
|
||||
public void setNetworks(List<NetworkResponse> networks) {
|
||||
this.networks = networks;
|
||||
}
|
||||
|
||||
public void setRestartRequired(Boolean restartRequired) {
|
||||
this.restartRequired = restartRequired;
|
||||
}
|
||||
|
||||
public void setNetworkDomain(String networkDomain) {
|
||||
this.networkDomain = networkDomain;
|
||||
}
|
||||
}
|
||||
|
|
@ -260,4 +260,14 @@ public class EventTypes {
|
|||
public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
|
||||
public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";
|
||||
|
||||
// VPC
|
||||
public static final String EVENT_VPC_CREATE = "VPC.CREATE";
|
||||
public static final String EVENT_VPC_UPDATE = "VPC.UPDATE";
|
||||
public static final String EVENT_VPC_DELETE = "VPC.DELETE";
|
||||
public static final String EVENT_VPC_RESTART = "VPC.RESTART";
|
||||
|
||||
|
||||
public static final String EVENT_VPC_OFFERING_CREATE = "VPC.OFFERING.CREATE";
|
||||
public static final String EVENT_VPC_OFFERING_UPDATE = "VPC.OFFERING.UPDATE";
|
||||
public static final String EVENT_VPC_OFFERING_DELETE = "VPC.OFFERING.DELETE";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,11 @@
|
|||
package com.cloud.hypervisor;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
|
|
@ -45,4 +47,10 @@ public interface HypervisorGuru extends Adapter {
|
|||
*
|
||||
*/
|
||||
boolean trackVmHostChange();
|
||||
|
||||
/**
|
||||
* @param profile
|
||||
* @return
|
||||
*/
|
||||
NicTO toNicTO(NicProfile profile);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,4 +76,14 @@ public interface IpAddress extends ControlledEntity {
|
|||
|
||||
boolean getSystem();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
Long getVpcId();
|
||||
|
||||
/**
|
||||
* @param vpcId
|
||||
*/
|
||||
void setVpcId(Long vpcId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,12 +37,15 @@ public interface Network extends ControlledEntity {
|
|||
public static class Service {
|
||||
private static List<Service> supportedServices = new ArrayList<Service>();
|
||||
|
||||
public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnTypes);
|
||||
public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnProtocols, Capability.VpnTypes);
|
||||
public static final Service Dhcp = new Service("Dhcp");
|
||||
public static final Service Dns = new Service("Dns", Capability.AllowDnsSuffixModification);
|
||||
public static final Service Gateway = new Service("Gateway");
|
||||
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols, Capability.MultipleIps, Capability.TrafficStatistics);
|
||||
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation, Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps, Capability.SupportedStickinessMethods, Capability.ElasticLb);
|
||||
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols,
|
||||
Capability.MultipleIps, Capability.TrafficStatistics, Capability.FirewallType);
|
||||
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation,
|
||||
Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps,
|
||||
Capability.SupportedStickinessMethods, Capability.ElasticLb);
|
||||
public static final Service UserData = new Service("UserData");
|
||||
public static final Service SourceNat = new Service("SourceNat", Capability.SupportedSourceNatTypes, Capability.RedundantRouter);
|
||||
public static final Service StaticNat = new Service("StaticNat", Capability.ElasticIp);
|
||||
|
|
@ -109,6 +112,7 @@ public interface Network extends ControlledEntity {
|
|||
public static final Provider ExternalGateWay = new Provider("ExternalGateWay", true);
|
||||
public static final Provider ElasticLoadBalancerVm = new Provider("ElasticLoadBalancerVm", false);
|
||||
public static final Provider SecurityGroupProvider = new Provider("SecurityGroupProvider", false);
|
||||
public static final Provider VPCVirtualRouter = new Provider("VpcVirtualRouter", false);
|
||||
public static final Provider None = new Provider("None", false);
|
||||
|
||||
private String name;
|
||||
|
|
@ -148,13 +152,16 @@ public interface Network extends ControlledEntity {
|
|||
public static final Capability SupportedStickinessMethods = new Capability("SupportedStickinessMethods");
|
||||
public static final Capability MultipleIps = new Capability("MultipleIps");
|
||||
public static final Capability SupportedSourceNatTypes = new Capability("SupportedSourceNatTypes");
|
||||
public static final Capability SupportedVpnTypes = new Capability("SupportedVpnTypes");
|
||||
public static final Capability SupportedVpnProtocols = new Capability("SupportedVpnTypes");
|
||||
public static final Capability VpnTypes = new Capability("VpnTypes");
|
||||
public static final Capability TrafficStatistics = new Capability("TrafficStatistics");
|
||||
public static final Capability LoadBalancingSupportedIps = new Capability("LoadBalancingSupportedIps");
|
||||
public static final Capability AllowDnsSuffixModification = new Capability("AllowDnsSuffixModification");
|
||||
public static final Capability RedundantRouter = new Capability("RedundantRouter");
|
||||
public static final Capability ElasticIp = new Capability("ElasticIp");
|
||||
public static final Capability ElasticLb = new Capability("ElasticLb");
|
||||
public static final Capability FirewallType = new Capability("FirewallType");
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
@ -279,4 +286,9 @@ public interface Network extends ControlledEntity {
|
|||
boolean isRestartRequired();
|
||||
|
||||
boolean getSpecifyIpRanges();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
Long getVpcId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class NetworkProfile implements Network {
|
|||
private ACLType aclType;
|
||||
private boolean restartRequired;
|
||||
private boolean specifyIpRanges;
|
||||
private Long vpcId;
|
||||
|
||||
public NetworkProfile(Network network) {
|
||||
this.id = network.getId();
|
||||
|
|
@ -67,6 +68,7 @@ public class NetworkProfile implements Network {
|
|||
this.aclType = network.getAclType();
|
||||
this.restartRequired = network.isRestartRequired();
|
||||
this.specifyIpRanges = network.getSpecifyIpRanges();
|
||||
this.vpcId = network.getVpcId();
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
|
|
@ -206,4 +208,9 @@ public class NetworkProfile implements Network {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,28 +37,21 @@ public interface NetworkService {
|
|||
|
||||
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
IpAddress allocateIP(long networkId, Account ipOwner) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Associates a public IP address for a router.
|
||||
*
|
||||
* @param ipId
|
||||
* - the command specifying ipAddress
|
||||
* @return ip address object
|
||||
* @throws ResourceAllocationException
|
||||
* , InsufficientCapacityException
|
||||
*/
|
||||
IpAddress associateIP(long ipId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException,
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
boolean disassociateIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
|
||||
boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
|
||||
|
||||
Network createNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException;
|
||||
Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceAllocationException;
|
||||
|
||||
List<? extends Network> searchForNetworks(ListNetworksCmd cmd);
|
||||
|
||||
boolean deleteNetwork(long networkId);
|
||||
|
||||
boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
int getActiveNicsInNetwork(long networkId);
|
||||
|
||||
|
|
@ -74,7 +67,8 @@ public interface NetworkService {
|
|||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
|
||||
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser, String domainSuffix, Long networkOfferingId, Boolean changeCidr);
|
||||
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
|
||||
String domainSuffix, Long networkOfferingId, Boolean changeCidr);
|
||||
|
||||
Integer getNetworkRate(long networkId, Long vmId);
|
||||
|
||||
|
|
@ -82,11 +76,14 @@ public interface NetworkService {
|
|||
|
||||
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
|
||||
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
|
||||
List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
|
||||
|
||||
List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name);
|
||||
List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword,
|
||||
Long startIndex, Long pageSize, String name);
|
||||
|
||||
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state);
|
||||
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags,
|
||||
String newVnetRangeString, String state);
|
||||
|
||||
boolean deletePhysicalNetwork(Long id);
|
||||
|
||||
|
|
@ -94,9 +91,11 @@ public interface NetworkService {
|
|||
|
||||
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
|
||||
|
||||
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName, Long destinationPhysicalNetworkId, List<String> enabledServices);
|
||||
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName,
|
||||
Long destinationPhysicalNetworkId, List<String> enabledServices);
|
||||
|
||||
List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId, String name, String state, Long startIndex, Long pageSize);
|
||||
List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId, String name,
|
||||
String state, Long startIndex, Long pageSize);
|
||||
|
||||
PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String state, List<String> enabledServices);
|
||||
|
||||
|
|
@ -112,7 +111,8 @@ public interface NetworkService {
|
|||
|
||||
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
|
||||
|
||||
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan);
|
||||
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType,
|
||||
String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan);
|
||||
|
||||
PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id);
|
||||
|
||||
|
|
@ -130,4 +130,40 @@ public interface NetworkService {
|
|||
|
||||
List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
List<? extends Network> listNetworksByVpc(long vpcId);
|
||||
|
||||
boolean isVmPartOfNetwork(long vmId, long ntwkId);
|
||||
|
||||
/**
|
||||
* @param entityId
|
||||
* @param networkId
|
||||
* @param vpcId
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ResourceAllocationException
|
||||
* @throws InsufficientAddressCapacityException
|
||||
*/
|
||||
IpAddress associateIP(long ipId, Long networkId, Long vpcId) throws InsufficientAddressCapacityException,
|
||||
ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* @param networkName
|
||||
* @param displayText
|
||||
* @param physicalNetworkId
|
||||
* @param vlan
|
||||
* @param startIp
|
||||
* @param endIP TODO
|
||||
* @param gateway
|
||||
* @param netmask
|
||||
* @param networkOwnerId
|
||||
* @return
|
||||
* @throws InsufficientCapacityException
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceAllocationException
|
||||
*/
|
||||
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
|
||||
String startIp, String endIP, String gateway, String netmask, long networkOwnerId)
|
||||
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ public interface VirtualNetworkApplianceService {
|
|||
* the command specifying router's id
|
||||
* @return DomainRouter object
|
||||
*/
|
||||
VirtualRouter startRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
VirtualRouter startRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Reboots domain router
|
||||
|
|
@ -35,7 +36,8 @@ public interface VirtualNetworkApplianceService {
|
|||
* the command specifying router's id
|
||||
* @return router if successful
|
||||
*/
|
||||
VirtualRouter rebootRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
VirtualRouter rebootRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
VirtualRouter upgradeRouter(UpgradeRouterCmd cmd);
|
||||
|
||||
|
|
@ -55,4 +57,5 @@ public interface VirtualNetworkApplianceService {
|
|||
VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
VirtualRouter destroyRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ package com.cloud.network;
|
|||
public interface VirtualRouterProvider {
|
||||
public enum VirtualRouterProviderType {
|
||||
VirtualRouter,
|
||||
ElasticLoadBalancerVm
|
||||
ElasticLoadBalancerVm,
|
||||
VPCVirtualRouter
|
||||
}
|
||||
|
||||
public VirtualRouterProviderType getType();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
// 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.network;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public interface VpcVirtualNetworkApplianceService {
|
||||
|
||||
/**
|
||||
* @param router
|
||||
* @param network
|
||||
* @param isRedundant
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws InsufficientCapacityException
|
||||
*/
|
||||
boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* @param router
|
||||
* @param network
|
||||
* @param isRedundant
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean removeRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
}
|
||||
|
|
@ -52,7 +52,8 @@ public interface NetworkElement extends Adapter {
|
|||
* @return true if network configuration is now usable; false if not; null if not handled by this element.
|
||||
* @throws InsufficientNetworkCapacityException TODO
|
||||
*/
|
||||
boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Prepare for a nic to be added into this network.
|
||||
|
|
@ -66,7 +67,9 @@ public interface NetworkElement extends Adapter {
|
|||
* @throws ResourceUnavailableException
|
||||
* @throws InsufficientNetworkCapacityException
|
||||
*/
|
||||
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* A nic is released from this network.
|
||||
|
|
@ -78,7 +81,8 @@ public interface NetworkElement extends Adapter {
|
|||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* The network is being shutdown.
|
||||
|
|
@ -89,7 +93,8 @@ public interface NetworkElement extends Adapter {
|
|||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
boolean shutdown(Network network, ReservationContext context, boolean cleanup)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* The network is being destroyed.
|
||||
|
|
@ -114,7 +119,8 @@ public interface NetworkElement extends Adapter {
|
|||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* This should return true if out of multiple services provided by this element, only some can be enabled. If all the services MUST be provided, this should return false.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import com.cloud.exception.ConcurrentOperationException;
|
|||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@ import java.util.List;
|
|||
import com.cloud.api.commands.ConfigureVirtualRouterElementCmd;
|
||||
import com.cloud.api.commands.ListVirtualRouterElementsCmd;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface VirtualRouterElementService extends PluggableService{
|
||||
VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd);
|
||||
VirtualRouterProvider addElement(Long nspId);
|
||||
VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType providerType);
|
||||
VirtualRouterProvider getCreatedElement(long id);
|
||||
List<? extends VirtualRouterProvider> searchForVirtualRouterElement(ListVirtualRouterElementsCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
// 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.network.element;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public interface VpcProvider extends NetworkElement{
|
||||
/**
|
||||
* Start vpc element as specified
|
||||
* @param vpc fully specified vpc configuration.
|
||||
* @throws InsufficientNetworkCapacityException TODO
|
||||
*/
|
||||
boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* @param vpc
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean shutdownVpc(Vpc vpc) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
boolean createPrivateGateway();
|
||||
|
||||
boolean createVpnGateway();
|
||||
|
||||
boolean deletePrivateGateway();
|
||||
|
||||
boolean deleteVpnGateway();
|
||||
}
|
||||
|
|
@ -30,8 +30,11 @@ public interface VirtualRouter extends VirtualMachine {
|
|||
FAULT
|
||||
}
|
||||
RedundantState getRedundantState();
|
||||
String getGuestIpAddress();
|
||||
String getPublicIpAddress();
|
||||
boolean isStopPending();
|
||||
void setStopPending(boolean stopPending);
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
Long getVpcId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public interface RulesService {
|
|||
|
||||
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
|
||||
|
||||
boolean enableStaticNat(long ipAddressId, long vmId, boolean isSystemVm) throws NetworkRuleConflictException, ResourceUnavailableException;
|
||||
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm) throws NetworkRuleConflictException, ResourceUnavailableException;
|
||||
|
||||
PortForwardingRule getPortForwardigRule(long ruleId);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
// 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.network.vpc;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.network.Network;
|
||||
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public interface Vpc extends ControlledEntity{
|
||||
public enum State {
|
||||
Enabled,
|
||||
Disabled
|
||||
}
|
||||
|
||||
public static final String _supportedProviders = Network.Provider.VPCVirtualRouter.getName();
|
||||
|
||||
boolean readyToUse();
|
||||
|
||||
long getId();
|
||||
|
||||
String getUuid();
|
||||
|
||||
String getName();
|
||||
|
||||
long getZoneId();
|
||||
|
||||
String getCidr();
|
||||
|
||||
State getState();
|
||||
|
||||
long getVpcOfferingId();
|
||||
|
||||
String getDisplayText();
|
||||
|
||||
String getNetworkDomain();
|
||||
|
||||
boolean isRestartRequired();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
// 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.network.vpc;
|
||||
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public interface VpcOffering {
|
||||
public enum State {
|
||||
Disabled,
|
||||
Enabled
|
||||
}
|
||||
|
||||
public static final String defaultVPCOfferingName = "Default VPC offering";
|
||||
|
||||
long getId();
|
||||
|
||||
String getUuid();
|
||||
|
||||
String getName();
|
||||
|
||||
String getUniqueName();
|
||||
|
||||
String getDisplayText();
|
||||
|
||||
State getState();
|
||||
|
||||
boolean isDefault();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
Long getServiceOfferingId();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
// 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.network.vpc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public interface VpcService {
|
||||
|
||||
public VpcOffering getVpcOffering(long vpcOfferingId);
|
||||
|
||||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices);
|
||||
|
||||
public Vpc getVpc(long vpcId);
|
||||
|
||||
public Vpc getActiveVpc(long vpcId);
|
||||
|
||||
public List<? extends Network> getVpcNetworks(long vpcId);
|
||||
|
||||
Map<Service, Set<Provider>> getVpcOffSvcProvidersMap(long vpcOffId);
|
||||
|
||||
List<? extends VpcOffering> listVpcOfferings(Long id, String name, String displayText, List<String> supportedServicesStr,
|
||||
Boolean isDefault, String keyword, String state, Long startIndex, Long pageSizeVal);
|
||||
|
||||
/**
|
||||
* @param offId
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteVpcOffering(long offId);
|
||||
|
||||
/**
|
||||
* @param vpcOffId
|
||||
* @param vpcOfferingName
|
||||
* @param displayText
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
public VpcOffering updateVpcOffering(long vpcOffId, String vpcOfferingName, String displayText, String state);
|
||||
|
||||
/**
|
||||
* @param zoneId
|
||||
* @param vpcOffId
|
||||
* @param vpcOwnerId
|
||||
* @param vpcName
|
||||
* @param displayText
|
||||
* @param cidr
|
||||
* @param networkDomain TODO
|
||||
* @return
|
||||
*/
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain);
|
||||
|
||||
/**
|
||||
* @param vpcId
|
||||
* @return
|
||||
* @throws InsufficientCapacityException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
public boolean deleteVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* @param vpcId
|
||||
* @param vpcName
|
||||
* @param displayText
|
||||
* @return
|
||||
*/
|
||||
public Vpc updateVpc(long vpcId, String vpcName, String displayText);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param vpcName
|
||||
* @param displayText
|
||||
* @param supportedServicesStr
|
||||
* @param cidr
|
||||
* @param state TODO
|
||||
* @param accountName
|
||||
* @param domainId
|
||||
* @param keyword
|
||||
* @param startIndex
|
||||
* @param pageSizeVal
|
||||
* @param zoneId TODO
|
||||
* @param isRecursive TODO
|
||||
* @param listAll TODO
|
||||
* @param restartRequired TODO
|
||||
* @param vpc
|
||||
* @return
|
||||
*/
|
||||
public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText,
|
||||
List<String> supportedServicesStr, String cidr, Long vpcOffId, String state, String accountName, Long domainId,
|
||||
String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll,
|
||||
Boolean restartRequired);
|
||||
|
||||
/**
|
||||
* @param vpcId
|
||||
* @return
|
||||
* @throws InsufficientCapacityException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
boolean startVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* @param vpcId
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
* @throws InsufficientCapacityException
|
||||
*/
|
||||
boolean restartVpc(Long id) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
}
|
||||
|
|
@ -23,7 +23,8 @@ import com.cloud.network.VpnUser;
|
|||
|
||||
public interface RemoteAccessVpnService {
|
||||
|
||||
RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall) throws NetworkRuleConflictException;
|
||||
RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall, long networkId)
|
||||
throws NetworkRuleConflictException;
|
||||
void destroyRemoteAccessVpn(long vpnServerAddressId) throws ResourceUnavailableException;
|
||||
RemoteAccessVpn startRemoteAccessVpn(long vpnServerAddressId, boolean openFirewall) throws ResourceUnavailableException;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,16 @@ public interface NetworkOffering {
|
|||
public final static String SystemControlNetwork = "System-Control-Network";
|
||||
public final static String SystemManagementNetwork = "System-Management-Network";
|
||||
public final static String SystemStorageNetwork = "System-Storage-Network";
|
||||
|
||||
public final static String SystemPrivateGatewayNetworkOffering = "System-Private-Gateway-Network-Offering";
|
||||
|
||||
public final static String DefaultSharedNetworkOfferingWithSGService = "DefaultSharedNetworkOfferingWithSGService";
|
||||
public final static String DefaultIsolatedNetworkOfferingWithSourceNatService = "DefaultIsolatedNetworkOfferingWithSourceNatService";
|
||||
public final static String OvsIsolatedNetworkOfferingWithSourceNatService = "OvsIsolatedNetworkOfferingWithSourceNatService";
|
||||
public final static String DefaultSharedNetworkOffering = "DefaultSharedNetworkOffering";
|
||||
public final static String DefaultIsolatedNetworkOffering = "DefaultIsolatedNetworkOffering";
|
||||
public final static String DefaultSharedEIPandELBNetworkOffering = "DefaultSharedNetscalerEIPandELBNetworkOffering";
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworks = "DefaultIsolatedNetworkOfferingForVpcNetworks";
|
||||
|
||||
|
||||
long getId();
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ public interface StorageService{
|
|||
* @throws ResourceUnavailableException
|
||||
* TODO
|
||||
*/
|
||||
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException, UnknownHostException, ResourceUnavailableException;
|
||||
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException,
|
||||
UnknownHostException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Creates the database object for a volume based on the given criteria
|
||||
|
|
@ -88,7 +89,8 @@ public interface StorageService{
|
|||
* @throws InsufficientCapacityException
|
||||
* TODO
|
||||
*/
|
||||
public StoragePool preparePrimaryStorageForMaintenance(Long primaryStorageId) throws ResourceUnavailableException, InsufficientCapacityException;
|
||||
public StoragePool preparePrimaryStorageForMaintenance(Long primaryStorageId) throws ResourceUnavailableException,
|
||||
InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Complete maintenance for primary storage
|
||||
|
|
@ -99,7 +101,8 @@ public interface StorageService{
|
|||
* @throws ResourceUnavailableException
|
||||
* TODO
|
||||
*/
|
||||
public StoragePool cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd) throws ResourceUnavailableException;
|
||||
public StoragePool cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd)
|
||||
throws ResourceUnavailableException;
|
||||
|
||||
public StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ public interface Nic {
|
|||
}
|
||||
|
||||
public enum State implements FiniteState<State, Event> {
|
||||
Allocated("Resource is allocated but not reserved"), Reserving("Resource is being reserved right now"), Reserved("Resource has been reserved."), Releasing("Resource is being released"), Deallocating(
|
||||
Allocated("Resource is allocated but not reserved"), Reserving("Resource is being reserved right now"),
|
||||
Reserved("Resource has been reserved."), Releasing("Resource is being released"), Deallocating(
|
||||
"Resource is being deallocated");
|
||||
|
||||
String _description;
|
||||
|
|
|
|||
|
|
@ -203,7 +203,8 @@ public class NicProfile {
|
|||
return strategy;
|
||||
}
|
||||
|
||||
public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate, boolean isSecurityGroupEnabled, String name) {
|
||||
public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate,
|
||||
boolean isSecurityGroupEnabled, String name) {
|
||||
this.id = nic.getId();
|
||||
this.networkId = network.getId();
|
||||
this.gateway = nic.getGateway();
|
||||
|
|
@ -230,13 +231,6 @@ public class NicProfile {
|
|||
}
|
||||
}
|
||||
|
||||
public NicProfile(long id, BroadcastDomainType type, Mode mode, long vmId) {
|
||||
this.id = id;
|
||||
this.broadcastType = type;
|
||||
this.mode = mode;
|
||||
this.vmId = vmId;
|
||||
}
|
||||
|
||||
public NicProfile(ReservationStrategy strategy, String ip4Address, String macAddress, String gateway, String netmask) {
|
||||
this.format = AddressFormat.Ip4;
|
||||
this.ip4Address = ip4Address;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
// 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.vm;
|
||||
|
||||
/**
|
||||
* @author Alena Prokharchyk
|
||||
*/
|
||||
public interface PluggableNics {
|
||||
boolean canPlugNics();
|
||||
}
|
||||
|
|
@ -50,7 +50,6 @@ import com.cloud.template.VirtualMachineTemplate;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
|
||||
public interface UserVmService {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -286,4 +286,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
|
|||
HypervisorType getHypervisorType();
|
||||
|
||||
public Map<String, String> getDetails();
|
||||
|
||||
boolean canPlugNics();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public interface VirtualMachineProfile<T extends VirtualMachine> {
|
|||
|
||||
public static final Param VmPassword = new Param("VmPassword");
|
||||
public static final Param ControlNic = new Param("ControlNic");
|
||||
public static final Param ReProgramNetwork = new Param("RestartNetwork");
|
||||
public static final Param ReProgramGuestNetworks = new Param("RestartNetwork");
|
||||
public static final Param PxeSeverType = new Param("PxeSeverType");
|
||||
public static final Param HaTag = new Param("HaTag");
|
||||
|
||||
|
|
|
|||
|
|
@ -337,3 +337,24 @@ deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
|
|||
createTags=com.cloud.api.commands.CreateTagsCmd;15
|
||||
deleteTags=com.cloud.api.commands.DeleteTagsCmd;15
|
||||
listTags=com.cloud.api.commands.ListTagsCmd;15
|
||||
|
||||
### VPC commands
|
||||
createVPC=com.cloud.api.commands.CreateVPCCmd;15
|
||||
listVPCs=com.cloud.api.commands.ListVPCsCmd;15
|
||||
deleteVPC=com.cloud.api.commands.DeleteVPCCmd;15
|
||||
updateVPC=com.cloud.api.commands.UpdateVPCCmd;15
|
||||
restartVPC=com.cloud.api.commands.RestartVPCCmd;15
|
||||
|
||||
#### VPC offering commands
|
||||
createVPCOffering=com.cloud.api.commands.CreateVPCOfferingCmd;1
|
||||
updateVPCOffering=com.cloud.api.commands.UpdateVPCOfferingCmd;1
|
||||
deleteVPCOffering=com.cloud.api.commands.DeleteVPCOfferingCmd;1
|
||||
listVPCOfferings=com.cloud.api.commands.ListVPCOfferingsCmd;15
|
||||
|
||||
#### Private gateway commands
|
||||
#createPrivateGateway=com.cloud.api.commands.CreatePrivateGatewayCmd;15
|
||||
#listPrivateGateways=com.cloud.api.commands.ListPrivateGatewaysCmd;15
|
||||
#deletePrivateGateway=com.cloud.api.commands.DeletePrivateGatewayCmd;15
|
||||
|
||||
#### Private network command
|
||||
createPrivateNetwork=com.cloud.api.commands.CreatePrivateNetworkCmd;1
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
<adapter name="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru"/>
|
||||
<adapter name="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru"/>
|
||||
<adapter name="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru"/>
|
||||
<adapter name="PrivateNetworkGuru" class="com.cloud.network.guru.PrivateNetworkGuru"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.cluster.ClusterServiceAdapter">
|
||||
<adapter name="ClusterService" class="com.cloud.cluster.ClusterServiceServletAdapter"/>
|
||||
|
|
@ -142,6 +143,7 @@
|
|||
<adapter name="BareMetal" class="com.cloud.network.element.BareMetalElement"/>
|
||||
<adapter name="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement"/>
|
||||
<adapter name="CiscoNexus1000vVSM" class="com.cloud.network.element.CiscoNexusVSMElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.cluster.agentlb.AgentLoadBalancerPlanner">
|
||||
<adapter name="ClusterBasedAgentLbPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner"/>
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ import com.cloud.utils.script.Script;
|
|||
public class VirtualRoutingResource implements Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualRoutingResource.class);
|
||||
private String _savepasswordPath; // This script saves a random password to the DomR file system
|
||||
private String _ipassocPath;
|
||||
private String _publicIpAddress;
|
||||
private String _firewallPath;
|
||||
private String _loadbPath;
|
||||
|
|
@ -90,11 +89,8 @@ public class VirtualRoutingResource implements Manager {
|
|||
private String _vmDataPath;
|
||||
private String _publicEthIf;
|
||||
private String _privateEthIf;
|
||||
private String _getRouterStatusPath;
|
||||
private String _bumpUpPriorityPath;
|
||||
private String _l2tpVpnPath;
|
||||
private String _getDomRVersionPath;
|
||||
|
||||
private String _routerProxyPath;
|
||||
|
||||
private int _timeout;
|
||||
private int _startTimeout;
|
||||
|
|
@ -147,36 +143,40 @@ public class VirtualRoutingResource implements Manager {
|
|||
|
||||
private Answer execute(VpnUsersCfgCommand cmd) {
|
||||
for (VpnUsersCfgCommand.UsernamePassword userpwd: cmd.getUserpwds()) {
|
||||
Script command = new Script(_l2tpVpnPath, _timeout, s_logger);
|
||||
command.add(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
||||
String args = "";
|
||||
if (!userpwd.isAdd()) {
|
||||
command.add("-U ", userpwd.getUsername());
|
||||
args +="-U ";
|
||||
args +=userpwd.getUsername();
|
||||
} else {
|
||||
command.add("-u ", userpwd.getUsernamePassword());
|
||||
args +="-u ";
|
||||
args += userpwd.getUsernamePassword();
|
||||
}
|
||||
String result = command.execute();
|
||||
String result = routerProxy("vpn_l2tp.sh", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), args);
|
||||
if (result != null) {
|
||||
return new Answer(cmd, false, "Configure VPN user failed for user " + userpwd.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
private Answer execute(RemoteAccessVpnCfgCommand cmd) {
|
||||
Script command = new Script(_l2tpVpnPath, _timeout, s_logger);
|
||||
command.add(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
||||
String args = "";
|
||||
if (cmd.isCreate()) {
|
||||
command.add("-r ", cmd.getIpRange());
|
||||
command.add("-p ", cmd.getPresharedKey());
|
||||
command.add("-s ", cmd.getVpnServerIp());
|
||||
command.add("-l ", cmd.getLocalIp());
|
||||
command.add("-c ");
|
||||
args += "-r ";
|
||||
args += cmd.getIpRange();
|
||||
args += " -p ";
|
||||
args += cmd.getPresharedKey();
|
||||
args += " -s ";
|
||||
args += cmd.getVpnServerIp();
|
||||
args += " -l ";
|
||||
args += cmd.getLocalIp();
|
||||
args += " -c ";
|
||||
} else {
|
||||
command.add("-d ");
|
||||
command.add("-s ", cmd.getVpnServerIp());
|
||||
args +="-d ";
|
||||
args += " -s ";
|
||||
args += cmd.getVpnServerIp();
|
||||
}
|
||||
String result = command.execute();
|
||||
String result = routerProxy("vpn_l2tp.sh", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), args);
|
||||
if (result != null) {
|
||||
return new Answer(cmd, false, "Configure VPN failed");
|
||||
}
|
||||
|
|
@ -474,9 +474,18 @@ public class VirtualRoutingResource implements Manager {
|
|||
}
|
||||
|
||||
public String getRouterStatus(String routerIP) {
|
||||
final Script command = new Script(_getRouterStatusPath, _timeout, s_logger);
|
||||
return routerProxy("checkrouter.sh", routerIP, null);
|
||||
}
|
||||
|
||||
|
||||
public String routerProxy(String script, String routerIP, String args) {
|
||||
final Script command = new Script(_routerProxyPath, _timeout, s_logger);
|
||||
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
||||
command.add(script);
|
||||
command.add(routerIP);
|
||||
if ( args != null ) {
|
||||
command.add(args);
|
||||
}
|
||||
String result = command.execute(parser);
|
||||
if (result == null) {
|
||||
return parser.getLine();
|
||||
|
|
@ -507,14 +516,7 @@ public class VirtualRoutingResource implements Manager {
|
|||
}
|
||||
|
||||
protected String getDomRVersion(String routerIP) {
|
||||
final Script command = new Script(_getDomRVersionPath, _timeout, s_logger);
|
||||
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
||||
command.add(routerIP);
|
||||
String result = command.execute(parser);
|
||||
if (result == null) {
|
||||
return parser.getLine();
|
||||
}
|
||||
return null;
|
||||
return routerProxy("netusage.sh", routerIP, null);
|
||||
}
|
||||
|
||||
protected Answer execute(GetDomRVersionCmd cmd) {
|
||||
|
|
@ -592,48 +594,49 @@ public class VirtualRoutingResource implements Manager {
|
|||
|
||||
|
||||
public String assignPublicIpAddress(final String vmName, final long id, final String vnet, final String privateIpAddress, final String macAddress, final String publicIpAddress) {
|
||||
|
||||
final Script command = new Script(_ipassocPath, _timeout, s_logger);
|
||||
command.add("-A");
|
||||
command.add("-f"); //first ip is source nat ip
|
||||
command.add("-r", vmName);
|
||||
command.add("-i", privateIpAddress);
|
||||
command.add("-a", macAddress);
|
||||
command.add("-l", publicIpAddress);
|
||||
|
||||
return command.execute();
|
||||
String args ="-A";
|
||||
args += " -f"; //first ip is source nat ip
|
||||
args += " -r ";
|
||||
args += vmName;
|
||||
args += " -i ";
|
||||
args += privateIpAddress;
|
||||
args += " -a ";
|
||||
args += macAddress;
|
||||
args += " -l ";
|
||||
args += publicIpAddress;
|
||||
return routerProxy("ipassoc.sh", privateIpAddress, args);
|
||||
}
|
||||
|
||||
|
||||
public String assignPublicIpAddress(final String vmName,
|
||||
final String privateIpAddress, final String publicIpAddress,
|
||||
final boolean add, final boolean firstIP, final boolean sourceNat,
|
||||
final String vlanId, final String vlanGateway,
|
||||
final String vlanNetmask, final String vifMacAddress, String guestIp, int nicNum){
|
||||
|
||||
final Script command = new Script(_ipassocPath, _timeout, s_logger);
|
||||
command.add( privateIpAddress);
|
||||
String args = "";
|
||||
if (add) {
|
||||
command.add("-A");
|
||||
args += "-A";
|
||||
} else {
|
||||
command.add("-D");
|
||||
}
|
||||
|
||||
if (sourceNat) {
|
||||
command.add("-s");
|
||||
}
|
||||
if (firstIP) {
|
||||
command.add( "-f");
|
||||
|
||||
args += "-D";
|
||||
}
|
||||
String cidrSize = Long.toString(NetUtils.getCidrSize(vlanNetmask));
|
||||
command.add( "-l", publicIpAddress + "/" + cidrSize);
|
||||
String publicNic = "eth" + nicNum;
|
||||
command.add("-c", publicNic);
|
||||
|
||||
command.add("-g", vlanGateway);
|
||||
|
||||
if (sourceNat) {
|
||||
args +=" -s";
|
||||
}
|
||||
if (firstIP) {
|
||||
args += " -f";
|
||||
}
|
||||
args += " -l ";
|
||||
args += publicIpAddress + "/" + cidrSize;
|
||||
|
||||
return command.execute();
|
||||
String publicNic = "eth" + nicNum;
|
||||
args += " -c ";
|
||||
args += publicNic;
|
||||
|
||||
args +=" -g ";
|
||||
args += vlanGateway;
|
||||
return routerProxy("ipassoc.sh", privateIpAddress, args);
|
||||
}
|
||||
|
||||
private void deletExitingLinkLocalRoutTable(String linkLocalBr) {
|
||||
|
|
@ -801,12 +804,6 @@ public class VirtualRoutingResource implements Manager {
|
|||
value = (String)params.get("ssh.port");
|
||||
_port = NumbersUtil.parseInt(value, 3922);
|
||||
|
||||
_ipassocPath = findScript("ipassoc.sh");
|
||||
if (_ipassocPath == null) {
|
||||
throw new ConfigurationException("Unable to find the ipassoc.sh");
|
||||
}
|
||||
s_logger.info("ipassoc.sh found in " + _ipassocPath);
|
||||
|
||||
_publicIpAddress = (String)params.get("public.ip.address");
|
||||
if (_publicIpAddress != null) {
|
||||
s_logger.warn("Incoming public ip address is overriden. Will always be using the same ip address: " + _publicIpAddress);
|
||||
|
|
@ -837,11 +834,6 @@ public class VirtualRoutingResource implements Manager {
|
|||
throw new ConfigurationException("Unable to find user_data.sh");
|
||||
}
|
||||
|
||||
_getRouterStatusPath = findScript("getRouterStatus.sh");
|
||||
if(_getRouterStatusPath == null) {
|
||||
throw new ConfigurationException("Unable to find getRouterStatus.sh");
|
||||
}
|
||||
|
||||
_publicEthIf = (String)params.get("public.network.device");
|
||||
if (_publicEthIf == null) {
|
||||
_publicEthIf = "xenbr1";
|
||||
|
|
@ -859,14 +851,9 @@ public class VirtualRoutingResource implements Manager {
|
|||
throw new ConfigurationException("Unable to find bumpUpPriority.sh");
|
||||
}
|
||||
|
||||
_l2tpVpnPath = findScript("l2tp_vpn.sh");
|
||||
if (_l2tpVpnPath == null) {
|
||||
throw new ConfigurationException("Unable to find l2tp_vpn.sh");
|
||||
}
|
||||
|
||||
_getDomRVersionPath = findScript("getDomRVersion.sh");
|
||||
if(_getDomRVersionPath == null) {
|
||||
throw new ConfigurationException("Unable to find getDomRVersion.sh");
|
||||
_routerProxyPath = findScript("routerProxy.sh");
|
||||
if (_routerProxyPath == null) {
|
||||
throw new ConfigurationException("Unable to find routerProxy.sh");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1021,7 +1021,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
protected Answer execute(CheckRouterCommand cmd) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Executing resource CheckRouterCommand: " + _gson.toJson(cmd));
|
||||
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/checkrouter.sh ");
|
||||
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/checkrouter.sh ");
|
||||
}
|
||||
|
||||
Pair<Boolean, String> result;
|
||||
|
|
@ -3871,12 +3871,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
try {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Executing /root/netusage.sh " + args + " on DomR " + privateIpAddress);
|
||||
s_logger.trace("Executing /opt/cloud/bin/netusage.sh " + args + " on DomR " + privateIpAddress);
|
||||
}
|
||||
|
||||
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(privateIpAddress, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null, "/root/netusage.sh " + args);
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(privateIpAddress, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/netusage.sh " + args);
|
||||
|
||||
if (!result.first()) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,8 @@ import com.cloud.agent.api.PingCommand;
|
|||
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
|
||||
import com.cloud.agent.api.PingRoutingWithOvsCommand;
|
||||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.agent.api.PlugNicAnswer;
|
||||
import com.cloud.agent.api.PlugNicCommand;
|
||||
import com.cloud.agent.api.PoolEjectCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
|
|
@ -113,8 +115,11 @@ import com.cloud.agent.api.RebootCommand;
|
|||
import com.cloud.agent.api.RebootRouterCommand;
|
||||
import com.cloud.agent.api.SecurityGroupRuleAnswer;
|
||||
import com.cloud.agent.api.SecurityGroupRulesCmd;
|
||||
import com.cloud.agent.api.SetSourceNatAnswer;
|
||||
import com.cloud.agent.api.SetupAnswer;
|
||||
import com.cloud.agent.api.SetupCommand;
|
||||
import com.cloud.agent.api.SetupGuestNetworkAnswer;
|
||||
import com.cloud.agent.api.SetupGuestNetworkCommand;
|
||||
import com.cloud.agent.api.StartAnswer;
|
||||
import com.cloud.agent.api.StartCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
|
|
@ -123,6 +128,8 @@ import com.cloud.agent.api.StartupStorageCommand;
|
|||
import com.cloud.agent.api.StopAnswer;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
import com.cloud.agent.api.UnPlugNicAnswer;
|
||||
import com.cloud.agent.api.UnPlugNicCommand;
|
||||
import com.cloud.agent.api.UpdateHostPasswordCommand;
|
||||
import com.cloud.agent.api.UpgradeSnapshotCommand;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
|
|
@ -134,6 +141,7 @@ import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
|
|||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocAnswer;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocVpcCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
|
||||
|
|
@ -142,6 +150,7 @@ import com.cloud.agent.api.routing.SetFirewallRulesAnswer;
|
|||
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetSourceNatCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
|
|
@ -512,12 +521,21 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return execute((GetDomRVersionCmd)cmd);
|
||||
} else if (clazz == CheckNetworkCommand.class) {
|
||||
return execute((CheckNetworkCommand) cmd);
|
||||
} else if (clazz == SetupGuestNetworkCommand.class) {
|
||||
return execute((SetupGuestNetworkCommand) cmd);
|
||||
} else if (clazz == PlugNicCommand.class) {
|
||||
return execute((PlugNicCommand) cmd);
|
||||
} else if (clazz == UnPlugNicCommand.class) {
|
||||
return execute((UnPlugNicCommand) cmd);
|
||||
} else if (clazz == IpAssocVpcCommand.class) {
|
||||
return execute((IpAssocVpcCommand) cmd);
|
||||
} else if (clazz == SetSourceNatCommand.class) {
|
||||
return execute((SetSourceNatCommand) cmd);
|
||||
} else {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected XsLocalNetwork getNativeNetworkForTraffic(Connection conn, TrafficType type, String name) throws XenAPIException, XmlRpcException {
|
||||
if (name != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -1334,8 +1352,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
private CheckRouterAnswer execute(CheckRouterCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
String args = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String result = callHostPlugin(conn, "vmops", "checkRouter", "args", args);
|
||||
String args = "checkrouter.sh " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new CheckRouterAnswer(cmd, "CheckRouterCommand failed");
|
||||
}
|
||||
|
|
@ -1344,8 +1362,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
private GetDomRVersionAnswer execute(GetDomRVersionCmd cmd) {
|
||||
Connection conn = getConnection();
|
||||
String args = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String result = callHostPlugin(conn, "vmops", "getDomRVersion", "args", args);
|
||||
String args = "get_template_version.sh " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new GetDomRVersionAnswer(cmd, "getDomRVersionCmd failed");
|
||||
}
|
||||
|
|
@ -1573,7 +1591,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
protected synchronized Answer execute(final RemoteAccessVpnCfgCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
String args = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String args = "vpn_l2tp.sh " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
if (cmd.isCreate()) {
|
||||
args += " -r " + cmd.getIpRange();
|
||||
args += " -p " + cmd.getPresharedKey();
|
||||
|
|
@ -1585,7 +1603,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
args += " -d ";
|
||||
args += " -s " + cmd.getVpnServerIp();
|
||||
}
|
||||
String result = callHostPlugin(conn, "vmops", "lt2p_vpn", "args", args);
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new Answer(cmd, false, "Configure VPN failed");
|
||||
}
|
||||
|
|
@ -1717,7 +1735,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with.");
|
||||
}
|
||||
|
||||
String args = privateIpAddress;
|
||||
String args = "ipassoc.sh " + privateIpAddress;
|
||||
|
||||
if (add) {
|
||||
args += " -A ";
|
||||
|
|
@ -1743,7 +1761,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
args += vlanGateway;
|
||||
|
||||
|
||||
String result = callHostPlugin(conn, "vmops", "ipassoc", "args", args);
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
throw new InternalErrorException("Xen plugin \"ipassoc\" failed.");
|
||||
}
|
||||
|
|
@ -6954,7 +6972,138 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
VirtualMachineTO vmto = cmd.getVirtualMachine();
|
||||
String vmName = vmto.getName();
|
||||
try {
|
||||
Set<VM> vms = VM.getByNameLabel(conn, vmName);
|
||||
if ( vms == null || vms.isEmpty() ) {
|
||||
return new UnPlugNicAnswer(cmd, false, "Can not find VM " + vmName);
|
||||
}
|
||||
VM vm = vms.iterator().next();
|
||||
NicTO nic = cmd.getNic();
|
||||
String mac = nic.getMac();
|
||||
for ( VIF vif : vm.getVIFs(conn)) {
|
||||
String lmac = vif.getMAC(conn);
|
||||
if ( lmac.equals(mac) ) {
|
||||
vif.unplug(conn);
|
||||
vif.destroy(conn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new UnPlugNicAnswer(cmd, true, "success");
|
||||
} catch (Exception e) {
|
||||
String msg = " UnPlug Nic failed due to " + e.toString();
|
||||
s_logger.warn(msg, e);
|
||||
return new UnPlugNicAnswer(cmd, false, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
private PlugNicAnswer execute(PlugNicCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
VirtualMachineTO vmto = cmd.getVirtualMachine();
|
||||
String vmName = vmto.getName();
|
||||
try {
|
||||
Set<VM> vms = VM.getByNameLabel(conn, vmName);
|
||||
if ( vms == null || vms.isEmpty() ) {
|
||||
return new PlugNicAnswer(cmd, false, "Can not find VM " + vmName);
|
||||
}
|
||||
VM vm = vms.iterator().next();
|
||||
NicTO nic = cmd.getNic();
|
||||
VIF vif = createVif(conn, vmName, vm, nic);
|
||||
vif.plug(conn);
|
||||
return new PlugNicAnswer(cmd, true, "success");
|
||||
} catch (Exception e) {
|
||||
String msg = " Plug Nic failed due to " + e.toString();
|
||||
s_logger.warn(msg, e);
|
||||
return new PlugNicAnswer(cmd, false, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
private SetupGuestNetworkAnswer execute(SetupGuestNetworkCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
NicTO nic = cmd.getNic();
|
||||
String domrIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String domrGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
|
||||
String domrName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
|
||||
String gw = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
|
||||
String cidr = Long.toString(NetUtils.getCidrSize(nic.getNetmask()));;
|
||||
String domainName = cmd.getNetworkDomain();
|
||||
String dns = cmd.getDefaultDns1();
|
||||
if (dns == null || dns.isEmpty()) {
|
||||
dns = cmd.getDefaultDns2();
|
||||
} else {
|
||||
String dns2= cmd.getDefaultDns2();
|
||||
if ( dns2 != null && !dns2.isEmpty()) {
|
||||
dns += "," + dns2;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Set<VM> vms = VM.getByNameLabel(conn, domrName);
|
||||
if ( vms == null || vms.isEmpty() ) {
|
||||
return new SetupGuestNetworkAnswer(cmd, false, "Can not find VM " + domrName);
|
||||
}
|
||||
VM vm = vms.iterator().next();
|
||||
String mac = nic.getMac();
|
||||
VIF domrVif = null;
|
||||
for ( VIF vif : vm.getVIFs(conn)) {
|
||||
String lmac = vif.getMAC(conn);
|
||||
if ( lmac.equals(mac) ) {
|
||||
domrVif = vif;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( domrVif == null ) {
|
||||
return new SetupGuestNetworkAnswer(cmd, false, "Can not find vif with mac " + mac + " for VM " + domrName);
|
||||
}
|
||||
|
||||
String args = "guestnw.sh " + domrIP + " -C";
|
||||
String dev = "eth" + domrVif.getDevice(conn);
|
||||
args += " -d " + dev;
|
||||
args += " -i " + domrGIP;
|
||||
args += " -g " + gw;
|
||||
args += " -m " + cidr;
|
||||
if ( dns != null && !dns.isEmpty() ) {
|
||||
args += " -s " + dns;
|
||||
}
|
||||
if ( domainName != null && !domainName.isEmpty() ) {
|
||||
args += " -e " + domainName;
|
||||
}
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new SetupGuestNetworkAnswer(cmd, false, "creating guest network failed due to " + ((result == null)? "null":result));
|
||||
}
|
||||
return new SetupGuestNetworkAnswer(cmd, true, "success");
|
||||
} catch (Exception e) {
|
||||
String msg = " UnPlug Nic failed due to " + e.toString();
|
||||
s_logger.warn(msg, e);
|
||||
return new SetupGuestNetworkAnswer(cmd, false, msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected IpAssocAnswer execute(IpAssocVpcCommand cmd) {
|
||||
//FIXME - add implementation here
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected SetSourceNatAnswer execute(SetSourceNatCommand cmd) {
|
||||
//FIXME - add implementation here
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,24 +142,22 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
|
||||
@Override
|
||||
protected String networkUsage(Connection conn, final String privateIpAddress, final String option, final String vif) {
|
||||
String args = null;
|
||||
String args = "netusage.sh " + privateIpAddress + " ";
|
||||
if (option.equals("get")) {
|
||||
args = "-g";
|
||||
args += "-g";
|
||||
} else if (option.equals("create")) {
|
||||
args = "-c";
|
||||
args += "-c";
|
||||
} else if (option.equals("reset")) {
|
||||
args = "-r";
|
||||
args += "-r";
|
||||
} else if (option.equals("addVif")) {
|
||||
args = "-a";
|
||||
args += "-a ";
|
||||
args += vif;
|
||||
} else if (option.equals("deleteVif")) {
|
||||
args = "-d";
|
||||
args += "-d ";
|
||||
args += vif;
|
||||
}
|
||||
|
||||
args += " -i ";
|
||||
args += privateIpAddress;
|
||||
return callHostPlugin(conn, "vmops", "networkUsage", "args", args);
|
||||
return callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
}
|
||||
|
||||
protected NetworkUsageAnswer execute(NetworkUsageCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -41,12 +41,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
|
||||
@Column(name="public_netmask")
|
||||
private String publicNetmask;
|
||||
|
||||
@Column(name="guest_ip_address")
|
||||
private String guestIpAddress;
|
||||
|
||||
@Column(name="network_id")
|
||||
long networkId;
|
||||
|
||||
@Column(name="is_redundant_router")
|
||||
boolean isRedundantRouter;
|
||||
|
|
@ -74,6 +68,9 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
@Column(name="scripts_version")
|
||||
private String scriptsVersion;
|
||||
|
||||
@Column(name="vpc_id")
|
||||
private Long vpcId;
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
long elementId,
|
||||
|
|
@ -83,20 +80,20 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
long networkId,
|
||||
boolean isRedundantRouter,
|
||||
int priority,
|
||||
boolean isPriorityBumpUp,
|
||||
RedundantState redundantState,
|
||||
boolean haEnabled, boolean stopPending) {
|
||||
boolean haEnabled,
|
||||
boolean stopPending, Long vpcId) {
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this.elementId = elementId;
|
||||
this.networkId = networkId;
|
||||
this.isRedundantRouter = isRedundantRouter;
|
||||
this.priority = priority;
|
||||
this.redundantState = redundantState;
|
||||
this.isPriorityBumpUp = isPriorityBumpUp;
|
||||
this.stopPending = stopPending;
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
|
|
@ -108,21 +105,21 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
long networkId,
|
||||
boolean isRedundantRouter,
|
||||
int priority,
|
||||
boolean isPriorityBumpUp,
|
||||
RedundantState redundantState,
|
||||
boolean haEnabled,
|
||||
boolean stopPending, VirtualMachine.Type vmType) {
|
||||
boolean stopPending,
|
||||
VirtualMachine.Type vmType, Long vpcId) {
|
||||
super(id, serviceOfferingId, name, name, vmType, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this.elementId = elementId;
|
||||
this.networkId = networkId;
|
||||
this.isRedundantRouter = isRedundantRouter;
|
||||
this.priority = priority;
|
||||
this.redundantState = redundantState;
|
||||
this.isPriorityBumpUp = isPriorityBumpUp;
|
||||
this.stopPending = stopPending;
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
|
||||
public long getElementId() {
|
||||
|
|
@ -141,14 +138,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
this.publicNetmask = publicNetmask;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public void setGuestIpAddress(String routerIpAddress) {
|
||||
this.guestIpAddress = routerIpAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterIdToDeployIn() {
|
||||
return dataCenterIdToDeployIn;
|
||||
|
|
@ -162,11 +151,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
return publicMacAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuestIpAddress() {
|
||||
return guestIpAddress;
|
||||
}
|
||||
|
||||
protected DomainRouterVO() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -249,4 +233,14 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
public void setScriptsVersion(String scriptsVersion) {
|
||||
this.scriptsVersion = scriptsVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlugNics() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,5 +458,10 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
|||
public void setServiceOfferingId(long serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlugNics() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
SUBSYSTEM=="net" KERNEL=="eth*" RUN+="/opt/cloud/bin/cloud-nic.sh $env{ACTION} %k"
|
||||
|
||||
|
|
@ -550,6 +550,79 @@ setup_router() {
|
|||
cp /etc/iptables/iptables-router /etc/iptables/rules
|
||||
}
|
||||
|
||||
|
||||
|
||||
setup_vpcrouter() {
|
||||
log_it "Setting up VPC virtual router system vm"
|
||||
|
||||
if [ "$hyp" == "vmware" ]; then
|
||||
setup_vmware_extra_nics
|
||||
fi
|
||||
|
||||
cat > /etc/network/interfaces << EOF
|
||||
auto lo $1
|
||||
iface lo inet loopback
|
||||
EOF
|
||||
setup_interface "0" $ETH0_IP $ETH0_MASK $GW
|
||||
|
||||
echo $NAME > /etc/hostname
|
||||
echo 'AVAHI_DAEMON_DETECT_LOCAL=0' > /etc/default/avahi-daemon
|
||||
hostname $NAME
|
||||
|
||||
#Nameserver
|
||||
sed -i -e "/^nameserver.*$/d" /etc/resolv.conf # remove previous entries
|
||||
sed -i -e "/^nameserver.*$/d" /etc/dnsmasq-resolv.conf # remove previous entries
|
||||
if [ -n "$internalNS1" ]
|
||||
then
|
||||
echo "nameserver $internalNS1" > /etc/dnsmasq-resolv.conf
|
||||
echo "nameserver $internalNS1" > /etc/resolv.conf
|
||||
fi
|
||||
|
||||
if [ -n "$internalNS2" ]
|
||||
then
|
||||
echo "nameserver $internalNS2" >> /etc/dnsmasq-resolv.conf
|
||||
echo "nameserver $internalNS2" >> /etc/resolv.conf
|
||||
fi
|
||||
if [ -n "$NS1" ]
|
||||
then
|
||||
echo "nameserver $NS1" >> /etc/dnsmasq-resolv.conf
|
||||
echo "nameserver $NS1" >> /etc/resolv.conf
|
||||
fi
|
||||
|
||||
if [ -n "$NS2" ]
|
||||
then
|
||||
echo "nameserver $NS2" >> /etc/dnsmasq-resolv.conf
|
||||
echo "nameserver $NS2" >> /etc/resolv.conf
|
||||
fi
|
||||
if [ -n "$MGMTNET" -a -n "$LOCAL_GW" ]
|
||||
then
|
||||
ip route add $MGMTNET via $LOCAL_GW dev eth1
|
||||
fi
|
||||
|
||||
ip route delete default
|
||||
|
||||
|
||||
sed -i /gateway/d /etc/hosts
|
||||
|
||||
echo "$ETH0_IP $NAME" >> /etc/hosts
|
||||
setup_sshd $ETH0_IP
|
||||
|
||||
enable_svc dnsmasq 1
|
||||
enable_svc haproxy 1
|
||||
enable_svc cloud-passwd-srvr 1
|
||||
enable_svc cloud 0
|
||||
disable_rpfilter_domR
|
||||
enable_fwding 1
|
||||
chkconfig nfs-common off
|
||||
cp /etc/iptables/iptables-vpcrouter /etc/iptables/rules
|
||||
cp /etc/vpcdnsmasq.conf /etc/dnsmasq.conf
|
||||
cp /etc/cloud-nic.rules /etc/udev/rules.d/cloud-nic.rules
|
||||
echo "" > /etc/dnsmasq.d/dhcphosts.txt
|
||||
echo "dhcp-hostsfile=/etc/dhcphosts.txt" > /etc/dnsmasq.d/cloud.conf
|
||||
}
|
||||
|
||||
|
||||
|
||||
setup_dhcpsrvr() {
|
||||
log_it "Setting up dhcp server system vm"
|
||||
setup_common eth0 eth1
|
||||
|
|
@ -721,6 +794,10 @@ start() {
|
|||
[ "$NAME" == "" ] && NAME=router
|
||||
setup_router
|
||||
;;
|
||||
vpcrouter)
|
||||
[ "$NAME" == "" ] && NAME=vpcrouter
|
||||
setup_vpcrouter
|
||||
;;
|
||||
dhcpsrvr)
|
||||
[ "$NAME" == "" ] && NAME=dhcpsrvr
|
||||
setup_dhcpsrvr
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
*nat
|
||||
:PREROUTING ACCEPT [0:0]
|
||||
:POSTROUTING ACCEPT [0:0]
|
||||
:OUTPUT ACCEPT [0:0]
|
||||
COMMIT
|
||||
*filter
|
||||
:INPUT DROP [0:0]
|
||||
:FORWARD DROP [0:0]
|
||||
:OUTPUT ACCEPT [0:0]
|
||||
-A INPUT -d 224.0.0.18/32 -j ACCEPT
|
||||
-A INPUT -d 225.0.0.50/32 -j ACCEPT
|
||||
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A INPUT -p icmp -j ACCEPT
|
||||
-A INPUT -i lo -j ACCEPT
|
||||
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
|
||||
COMMIT
|
||||
*mangle
|
||||
:PREROUTING ACCEPT [0:0]
|
||||
:INPUT ACCEPT [0:0]
|
||||
:FORWARD ACCEPT [0:0]
|
||||
:OUTPUT ACCEPT [0:0]
|
||||
:POSTROUTING ACCEPT [0:0]
|
||||
-A PREROUTING -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
|
||||
-A OUTPUT -p udp --dport bootpc -j CHECKSUM --checksum-fill
|
||||
COMMIT
|
||||
|
|
@ -0,0 +1,465 @@
|
|||
# Configuration file for dnsmasq.
|
||||
#
|
||||
# Format is one option per line, legal options are the same
|
||||
# as the long options legal on the command line. See
|
||||
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
|
||||
|
||||
# The following two options make you a better netizen, since they
|
||||
# tell dnsmasq to filter out queries which the public DNS cannot
|
||||
# answer, and which load the servers (especially the root servers)
|
||||
# uneccessarily. If you have a dial-on-demand link they also stop
|
||||
# these requests from bringing up the link uneccessarily.
|
||||
|
||||
# Never forward plain names (without a dot or domain part)
|
||||
domain-needed
|
||||
# Never forward addresses in the non-routed address spaces.
|
||||
bogus-priv
|
||||
|
||||
|
||||
# Uncomment this to filter useless windows-originated DNS requests
|
||||
# which can trigger dial-on-demand links needlessly.
|
||||
# Note that (amongst other things) this blocks all SRV requests,
|
||||
# so don't use it if you use eg Kerberos.
|
||||
# This option only affects forwarding, SRV records originating for
|
||||
# dnsmasq (via srv-host= lines) are not suppressed by it.
|
||||
#filterwin2k
|
||||
|
||||
# Change this line if you want dns to get its upstream servers from
|
||||
# somewhere other that /etc/resolv.conf
|
||||
resolv-file=/etc/dnsmasq-resolv.conf
|
||||
|
||||
# By default, dnsmasq will send queries to any of the upstream
|
||||
# servers it knows about and tries to favour servers to are known
|
||||
# to be up. Uncommenting this forces dnsmasq to try each query
|
||||
# with each server strictly in the order they appear in
|
||||
# /etc/resolv.conf
|
||||
#strict-order
|
||||
|
||||
# If you don't want dnsmasq to read /etc/resolv.conf or any other
|
||||
# file, getting its servers from this file instead (see below), then
|
||||
# uncomment this.
|
||||
#no-resolv
|
||||
|
||||
# If you don't want dnsmasq to poll /etc/resolv.conf or other resolv
|
||||
# files for changes and re-read them then uncomment this.
|
||||
#no-poll
|
||||
|
||||
# Add other name servers here, with domain specs if they are for
|
||||
# non-public domains.
|
||||
#server=/localnet/192.168.0.1
|
||||
|
||||
# Example of routing PTR queries to nameservers: this will send all
|
||||
# address->name queries for 192.168.3/24 to nameserver 10.1.2.3
|
||||
#server=/3.168.192.in-addr.arpa/10.1.2.3
|
||||
|
||||
# Add local-only domains here, queries in these domains are answered
|
||||
# from /etc/hosts or DHCP only.
|
||||
local=/2.vmops-test.vmops.com/
|
||||
|
||||
# Add domains which you want to force to an IP address here.
|
||||
# The example below send any host in doubleclick.net to a local
|
||||
# webserver.
|
||||
#address=/doubleclick.net/127.0.0.1
|
||||
|
||||
# If you want dnsmasq to change uid and gid to something other
|
||||
# than the default, edit the following lines.
|
||||
#user=
|
||||
#group=
|
||||
|
||||
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
||||
# specified interfaces (and the loopback) give the name of the
|
||||
# interface (eg eth0) here.
|
||||
# Repeat the line for more than one interface.
|
||||
#interface=eth0
|
||||
|
||||
# Or you can specify which interface _not_ to listen on
|
||||
except-interface=lo
|
||||
|
||||
# Or which to listen on by address (remember to include 127.0.0.1 if
|
||||
# you use this.)
|
||||
#listen-address=
|
||||
# If you want dnsmasq to provide only DNS service on an interface,
|
||||
# configure it as shown above, and then use the following line to
|
||||
# disable DHCP on it.
|
||||
#no-dhcp-interface=eth1
|
||||
|
||||
# On systems which support it, dnsmasq binds the wildcard address,
|
||||
# even when it is listening on only some interfaces. It then discards
|
||||
# requests that it shouldn't reply to. This has the advantage of
|
||||
# working even when interfaces come and go and change address. If you
|
||||
# want dnsmasq to really bind only the interfaces it is listening on,
|
||||
# uncomment this option. About the only time you may need this is when
|
||||
# running another nameserver on the same machine.
|
||||
bind-interfaces
|
||||
|
||||
# If you don't want dnsmasq to read /etc/hosts, uncomment the
|
||||
# following line.
|
||||
#no-hosts
|
||||
# or if you want it to read another file, as well as /etc/hosts, use
|
||||
# this.
|
||||
#addn-hosts=/etc/banner_add_hosts
|
||||
|
||||
# Set this (and domain: see below) if you want to have a domain
|
||||
# automatically added to simple names in a hosts-file.
|
||||
expand-hosts
|
||||
|
||||
# Set the domain for dnsmasq. this is optional, but if it is set, it
|
||||
# does the following things.
|
||||
# 1) Allows DHCP hosts to have fully qualified domain names, as long
|
||||
# as the domain part matches this setting.
|
||||
# 2) Sets the "domain" DHCP option thereby potentially setting the
|
||||
# domain of all systems configured by DHCP
|
||||
# 3) Provides the domain part for "expand-hosts"
|
||||
#domain=2.vmops-test.vmops.com
|
||||
|
||||
# Uncomment this to enable the integrated DHCP server, you need
|
||||
# to supply the range of addresses available for lease and optionally
|
||||
# a lease time. If you have more than one network, you will need to
|
||||
# repeat this for each network on which you want to supply DHCP
|
||||
# service.
|
||||
#dhcp-range=10.1.1.1,static
|
||||
#dhcp-range=10.0.0.1,10.255.255.255
|
||||
#dhcp-hostsfile=/etc/dhcphosts.txt
|
||||
|
||||
# This is an example of a DHCP range where the netmask is given. This
|
||||
# is needed for networks we reach the dnsmasq DHCP server via a relay
|
||||
# agent. If you don't know what a DHCP relay agent is, you probably
|
||||
# don't need to worry about this.
|
||||
#dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h
|
||||
|
||||
# This is an example of a DHCP range with a network-id, so that
|
||||
# some DHCP options may be set only for this network.
|
||||
#dhcp-range=red,192.168.0.50,192.168.0.150
|
||||
|
||||
# Supply parameters for specified hosts using DHCP. There are lots
|
||||
# of valid alternatives, so we will give examples of each. Note that
|
||||
# IP addresses DO NOT have to be in the range given above, they just
|
||||
# need to be on the same network. The order of the parameters in these
|
||||
# do not matter, it's permissble to give name,adddress and MAC in any order
|
||||
|
||||
# Always allocate the host with ethernet address 11:22:33:44:55:66
|
||||
# The IP address 192.168.0.60
|
||||
#dhcp-host=11:22:33:44:55:66,192.168.0.60
|
||||
|
||||
# Always set the name of the host with hardware address
|
||||
# 11:22:33:44:55:66 to be "fred"
|
||||
#dhcp-host=11:22:33:44:55:66,fred
|
||||
|
||||
# Always give the host with ethernet address 11:22:33:44:55:66
|
||||
# the name fred and IP address 192.168.0.60 and lease time 45 minutes
|
||||
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
|
||||
|
||||
# Give the machine which says it's name is "bert" IP address
|
||||
# 192.168.0.70 and an infinite lease
|
||||
#dhcp-host=bert,192.168.0.70,infinite
|
||||
|
||||
# Always give the host with client identifier 01:02:02:04
|
||||
# the IP address 192.168.0.60
|
||||
#dhcp-host=id:01:02:02:04,192.168.0.60
|
||||
|
||||
# Always give the host with client identifier "marjorie"
|
||||
# the IP address 192.168.0.60
|
||||
#dhcp-host=id:marjorie,192.168.0.60
|
||||
|
||||
# Enable the address given for "judge" in /etc/hosts
|
||||
# to be given to a machine presenting the name "judge" when
|
||||
# it asks for a DHCP lease.
|
||||
#dhcp-host=judge
|
||||
|
||||
# Never offer DHCP service to a machine whose ethernet
|
||||
# address is 11:22:33:44:55:66
|
||||
#dhcp-host=11:22:33:44:55:66,ignore
|
||||
|
||||
# Ignore any client-id presented by the machine with ethernet
|
||||
# address 11:22:33:44:55:66. This is useful to prevent a machine
|
||||
# being treated differently when running under different OS's or
|
||||
# between PXE boot and OS boot.
|
||||
#dhcp-host=11:22:33:44:55:66,id:*
|
||||
|
||||
# Send extra options which are tagged as "red" to
|
||||
# the machine with ethernet address 11:22:33:44:55:66
|
||||
#dhcp-host=11:22:33:44:55:66,net:red
|
||||
|
||||
# Send extra options which are tagged as "red" to
|
||||
# any machine with ethernet address starting 11:22:33:
|
||||
#dhcp-host=11:22:33:*:*:*,net:red
|
||||
|
||||
# Ignore any clients which are specified in dhcp-host lines
|
||||
# or /etc/ethers. Equivalent to ISC "deny unkown-clients".
|
||||
# This relies on the special "known" tag which is set when
|
||||
# a host is matched.
|
||||
#dhcp-ignore=#known
|
||||
|
||||
# Send extra options which are tagged as "red" to any machine whose
|
||||
# DHCP vendorclass string includes the substring "Linux"
|
||||
#dhcp-vendorclass=red,Linux
|
||||
|
||||
# Send extra options which are tagged as "red" to any machine one
|
||||
# of whose DHCP userclass strings includes the substring "accounts"
|
||||
#dhcp-userclass=red,accounts
|
||||
|
||||
# Send extra options which are tagged as "red" to any machine whose
|
||||
# MAC address matches the pattern.
|
||||
#dhcp-mac=red,00:60:8C:*:*:*
|
||||
|
||||
# If this line is uncommented, dnsmasq will read /etc/ethers and act
|
||||
# on the ethernet-address/IP pairs found there just as if they had
|
||||
# been given as --dhcp-host options. Useful if you keep
|
||||
# MAC-address/host mappings there for other purposes.
|
||||
#read-ethers
|
||||
|
||||
# Send options to hosts which ask for a DHCP lease.
|
||||
# See RFC 2132 for details of available options.
|
||||
# Common options can be given to dnsmasq by name:
|
||||
# run "dnsmasq --help dhcp" to get a list.
|
||||
# Note that all the common settings, such as netmask and
|
||||
# broadcast address, DNS server and default route, are given
|
||||
# sane defaults by dnsmasq. You very likely will not need
|
||||
# any dhcp-options. If you use Windows clients and Samba, there
|
||||
# are some options which are recommended, they are detailed at the
|
||||
# end of this section.
|
||||
|
||||
# Override the default route supplied by dnsmasq, which assumes the
|
||||
# router is the same machine as the one running dnsmasq.
|
||||
#dhcp-option=3,1.2.3.4
|
||||
|
||||
# Do the same thing, but using the option name
|
||||
#dhcp-option=option:router,1.2.3.4
|
||||
|
||||
# Override the default route supplied by dnsmasq and send no default
|
||||
# route at all. Note that this only works for the options sent by
|
||||
# default (1, 3, 6, 12, 28) the same line will send a zero-length option
|
||||
# for all other option numbers.
|
||||
#dhcp-option=3
|
||||
|
||||
# Set the NTP time server addresses to 192.168.0.4 and 10.10.0.5
|
||||
#dhcp-option=option:ntp-server,192.168.0.4,10.10.0.5
|
||||
|
||||
# Set the NTP time server address to be the same machine as
|
||||
# is running dnsmasq
|
||||
#dhcp-option=42,0.0.0.0
|
||||
|
||||
# Set the NIS domain name to "welly"
|
||||
#dhcp-option=40,welly
|
||||
|
||||
# Set the default time-to-live to 50
|
||||
#dhcp-option=23,50
|
||||
|
||||
# Set the "all subnets are local" flag
|
||||
#dhcp-option=27,1
|
||||
|
||||
# Set the domain
|
||||
dhcp-option=15,"2.vmops-test.vmops.com"
|
||||
|
||||
# Send the etherboot magic flag and then etherboot options (a string).
|
||||
#dhcp-option=128,e4:45:74:68:00:00
|
||||
#dhcp-option=129,NIC=eepro100
|
||||
|
||||
# Specify an option which will only be sent to the "red" network
|
||||
# (see dhcp-range for the declaration of the "red" network)
|
||||
# Note that the net: part must precede the option: part.
|
||||
#dhcp-option = net:red, option:ntp-server, 192.168.1.1
|
||||
|
||||
# The following DHCP options set up dnsmasq in the same way as is specified
|
||||
# for the ISC dhcpcd in
|
||||
# http://www.samba.org/samba/ftp/docs/textdocs/DHCP-Server-Configuration.txt
|
||||
# adapted for a typical dnsmasq installation where the host running
|
||||
# dnsmasq is also the host running samba.
|
||||
# you may want to uncomment them if you use Windows clients and Samba.
|
||||
#dhcp-option=19,0 # option ip-forwarding off
|
||||
#dhcp-option=44,0.0.0.0 # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)
|
||||
#dhcp-option=45,0.0.0.0 # netbios datagram distribution server
|
||||
#dhcp-option=46,8 # netbios node type
|
||||
#dhcp-option=47 # empty netbios scope.
|
||||
|
||||
# Send RFC-3397 DNS domain search DHCP option. WARNING: Your DHCP client
|
||||
# probably doesn't support this......
|
||||
#dhcp-option=option:domain-search,eng.apple.com,marketing.apple.com
|
||||
|
||||
# Send RFC-3442 classless static routes (note the netmask encoding)
|
||||
#dhcp-option=121,192.168.1.0/24,1.2.3.4,10.0.0.0/8,5.6.7.8
|
||||
|
||||
# Send vendor-class specific options encapsulated in DHCP option 43.
|
||||
# The meaning of the options is defined by the vendor-class so
|
||||
# options are sent only when the client supplied vendor class
|
||||
# matches the class given here. (A substring match is OK, so "MSFT"
|
||||
# matches "MSFT" and "MSFT 5.0"). This example sets the
|
||||
# mtftp address to 0.0.0.0 for PXEClients.
|
||||
#dhcp-option=vendor:PXEClient,1,0.0.0.0
|
||||
|
||||
# Send microsoft-specific option to tell windows to release the DHCP lease
|
||||
# when it shuts down. Note the "i" flag, to tell dnsmasq to send the
|
||||
# value as a four-byte integer - that's what microsoft wants. See
|
||||
# http://technet2.microsoft.com/WindowsServer/en/library/a70f1bb7-d2d4-49f0-96d6-4b7414ecfaae1033.mspx?mfr=true
|
||||
dhcp-option=vendor:MSFT,2,1i
|
||||
|
||||
# Send the Encapsulated-vendor-class ID needed by some configurations of
|
||||
# Etherboot to allow is to recognise the DHCP server.
|
||||
#dhcp-option=vendor:Etherboot,60,"Etherboot"
|
||||
|
||||
# Send options to PXELinux. Note that we need to send the options even
|
||||
# though they don't appear in the parameter request list, so we need
|
||||
# to use dhcp-option-force here.
|
||||
# See http://syslinux.zytor.com/pxe.php#special for details.
|
||||
# Magic number - needed before anything else is recognised
|
||||
#dhcp-option-force=208,f1:00:74:7e
|
||||
# Configuration file name
|
||||
#dhcp-option-force=209,configs/common
|
||||
# Path prefix
|
||||
#dhcp-option-force=210,/tftpboot/pxelinux/files/
|
||||
# Reboot time. (Note 'i' to send 32-bit value)
|
||||
#dhcp-option-force=211,30i
|
||||
|
||||
# Set the boot filename for BOOTP. You will only need
|
||||
# this is you want to boot machines over the network and you will need
|
||||
# a TFTP server; either dnsmasq's built in TFTP server or an
|
||||
# external one. (See below for how to enable the TFTP server.)
|
||||
#dhcp-boot=pxelinux.0
|
||||
|
||||
# Enable dnsmasq's built-in TFTP server
|
||||
#enable-tftp
|
||||
|
||||
# Set the root directory for files availble via FTP.
|
||||
#tftp-root=/var/ftpd
|
||||
|
||||
# Make the TFTP server more secure: with this set, only files owned by
|
||||
# the user dnsmasq is running as will be send over the net.
|
||||
#tftp-secure
|
||||
|
||||
# Set the boot file name only when the "red" tag is set.
|
||||
#dhcp-boot=net:red,pxelinux.red-net
|
||||
|
||||
# An example of dhcp-boot with an external server: the name and IP
|
||||
# address of the server are given after the filename.
|
||||
#dhcp-boot=/var/ftpd/pxelinux.0,boothost,192.168.0.3
|
||||
|
||||
# Set the limit on DHCP leases, the default is 150
|
||||
#dhcp-lease-max=150
|
||||
|
||||
# The DHCP server needs somewhere on disk to keep its lease database.
|
||||
# This defaults to a sane location, but if you want to change it, use
|
||||
# the line below.
|
||||
#dhcp-leasefile=/var/lib/misc/dnsmasq.leases
|
||||
leasefile-ro
|
||||
|
||||
# Set the DHCP server to authoritative mode. In this mode it will barge in
|
||||
# and take over the lease for any client which broadcasts on the network,
|
||||
# whether it has a record of the lease or not. This avoids long timeouts
|
||||
# when a machine wakes up on a new network. DO NOT enable this if there's
|
||||
# the slighest chance that you might end up accidentally configuring a DHCP
|
||||
# server for your campus/company accidentally. The ISC server uses
|
||||
# the same option, and this URL provides more information:
|
||||
# http://www.isc.org/index.pl?/sw/dhcp/authoritative.php
|
||||
#dhcp-authoritative
|
||||
|
||||
# Run an executable when a DHCP lease is created or destroyed.
|
||||
# The arguments sent to the script are "add" or "del",
|
||||
# then the MAC address, the IP address and finally the hostname
|
||||
# if there is one.
|
||||
#dhcp-script=/bin/echo
|
||||
|
||||
# Set the cachesize here.
|
||||
#cache-size=150
|
||||
|
||||
# If you want to disable negative caching, uncomment this.
|
||||
#no-negcache
|
||||
|
||||
# Normally responses which come form /etc/hosts and the DHCP lease
|
||||
# file have Time-To-Live set as zero, which conventionally means
|
||||
# do not cache further. If you are happy to trade lower load on the
|
||||
# server for potentially stale date, you can set a time-to-live (in
|
||||
# seconds) here.
|
||||
#local-ttl=
|
||||
|
||||
# If you want dnsmasq to detect attempts by Verisign to send queries
|
||||
# to unregistered .com and .net hosts to its sitefinder service and
|
||||
# have dnsmasq instead return the correct NXDOMAIN response, uncomment
|
||||
# this line. You can add similar lines to do the same for other
|
||||
# registries which have implemented wildcard A records.
|
||||
#bogus-nxdomain=64.94.110.11
|
||||
|
||||
# If you want to fix up DNS results from upstream servers, use the
|
||||
# alias option. This only works for IPv4.
|
||||
# This alias makes a result of 1.2.3.4 appear as 5.6.7.8
|
||||
#alias=1.2.3.4,5.6.7.8
|
||||
# and this maps 1.2.3.x to 5.6.7.x
|
||||
#alias=1.2.3.0,5.6.7.0,255.255.255.0
|
||||
|
||||
|
||||
# Change these lines if you want dnsmasq to serve MX records.
|
||||
|
||||
# Return an MX record named "maildomain.com" with target
|
||||
# servermachine.com and preference 50
|
||||
#mx-host=maildomain.com,servermachine.com,50
|
||||
|
||||
# Set the default target for MX records created using the localmx option.
|
||||
#mx-target=servermachine.com
|
||||
|
||||
# Return an MX record pointing to the mx-target for all local
|
||||
# machines.
|
||||
#localmx
|
||||
|
||||
# Return an MX record pointing to itself for all local machines.
|
||||
#selfmx
|
||||
|
||||
# Change the following lines if you want dnsmasq to serve SRV
|
||||
# records. These are useful if you want to serve ldap requests for
|
||||
# Active Directory and other windows-originated DNS requests.
|
||||
# See RFC 2782.
|
||||
# You may add multiple srv-host lines.
|
||||
# The fields are <name>,<target>,<port>,<priority>,<weight>
|
||||
# If the domain part if missing from the name (so that is just has the
|
||||
# service and protocol sections) then the domain given by the domain=
|
||||
# config option is used. (Note that expand-hosts does not need to be
|
||||
# set for this to work.)
|
||||
|
||||
# A SRV record sending LDAP for the example.com domain to
|
||||
# ldapserver.example.com port 289
|
||||
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
|
||||
|
||||
# A SRV record sending LDAP for the example.com domain to
|
||||
# ldapserver.example.com port 289 (using domain=)
|
||||
###domain=example.com
|
||||
#srv-host=_ldap._tcp,ldapserver.example.com,389
|
||||
|
||||
# Two SRV records for LDAP, each with different priorities
|
||||
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1
|
||||
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2
|
||||
|
||||
# A SRV record indicating that there is no LDAP server for the domain
|
||||
# example.com
|
||||
#srv-host=_ldap._tcp.example.com
|
||||
|
||||
# The following line shows how to make dnsmasq serve an arbitrary PTR
|
||||
# record. This is useful for DNS-SD. (Note that the
|
||||
# domain-name expansion done for SRV records _does_not
|
||||
# occur for PTR records.)
|
||||
#ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services"
|
||||
|
||||
# Change the following lines to enable dnsmasq to serve TXT records.
|
||||
# These are used for things like SPF and zeroconf. (Note that the
|
||||
# domain-name expansion done for SRV records _does_not
|
||||
# occur for TXT records.)
|
||||
|
||||
#Example SPF.
|
||||
#txt-record=example.com,"v=spf1 a -all"
|
||||
|
||||
#Example zeroconf
|
||||
#txt-record=_http._tcp.example.com,name=value,paper=A4
|
||||
|
||||
|
||||
# For debugging purposes, log each DNS query as it passes through
|
||||
# dnsmasq.
|
||||
#log-queries
|
||||
|
||||
# Log lots of extra information about DHCP transactions.
|
||||
#log-dhcp
|
||||
|
||||
log-facility=/var/log/dnsmasq.log
|
||||
|
||||
# Include a another lot of configuration options.
|
||||
#conf-file=/etc/dnsmasq.more.conf
|
||||
conf-dir=/etc/dnsmasq.d
|
||||
|
||||
# Don't reply Windows's periodical DNS request
|
||||
filterwin2k
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
#!/usr/bin/env bash
|
||||
# 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
|
||||
# firewall_rule.sh -- allow some ports / protocols to vm instances
|
||||
# @VERSION@
|
||||
|
||||
source /root/func.sh
|
||||
|
||||
lock="biglock"
|
||||
locked=$(getLockFile $lock)
|
||||
if [ "$locked" != "1" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s: -a <public ip address:protocol:startport:endport:sourcecidrs> \n" $(basename $0) >&2
|
||||
printf "sourcecidrs format: cidr1-cidr2-cidr3-...\n"
|
||||
}
|
||||
#set -x
|
||||
#FIXME: eating up the error code during execution of iptables
|
||||
acl_remove_backup() {
|
||||
sudo iptables -F _ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -D FORWARD -o $dev -d $gcidr -j _ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -X _ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -F _ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -D FORWARD -i $dev -s $gcidr -j _ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -X _ACL_OUTBOUND_$ip 2>/dev/null
|
||||
}
|
||||
|
||||
acl_remove() {
|
||||
sudo iptables -F ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -D FORWARD -o $dev -d $gcidr -j ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -X ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -F ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -D FORWARD -i $dev -s $gcidr -j ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -X ACL_OUTBOUND_$ip 2>/dev/null
|
||||
}
|
||||
|
||||
acl_restore() {
|
||||
acl_remove
|
||||
sudo iptables -E _ACL_INBOUND_$ip ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -E _ACL_OUTBOUND_$ip ACL_OUTBOUND_$ip 2>/dev/null
|
||||
}
|
||||
|
||||
acl_save() {
|
||||
acl_remove_backup
|
||||
sudo iptables -E ACL_INBOUND_$ip _ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -E ACL_OUTBOUND_$ip _ACL_OUTBOUND_$gGW 2>/dev/null
|
||||
}
|
||||
|
||||
acl_chain_for_guest_network () {
|
||||
acl_save
|
||||
# inbound
|
||||
sudo iptables -E ACL_INBOUND_$ip _ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -N ACL_INBOUND_$ip 2>/dev/null
|
||||
# drop if no rules match (this will be the last rule in the chain)
|
||||
sudo iptables -A ACL_INBOUND_$ip -j DROP 2>/dev/null
|
||||
sudo iptables -A FORWARD -o $dev -d $gcidr -j ACL_INBOUND_$ip 2>/dev/null
|
||||
# outbound
|
||||
sudo iptables -E ACL_OUTBOUND_$ip _ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -N ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -A ACL_OUTBOUND_$ip -j DROP 2>/dev/null
|
||||
sudo iptables -D FORWARD -i $dev -s $gcidr -j ACL_OUTBOUND_$ip 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
|
||||
acl_entry_for_guest_network() {
|
||||
local rule=$1
|
||||
|
||||
local inbound=$(echo $rule | cut -d: -f1)
|
||||
local prot=$(echo $rules | cut -d: -f2)
|
||||
local sport=$(echo $rules | cut -d: -f3)
|
||||
local eport=$(echo $rules | cut -d: -f4)
|
||||
local cidrs=$(echo $rules | cut -d: -f5 | sed 's/-/ /g')
|
||||
|
||||
logger -t cloud "$(basename $0): enter apply acl rules for guest network: $gcidr, inbound:$inbound:$prot:$sport:$eport:$cidrs"
|
||||
|
||||
# note that rules are inserted after the RELATED,ESTABLISHED rule
|
||||
# but before the DROP rule
|
||||
for lcidr in $scidrs
|
||||
do
|
||||
[ "$prot" == "reverted" ] && continue;
|
||||
if [ "$prot" == "icmp" ]
|
||||
then
|
||||
typecode="$sport/$eport"
|
||||
[ "$eport" == "-1" ] && typecode="$sport"
|
||||
[ "$sport" == "-1" ] && typecode="any"
|
||||
if [ "$inbound" == "1" ]
|
||||
then
|
||||
sudo iptables -I ACL_INBOUND_$gGW -p $prot -s $lcidr \
|
||||
--icmp-type $typecode -j ACCEPT
|
||||
else
|
||||
sudo iptables -I ACL_OUTBOUND_$gGW -p $prot -d $lcidr \
|
||||
--icmp-type $typecode -j ACCEPT
|
||||
fi
|
||||
else
|
||||
if [ "$inbound" == "1" ]
|
||||
then
|
||||
sudo iptables -I ACL_INBOUND_$gGW -p $prot -s $lcidr \
|
||||
--dport $sport:$eport -j ACCEPT
|
||||
else
|
||||
sudo iptables -I ACL_OUTBOUND_$gGW -p $prot -d $lcidr \
|
||||
--dport $sport:$eport -j ACCEP`T
|
||||
fi
|
||||
result=$?
|
||||
[ $result -gt 0 ] &&
|
||||
logger -t cloud "Error adding iptables entry for guest network : $gcidr,inbound:$inbound:$prot:$sport:$eport:$cidrs" &&
|
||||
break
|
||||
done
|
||||
|
||||
logger -t cloud "$(basename $0): exit apply acl rules for guest network : $gcidr"
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
shift
|
||||
dflag=0
|
||||
gflag=0
|
||||
aflag=0
|
||||
rules=""
|
||||
rules_list=""
|
||||
gcidr=""
|
||||
ip=""
|
||||
dev=""
|
||||
while getopts ':d:g:a:' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
d) dflag=1
|
||||
dev="$OPTAGR"
|
||||
g) gflag=1
|
||||
gcidr="$OPTAGR"
|
||||
a) aflag=1
|
||||
rules="$OPTARG"
|
||||
;;
|
||||
?) usage
|
||||
unlock_exit 2 $lock $locked
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$dflag$gflag$aflag" != "!11" ]
|
||||
then
|
||||
usage()
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$rules" == "" ]
|
||||
then
|
||||
rules_list=$(echo $rules | cut -d, -f1- --output-delimiter=" ")
|
||||
fi
|
||||
|
||||
# rule format
|
||||
# protocal:sport:eport:cidr
|
||||
#-a tcp:80:80:0.0.0.0/0::tcp:220:220:0.0.0.0/0:,172.16.92.44:tcp:222:222:192.168.10.0/24-75.57.23.0/22-88.100.33.1/32
|
||||
# if any entry is reverted , entry will be in the format <ip>:reverted:0:0:0
|
||||
# example : 172.16.92.44:tcp:80:80:0.0.0.0/0:,172.16.92.44:tcp:220:220:0.0.0.0/0:,200.1.1.2:reverted:0:0:0
|
||||
|
||||
success=0
|
||||
ip=$(echo $gcidr | awk -F'/' '{print $1}')
|
||||
|
||||
acl_chain_for_guest_network
|
||||
|
||||
for r in $rules_list
|
||||
do
|
||||
acl_entry_for_guest_network $r
|
||||
success=$?
|
||||
if [ $success -gt 0 ]
|
||||
then
|
||||
logger -t cloud "$(basename $0): failure to apply fw rules for guest network: $gcidr"
|
||||
break
|
||||
else
|
||||
logger -t cloud "$(basename $0): successful in applying fw rules for guest network: $gcidr"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $success -gt 0 ]
|
||||
then
|
||||
logger -t cloud "$(basename $0): restoring from backup for guest network: $gcidr"
|
||||
acl_restore
|
||||
else
|
||||
logger -t cloud "$(basename $0): deleting backup for guest network: $gcidr"
|
||||
acl_remove_backup
|
||||
fi
|
||||
unlock_exit $success $lock $locked
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
plug_nic() {
|
||||
sudo iptables -t mangle -A PREROUTING -i $dev -m state --state NEW -j MARK --set-mark $tableNo 2>/dev/null
|
||||
sudo iptables -t mangle -A PREROUTING -i $dev -m state --state NEW -j CONNMARK --save-mark 2>/dev/null
|
||||
|
||||
sudo echo "$tableNo $tableName" >> /etc/iproute2/rt_tables 2>/dev/null
|
||||
sudo ip rule add fwmark $tableNo table $tableName 2>/dev/null
|
||||
sudo ip route flush table $tableName
|
||||
sudo ip route flush cache
|
||||
}
|
||||
|
||||
|
||||
unplug_nic() {
|
||||
sudo iptables -t mangle -D PREROUTING -i $dev -m state --state NEW -j MARK --set-mark $tableNo 2>/dev/null
|
||||
sudo iptables -t mangle -D PREROUTING -i $dev -m state --state NEW -j CONNMARK --save-mark 2>/dev/null
|
||||
|
||||
sudo ip rule del fwmark $tableNo 2>/dev/null
|
||||
sudo ip route flush table $tableName
|
||||
sudo sed -i /"$tableNo $tableName"/d /etc/iproute2/rt_tables 2>/dev/null
|
||||
sudo ip route flush cache
|
||||
}
|
||||
|
||||
action=$1
|
||||
dev=$2
|
||||
tableNo=$(echo $dev | awk -F'eth' '{print $2}')
|
||||
tableName="Table_$dev"
|
||||
|
||||
if [ $action == 'add' ]
|
||||
then
|
||||
plug_nic
|
||||
else
|
||||
unplug_nic
|
||||
fi
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
#!/usr/bin/env bash
|
||||
# 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
|
||||
|
||||
# guestnw.sh -- create/destroy guest network
|
||||
# @VERSION@
|
||||
|
||||
source /root/func.sh
|
||||
|
||||
lock="biglock"
|
||||
locked=$(getLockFile $lock)
|
||||
if [ "$locked" != "1" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usage() {
|
||||
printf "Usage:\n %s -A -c <dev> -g <gateway> -m <network mask> -d <dns ip> -r <dhcp ip range> [-f] \n" $(basename $0) >&2
|
||||
printf " %s -D -c <dev> \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
|
||||
setup_dnsmasq() {
|
||||
logger -t cloud "Setting up dnsmasq for network $ip/$mask "
|
||||
# setup static
|
||||
sed -i -e "/^[#]*dhcp-range=interface:$dev/d" /etc/dnsmasq.d/cloud.conf
|
||||
echo "dhcp-range=interface:$dev,set:interface-$dev,$ip,static" >> /etc/dnsmasq.d/cloud.conf
|
||||
# setup gateway
|
||||
sed -i -e "/^[#]*dhcp-option=tag:interface-$dev,option:router.*$/d" /etc/dnsmasq.d/cloud.conf
|
||||
if [ -n "$gw" ]
|
||||
then
|
||||
echo "dhcp-option=tag:interface-$dev,option:router,$gw" >> /etc/dnsmasq.d/cloud.conf
|
||||
fi
|
||||
# setup DNS
|
||||
sed -i -e "/^[#]*dhcp-option=tag:interface-$dev,6.*$/d" /etc/dnsmasq.d/cloud.conf
|
||||
if [ -n "$DNS" ]
|
||||
then
|
||||
echo "dhcp-option=tag:interface-$dev,6,$DNS" >> /etc/dnsmasq.d/cloud.conf
|
||||
fi
|
||||
# setup DOMAIN
|
||||
sed -i -e "/^[#]*dhcp-option=tag:interface-$dev,15.*$/d" /etc/dnsmasq.d/cloud.conf
|
||||
if [ -n "$DOMAIN" ]
|
||||
then
|
||||
echo "dhcp-option=tag:interface-$dev,15,$DOMAIN" >> /etc/dnsmasq.d/cloud.conf
|
||||
fi
|
||||
service dnsmasq restart
|
||||
sleep 1
|
||||
}
|
||||
|
||||
desetup_dnsmasq() {
|
||||
logger -t cloud "Setting up dnsmasq for network $ip/$mask "
|
||||
|
||||
sed -i -e "/^[#]*dhcp-option=tag:interface-$dev,option:router.*$/d" /etc/dnsmasq.d/cloud.conf
|
||||
sed -i -e "/^[#]*dhcp-option=tag:interface-$dev,6.*$/d" /etc/dnsmasq.d/cloud.conf
|
||||
sed -i -e "/^[#]*dhcp-range=interface:$dev/d" /etc/dnsmasq.d/cloud.conf
|
||||
service dnsmasq restart
|
||||
sleep 1
|
||||
}
|
||||
|
||||
|
||||
create_guest_network() {
|
||||
logger -t cloud " $(basename $0): Create network on interface $dev, gateway $gw, network $ip/$mask "
|
||||
# setup ip configuration
|
||||
sudo ip addr add dev $dev $ip/$mask
|
||||
sudo ip link set $dev up
|
||||
sudo arping -c 3 -I $dev -A -U -s $ip $ip;
|
||||
# setup rules to allow dhcp/dns request
|
||||
sudo iptables -A INPUT -i $dev -p udp -m udp --dport 67 -j ACCEPT
|
||||
sudo iptables -A INPUT -i $dev -p udp -m udp --dport 53 -j ACCEPT
|
||||
|
||||
# create inbound acl chain
|
||||
if sudo iptables -N ACL_INBOUND_$ip 2>/dev/null
|
||||
then
|
||||
logger -t cloud "$(basename $0): create VPC inbound acl chain for network $ip/$mask"
|
||||
# policy drop
|
||||
sudo iptables -A ACL_INBOUND_$ip -j DROP >/dev/null
|
||||
sudo iptables -A FORWARD -o $dev -d $ip/$mask -j ACL_INBOUND_$ip
|
||||
fi
|
||||
# create outbound acl chain
|
||||
if sudo iptables -N ACL_OUTBOUND_$ip 2>/dev/null
|
||||
then
|
||||
logger -t cloud "$(basename $0): create VPC outbound acl chain for network $ip/$mask"
|
||||
sudo iptables -A ACL_OUTBOUND_$ip -j DROP >/dev/null
|
||||
sudo iptables -A FORWARD -i $dev -s $ip/$mask -j ACL_OUTBOUND_$ip
|
||||
fi
|
||||
|
||||
setup_dnsmasq
|
||||
}
|
||||
|
||||
destroy_guest_network() {
|
||||
logger -t cloud " $(basename $0): Create network on interface $dev, gateway $gw, network $ip/$mask "
|
||||
# destroy inbound acl chain
|
||||
sudo iptables -F ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -D FORWARD -o $dev -d $ip/$mask -j ACL_INBOUND_$ip 2>/dev/null
|
||||
sudo iptables -X ACL_INBOUND_$ip 2>/dev/null
|
||||
# destroy outbound acl chain
|
||||
sudo iptables -F ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -D FORWARD -i $dev -s $ip/$mask -j ACL_OUTBOUND_$ip 2>/dev/null
|
||||
sudo iptables -X ACL_OUTBOUND_$ip 2>/dev/null
|
||||
|
||||
desetup_dnsmasq
|
||||
}
|
||||
|
||||
#set -x
|
||||
nflag=0
|
||||
dflag=
|
||||
cflag=
|
||||
gflag=
|
||||
Cflag=
|
||||
Dflag=
|
||||
|
||||
op=""
|
||||
|
||||
|
||||
while getopts 'CDn:m:d:i:g:s:e:' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
C) Cflag=1
|
||||
op="-C"
|
||||
;;
|
||||
D) Dflag=1
|
||||
op="-D"
|
||||
;;
|
||||
n) nflag=1
|
||||
network="$OPTAGR"
|
||||
;;
|
||||
m) mflag=1
|
||||
mask="$OPTARG"
|
||||
;;
|
||||
d) dflag=1
|
||||
dev="$OPTARG"
|
||||
;;
|
||||
i) iflag=1
|
||||
ip="$OPTARG"
|
||||
;;
|
||||
g) gflag=1
|
||||
gw="$OPTARG"
|
||||
;;
|
||||
s) sflag=1
|
||||
DNS="$OPTARG"
|
||||
;;
|
||||
e) eflag=1
|
||||
DOMAIN="$OPTARG"
|
||||
;;
|
||||
?) usage
|
||||
unlock_exit 2 $lock $locked
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [ "$Cflag$Dflag$dflag" != "11" ]
|
||||
then
|
||||
usage
|
||||
unlock_exit 2 $lock $locked
|
||||
fi
|
||||
|
||||
if [ "$Cflag" == "1" ] && ["$iflag$gflag$mflag" != "111" ]
|
||||
then
|
||||
usage
|
||||
unlock_exit 2 $lock $locked
|
||||
fi
|
||||
|
||||
|
||||
if [ "$Cflag" == "1" ]
|
||||
then
|
||||
create_guest_network
|
||||
fi
|
||||
|
||||
|
||||
if [ "$Dflag" == "1" ]
|
||||
then
|
||||
destroy_guest_network
|
||||
fi
|
||||
|
||||
unlock_exit 0 $lock $locked
|
||||
0
patches/systemvm/debian/config/root/ipassoc.sh → patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
Normal file → Executable file
0
patches/systemvm/debian/config/root/ipassoc.sh → patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
Normal file → Executable file
0
patches/systemvm/debian/config/root/netusage.sh → patches/systemvm/debian/config/opt/cloud/bin/netusage.sh
Normal file → Executable file
0
patches/systemvm/debian/config/root/netusage.sh → patches/systemvm/debian/config/opt/cloud/bin/netusage.sh
Normal file → Executable file
|
|
@ -0,0 +1,225 @@
|
|||
#!/usr/bin/env bash
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: ipassoc.sh 9804 2010-06-22 18:36:49Z alex $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/network/domr/ipassoc.sh $
|
||||
# ipassoc.sh -- associate/disassociate a public ip with an instance
|
||||
# @VERSION@
|
||||
|
||||
source /root/func.sh
|
||||
|
||||
lock="biglock"
|
||||
locked=$(getLockFile $lock)
|
||||
if [ "$locked" != "1" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usage() {
|
||||
printf "Usage:\n %s -A -l <public-ip-address> -c <dev> [-f] \n" $(basename $0) >&2
|
||||
printf " %s -D -l <public-ip-address> -c <dev> [-f] \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
remove_routing() {
|
||||
local pubIp=$1
|
||||
logger -t cloud "$(basename $0):Remove routing $pubIp on interface $ethDev"
|
||||
local ipNoMask=$(echo $pubIp | awk -F'/' '{print $1}')
|
||||
local mask=$(echo $pubIp | awk -F'/' '{print $2}')
|
||||
local tableNo=$(echo $ethDev | awk -F'eth' '{print $2}')
|
||||
|
||||
local tableName="Table_$ethDev"
|
||||
local ethMask=$(ip route list scope link dev $ethDev | awk '{print $1}')
|
||||
if [ "$ethMask" == "" ]
|
||||
then
|
||||
# rules and routes will be deleted for the last ip of the interface.
|
||||
sudo ip rule delete fwmark $tableNo table $tableName
|
||||
sudo ip rule delete table $tableName
|
||||
sudo ip route flush table $tableName
|
||||
sudo ip route flush cache
|
||||
logger -t cloud "$(basename $0):Remove routing $pubIp - routes and rules deleted"
|
||||
fi
|
||||
}
|
||||
|
||||
# copy eth0,eth1 and the current public interface
|
||||
copy_routes_from_main() {
|
||||
local tableName=$1
|
||||
|
||||
#get the network masks from the main table
|
||||
local eth0Mask=$(ip route list scope link dev eth0 | awk '{print $1}')
|
||||
local eth1Mask=$(ip route list scope link dev eth1 | awk '{print $1}')
|
||||
local ethMask=$(ip route list scope link dev $ethDev | awk '{print $1}')
|
||||
|
||||
# eth0,eth1 and other know routes will be skipped, so as main routing table will decide the route. This will be useful if the interface is down and up.
|
||||
sudo ip route add throw $eth0Mask table $tableName proto static
|
||||
sudo ip route add throw $eth1Mask table $tableName proto static
|
||||
sudo ip route add throw $ethMask table $tableName proto static
|
||||
return 0;
|
||||
}
|
||||
|
||||
ip_addr_add() {
|
||||
local dev="$1"
|
||||
local ip="$2"
|
||||
}
|
||||
|
||||
add_routing() {
|
||||
local pubIp=$1
|
||||
logger -t cloud "$(basename $0):Add routing $pubIp on interface $ethDev"
|
||||
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
|
||||
local mask=$(echo $1 | awk -F'/' '{print $2}')
|
||||
|
||||
local tableName="Table_$ethDev"
|
||||
local tablePresent=$(grep $tableName /etc/iproute2/rt_tables)
|
||||
local tableNo=$(echo $ethDev | awk -F'eth' '{print $2}')
|
||||
if [ "$tablePresent" == "" ]
|
||||
then
|
||||
if [ "$tableNo" == ""]
|
||||
then
|
||||
return 0;
|
||||
fi
|
||||
sudo echo "$tableNo $tableName" >> /etc/iproute2/rt_tables
|
||||
fi
|
||||
|
||||
copy_routes_from_main $tableName
|
||||
# NOTE: this entry will be deleted if the interface is down without knowing to Management server, in that case all the outside traffic will be send through main routing table or it will be the first public NIC.
|
||||
sudo ip route add default via $defaultGwIP table $tableName proto static
|
||||
sudo ip route flush cache
|
||||
|
||||
local ethMask=$(ip route list scope link dev $ethDev | awk '{print $1}')
|
||||
local rulePresent=$(ip rule show | grep $ethMask)
|
||||
if [ "$rulePresent" == "" ]
|
||||
then
|
||||
# rules will be added while adding the first ip of the interface
|
||||
sudo ip rule add from $ethMask table $tableName
|
||||
sudo ip rule add fwmark $tableNo table $tableName
|
||||
logger -t cloud "$(basename $0):Add routing $pubIp rules added"
|
||||
fi
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
add_an_ip () {
|
||||
local pubIp=$1
|
||||
logger -t cloud "$(basename $0):Adding ip $pubIp on interface $ethDev"
|
||||
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
|
||||
sudo ip link show $ethDev | grep "state DOWN" > /dev/null
|
||||
local old_state=$?
|
||||
|
||||
sudo ip addr add dev $dev $ip
|
||||
if [ $if_keep_state -ne 1 -o $old_state -ne 0 ]
|
||||
then
|
||||
sudo ip link set $ethDev up
|
||||
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
||||
fi
|
||||
add_routing $1
|
||||
return $?
|
||||
|
||||
}
|
||||
|
||||
remove_an_ip () {
|
||||
local pubIp=$1
|
||||
logger -t cloud "$(basename $0):Removing ip $pubIp on interface $ethDev"
|
||||
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
|
||||
local mask=$(echo $1 | awk -F'/' '{print $2}')
|
||||
local existingIpMask=$(sudo ip addr show dev $ethDev | grep inet | awk '{print $2}' | grep -w $ipNoMask)
|
||||
[ "$existingIpMask" == "" ] && return 0
|
||||
remove_snat $1
|
||||
local existingMask=$(echo $existingIpMask | awk -F'/' '{print $2}')
|
||||
if [ "$existingMask" == "32" ]
|
||||
then
|
||||
sudo ip addr del dev $ethDev $existingIpMask
|
||||
result=$?
|
||||
fi
|
||||
|
||||
if [ "$existingMask" != "32" ]
|
||||
then
|
||||
replaceIpMask=`sudo ip addr show dev $ethDev | grep inet | grep -v $existingIpMask | awk '{print $2}' | sort -t/ -k2 -n|tail -1`
|
||||
sudo ip addr del dev $ethDev $existingIpMask;
|
||||
if [ -n "$replaceIpMask" ]; then
|
||||
sudo ip addr del dev $ethDev $replaceIpMask;
|
||||
replaceIp=`echo $replaceIpMask | awk -F/ '{print $1}'`;
|
||||
ip_addr_add $ethDev $replaceIp/$existingMask
|
||||
fi
|
||||
result=$?
|
||||
fi
|
||||
|
||||
if [ $result -gt 0 -a $result -ne 2 ]
|
||||
then
|
||||
remove_routing $1
|
||||
return 1
|
||||
fi
|
||||
remove_routing $1
|
||||
return 0
|
||||
}
|
||||
|
||||
#set -x
|
||||
lflag=
|
||||
cflag=
|
||||
op=""
|
||||
|
||||
|
||||
while getopts 'sfADa:l:c:g:' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
A) Aflag=1
|
||||
op="-A"
|
||||
;;
|
||||
D) Dflag=1
|
||||
op="-D"
|
||||
;;
|
||||
l) lflag=1
|
||||
publicIp="$OPTARG"
|
||||
;;
|
||||
c) cflag=1
|
||||
ethDev="$OPTARG"
|
||||
;;
|
||||
g) gflag=1
|
||||
defaultGwIP="$OPTARG"
|
||||
;;
|
||||
?) usage
|
||||
unlock_exit 2 $lock $locked
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [ "$Aflag$Dflag" != "1" ]
|
||||
then
|
||||
usage
|
||||
unlock_exit 2 $lock $locked
|
||||
fi
|
||||
|
||||
if [ "$lflag$cflag" != "11" ]
|
||||
then
|
||||
usage
|
||||
unlock_exit 2 $lock $locked
|
||||
fi
|
||||
|
||||
|
||||
if [ "$Aflag" == "1" ]
|
||||
then
|
||||
add_an_ip $publicIp &&
|
||||
unlock_exit $? $lock $locked
|
||||
fi
|
||||
|
||||
|
||||
if [ "$Dflag" == "1" ]
|
||||
then
|
||||
remove_an_ip $publicIp &&
|
||||
unlock_exit $? $lock $locked
|
||||
fi
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
#!/bin/bash
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#set -x
|
||||
usage() {
|
||||
printf "Usage:\n"
|
||||
printf "Create VPN : %s -c -r <ip range for clients> -l <local ip> -p <ipsec psk> -s <public ip> -D <eth for public ip> -z < zone cidr> \n" $(basename $0)
|
||||
printf "Delete VPN : %s -d -l <local ip> -s <public ip> -D <eth for public ip> -z < zone cidr> \n" $(basename $0)
|
||||
printf "Add VPN User : %s -u <username,password> \n" $(basename $0)
|
||||
printf "Remote VPN User: %s -U <username \n" $(basename $0)
|
||||
}
|
||||
|
||||
iptables_() {
|
||||
local op=$1
|
||||
local public_ip=$2
|
||||
|
||||
sudo iptables $op INPUT -i $dev -d $public_ip -p udp --dport 500 -j ACCEPT
|
||||
sudo iptables $op INPUT -i $dev -d $public_ip -p udp --dport 4500 -j ACCEPT
|
||||
sudo iptables $op INPUT -i $dev -d $public_ip -p udp --dport 1701 -j ACCEPT
|
||||
sudo iptables $op INPUT -i $dev -p ah -j ACCEPT
|
||||
sudo iptables $op INPUT -i $dev -p esp -j ACCEPT
|
||||
sudo iptables $op FORWARD -i ppp+ -d $zcidr -j ACCEPT
|
||||
sudo iptables $op FORWARD -i ppp+ -o ppp+ -j ACCEPT
|
||||
sudo iptables $op INPUT -i ppp+ -p udp --dport 53 -j ACCEPT
|
||||
sudo iptables -t nat $op PREROUTING -i ppp+ -p udp --dport 53 -j DNAT --to-destination $local_ip
|
||||
}
|
||||
|
||||
ipsec_server() {
|
||||
local op=$1
|
||||
if [ "$op" == "restart" ]
|
||||
then
|
||||
service ipsec stop
|
||||
service xl2tpd stop
|
||||
service ipsec start
|
||||
service xl2tpd start
|
||||
return $?
|
||||
fi
|
||||
service ipsec $op
|
||||
service xl2tpd $op
|
||||
}
|
||||
|
||||
create_l2tp_ipsec_vpn_server() {
|
||||
local ipsec_psk=$1
|
||||
local public_ip=$2
|
||||
local client_range=$3
|
||||
local local_ip=$4
|
||||
|
||||
sed -i -e "s/left=.*$/left=$public_ip/" /etc/ipsec.d/l2tp.conf
|
||||
echo ": PSK \"$ipsec_psk\"" > /etc/ipsec.d/ipsec.any.secrets
|
||||
sed -i -e "s/^ip range = .*$/ip range = $client_range/" /etc/xl2tpd/xl2tpd.conf
|
||||
sed -i -e "s/^local ip = .*$/local ip = $local_ip/" /etc/xl2tpd/xl2tpd.conf
|
||||
|
||||
sed -i -e "s/^ms-dns.*$/ms-dns $local_ip/" /etc/ppp/options.xl2tpd
|
||||
|
||||
iptables_ "-D" $public_ip
|
||||
iptables_ "-I" $public_ip
|
||||
|
||||
ipsec_server "restart"
|
||||
|
||||
ipsec auto --rereadsecrets
|
||||
ipsec auto --replace L2TP-PSK
|
||||
}
|
||||
|
||||
destroy_l2tp_ipsec_vpn_server() {
|
||||
local public_ip=$1
|
||||
|
||||
ipsec auto --down L2TP-PSK
|
||||
|
||||
iptables_ "-D" $public_ip
|
||||
|
||||
ipsec_server "stop"
|
||||
}
|
||||
|
||||
remove_l2tp_ipsec_user() {
|
||||
local u=$1
|
||||
sed -i -e "/^$u .*$/d" /etc/ppp/chap-secrets
|
||||
if [ -x /usr/bin/tdbdump ]; then
|
||||
pid=$(tdbdump /var/run/pppd2.tdb | grep -w $u | awk -F';' '{print $4}' | awk -F= '{print $2}')
|
||||
[ "$pid" != "" ] && kill -9 $pid
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
add_l2tp_ipsec_user() {
|
||||
local u=$1
|
||||
local passwd=$2
|
||||
|
||||
remove_l2tp_ipsec_user $u
|
||||
echo "$u * $passwd *" >> /etc/ppp/chap-secrets
|
||||
}
|
||||
|
||||
rflag=
|
||||
pflag=
|
||||
lflag=
|
||||
sflag=
|
||||
create=
|
||||
destroy=
|
||||
useradd=
|
||||
userdel=
|
||||
|
||||
while getopts 'cdl:p:r:s:u:U:D:z' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
c) create=1
|
||||
;;
|
||||
d) destroy=1
|
||||
;;
|
||||
u) useradd=1
|
||||
user_pwd="$OPTARG"
|
||||
;;
|
||||
U) userdel=1
|
||||
user="$OPTARG"
|
||||
;;
|
||||
r) rflag=1
|
||||
client_range="$OPTARG"
|
||||
;;
|
||||
p) pflag=1
|
||||
ipsec_psk="$OPTARG"
|
||||
;;
|
||||
l) lflag=1
|
||||
local_ip="$OPTARG"
|
||||
;;
|
||||
s) sflag=1
|
||||
server_ip="$OPTARG"
|
||||
;;
|
||||
D) dev="$OPTARG"
|
||||
;;
|
||||
z) zcidr="$OPTARG"
|
||||
;;
|
||||
?) usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ "$create$destroy" == "11" ] || [ "$create$destroy$useradd$userdel" == "" ] && usage && exit 2
|
||||
[ "$create" == "1" ] && [ "$lflag$pflag$rflag$sflag" != "1111" ] && usage && exit 2
|
||||
|
||||
if [ "$create" == "1" ]; then
|
||||
create_l2tp_ipsec_vpn_server $ipsec_psk $server_ip $client_range $local_ip
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ "$destroy" == "1" ]; then
|
||||
destroy_l2tp_ipsec_vpn_server $server_ip
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ "$useradd" == "1" ]; then
|
||||
u=$(echo $user_pwd | awk -F',' '{print $1}')
|
||||
pwd=$(echo $user_pwd | awk -F',' '{print $2}')
|
||||
add_l2tp_ipsec_user $u $pwd
|
||||
exit $?
|
||||
fi
|
||||
if [ "$userdel" == "1" ]; then
|
||||
remove_l2tp_ipsec_user $user
|
||||
exit $?
|
||||
fi
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash
|
||||
# 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
|
||||
|
||||
usage() {
|
||||
printf "Usage:\n %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
printf " %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
check_gw() {
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
sleep 1
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
fi
|
||||
return $?;
|
||||
}
|
||||
|
||||
|
||||
check_gw "$domRIp"
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/opt/cloud/bin/get_template_version.sh"
|
||||
exit $?
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: ipassoc.sh 9804 2010-06-22 18:36:49Z alex $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/network/domr/ipassoc.sh $
|
||||
# ipassoc.sh -- associate/disassociate a public ip with an instance
|
||||
# 2.1.4
|
||||
usage() {
|
||||
printf "Usage:\n %s -A -i <domR eth1 ip> -l <public-ip-address> -r <domr name> [-f] \n" $(basename $0) >&2
|
||||
printf " %s -D -i <domR eth1 ip> -l <public-ip-address> -r <domr name> [-f] \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
|
||||
check_gw() {
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
sleep 1
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
fi
|
||||
return $?;
|
||||
}
|
||||
|
||||
|
||||
check_gw "$domRIp"
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/root/ipassoc.sh $*"
|
||||
exit $?
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/bash
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# @VERSION@
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
domr=$1
|
||||
shift
|
||||
ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/opt/cloud/bin/vpn_l2tp.sh $*" >/dev/null
|
||||
|
||||
exit $?
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: networkUsage.sh 9879 2010-06-24 02:41:46Z anthony $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/hypervisor/xenserver/networkUsage.sh $
|
||||
# networkUsage.sh -- create iptable rules to gather network stats
|
||||
usage() {
|
||||
printf "Usage: %s -[c|g|r] -i <domR eth1 ip> [-[a|d] <public interface>]\n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
check_gw() {
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
sleep 1
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
fi
|
||||
return $?;
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
|
||||
while getopts 'cgri:a:d:' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
i) iflag=1
|
||||
domRIp="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ! check_gw "$domRIp"
|
||||
then
|
||||
printf "Unable to ping the routing domain, exiting\n" >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/root/netusage.sh $*"
|
||||
exit $?
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
|
@ -12,14 +12,11 @@
|
|||
#
|
||||
# Automatically generated by addcopyright.py at 04/03/2012
|
||||
|
||||
usage() {
|
||||
printf "Usage:\n %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
printf " %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
# used as a proxy to call script inside virtual router
|
||||
|
||||
#set -x
|
||||
|
||||
check_gw() {
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
|
|
@ -28,15 +25,30 @@ check_gw() {
|
|||
sleep 1
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
fi
|
||||
return $?;
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
|
||||
script=$1
|
||||
shift
|
||||
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
check_gw "$domRIp"
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/root/checkrouter.sh"
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/opt/cloud/bin/$script $*"
|
||||
exit $?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -139,21 +139,6 @@ def pingxenserver(session, args):
|
|||
txt = 'success'
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def ipassoc(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/ipassoc.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
txt = 'success'
|
||||
except:
|
||||
util.SMlog(" ip associate failed " )
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def vm_data(session, args):
|
||||
router_ip = args.pop('routerIP')
|
||||
|
|
@ -247,21 +232,6 @@ def saveDhcpEntry(session, args):
|
|||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def lt2p_vpn(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/l2tp_vpn.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
txt = 'success'
|
||||
except:
|
||||
util.SMlog("l2tp vpn failed " )
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def setLinkLocalIP(session, args):
|
||||
brName = args['brName']
|
||||
|
|
@ -307,6 +277,8 @@ def setLinkLocalIP(session, args):
|
|||
txt = 'success'
|
||||
return txt
|
||||
|
||||
|
||||
|
||||
@echo
|
||||
def setFirewallRule(session, args):
|
||||
sargs = args['args']
|
||||
|
|
@ -322,6 +294,24 @@ def setFirewallRule(session, args):
|
|||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def routerProxy(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/router_proxy.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
if txt is None or len(txt) == 0 :
|
||||
txt = 'success'
|
||||
except:
|
||||
util.SMlog("routerProxy command " + sargs + " failed " )
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
|
||||
|
||||
@echo
|
||||
def setLoadBalancerRule(session, args):
|
||||
sargs = args['args']
|
||||
|
|
@ -368,19 +358,6 @@ def deleteFile(session, args):
|
|||
return txt
|
||||
|
||||
|
||||
@echo
|
||||
def networkUsage(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/networkUsage.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
except:
|
||||
util.SMlog(" network usage error " )
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
def get_private_nic(session, args):
|
||||
vms = session.xenapi.VM.get_all()
|
||||
|
|
@ -1418,20 +1395,6 @@ def network_rules(session, args):
|
|||
except:
|
||||
util.SMlog("Failed to network rule !")
|
||||
|
||||
@echo
|
||||
def checkRouter(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/getRouterStatus.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
except:
|
||||
util.SMlog(" check router status fail! ")
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def bumpUpPriority(session, args):
|
||||
sargs = args['args']
|
||||
|
|
@ -1447,33 +1410,20 @@ def bumpUpPriority(session, args):
|
|||
|
||||
return txt
|
||||
|
||||
@echo
|
||||
def getDomRVersion(session, args):
|
||||
sargs = args['args']
|
||||
cmd = sargs.split(' ')
|
||||
cmd.insert(0, "/opt/xensource/bin/getDomRVersion.sh")
|
||||
cmd.insert(0, "/bin/bash")
|
||||
try:
|
||||
txt = util.pread2(cmd)
|
||||
except:
|
||||
util.SMlog(" get domR version fail! ")
|
||||
txt = ''
|
||||
|
||||
return txt
|
||||
|
||||
if __name__ == "__main__":
|
||||
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats,
|
||||
"getvncport": getvncport, "getgateway": getgateway, "preparemigration": preparemigration,
|
||||
"setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver,
|
||||
"ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword,
|
||||
"saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule,
|
||||
"vm_data": vm_data, "savePassword": savePassword,
|
||||
"saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "routerProxy": routerProxy,
|
||||
"setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile,
|
||||
"networkUsage": networkUsage, "network_rules":network_rules,
|
||||
"network_rules":network_rules,
|
||||
"can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules,
|
||||
"destroy_network_rules_for_vm":destroy_network_rules_for_vm,
|
||||
"default_network_rules_systemvm":default_network_rules_systemvm,
|
||||
"get_rule_logs_for_vms":get_rule_logs_for_vms,
|
||||
"setLinkLocalIP":setLinkLocalIP, "lt2p_vpn":lt2p_vpn,
|
||||
"cleanup_rules":cleanup_rules, "checkRouter":checkRouter,
|
||||
"bumpUpPriority":bumpUpPriority, "getDomRVersion":getDomRVersion,
|
||||
"setLinkLocalIP":setLinkLocalIP,
|
||||
"cleanup_rules":cleanup_rules,
|
||||
"bumpUpPriority":bumpUpPriority,
|
||||
"kill_copy_process":kill_copy_process})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# This file specifies the files that need
|
||||
#
|
||||
# to be transferred over to the XenServer.
|
||||
# The format of this file is as follows:
|
||||
# [Name of file]=[source path],[file permission],[destination path]
|
||||
|
|
@ -11,7 +12,6 @@
|
|||
# If [source path] does not start with '/' or '~', then it is relative path to the location of the patch file.
|
||||
NFSSR.py=/opt/xensource/sm
|
||||
vmops=..,0755,/etc/xapi.d/plugins
|
||||
ovsgre=..,0755,/etc/xapi.d/plugins
|
||||
ovstunnel=..,0755,/etc/xapi.d/plugins
|
||||
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
|
||||
hostvmstats.py=..,0755,/opt/xensource/sm
|
||||
|
|
@ -23,13 +23,11 @@ make_migratable.sh=..,0755,/opt/xensource/bin
|
|||
setup_iscsi.sh=..,0755,/opt/xensource/bin
|
||||
pingtest.sh=../../..,0755,/opt/xensource/bin
|
||||
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
networkUsage.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
cloud-setup-bonding.sh=..,0755,/opt/xensource/bin
|
||||
copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin
|
||||
copy_vhd_from_secondarystorage.sh=..,0755,/opt/xensource/bin
|
||||
|
|
|
|||
|
|
@ -22,13 +22,11 @@ setup_iscsi.sh=..,0755,/opt/xensource/bin
|
|||
cloud-setup-bonding.sh=..,0755,/opt/xensource/bin
|
||||
pingtest.sh=../../..,0755,/opt/xensource/bin
|
||||
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
networkUsage.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
l2tp_vpn.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
copy_vhd_to_secondarystorage.sh=..,0755,/opt/xensource/bin
|
||||
copy_vhd_from_secondarystorage.sh=..,0755,/opt/xensource/bin
|
||||
kill_copy_process.sh=..,0755,/opt/xensource/bin
|
||||
|
|
@ -44,8 +42,6 @@ create_privatetemplate_from_snapshot.sh=..,0755,/opt/xensource/bin
|
|||
upgrade_snapshot.sh=..,0755,/opt/xensource/bin
|
||||
cloud-clean-vlan.sh=..,0755,/opt/xensource/bin
|
||||
cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
|
||||
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
|
||||
swift=..,0755,/opt/xensource/bin
|
||||
swiftxen=..,0755,/etc/xapi.d/plugins
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue