mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
delete F5 and SRX plugins (#7023)
This commit is contained in:
parent
b392084950
commit
df96af3de4
@ -929,21 +929,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>srx</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>noredist</name>
|
||||
</property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-network-srx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>vmware</id>
|
||||
<activation>
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with 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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-plugin-network-f5</artifactId>
|
||||
<name>Apache CloudStack Plugin - F5</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.18.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.cloud.com.f5</groupId>
|
||||
<artifactId>icontrol</artifactId>
|
||||
<version>12.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-discovery</groupId>
|
||||
<artifactId>commons-discovery</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -1,118 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "addExternalLoadBalancer", description = "Adds F5 external load balancer appliance.", responseObject = ExternalLoadBalancerResponse.class,
|
||||
requestHasSensitiveInfo = true, responseHasSensitiveInfo = false)
|
||||
@Deprecated
|
||||
// API supported only for backward compatibility.
|
||||
public class AddExternalLoadBalancerCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AddExternalLoadBalancerCmd.class.getName());
|
||||
private static final String s_name = "addexternalloadbalancerresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = ZoneResponse.class,
|
||||
required = true,
|
||||
description = "Zone in which to add the external load balancer appliance.")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "URL of the external load balancer appliance.")
|
||||
private String url;
|
||||
|
||||
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Username of the external load balancer appliance.")
|
||||
private String username;
|
||||
|
||||
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "Password of the external load balancer appliance.")
|
||||
private String password;
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
Host externalLoadBalancer = _f5DeviceManagerService.addExternalLoadBalancer(this);
|
||||
ExternalLoadBalancerResponse response = _f5DeviceManagerService.createExternalLoadBalancerResponse(externalLoadBalancer);
|
||||
response.setObjectName("externalloadbalancer");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} catch (InvalidParameterValueException ipve) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
|
||||
} catch (CloudRuntimeException cre) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,143 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "addF5LoadBalancer", responseObject = F5LoadBalancerResponse.class, description = "Adds a F5 BigIP load balancer device",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class AddF5LoadBalancerCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(AddF5LoadBalancerCmd.class.getName());
|
||||
private static final String s_name = "addf5bigiploadbalancerresponse";
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = PhysicalNetworkResponse.class,
|
||||
required = true,
|
||||
description = "the Physical Network ID")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "URL of the F5 load balancer appliance.")
|
||||
private String url;
|
||||
|
||||
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Credentials to reach F5 BigIP load balancer device")
|
||||
private String username;
|
||||
|
||||
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "Credentials to reach F5 BigIP load balancer device")
|
||||
private String password;
|
||||
|
||||
@Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, required = true, description = "supports only F5BigIpLoadBalancer")
|
||||
private String deviceType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = _f5DeviceManagerService.addF5LoadBalancer(this);
|
||||
if (lbDeviceVO != null) {
|
||||
F5LoadBalancerResponse response = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
|
||||
response.setObjectName("f5loadbalancer");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add F5 Big IP load balancer due to internal error.");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Adding a F5 Big Ip load balancer device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_LB_DEVICE_ADD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
}
|
||||
@ -1,124 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "configureF5LoadBalancer", responseObject = F5LoadBalancerResponse.class, description = "configures a F5 load balancer device",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class ConfigureF5LoadBalancerCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ConfigureF5LoadBalancerCmd.class.getName());
|
||||
private static final String s_name = "configuref5Rloadbalancerresponse";
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.LOAD_BALANCER_DEVICE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = F5LoadBalancerResponse.class,
|
||||
required = true,
|
||||
description = "F5 load balancer device ID")
|
||||
private Long lbDeviceId;
|
||||
|
||||
@Parameter(name = ApiConstants.LOAD_BALANCER_DEVICE_CAPACITY,
|
||||
type = CommandType.LONG,
|
||||
required = false,
|
||||
description = "capacity of the device, Capacity will be interpreted as number of networks device can handle")
|
||||
private Long capacity;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getLoadBalancerDeviceId() {
|
||||
return lbDeviceId;
|
||||
}
|
||||
|
||||
public Long getLoadBalancerCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = _f5DeviceManagerService.configureF5LoadBalancer(this);
|
||||
if (lbDeviceVO != null) {
|
||||
F5LoadBalancerResponse response = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
|
||||
response.setObjectName("f5loadbalancer");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure F5 load balancer due to internal error.");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Configuring a F5 load balancer device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_LB_DEVICE_CONFIGURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
}
|
||||
@ -1,96 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "deleteExternalLoadBalancer", description = "Deletes a F5 external load balancer appliance added in a zone.", responseObject = SuccessResponse.class,
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@Deprecated
|
||||
// API supported for backward compatibility.
|
||||
public class DeleteExternalLoadBalancerCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteExternalLoadBalancerCmd.class.getName());
|
||||
private static final String s_name = "deleteexternalloadbalancerresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = HostResponse.class,
|
||||
required = true,
|
||||
description = "Id of the external loadbalancer appliance.")
|
||||
private Long id;
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
boolean result = _f5DeviceManagerService.deleteExternalLoadBalancer(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete external load balancer.");
|
||||
}
|
||||
} catch (InvalidParameterValueException e) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Failed to delete external load balancer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,112 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "deleteF5LoadBalancer", responseObject = SuccessResponse.class, description = " delete a F5 load balancer device",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class DeleteF5LoadBalancerCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteF5LoadBalancerCmd.class.getName());
|
||||
private static final String s_name = "deletef5loadbalancerresponse";
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.LOAD_BALANCER_DEVICE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = F5LoadBalancerResponse.class,
|
||||
required = true,
|
||||
description = "netscaler load balancer device ID")
|
||||
private Long lbDeviceId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getLoadBalancerDeviceId() {
|
||||
return lbDeviceId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
boolean result = _f5DeviceManagerService.deleteF5LoadBalancer(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete F5 load balancer.");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Deleting a F5 load balancer device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_LOAD_BALANCER_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
}
|
||||
@ -1,90 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
|
||||
@APICommand(name = "listExternalLoadBalancers", description = "Lists F5 external load balancer appliances added in a zone.", responseObject = HostResponse.class,
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@Deprecated
|
||||
// API supported for backward compatibility.
|
||||
public class ListExternalLoadBalancersCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListExternalLoadBalancersCmd.class.getName());
|
||||
private static final String s_name = "listexternalloadbalancersresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "zone Id")
|
||||
private long zoneId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
List<? extends Host> externalLoadBalancers = _f5DeviceManagerService.listExternalLoadBalancers(this);
|
||||
ListResponse<ExternalLoadBalancerResponse> listResponse = new ListResponse<ExternalLoadBalancerResponse>();
|
||||
List<ExternalLoadBalancerResponse> responses = new ArrayList<ExternalLoadBalancerResponse>();
|
||||
for (Host externalLoadBalancer : externalLoadBalancers) {
|
||||
ExternalLoadBalancerResponse response = _f5DeviceManagerService.createExternalLoadBalancerResponse(externalLoadBalancer);
|
||||
response.setObjectName("externalloadbalancer");
|
||||
response.setResponseName(getCommandName());
|
||||
responses.add(response);
|
||||
}
|
||||
|
||||
listResponse.setResponses(responses);
|
||||
listResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(listResponse);
|
||||
}
|
||||
}
|
||||
@ -1,108 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ResponseObject.ResponseView;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "listF5LoadBalancerNetworks", responseObject = NetworkResponse.class, description = "lists network that are using a F5 load balancer device",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class ListF5LoadBalancerNetworksCmd extends BaseListCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ListF5LoadBalancerNetworksCmd.class.getName());
|
||||
private static final String s_name = "listf5loadbalancernetworksresponse";
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.LOAD_BALANCER_DEVICE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = F5LoadBalancerResponse.class,
|
||||
required = true,
|
||||
description = "f5 load balancer device ID")
|
||||
private Long lbDeviceId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getLoadBalancerDeviceId() {
|
||||
return lbDeviceId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
List<? extends Network> networks = _f5DeviceManagerService.listNetworks(this);
|
||||
ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
|
||||
List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
|
||||
|
||||
if (networks != null && !networks.isEmpty()) {
|
||||
for (Network network : networks) {
|
||||
NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network);
|
||||
networkResponses.add(networkResponse);
|
||||
}
|
||||
}
|
||||
|
||||
response.setResponses(networkResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
}
|
||||
@ -1,112 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "listF5LoadBalancers", responseObject = F5LoadBalancerResponse.class, description = "lists F5 load balancer devices",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class ListF5LoadBalancersCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListF5LoadBalancersCmd.class.getName());
|
||||
private static final String s_name = "listf5loadbalancerresponse";
|
||||
@Inject
|
||||
F5ExternalLoadBalancerElementService _f5DeviceManagerService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name = ApiConstants.LOAD_BALANCER_DEVICE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = F5LoadBalancerResponse.class,
|
||||
description = "f5 load balancer device ID")
|
||||
private Long lbDeviceId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getLoadBalancerDeviceId() {
|
||||
return lbDeviceId;
|
||||
}
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
List<ExternalLoadBalancerDeviceVO> lbDevices = _f5DeviceManagerService.listF5LoadBalancers(this);
|
||||
ListResponse<F5LoadBalancerResponse> response = new ListResponse<F5LoadBalancerResponse>();
|
||||
List<F5LoadBalancerResponse> lbDevicesResponse = new ArrayList<F5LoadBalancerResponse>();
|
||||
|
||||
if (lbDevices != null && !lbDevices.isEmpty()) {
|
||||
for (ExternalLoadBalancerDeviceVO lbDeviceVO : lbDevices) {
|
||||
F5LoadBalancerResponse lbdeviceResponse = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
|
||||
lbDevicesResponse.add(lbdeviceResponse);
|
||||
}
|
||||
}
|
||||
|
||||
response.setResponses(lbDevicesResponse);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
}
|
||||
@ -1,109 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
@EntityReference(value = ExternalLoadBalancerDeviceVO.class)
|
||||
public class F5LoadBalancerResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.LOAD_BALANCER_DEVICE_ID)
|
||||
@Param(description = "device id of the F5 load balancer")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
|
||||
@Param(description = "the physical network to which this F5 device belongs to")
|
||||
private String physicalNetworkId;
|
||||
|
||||
@SerializedName(ApiConstants.PROVIDER)
|
||||
@Param(description = "name of the provider")
|
||||
private String providerName;
|
||||
|
||||
@SerializedName(ApiConstants.LOAD_BALANCER_DEVICE_NAME)
|
||||
@Param(description = "device name")
|
||||
private String deviceName;
|
||||
|
||||
@SerializedName(ApiConstants.LOAD_BALANCER_DEVICE_STATE)
|
||||
@Param(description = "device state")
|
||||
private String deviceState;
|
||||
|
||||
@SerializedName(ApiConstants.LOAD_BALANCER_DEVICE_CAPACITY)
|
||||
@Param(description = "device capacity")
|
||||
private Long deviceCapacity;
|
||||
|
||||
@SerializedName(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED)
|
||||
@Param(description = "true if device is dedicated for an account")
|
||||
private Boolean dedicatedLoadBalancer;
|
||||
|
||||
@SerializedName(ApiConstants.PUBLIC_INTERFACE)
|
||||
@Param(description = "the public interface of the load balancer")
|
||||
private String publicInterface;
|
||||
|
||||
@SerializedName(ApiConstants.PRIVATE_INTERFACE)
|
||||
@Param(description = "the private interface of the load balancer")
|
||||
private String privateInterface;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS)
|
||||
@Param(description = "the management IP address of the external load balancer")
|
||||
private String ipAddress;
|
||||
|
||||
public void setId(String lbDeviceId) {
|
||||
this.id = lbDeviceId;
|
||||
}
|
||||
|
||||
public void setPhysicalNetworkId(String physicalNetworkId) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
public void setProvider(String provider) {
|
||||
this.providerName = provider;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceCapacity(long deviceCapacity) {
|
||||
this.deviceCapacity = deviceCapacity;
|
||||
}
|
||||
|
||||
public void setDeviceState(String deviceState) {
|
||||
this.deviceState = deviceState;
|
||||
}
|
||||
|
||||
public void setDedicatedLoadBalancer(boolean isDedicated) {
|
||||
this.dedicatedLoadBalancer = isDedicated;
|
||||
}
|
||||
|
||||
public void setPublicInterface(String publicInterface) {
|
||||
this.publicInterface = publicInterface;
|
||||
}
|
||||
|
||||
public void setPrivateInterface(String privateInterface) {
|
||||
this.privateInterface = privateInterface;
|
||||
}
|
||||
|
||||
public void setIpAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
}
|
||||
@ -1,538 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
|
||||
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.commands.AddExternalLoadBalancerCmd;
|
||||
import com.cloud.api.commands.AddF5LoadBalancerCmd;
|
||||
import com.cloud.api.commands.ConfigureF5LoadBalancerCmd;
|
||||
import com.cloud.api.commands.DeleteExternalLoadBalancerCmd;
|
||||
import com.cloud.api.commands.DeleteF5LoadBalancerCmd;
|
||||
import com.cloud.api.commands.ListExternalLoadBalancersCmd;
|
||||
import com.cloud.api.commands.ListF5LoadBalancerNetworksCmd;
|
||||
import com.cloud.api.commands.ListF5LoadBalancersCmd;
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceManager;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceState;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.resource.F5BigIpResource;
|
||||
import com.cloud.network.rules.LbStickinessMethod;
|
||||
import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
|
||||
import com.cloud.network.rules.LoadBalancerContainer;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, IpDeployer,
|
||||
F5ExternalLoadBalancerElementService, ExternalLoadBalancerDeviceManager {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(F5ExternalLoadBalancerElement.class);
|
||||
|
||||
@Inject
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
ExternalLoadBalancerDeviceDao _lbDeviceDao;
|
||||
@Inject
|
||||
NetworkExternalLoadBalancerDao _networkLBDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
HostDetailsDao _detailsDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
private boolean canHandle(Network config, List<LoadBalancingRule> rules) {
|
||||
if ((config.getGuestType() != Network.GuestType.Isolated && config.getGuestType() != Network.GuestType.Shared) || config.getTrafficType() != TrafficType.Guest) {
|
||||
|
||||
s_logger.trace("Not handling network with Type " + config.getGuestType() + " and traffic type " + config.getTrafficType());
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
|
||||
if (!lbCaps.isEmpty()) {
|
||||
String schemeCaps = lbCaps.get(Capability.LbSchemes);
|
||||
if (schemeCaps != null && rules != null && !rules.isEmpty()) {
|
||||
for (LoadBalancingRule rule : rules) {
|
||||
if (!schemeCaps.contains(rule.getScheme().toString())) {
|
||||
s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported by the provider " + this.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) && _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb,
|
||||
Network.Provider.F5BigIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException,
|
||||
ConcurrentOperationException, InsufficientNetworkCapacityException {
|
||||
|
||||
if (!canHandle(guestConfig, null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return manageGuestNetworkWithExternalLoadBalancer(true, guestConfig);
|
||||
} catch (InsufficientCapacityException capacityException) {
|
||||
throw new ResourceUnavailableException("There are no F5 load balancer devices with the free capacity for implementing this network", DataCenter.class,
|
||||
guestConfig.getDataCenterId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(Network config, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network guestConfig, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
if (!canHandle(guestConfig, null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return manageGuestNetworkWithExternalLoadBalancer(false, guestConfig);
|
||||
} catch (InsufficientCapacityException capacityException) {
|
||||
// TODO: handle out of capacity exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroy(Network config, ReservationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateLBRule(Network network, LoadBalancingRule rule) {
|
||||
if (canHandle(network, new ArrayList<LoadBalancingRule>(Arrays.asList(rule)))) {
|
||||
String algo = rule.getAlgorithm();
|
||||
return (algo.equals("roundrobin") || algo.equals("leastconn"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyLBRules(Network config, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
|
||||
if (!canHandle(config, rules)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return applyLoadBalancerRules(config, rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Service, Map<Capability, String>> getCapabilities() {
|
||||
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
|
||||
// Set capabilities for LB service
|
||||
Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
|
||||
|
||||
// Specifies that the RoundRobin and Leastconn algorithms are supported for load balancing rules
|
||||
lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn");
|
||||
|
||||
// specifies that F5 BIG IP network element can provide shared mode only
|
||||
lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated, shared");
|
||||
|
||||
// Specifies that load balancing rules can be made for either TCP or UDP traffic
|
||||
lbCapabilities.put(Capability.SupportedProtocols, "tcp,udp");
|
||||
|
||||
// Specifies that this element can measure network usage on a per public IP basis
|
||||
lbCapabilities.put(Capability.TrafficStatistics, "per public ip");
|
||||
|
||||
// Specifies that load balancing rules can only be made with public IPs that aren't source NAT IPs
|
||||
lbCapabilities.put(Capability.LoadBalancingSupportedIps, "additional");
|
||||
|
||||
// Support inline mode with firewall
|
||||
lbCapabilities.put(Capability.InlineMode, "true");
|
||||
|
||||
//support only for public lb
|
||||
lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
|
||||
|
||||
LbStickinessMethod method;
|
||||
List<LbStickinessMethod> methodList = new ArrayList<LbStickinessMethod>();
|
||||
method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is cookie based sticky method, can be used only for http");
|
||||
methodList.add(method);
|
||||
method.addParam("holdtime", false, "time period (in seconds) for which persistence is in effect.", false);
|
||||
|
||||
Gson gson = new Gson();
|
||||
String stickyMethodList = gson.toJson(methodList);
|
||||
lbCapabilities.put(Capability.SupportedStickinessMethods, stickyMethodList);
|
||||
|
||||
capabilities.put(Service.Lb, lbCapabilities);
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Provider getProvider() {
|
||||
return Provider.F5BigIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady(PhysicalNetworkServiceProvider provider) {
|
||||
List<ExternalLoadBalancerDeviceVO> lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), Provider.F5BigIp.getName());
|
||||
|
||||
// true if at-least one F5 device is added in to physical network and is in configured (in enabled state) state
|
||||
if (lbDevices != null && !lbDevices.isEmpty()) {
|
||||
for (ExternalLoadBalancerDeviceVO lbDevice : lbDevices) {
|
||||
if (lbDevice.getState() == LBDeviceState.Enabled) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEnableIndividualServices() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||
cmdList.add(AddExternalLoadBalancerCmd.class);
|
||||
cmdList.add(AddF5LoadBalancerCmd.class);
|
||||
cmdList.add(ConfigureF5LoadBalancerCmd.class);
|
||||
cmdList.add(DeleteExternalLoadBalancerCmd.class);
|
||||
cmdList.add(DeleteF5LoadBalancerCmd.class);
|
||||
cmdList.add(ListExternalLoadBalancersCmd.class);
|
||||
cmdList.add(ListF5LoadBalancerNetworksCmd.class);
|
||||
cmdList.add(ListF5LoadBalancersCmd.class);
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Host addExternalLoadBalancer(AddExternalLoadBalancerCmd cmd) {
|
||||
Long zoneId = cmd.getZoneId();
|
||||
DataCenterVO zone = null;
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = null;
|
||||
HostVO lbHost = null;
|
||||
|
||||
zone = _dcDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
|
||||
}
|
||||
|
||||
List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
|
||||
if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
|
||||
throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: " + zoneId +
|
||||
" to add this device.");
|
||||
}
|
||||
pNetwork = physicalNetworks.get(0);
|
||||
|
||||
String deviceType = NetworkDevice.F5BigIpLoadBalancer.getName();
|
||||
lbDeviceVO = addExternalLoadBalancer(pNetwork.getId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(),
|
||||
deviceType, new F5BigIpResource(), false, false, null, null);
|
||||
|
||||
if (lbDeviceVO != null) {
|
||||
lbHost = _hostDao.findById(lbDeviceVO.getHostId());
|
||||
}
|
||||
|
||||
return lbHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean deleteExternalLoadBalancer(DeleteExternalLoadBalancerCmd cmd) {
|
||||
return deleteExternalLoadBalancer(cmd.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Host> listExternalLoadBalancers(ListExternalLoadBalancersCmd cmd) {
|
||||
Long zoneId = cmd.getZoneId();
|
||||
DataCenterVO zone = null;
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
|
||||
if (zoneId != null) {
|
||||
zone = _dcDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
|
||||
}
|
||||
|
||||
List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
|
||||
if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
|
||||
throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: " + zoneId +
|
||||
" to add this device.");
|
||||
}
|
||||
pNetwork = physicalNetworks.get(0);
|
||||
return listExternalLoadBalancers(pNetwork.getId(), NetworkDevice.F5BigIpLoadBalancer.getName());
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Zone Id must be specified to list the external load balancers");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ExternalLoadBalancerResponse createExternalLoadBalancerResponse(Host externalLb) {
|
||||
return super.createExternalLoadBalancerResponse(externalLb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalLoadBalancerDeviceVO addF5LoadBalancer(AddF5LoadBalancerCmd cmd) {
|
||||
String deviceName = cmd.getDeviceType();
|
||||
if (!deviceName.equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
|
||||
throw new InvalidParameterValueException("Invalid F5 load balancer device type");
|
||||
}
|
||||
|
||||
return addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(),
|
||||
deviceName, new F5BigIpResource(), false, false, null,
|
||||
null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteF5LoadBalancer(DeleteF5LoadBalancerCmd cmd) {
|
||||
Long lbDeviceId = cmd.getLoadBalancerDeviceId();
|
||||
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
|
||||
if ((lbDeviceVo == null) || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
|
||||
throw new InvalidParameterValueException("No F5 load balancer device found with ID: " + lbDeviceId);
|
||||
}
|
||||
|
||||
return deleteExternalLoadBalancer(lbDeviceVo.getHostId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalLoadBalancerDeviceVO configureF5LoadBalancer(ConfigureF5LoadBalancerCmd cmd) {
|
||||
Long lbDeviceId = cmd.getLoadBalancerDeviceId();
|
||||
Long capacity = cmd.getLoadBalancerCapacity();
|
||||
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
|
||||
if ((lbDeviceVo == null) || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
|
||||
throw new InvalidParameterValueException("No F5 load balancer device found with ID: " + lbDeviceId);
|
||||
}
|
||||
|
||||
if (capacity != null) {
|
||||
// check if any networks are using this F5 device
|
||||
List<NetworkExternalLoadBalancerVO> networks = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
|
||||
if ((networks != null) && !networks.isEmpty()) {
|
||||
if (capacity < networks.size()) {
|
||||
throw new CloudRuntimeException("There are more number of networks already using this F5 device than configured capacity");
|
||||
}
|
||||
}
|
||||
if (capacity != null) {
|
||||
lbDeviceVo.setCapacity(capacity);
|
||||
}
|
||||
}
|
||||
|
||||
lbDeviceVo.setState(LBDeviceState.Enabled);
|
||||
_lbDeviceDao.update(lbDeviceId, lbDeviceVo);
|
||||
return lbDeviceVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExternalLoadBalancerDeviceVO> listF5LoadBalancers(ListF5LoadBalancersCmd cmd) {
|
||||
Long physcialNetworkId = cmd.getPhysicalNetworkId();
|
||||
Long lbDeviceId = cmd.getLoadBalancerDeviceId();
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
List<ExternalLoadBalancerDeviceVO> lbDevices = new ArrayList<ExternalLoadBalancerDeviceVO>();
|
||||
|
||||
if (physcialNetworkId == null && lbDeviceId == null) {
|
||||
throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
|
||||
}
|
||||
|
||||
if (lbDeviceId != null) {
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
|
||||
if (lbDeviceVo == null || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
|
||||
throw new InvalidParameterValueException("Could not find F5 load balancer device with ID: " + lbDeviceId);
|
||||
}
|
||||
lbDevices.add(lbDeviceVo);
|
||||
return lbDevices;
|
||||
}
|
||||
|
||||
if (physcialNetworkId != null) {
|
||||
pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
|
||||
if (pNetwork == null) {
|
||||
throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
|
||||
}
|
||||
lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.F5BigIp.getName());
|
||||
return lbDevices;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Network> listNetworks(ListF5LoadBalancerNetworksCmd cmd) {
|
||||
Long lbDeviceId = cmd.getLoadBalancerDeviceId();
|
||||
List<NetworkVO> networks = new ArrayList<NetworkVO>();
|
||||
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
|
||||
if (lbDeviceVo == null || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
|
||||
throw new InvalidParameterValueException("Could not find F5 load balancer device with ID " + lbDeviceId);
|
||||
}
|
||||
|
||||
List<NetworkExternalLoadBalancerVO> networkLbMaps = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
|
||||
if (networkLbMaps != null && !networkLbMaps.isEmpty()) {
|
||||
for (NetworkExternalLoadBalancerVO networkLbMap : networkLbMaps) {
|
||||
NetworkVO network = _networkDao.findById(networkLbMap.getNetworkId());
|
||||
networks.add(network);
|
||||
}
|
||||
}
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public F5LoadBalancerResponse createF5LoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO) {
|
||||
F5LoadBalancerResponse response = new F5LoadBalancerResponse();
|
||||
Host lbHost = _hostDao.findById(lbDeviceVO.getHostId());
|
||||
Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVO.getHostId());
|
||||
|
||||
response.setId(lbDeviceVO.getUuid());
|
||||
response.setIpAddress(lbHost.getPrivateIpAddress());
|
||||
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(lbDeviceVO.getPhysicalNetworkId());
|
||||
if (pnw != null) {
|
||||
response.setPhysicalNetworkId(pnw.getUuid());
|
||||
}
|
||||
response.setPublicInterface(lbDetails.get("publicInterface"));
|
||||
response.setPrivateInterface(lbDetails.get("privateInterface"));
|
||||
response.setDeviceName(lbDeviceVO.getDeviceName());
|
||||
if (lbDeviceVO.getCapacity() == 0) {
|
||||
long defaultLbCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalLoadBalancerCapacity.key()), 50);
|
||||
response.setDeviceCapacity(defaultLbCapacity);
|
||||
} else {
|
||||
response.setDeviceCapacity(lbDeviceVO.getCapacity());
|
||||
}
|
||||
response.setDedicatedLoadBalancer(lbDeviceVO.getIsDedicatedDevice());
|
||||
response.setProvider(lbDeviceVO.getProviderName());
|
||||
response.setDeviceState(lbDeviceVO.getState().name());
|
||||
response.setObjectName("f5loadbalancer");
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> service) throws ResourceUnavailableException {
|
||||
// return true, as IP will be associated as part of LB rule configuration
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpDeployer getIpDeployer(Network network) {
|
||||
ExternalLoadBalancerDeviceVO lbDevice = getExternalLoadBalancerForNetwork(network);
|
||||
if (lbDevice == null) {
|
||||
s_logger.error("Cannot find external load balanacer for network " + network.getName());
|
||||
s_logger.error("Make F5 as dummy ip deployer, since we likely met this when clean up resource after shutdown network");
|
||||
return this;
|
||||
}
|
||||
if (_networkManager.isNetworkInlineMode(network)) {
|
||||
return getIpDeployerForInlineMode(network);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoadBalancerTO> updateHealthChecks(Network network, List<LoadBalancingRule> lbrules) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlesOnlyRulesInTransitionState() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,97 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
|
||||
|
||||
import com.cloud.api.commands.AddExternalLoadBalancerCmd;
|
||||
import com.cloud.api.commands.AddF5LoadBalancerCmd;
|
||||
import com.cloud.api.commands.ConfigureF5LoadBalancerCmd;
|
||||
import com.cloud.api.commands.DeleteExternalLoadBalancerCmd;
|
||||
import com.cloud.api.commands.DeleteF5LoadBalancerCmd;
|
||||
import com.cloud.api.commands.ListExternalLoadBalancersCmd;
|
||||
import com.cloud.api.commands.ListF5LoadBalancerNetworksCmd;
|
||||
import com.cloud.api.commands.ListF5LoadBalancersCmd;
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface F5ExternalLoadBalancerElementService extends PluggableService {
|
||||
|
||||
/**
|
||||
* adds a F5 load balancer device in to a physical network
|
||||
* @param AddF5LoadBalancerCmd
|
||||
* @return ExternalLoadBalancerDeviceVO object for the device added
|
||||
*/
|
||||
public ExternalLoadBalancerDeviceVO addF5LoadBalancer(AddF5LoadBalancerCmd cmd);
|
||||
|
||||
/**
|
||||
* removes a F5 load balancer device from a physical network
|
||||
* @param DeleteF5LoadBalancerCmd
|
||||
* @return true if F5 load balancer device is successfully deleted
|
||||
*/
|
||||
public boolean deleteF5LoadBalancer(DeleteF5LoadBalancerCmd cmd);
|
||||
|
||||
/**
|
||||
* configures a F5 load balancer device added in a physical network
|
||||
* @param ConfigureF5LoadBalancerCmd
|
||||
* @return ExternalLoadBalancerDeviceVO for the device configured
|
||||
*/
|
||||
public ExternalLoadBalancerDeviceVO configureF5LoadBalancer(ConfigureF5LoadBalancerCmd cmd);
|
||||
|
||||
/**
|
||||
* lists all the load balancer devices added in to a physical network
|
||||
* @param ListF5LoadBalancersCmd
|
||||
* @return list of ExternalLoadBalancerDeviceVO for the devices in the physical network.
|
||||
*/
|
||||
public List<ExternalLoadBalancerDeviceVO> listF5LoadBalancers(ListF5LoadBalancersCmd cmd);
|
||||
|
||||
/**
|
||||
* lists all the guest networks using a F5 load balancer device
|
||||
* @param ListF5LoadBalancerNetworksCmd
|
||||
* @return list of the guest networks that are using this F5 load balancer
|
||||
*/
|
||||
public List<? extends Network> listNetworks(ListF5LoadBalancerNetworksCmd cmd);
|
||||
|
||||
public F5LoadBalancerResponse createF5LoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO);
|
||||
|
||||
/* Deprecated API helper function */
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
Host addExternalLoadBalancer(AddExternalLoadBalancerCmd cmd);
|
||||
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
boolean deleteExternalLoadBalancer(DeleteExternalLoadBalancerCmd cmd);
|
||||
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
List<Host> listExternalLoadBalancers(ListExternalLoadBalancersCmd cmd);
|
||||
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
ExternalLoadBalancerResponse createExternalLoadBalancerResponse(Host externalLb);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,18 +0,0 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with 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.
|
||||
name=f5
|
||||
parent=network
|
||||
@ -1,34 +0,0 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd"
|
||||
>
|
||||
|
||||
<bean id="F5BigIP" class="com.cloud.network.element.F5ExternalLoadBalancerElement">
|
||||
<property name="name" value="F5BigIP" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -1,37 +0,0 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with 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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-plugin-network-srx</artifactId>
|
||||
<name>Apache CloudStack Plugin - Juniper SRX</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.18.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.cloud.com.f5</groupId>
|
||||
<artifactId>icontrol</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -1,110 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ExternalFirewallResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "addExternalFirewall", description = "Adds an external firewall appliance", responseObject = ExternalFirewallResponse.class,
|
||||
requestHasSensitiveInfo = true, responseHasSensitiveInfo = false)
|
||||
public class AddExternalFirewallCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AddExternalFirewallCmd.class.getName());
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = ZoneResponse.class,
|
||||
required = true,
|
||||
description = "Zone in which to add the external firewall appliance.")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "URL of the external firewall appliance.")
|
||||
private String url;
|
||||
|
||||
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Username of the external firewall appliance.")
|
||||
private String username;
|
||||
|
||||
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "Password of the external firewall appliance.")
|
||||
private String password;
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxElementService;
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
Host externalFirewall = _srxElementService.addExternalFirewall(this);
|
||||
ExternalFirewallResponse response = _srxElementService.createExternalFirewallResponse(externalFirewall);
|
||||
response.setObjectName("externalfirewall");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} catch (InvalidParameterValueException ipve) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
|
||||
} catch (CloudRuntimeException cre) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,135 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.api.response.SrxFirewallResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "addSrxFirewall", responseObject = SrxFirewallResponse.class, description = "Adds a SRX firewall device",
|
||||
requestHasSensitiveInfo = true, responseHasSensitiveInfo = false)
|
||||
public class AddSrxFirewallCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AddSrxFirewallCmd.class.getName());
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxFwService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = PhysicalNetworkResponse.class,
|
||||
required = true,
|
||||
description = "the Physical Network ID")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "URL of the SRX appliance.")
|
||||
private String url;
|
||||
|
||||
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Credentials to reach SRX firewall device")
|
||||
private String username;
|
||||
|
||||
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "Credentials to reach SRX firewall device")
|
||||
private String password;
|
||||
|
||||
@Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, required = true, description = "supports only JuniperSRXFirewall")
|
||||
private String deviceType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
ExternalFirewallDeviceVO fwDeviceVO = _srxFwService.addSrxFirewall(this);
|
||||
if (fwDeviceVO != null) {
|
||||
SrxFirewallResponse response = _srxFwService.createSrxFirewallResponse(fwDeviceVO);
|
||||
response.setObjectName("srxfirewall");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add SRX firewall due to internal error.");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Adding a SRX firewall device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_FIREWALL_DEVICE_ADD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
}
|
||||
@ -1,117 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.api.response.SrxFirewallResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "configureSrxFirewall", responseObject = SrxFirewallResponse.class, description = "Configures a SRX firewall device",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class ConfigureSrxFirewallCmd extends BaseAsyncCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ConfigureSrxFirewallCmd.class.getName());
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxFwService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.FIREWALL_DEVICE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = SrxFirewallResponse.class,
|
||||
required = true,
|
||||
description = "SRX firewall device ID")
|
||||
private Long fwDeviceId;
|
||||
|
||||
@Parameter(name = ApiConstants.FIREWALL_DEVICE_CAPACITY,
|
||||
type = CommandType.LONG,
|
||||
required = false,
|
||||
description = "capacity of the firewall device, Capacity will be interpreted as number of networks device can handle")
|
||||
private Long capacity;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getFirewallDeviceId() {
|
||||
return fwDeviceId;
|
||||
}
|
||||
|
||||
public Long getFirewallCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
ExternalFirewallDeviceVO fwDeviceVO = _srxFwService.configureSrxFirewall(this);
|
||||
if (fwDeviceVO != null) {
|
||||
SrxFirewallResponse response = _srxFwService.createSrxFirewallResponse(fwDeviceVO);
|
||||
response.setObjectName("srxfirewall");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure SRX firewall device due to internal error.");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Configuring a SRX firewall device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_FIREWALL_DEVICE_CONFIGURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "deleteExternalFirewall", description = "Deletes an external firewall appliance.", responseObject = SuccessResponse.class,
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class DeleteExternalFirewallCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteExternalFirewallCmd.class.getName());
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = HostResponse.class, required = true, description = "Id of the external firewall appliance.")
|
||||
private Long id;
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxElementService;
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
boolean result = _srxElementService.deleteExternalFirewall(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete external firewall.");
|
||||
}
|
||||
} catch (InvalidParameterValueException e) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Failed to delete external firewall.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.api.response.SrxFirewallResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "deleteSrxFirewall", responseObject = SuccessResponse.class, description = " delete a SRX firewall device",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class DeleteSrxFirewallCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteSrxFirewallCmd.class.getName());
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxElementService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.FIREWALL_DEVICE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = SrxFirewallResponse.class,
|
||||
required = true,
|
||||
description = "srx firewall device ID")
|
||||
private Long fwDeviceId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getFirewallDeviceId() {
|
||||
return fwDeviceId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
boolean result = _srxElementService.deleteSrxFirewall(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete SRX firewall device");
|
||||
}
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Deleting SRX firewall device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_EXTERNAL_FIREWALL_DEVICE_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ExternalFirewallResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
|
||||
@APICommand(name = "listExternalFirewalls", description = "List external firewall appliances.", responseObject = ExternalFirewallResponse.class,
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class ListExternalFirewallsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListExternalFirewallsCmd.class.getName());
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "zone Id")
|
||||
private long zoneId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxElementService;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
List<? extends Host> externalFirewalls = _srxElementService.listExternalFirewalls(this);
|
||||
|
||||
ListResponse<ExternalFirewallResponse> listResponse = new ListResponse<ExternalFirewallResponse>();
|
||||
List<ExternalFirewallResponse> responses = new ArrayList<ExternalFirewallResponse>();
|
||||
for (Host externalFirewall : externalFirewalls) {
|
||||
ExternalFirewallResponse response = _srxElementService.createExternalFirewallResponse(externalFirewall);
|
||||
response.setObjectName("externalfirewall");
|
||||
response.setResponseName(getCommandName());
|
||||
responses.add(response);
|
||||
}
|
||||
|
||||
listResponse.setResponses(responses);
|
||||
listResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(listResponse);
|
||||
}
|
||||
}
|
||||
@ -1,102 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ResponseObject.ResponseView;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
|
||||
import com.cloud.api.response.SrxFirewallResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "listSrxFirewallNetworks", responseObject = NetworkResponse.class, description = "lists network that are using SRX firewall device",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class ListSrxFirewallNetworksCmd extends BaseListCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ListSrxFirewallNetworksCmd.class.getName());
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxFwService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.LOAD_BALANCER_DEVICE_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = SrxFirewallResponse.class,
|
||||
required = true,
|
||||
description = "netscaler load balancer device ID")
|
||||
private Long fwDeviceId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getFirewallDeviceId() {
|
||||
return fwDeviceId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
List<? extends Network> networks = _srxFwService.listNetworks(this);
|
||||
ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
|
||||
List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
|
||||
|
||||
if (networks != null && !networks.isEmpty()) {
|
||||
for (Network network : networks) {
|
||||
NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network);
|
||||
networkResponses.add(networkResponse);
|
||||
}
|
||||
}
|
||||
|
||||
response.setResponses(networkResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,109 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
|
||||
import com.cloud.api.response.SrxFirewallResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO;
|
||||
import com.cloud.network.element.JuniperSRXFirewallElementService;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "listSrxFirewalls", responseObject = SrxFirewallResponse.class, description = "lists SRX firewall devices in a physical network",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class ListSrxFirewallsCmd extends BaseListCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(ListSrxFirewallsCmd.class.getName());
|
||||
private static final String s_name = "listsrxfirewallresponse";
|
||||
@Inject
|
||||
JuniperSRXFirewallElementService _srxFwService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name = ApiConstants.FIREWALL_DEVICE_ID, type = CommandType.UUID, entityType = SrxFirewallResponse.class, description = "SRX firewall device ID")
|
||||
private Long fwDeviceId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getFirewallDeviceId() {
|
||||
return fwDeviceId;
|
||||
}
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException {
|
||||
try {
|
||||
List<ExternalFirewallDeviceVO> fwDevices = _srxFwService.listSrxFirewalls(this);
|
||||
ListResponse<SrxFirewallResponse> response = new ListResponse<SrxFirewallResponse>();
|
||||
List<SrxFirewallResponse> fwDevicesResponse = new ArrayList<SrxFirewallResponse>();
|
||||
|
||||
if (fwDevices != null && !fwDevices.isEmpty()) {
|
||||
for (ExternalFirewallDeviceVO fwDeviceVO : fwDevices) {
|
||||
SrxFirewallResponse lbdeviceResponse = _srxFwService.createSrxFirewallResponse(fwDeviceVO);
|
||||
fwDevicesResponse.add(lbdeviceResponse);
|
||||
}
|
||||
}
|
||||
|
||||
response.setResponses(fwDevicesResponse);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
||||
} catch (CloudRuntimeException runtimeExcp) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
}
|
||||
@ -1,159 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
@EntityReference(value = ExternalFirewallDeviceVO.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class SrxFirewallResponse extends BaseResponse {
|
||||
|
||||
@SerializedName(ApiConstants.FIREWALL_DEVICE_ID)
|
||||
@Param(description = "device id of the SRX firewall")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
|
||||
@Param(description = "the physical network to which this SRX firewall belongs to")
|
||||
private String physicalNetworkId;
|
||||
|
||||
@SerializedName(ApiConstants.PROVIDER)
|
||||
@Param(description = "name of the provider")
|
||||
private String providerName;
|
||||
|
||||
@SerializedName(ApiConstants.FIREWALL_DEVICE_NAME)
|
||||
@Param(description = "device name")
|
||||
private String deviceName;
|
||||
|
||||
@SerializedName(ApiConstants.FIREWALL_DEVICE_STATE)
|
||||
@Param(description = "device state")
|
||||
private String deviceState;
|
||||
|
||||
@SerializedName(ApiConstants.FIREWALL_DEVICE_CAPACITY)
|
||||
@Param(description = "device capacity")
|
||||
private Long deviceCapacity;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID)
|
||||
@Param(description = "the zone ID of the external firewall")
|
||||
private String zoneId;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS)
|
||||
@Param(description = "the management IP address of the external firewall")
|
||||
private String ipAddress;
|
||||
|
||||
@SerializedName(ApiConstants.USERNAME)
|
||||
@Param(description = "the username that's used to log in to the external firewall")
|
||||
private String username;
|
||||
|
||||
@SerializedName(ApiConstants.PUBLIC_INTERFACE)
|
||||
@Param(description = "the public interface of the external firewall")
|
||||
private String publicInterface;
|
||||
|
||||
@SerializedName(ApiConstants.USAGE_INTERFACE)
|
||||
@Param(description = "the usage interface of the external firewall")
|
||||
private String usageInterface;
|
||||
|
||||
@SerializedName(ApiConstants.PRIVATE_INTERFACE)
|
||||
@Param(description = "the private interface of the external firewall")
|
||||
private String privateInterface;
|
||||
|
||||
@SerializedName(ApiConstants.PUBLIC_ZONE)
|
||||
@Param(description = "the public security zone of the external firewall")
|
||||
private String publicZone;
|
||||
|
||||
@SerializedName(ApiConstants.PRIVATE_ZONE)
|
||||
@Param(description = "the private security zone of the external firewall")
|
||||
private String privateZone;
|
||||
|
||||
@SerializedName(ApiConstants.NUM_RETRIES)
|
||||
@Param(description = "the number of times to retry requests to the external firewall")
|
||||
private String numRetries;
|
||||
|
||||
@SerializedName(ApiConstants.TIMEOUT)
|
||||
@Param(description = "the timeout (in seconds) for requests to the external firewall")
|
||||
private String timeout;
|
||||
|
||||
public void setId(String lbDeviceId) {
|
||||
this.id = lbDeviceId;
|
||||
}
|
||||
|
||||
public void setPhysicalNetworkId(String physicalNetworkId) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
public void setProvider(String provider) {
|
||||
this.providerName = provider;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceCapacity(long deviceCapacity) {
|
||||
this.deviceCapacity = deviceCapacity;
|
||||
}
|
||||
|
||||
public void setDeviceState(String deviceState) {
|
||||
this.deviceState = deviceState;
|
||||
}
|
||||
|
||||
public void setIpAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public void setPublicInterface(String publicInterface) {
|
||||
this.publicInterface = publicInterface;
|
||||
}
|
||||
|
||||
public void setUsageInterface(String usageInterface) {
|
||||
this.usageInterface = usageInterface;
|
||||
}
|
||||
|
||||
public void setPrivateInterface(String privateInterface) {
|
||||
this.privateInterface = privateInterface;
|
||||
}
|
||||
|
||||
public void setPublicZone(String publicZone) {
|
||||
this.publicZone = publicZone;
|
||||
}
|
||||
|
||||
public void setPrivateZone(String privateZone) {
|
||||
this.privateZone = privateZone;
|
||||
}
|
||||
|
||||
public String getNumRetries() {
|
||||
return numRetries;
|
||||
}
|
||||
|
||||
public void setNumRetries(String numRetries) {
|
||||
this.numRetries = numRetries;
|
||||
}
|
||||
|
||||
public String getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(String timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
}
|
||||
@ -1,551 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.response.ExternalFirewallResponse;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.commands.AddExternalFirewallCmd;
|
||||
import com.cloud.api.commands.AddSrxFirewallCmd;
|
||||
import com.cloud.api.commands.ConfigureSrxFirewallCmd;
|
||||
import com.cloud.api.commands.DeleteExternalFirewallCmd;
|
||||
import com.cloud.api.commands.DeleteSrxFirewallCmd;
|
||||
import com.cloud.api.commands.ListExternalFirewallsCmd;
|
||||
import com.cloud.api.commands.ListSrxFirewallNetworksCmd;
|
||||
import com.cloud.api.commands.ListSrxFirewallsCmd;
|
||||
import com.cloud.api.response.SrxFirewallResponse;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.ExternalFirewallDeviceManagerImpl;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceDao;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO.FirewallDeviceState;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkExternalFirewallDao;
|
||||
import com.cloud.network.dao.NetworkExternalFirewallVO;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.network.resource.JuniperSrxResource;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceManagerImpl implements SourceNatServiceProvider, FirewallServiceProvider,
|
||||
PortForwardingServiceProvider, IpDeployer, JuniperSRXFirewallElementService, StaticNatServiceProvider {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(JuniperSRXExternalFirewallElement.class);
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject
|
||||
NetworkDao _networksDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
ExternalFirewallDeviceDao _fwDevicesDao;
|
||||
@Inject
|
||||
NetworkExternalFirewallDao _networkFirewallDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
HostDetailsDao _hostDetailDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
|
||||
private boolean canHandle(Network network, Service service) {
|
||||
DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
||||
if ((zone.getNetworkType() == NetworkType.Advanced && !(network.getGuestType() == Network.GuestType.Isolated || network.getGuestType() == Network.GuestType.Shared)) ||
|
||||
(zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) {
|
||||
s_logger.trace("Element " + getProvider().getName() + "is not handling network type = " + network.getGuestType());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (service == null) {
|
||||
if (!_networkManager.isProviderForNetwork(getProvider(), network.getId())) {
|
||||
s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!_networkManager.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) {
|
||||
s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() + " in the network " + network);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException,
|
||||
ConcurrentOperationException, InsufficientNetworkCapacityException {
|
||||
DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
||||
|
||||
// don't have to implement network is Basic zone
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
s_logger.debug("Not handling network implement in zone of type " + NetworkType.Basic);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!canHandle(network, null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return manageGuestNetworkWithExternalFirewall(true, network);
|
||||
} catch (InsufficientCapacityException capacityException) {
|
||||
// TODO: handle out of capacity exception in more gracefule manner when multiple providers are present for
|
||||
// the network
|
||||
s_logger.error("Fail to implement the JuniperSRX for network " + network, capacityException);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
|
||||
throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(Network config, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
||||
|
||||
// don't have to implement network is Basic zone
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
s_logger.debug("Not handling network shutdown in zone of type " + NetworkType.Basic);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!canHandle(network, null)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return manageGuestNetworkWithExternalFirewall(false, network);
|
||||
} catch (InsufficientCapacityException capacityException) {
|
||||
// TODO: handle out of capacity exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroy(Network config, ReservationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyFWRules(Network config, List<? extends FirewallRule> rules) throws ResourceUnavailableException {
|
||||
if (!canHandle(config, Service.Firewall)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rules != null && rules.size() == 1) {
|
||||
// for SRX no need to add default egress rule to DENY traffic
|
||||
if (rules.get(0).getTrafficType() == FirewallRule.TrafficType.Egress && rules.get(0).getType() == FirewallRule.FirewallRuleType.System &&
|
||||
!_networkManager.getNetworkEgressDefaultPolicy(config.getId()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return applyFirewallRules(config, rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Provider getProvider() {
|
||||
return Provider.JuniperSRX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Service, Map<Capability, String>> getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
private static Map<Service, Map<Capability, String>> setCapabilities() {
|
||||
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
|
||||
// Set capabilities for Firewall service
|
||||
Map<Capability, String> firewallCapabilities = new HashMap<Capability, String>();
|
||||
firewallCapabilities.put(Capability.SupportedProtocols, "tcp,udp,icmp");
|
||||
firewallCapabilities.put(Capability.SupportedEgressProtocols, "tcp,udp,icmp,all");
|
||||
firewallCapabilities.put(Capability.MultipleIps, "true");
|
||||
firewallCapabilities.put(Capability.TrafficStatistics, "per public ip");
|
||||
firewallCapabilities.put(Capability.SupportedTrafficDirection, "ingress, egress");
|
||||
capabilities.put(Service.Firewall, firewallCapabilities);
|
||||
|
||||
// Disabling VPN for Juniper in Acton as it 1) Was never tested 2) probably just doesn't work
|
||||
// // Set VPN capabilities
|
||||
// Map<Capability, String> vpnCapabilities = new HashMap<Capability, String>();
|
||||
// vpnCapabilities.put(Capability.SupportedVpnTypes, "ipsec");
|
||||
// capabilities.put(Service.Vpn, vpnCapabilities);
|
||||
|
||||
capabilities.put(Service.Gateway, null);
|
||||
|
||||
Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>();
|
||||
// Specifies that this element supports either one source NAT rule per account, or no source NAT rules at all;
|
||||
// in the latter case a shared interface NAT rule will be used
|
||||
sourceNatCapabilities.put(Capability.SupportedSourceNatTypes, "peraccount, perzone");
|
||||
capabilities.put(Service.SourceNat, sourceNatCapabilities);
|
||||
|
||||
// Specifies that port forwarding rules are supported by this element
|
||||
capabilities.put(Service.PortForwarding, null);
|
||||
|
||||
// Specifies that static NAT rules are supported by this element
|
||||
capabilities.put(Service.StaticNat, null);
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyPFRules(Network network, List<PortForwardingRule> rules) throws ResourceUnavailableException {
|
||||
if (!canHandle(network, Service.PortForwarding)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return applyPortForwardingRules(network, rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady(PhysicalNetworkServiceProvider provider) {
|
||||
|
||||
List<ExternalFirewallDeviceVO> fwDevices = _fwDevicesDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), Provider.JuniperSRX.getName());
|
||||
// true if at-least one SRX device is added in to physical network and is in configured (in enabled state) state
|
||||
if (fwDevices != null && !fwDevices.isEmpty()) {
|
||||
for (ExternalFirewallDeviceVO fwDevice : fwDevices) {
|
||||
if (fwDevice.getDeviceState() == FirewallDeviceState.Enabled) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEnableIndividualServices() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
// should use more generic addNetworkDevice command to add firewall
|
||||
public
|
||||
Host addExternalFirewall(AddExternalFirewallCmd cmd) {
|
||||
Long zoneId = cmd.getZoneId();
|
||||
DataCenterVO zone = null;
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
HostVO fwHost = null;
|
||||
|
||||
zone = _dcDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
|
||||
}
|
||||
|
||||
List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
|
||||
if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
|
||||
throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: " + zoneId +
|
||||
" to add this device.");
|
||||
}
|
||||
pNetwork = physicalNetworks.get(0);
|
||||
|
||||
String deviceType = NetworkDevice.JuniperSRXFirewall.getName();
|
||||
ExternalFirewallDeviceVO fwDeviceVO =
|
||||
addExternalFirewall(pNetwork.getId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceType, new JuniperSrxResource());
|
||||
if (fwDeviceVO != null) {
|
||||
fwHost = _hostDao.findById(fwDeviceVO.getHostId());
|
||||
}
|
||||
|
||||
return fwHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteExternalFirewall(DeleteExternalFirewallCmd cmd) {
|
||||
return deleteExternalFirewall(cmd.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
// should use more generic listNetworkDevice command
|
||||
public
|
||||
List<Host> listExternalFirewalls(ListExternalFirewallsCmd cmd) {
|
||||
List<Host> firewallHosts = new ArrayList<Host>();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
DataCenterVO zone = null;
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
|
||||
if (zoneId != null) {
|
||||
zone = _dcDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
|
||||
}
|
||||
|
||||
List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
|
||||
if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
|
||||
throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: " + zoneId +
|
||||
" to add this device.");
|
||||
}
|
||||
pNetwork = physicalNetworks.get(0);
|
||||
}
|
||||
|
||||
firewallHosts.addAll(listExternalFirewalls(pNetwork.getId(), NetworkDevice.JuniperSRXFirewall.getName()));
|
||||
return firewallHosts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalFirewallResponse createExternalFirewallResponse(Host externalFirewall) {
|
||||
return super.createExternalFirewallResponse(externalFirewall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||
cmdList.add(AddExternalFirewallCmd.class);
|
||||
cmdList.add(AddSrxFirewallCmd.class);
|
||||
cmdList.add(ConfigureSrxFirewallCmd.class);
|
||||
cmdList.add(DeleteExternalFirewallCmd.class);
|
||||
cmdList.add(DeleteSrxFirewallCmd.class);
|
||||
cmdList.add(ListExternalFirewallsCmd.class);
|
||||
cmdList.add(ListSrxFirewallNetworksCmd.class);
|
||||
cmdList.add(ListSrxFirewallsCmd.class);
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalFirewallDeviceVO addSrxFirewall(AddSrxFirewallCmd cmd) {
|
||||
String deviceName = cmd.getDeviceType();
|
||||
if (!deviceName.equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
|
||||
throw new InvalidParameterValueException("Invalid SRX firewall device type");
|
||||
}
|
||||
return addExternalFirewall(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceName, new JuniperSrxResource());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSrxFirewall(DeleteSrxFirewallCmd cmd) {
|
||||
Long fwDeviceId = cmd.getFirewallDeviceId();
|
||||
|
||||
ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId);
|
||||
if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
|
||||
throw new InvalidParameterValueException("No SRX firewall device found with ID: " + fwDeviceId);
|
||||
}
|
||||
return deleteExternalFirewall(fwDeviceVO.getHostId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalFirewallDeviceVO configureSrxFirewall(ConfigureSrxFirewallCmd cmd) {
|
||||
Long fwDeviceId = cmd.getFirewallDeviceId();
|
||||
Long deviceCapacity = cmd.getFirewallCapacity();
|
||||
|
||||
ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId);
|
||||
if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
|
||||
throw new InvalidParameterValueException("No SRX firewall device found with ID: " + fwDeviceId);
|
||||
}
|
||||
|
||||
if (deviceCapacity != null) {
|
||||
// check if any networks are using this SRX device
|
||||
List<NetworkExternalFirewallVO> networks = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId);
|
||||
if ((networks != null) && !networks.isEmpty()) {
|
||||
if (deviceCapacity < networks.size()) {
|
||||
throw new CloudRuntimeException("There are more number of networks already using this SRX firewall device than configured capacity");
|
||||
}
|
||||
}
|
||||
if (deviceCapacity != null) {
|
||||
fwDeviceVO.setCapacity(deviceCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
fwDeviceVO.setDeviceState(FirewallDeviceState.Enabled);
|
||||
_fwDevicesDao.update(fwDeviceId, fwDeviceVO);
|
||||
return fwDeviceVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExternalFirewallDeviceVO> listSrxFirewalls(ListSrxFirewallsCmd cmd) {
|
||||
Long physcialNetworkId = cmd.getPhysicalNetworkId();
|
||||
Long fwDeviceId = cmd.getFirewallDeviceId();
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
List<ExternalFirewallDeviceVO> fwDevices = new ArrayList<ExternalFirewallDeviceVO>();
|
||||
|
||||
if (physcialNetworkId == null && fwDeviceId == null) {
|
||||
throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
|
||||
}
|
||||
|
||||
if (fwDeviceId != null) {
|
||||
ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId);
|
||||
if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
|
||||
throw new InvalidParameterValueException("Could not find SRX firewall device with ID: " + fwDeviceId);
|
||||
}
|
||||
fwDevices.add(fwDeviceVo);
|
||||
}
|
||||
|
||||
if (physcialNetworkId != null) {
|
||||
pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
|
||||
if (pNetwork == null) {
|
||||
throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
|
||||
}
|
||||
fwDevices = _fwDevicesDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.JuniperSRX.getName());
|
||||
}
|
||||
|
||||
return fwDevices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Network> listNetworks(ListSrxFirewallNetworksCmd cmd) {
|
||||
Long fwDeviceId = cmd.getFirewallDeviceId();
|
||||
List<NetworkVO> networks = new ArrayList<NetworkVO>();
|
||||
|
||||
ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId);
|
||||
if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
|
||||
throw new InvalidParameterValueException("Could not find SRX firewall device with ID " + fwDeviceId);
|
||||
}
|
||||
|
||||
List<NetworkExternalFirewallVO> networkFirewallMaps = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId);
|
||||
if (networkFirewallMaps != null && !networkFirewallMaps.isEmpty()) {
|
||||
for (NetworkExternalFirewallVO networkFirewallMap : networkFirewallMaps) {
|
||||
NetworkVO network = _networkDao.findById(networkFirewallMap.getNetworkId());
|
||||
networks.add(network);
|
||||
}
|
||||
}
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SrxFirewallResponse createSrxFirewallResponse(ExternalFirewallDeviceVO fwDeviceVO) {
|
||||
SrxFirewallResponse response = new SrxFirewallResponse();
|
||||
Map<String, String> fwDetails = _hostDetailDao.findDetails(fwDeviceVO.getHostId());
|
||||
Host fwHost = _hostDao.findById(fwDeviceVO.getHostId());
|
||||
|
||||
response.setId(fwDeviceVO.getUuid());
|
||||
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(fwDeviceVO.getPhysicalNetworkId());
|
||||
if (pnw != null) {
|
||||
response.setPhysicalNetworkId(pnw.getUuid());
|
||||
}
|
||||
response.setDeviceName(fwDeviceVO.getDeviceName());
|
||||
if (fwDeviceVO.getCapacity() == 0) {
|
||||
long defaultFwCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalFirewallCapacity.key()), 50);
|
||||
response.setDeviceCapacity(defaultFwCapacity);
|
||||
} else {
|
||||
response.setDeviceCapacity(fwDeviceVO.getCapacity());
|
||||
}
|
||||
response.setProvider(fwDeviceVO.getProviderName());
|
||||
response.setDeviceState(fwDeviceVO.getDeviceState().name());
|
||||
response.setIpAddress(fwHost.getPrivateIpAddress());
|
||||
response.setPublicInterface(fwDetails.get("publicInterface"));
|
||||
response.setUsageInterface(fwDetails.get("usageInterface"));
|
||||
response.setPrivateInterface(fwDetails.get("privateInterface"));
|
||||
response.setPublicZone(fwDetails.get("publicZone"));
|
||||
response.setPrivateZone(fwDetails.get("privateZone"));
|
||||
response.setNumRetries(fwDetails.get("numRetries"));
|
||||
response.setTimeout(fwDetails.get("timeout"));
|
||||
response.setObjectName("srxfirewall");
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
if (!services.contains(Service.Firewall)) {
|
||||
s_logger.warn("SRX must be used as Firewall Service Provider in the network");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpDeployer getIpDeployer(Network network) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> service) throws ResourceUnavailableException {
|
||||
// return true, as IP will be associated as part of static NAT/port forwarding rule configuration
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNats(Network config, List<? extends StaticNat> rules) throws ResourceUnavailableException {
|
||||
if (!canHandle(config, Service.StaticNat)) {
|
||||
return false;
|
||||
}
|
||||
return applyStaticNatRules(config, rules);
|
||||
}
|
||||
}
|
||||
@ -1,95 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.ExternalFirewallResponse;
|
||||
|
||||
import com.cloud.api.commands.AddExternalFirewallCmd;
|
||||
import com.cloud.api.commands.AddSrxFirewallCmd;
|
||||
import com.cloud.api.commands.ConfigureSrxFirewallCmd;
|
||||
import com.cloud.api.commands.DeleteExternalFirewallCmd;
|
||||
import com.cloud.api.commands.DeleteSrxFirewallCmd;
|
||||
import com.cloud.api.commands.ListExternalFirewallsCmd;
|
||||
import com.cloud.api.commands.ListSrxFirewallNetworksCmd;
|
||||
import com.cloud.api.commands.ListSrxFirewallsCmd;
|
||||
import com.cloud.api.response.SrxFirewallResponse;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface JuniperSRXFirewallElementService extends PluggableService {
|
||||
|
||||
/**
|
||||
* adds a SRX firewall device in to a physical network
|
||||
* @param AddSrxFirewallCmd
|
||||
* @return ExternalFirewallDeviceVO object for the firewall added
|
||||
*/
|
||||
public ExternalFirewallDeviceVO addSrxFirewall(AddSrxFirewallCmd cmd);
|
||||
|
||||
/**
|
||||
* removes SRX firewall device from a physical network
|
||||
* @param DeleteSrxFirewallCmd
|
||||
* @return true if firewall device successfully deleted
|
||||
*/
|
||||
public boolean deleteSrxFirewall(DeleteSrxFirewallCmd cmd);
|
||||
|
||||
/**
|
||||
* configures a SRX firewal device added in a physical network
|
||||
* @param ConfigureSrxFirewallCmd
|
||||
* @return ExternalFirewallDeviceVO for the device configured
|
||||
*/
|
||||
public ExternalFirewallDeviceVO configureSrxFirewall(ConfigureSrxFirewallCmd cmd);
|
||||
|
||||
/**
|
||||
* lists all the SRX firewall devices added in to a physical network
|
||||
* @param ListSrxFirewallsCmd
|
||||
* @return list of ExternalFirewallDeviceVO for the devices in the physical network.
|
||||
*/
|
||||
public List<ExternalFirewallDeviceVO> listSrxFirewalls(ListSrxFirewallsCmd cmd);
|
||||
|
||||
/**
|
||||
* lists all the guest networks using a SRX firewall device
|
||||
* @param ListSrxFirewallNetworksCmd
|
||||
* @return list of the guest networks that are using this F5 load balancer
|
||||
*/
|
||||
public List<? extends Network> listNetworks(ListSrxFirewallNetworksCmd cmd);
|
||||
|
||||
public SrxFirewallResponse createSrxFirewallResponse(ExternalFirewallDeviceVO fwDeviceVO);
|
||||
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
Host addExternalFirewall(AddExternalFirewallCmd cmd);
|
||||
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
boolean deleteExternalFirewall(DeleteExternalFirewallCmd cmd);
|
||||
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
List<Host> listExternalFirewalls(ListExternalFirewallsCmd cmd);
|
||||
|
||||
@Deprecated
|
||||
// API helper function supported for backward compatibility
|
||||
public
|
||||
ExternalFirewallResponse createExternalFirewallResponse(Host externalFirewall);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,18 +0,0 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with 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.
|
||||
name=srx
|
||||
parent=network
|
||||
@ -1,35 +0,0 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd"
|
||||
>
|
||||
|
||||
<bean id="JuniperSRX"
|
||||
class="com.cloud.network.element.JuniperSRXExternalFirewallElement">
|
||||
<property name="name" value="JuniperSRX" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -168,17 +168,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>srx</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>noredist</name>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>network-elements/juniper-srx</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>vmware</id>
|
||||
<activation>
|
||||
|
||||
@ -2894,7 +2894,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
for (Network.Provider serviceProvider : serviceProviders) {
|
||||
// return only Virtual Router/JuniperSRX/CiscoVnmc as a provider for the firewall
|
||||
if (service == Service.Firewall
|
||||
&& !(serviceProvider == Provider.VirtualRouter || serviceProvider == Provider.JuniperSRX || serviceProvider == Provider.CiscoVnmc || serviceProvider == Provider.PaloAlto || serviceProvider == Provider.BigSwitchBcf)) {
|
||||
&& !(serviceProvider == Provider.VirtualRouter || serviceProvider == Provider.CiscoVnmc || serviceProvider == Provider.PaloAlto || serviceProvider == Provider.BigSwitchBcf)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -5957,7 +5957,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
throw new InvalidParameterValueException("Invalid service provider: " + prvNameStr);
|
||||
}
|
||||
|
||||
if (provider == Provider.JuniperSRX || provider == Provider.CiscoVnmc) {
|
||||
if (provider == Provider.CiscoVnmc) {
|
||||
firewallProvider = provider;
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
/* ExternalFirewallDeviceManager provides a abstract implementation for managing a external firewall in devices agnostic manner.
|
||||
* Device specific managers for external firewall (like SRX) should be implemented as pluggable service extending
|
||||
* Device specific managers for external firewall should be implemented as pluggable service extending
|
||||
* ExternalFirewallDeviceManager implementation. An implementation of device specific manager can override default behaviour when needed.
|
||||
*/
|
||||
|
||||
|
||||
@ -1,595 +0,0 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with 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.
|
||||
-->
|
||||
<srxstresswithportfwd>
|
||||
|
||||
<command>
|
||||
<name>createAccount</name>
|
||||
<testcase>Creating account</testcase>
|
||||
<parameters>
|
||||
<item setparam="true" random="true">
|
||||
<name>account</name>
|
||||
<param>accountname</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>accounttype</name>
|
||||
<value>1</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>domainid</name>
|
||||
<value>1</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>email</name>
|
||||
<value>srxstress@gmail.com</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>firstname</name>
|
||||
<value>srxstress</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>lastname</name>
|
||||
<value>srxstresslastname</value>
|
||||
</item>
|
||||
<item random="true" setparam="true">
|
||||
<name>username</name>
|
||||
<param>usernameparam</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>password</name>
|
||||
<value>password</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>accountid</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<!-- Create default network-->
|
||||
<command>
|
||||
<name>createNetwork</name>
|
||||
<testcase>Creating default network</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>zoneid</name>
|
||||
<param>globalzoneid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>networkOfferingId</name>
|
||||
<param>globalnetworkofferingid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>account</name>
|
||||
<param>accountname</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>domainid</name>
|
||||
<value>1</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>name</name>
|
||||
<value>srxstressnetwork</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>displaytext</name>
|
||||
<value>srxstressnetwork</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>networkid</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>deployVirtualMachine</name>
|
||||
<testcase>deploying virtual machine</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>zoneid</name>
|
||||
<param>globalzoneid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>serviceofferingid</name>
|
||||
<param>globalserviceofferingid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>templateid</name>
|
||||
<param>globaltemplateid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>account</name>
|
||||
<param>accountname</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>domainid</name>
|
||||
<value>1</value>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>networkids</name>
|
||||
<param>networkid</param>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>vmid</param>
|
||||
</item>
|
||||
<item setparam="true">
|
||||
<name>name</name>
|
||||
<param>vmname</param>
|
||||
</item>
|
||||
<item setparam="true">
|
||||
<name>ipaddress</name>
|
||||
<param>vmipaddress</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>deployVirtualMachine</name>
|
||||
<testcase>deploying virtual machine</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>zoneid</name>
|
||||
<param>globalzoneid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>serviceofferingid</name>
|
||||
<param>globalserviceofferingid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>templateid</name>
|
||||
<param>globaltemplateid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>account</name>
|
||||
<param>accountname</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>domainid</name>
|
||||
<value>1</value>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>networkids</name>
|
||||
<param>networkid</param>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>vmid1</param>
|
||||
</item>
|
||||
<item setparam="true">
|
||||
<name>name</name>
|
||||
<param>vmname1</param>
|
||||
</item>
|
||||
<item setparam="true">
|
||||
<name>ipaddress1</name>
|
||||
<param>vmipaddress</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>associateIpAddress</name>
|
||||
<testcase>Associating first public ip address</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>zoneid</name>
|
||||
<param>globalzoneid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>account</name>
|
||||
<param>accountname</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>domainid</name>
|
||||
<value>1</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>nonsourcenatpublicip1id</param>
|
||||
</item>
|
||||
<item setparam="true">
|
||||
<name>ipaddress</name>
|
||||
<param>nonsourcenatpublicip1</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>associateIpAddress</name>
|
||||
<testcase>Associating second public ip address</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>zoneid</name>
|
||||
<param>globalzoneid</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>account</name>
|
||||
<param>accountname</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>domainid</name>
|
||||
<value>1</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>nonsourcenatpublicip2id</param>
|
||||
</item>
|
||||
<item setparam="true">
|
||||
<name>ipaddress</name>
|
||||
<param>nonsourcenatpublicip2</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>enableStaticNat</name>
|
||||
<testcase>Enable Static NAT - 1</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip1id</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>virtualmachineid</name>
|
||||
<param>vmid</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>enableStaticNat</name>
|
||||
<testcase>Enable Static NAT - 2</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip2id</param>
|
||||
</item>
|
||||
<item getparam="true">
|
||||
<name>virtualmachineid</name>
|
||||
<param>vmid1</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<!-- IP FORWARDING SECTION -->
|
||||
<command>
|
||||
<name>createIpForwardingRule</name>
|
||||
<testcase>Creating Ip forwarding rule - 1</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip1id</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>startPort</name>
|
||||
<value>22</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>endPort</name>
|
||||
<value>22</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>protocol</name>
|
||||
<value>TCP</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule1</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>createIpForwardingRule</name>
|
||||
<testcase>Creating Ip forwarding rule - 2</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip1id</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>startPort</name>
|
||||
<value>33</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>endPort</name>
|
||||
<value>35</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>protocol</name>
|
||||
<value>TCP</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule2</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>createIpForwardingRule</name>
|
||||
<testcase>Creating Ip forwarding rule - 3</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip1id</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>startPort</name>
|
||||
<value>44</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>endPort</name>
|
||||
<value>55</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>protocol</name>
|
||||
<value>TCP</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule3</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>sleep.sh</name>
|
||||
<script>true</script>
|
||||
<testcase>Sleeping for 2 mins to ensure that vm comes up for ssh test</testcase>
|
||||
<parameters>
|
||||
<item>
|
||||
<name>s</name>
|
||||
<value>120</value>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>ssh.sh</name>
|
||||
<script>true</script>
|
||||
<testcase>Ssh test for the vm</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>h</name>
|
||||
<param>nonsourcenatpublicip1</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>p</name>
|
||||
<value>password</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>u</name>
|
||||
<value>http://yahoo.com</value>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>deleteIpForwardingRule</name>
|
||||
<testcase>Delete Ip forwarding rule - 1</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule1</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>deleteIpForwardingRule</name>
|
||||
<testcase>Delete Ip forwarding rule - 2</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule2</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
|
||||
<command>
|
||||
<name>deleteIpForwardingRule</name>
|
||||
<testcase>Delete Ip forwarding rule - 3</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule3</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>sleep.sh</name>
|
||||
<script>true</script>
|
||||
<testcase>Sleeping for 1 min </testcase>
|
||||
<parameters>
|
||||
<item>
|
||||
<name>s</name>
|
||||
<value>60</value>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>createIpForwardingRule</name>
|
||||
<testcase>Creating Ip forwarding rule - 4</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip2id</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>startPort</name>
|
||||
<value>22</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>endPort</name>
|
||||
<value>22</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>protocol</name>
|
||||
<value>TCP</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule1</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>createIpForwardingRule</name>
|
||||
<testcase>Creating Ip forwarding rule - 5</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip2id</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>startPort</name>
|
||||
<value>33</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>endPort</name>
|
||||
<value>35</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>protocol</name>
|
||||
<value>TCP</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule2</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>createIpForwardingRule</name>
|
||||
<testcase>Creating Ip forwarding rule - 6</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip3id</param>
|
||||
</item>
|
||||
<item>
|
||||
<name>startPort</name>
|
||||
<value>44</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>endPort</name>
|
||||
<value>55</value>
|
||||
</item>
|
||||
<item>
|
||||
<name>protocol</name>
|
||||
<value>TCP</value>
|
||||
</item>
|
||||
</parameters>
|
||||
<returnvalue>
|
||||
<item setparam="true">
|
||||
<name>id</name>
|
||||
<param>ipfwdrule3</param>
|
||||
</item>
|
||||
</returnvalue>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>disableStaticNat</name>
|
||||
<testcase>Disable Static NAT - 2</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip2id</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
|
||||
<command>
|
||||
<name>disassociateIpAddress</name>
|
||||
<testcase>Dissociating second public ip address</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>id</name>
|
||||
<param>nonsourcenatpublicip2id</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>disableStaticNat</name>
|
||||
<testcase>Disable Static NAT - 1</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>ipaddressid</name>
|
||||
<param>nonsourcenatpublicip1id</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>disassociateIpAddress</name>
|
||||
<testcase>Dissociating first public ip address</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>id</name>
|
||||
<param>nonsourcenatpublicip1id</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>deleteAccount</name>
|
||||
<testcase>Delete account</testcase>
|
||||
<parameters>
|
||||
<item getparam="true">
|
||||
<name>id</name>
|
||||
<param>accountid</param>
|
||||
</item>
|
||||
</parameters>
|
||||
</command>
|
||||
|
||||
|
||||
|
||||
|
||||
</srxstresswithportfwd>
|
||||
|
||||
@ -270,31 +270,6 @@ class netscaler(object):
|
||||
return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
|
||||
for r in req])
|
||||
|
||||
|
||||
class srx(object):
|
||||
|
||||
def __init__(self, hostname=None, username='root', password='admin'):
|
||||
self.hostname = hostname
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.networkdevicetype = 'JuniperSRXFirewall'
|
||||
self.publicinterface = '1/1'
|
||||
self.privateinterface = '1/1'
|
||||
self.numretries = '2'
|
||||
self.fwdevicededicated = 'false'
|
||||
self.timeout = '300'
|
||||
self.publicnetwork = 'untrusted'
|
||||
self.privatenetwork = 'trusted'
|
||||
|
||||
def getUrl(self):
|
||||
return repr(self)
|
||||
|
||||
def __repr__(self):
|
||||
req = list(zip(list(self.__dict__.keys()), list(self.__dict__.values())))
|
||||
return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
|
||||
for r in req])
|
||||
|
||||
|
||||
class bigip(object):
|
||||
|
||||
def __init__(self, hostname=None, username='root', password='default'):
|
||||
@ -701,13 +676,7 @@ def descSetupInAdvancedMode():
|
||||
nsprovider = provider('Netscaler')
|
||||
nsprovider.devices.append(netscaler(hostname='10.147.40.100'))
|
||||
|
||||
srxprovider = provider('JuniperSRX')
|
||||
srxprovider.devices.append(srx(hostname='10.147.40.3'))
|
||||
|
||||
f5provider = provider('F5BigIp')
|
||||
f5provider.devices.append(bigip(hostname='10.147.40.3'))
|
||||
|
||||
pn.providers.extend([vpcprovider, nsprovider, srxprovider, f5provider])
|
||||
pn.providers.extend([vpcprovider, nsprovider])
|
||||
z.physical_networks.append(pn)
|
||||
|
||||
'''create 10 pods'''
|
||||
|
||||
@ -682,65 +682,6 @@ export default {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'JuniperSRX',
|
||||
actions: [
|
||||
{
|
||||
api: 'addSrxFirewall',
|
||||
listView: true,
|
||||
icon: 'plus-outlined',
|
||||
label: 'label.add.srx.device',
|
||||
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/network/providers/AddSrxFirewall.vue')))
|
||||
},
|
||||
{
|
||||
api: 'updateNetworkServiceProvider',
|
||||
icon: 'stop-outlined',
|
||||
listView: true,
|
||||
label: 'label.disable.provider',
|
||||
confirm: 'message.confirm.disable.provider',
|
||||
show: (record) => { return record && record.id && record.state === 'Enabled' },
|
||||
mapping: {
|
||||
state: {
|
||||
value: (record) => { return 'Disabled' }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
api: 'updateNetworkServiceProvider',
|
||||
icon: 'play-circle-outlined',
|
||||
listView: true,
|
||||
label: 'label.enable.provider',
|
||||
confirm: 'message.confirm.enable.provider',
|
||||
show: (record) => { return record && record.id && record.state === 'Disabled' },
|
||||
mapping: {
|
||||
state: {
|
||||
value: (record) => { return 'Enabled' }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
api: 'deleteNetworkServiceProvider',
|
||||
listView: true,
|
||||
icon: 'poweroff-outlined',
|
||||
label: 'label.shutdown.provider',
|
||||
confirm: 'message.confirm.delete.provider',
|
||||
show: (record) => { return record && record.id }
|
||||
}
|
||||
],
|
||||
details: ['name', 'state', 'id', 'servicelist'],
|
||||
lists: [
|
||||
{
|
||||
title: 'label.devices',
|
||||
api: 'listSrxFirewalls',
|
||||
mapping: {
|
||||
physicalnetworkid: {
|
||||
value: (record) => { return record.physicalnetworkid }
|
||||
}
|
||||
},
|
||||
columns: ['ipaddress', 'fwdevicestate', 'action']
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Netscaler',
|
||||
actions: [
|
||||
|
||||
@ -1,381 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with 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.
|
||||
|
||||
<template>
|
||||
<div class="form-layout" v-ctrl-enter="handleSubmit">
|
||||
<a-form
|
||||
:ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
layout="vertical"
|
||||
@finish="handleSubmit"
|
||||
>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="ip" ref="ip" :label="$t('label.ip')">
|
||||
<a-input
|
||||
:placeholder="apiParams.url.description"
|
||||
v-focus="true"
|
||||
v-model:value="form.ip" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="username" ref="username" :label="$t('label.username')">
|
||||
<a-input
|
||||
:placeholder="apiParams.username.description"
|
||||
v-model:value="form.username" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="password" ref="password" :label="$t('label.password')">
|
||||
<a-input-password
|
||||
:placeholder="apiParams.password.description"
|
||||
v-model:value="form.password" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="networkdevicetype" ref="networkdevicetype" :label="$t('label.networkdevicetype')">
|
||||
<a-select
|
||||
:placeholder="apiParams.networkdevicetype.description"
|
||||
v-model:value="form.networkdevicetype"
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
:filterOption="(input, option) => {
|
||||
return option.children[0].children.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
}" >
|
||||
<a-select-option
|
||||
v-for="opt in networkDeviceType"
|
||||
:key="opt.id">{{ $t(opt.description) }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="publicinterface" ref="publicinterface" :label="$t('label.publicinterface')">
|
||||
<a-input v-model:value="form.publicinterface" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="privateinterface" ref="privateinterface" :label="$t('label.privateinterface')">
|
||||
<a-input v-model:value="form.privateinterface" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="usageinterface" ref="usageinterface" :label="$t('label.usageinterface')">
|
||||
<a-input v-model:value="form.usageinterface" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="12" :lg="12">
|
||||
<a-form-item name="numretries" ref="numretries" :label="$t('label.numretries')">
|
||||
<a-input-number
|
||||
style="width: 100%"
|
||||
v-model:value="form.numretries" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="12" :lg="12">
|
||||
<a-form-item name="timeout" ref="timeout" :label="$t('label.timeout')">
|
||||
<a-input-number
|
||||
style="width: 100%"
|
||||
v-model:value="form.timeout" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="12" :lg="12">
|
||||
<a-form-item name="publicnetwork" ref="publicnetwork" :label="$t('label.publicnetwork')">
|
||||
<a-input
|
||||
v-model:value="form.publicnetwork"
|
||||
:disabled="true" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="12" :lg="12">
|
||||
<a-form-item name="privatenetwork" ref="privatenetwork" :label="$t('label.privatenetwork')">
|
||||
<a-input
|
||||
v-model:value="form.privatenetwork"
|
||||
:disabled="true" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :md="24" :lg="24">
|
||||
<a-form-item name="capacity" ref="capacity" :label="$t('label.capacity')">
|
||||
<a-input
|
||||
v-model:value="form.capacity" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div :span="24" class="action-button">
|
||||
<a-button :loading="loading" @click="onCloseAction">{{ $t('label.cancel') }}</a-button>
|
||||
<a-button :loading="loading" ref="submit" type="primary" @click="handleSubmit">{{ $t('label.ok') }}</a-button>
|
||||
</div>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, reactive, toRaw } from 'vue'
|
||||
import { api } from '@/api'
|
||||
|
||||
export default {
|
||||
name: 'AddSrxFirewall',
|
||||
props: {
|
||||
resource: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
action: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
apiParams: {},
|
||||
loading: false,
|
||||
nsp: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
networkDeviceType () {
|
||||
const items = []
|
||||
items.push({
|
||||
id: 'JuniperSRXFirewall',
|
||||
description: 'label.srx.firewall'
|
||||
})
|
||||
|
||||
return items
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.initForm()
|
||||
this.apiParams = this.$getApiParams('addSrxFirewall')
|
||||
},
|
||||
mounted () {
|
||||
if (this.resource && Object.keys(this.resource).length > 0) {
|
||||
this.nsp = this.resource
|
||||
}
|
||||
},
|
||||
inject: ['provideCloseAction', 'provideReload', 'provideCloseAction', 'parentPollActionCompletion'],
|
||||
methods: {
|
||||
onCloseAction () {
|
||||
this.provideCloseAction()
|
||||
},
|
||||
initForm () {
|
||||
this.formRef = ref()
|
||||
this.form = reactive({
|
||||
numretries: 2,
|
||||
timeout: 300,
|
||||
publicnetwork: 'untrusted',
|
||||
privatenetwork: 'untrusted'
|
||||
})
|
||||
this.rules = reactive({
|
||||
ip: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
username: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
password: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
networkdevicetype: [{ required: true, message: this.$t('message.error.select') }],
|
||||
numretries: [{ type: 'number' }],
|
||||
timeout: [{ type: 'number' }]
|
||||
})
|
||||
},
|
||||
handleSubmit (e) {
|
||||
e.preventDefault()
|
||||
if (this.loading) return
|
||||
this.formRef.value.validate().then(async () => {
|
||||
const values = toRaw(this.form)
|
||||
const params = {}
|
||||
params.physicalnetworkid = this.resource.physicalnetworkid
|
||||
params.username = values.username
|
||||
params.password = values.password
|
||||
params.networkdevicetype = values.networkdevicetype
|
||||
|
||||
const url = []
|
||||
const ip = values.ip
|
||||
url.push('https://' + ip)
|
||||
let isQuestionMarkAdded = false
|
||||
|
||||
const publicInterface = values.publicinterface ? values.publicinterface : null
|
||||
if (publicInterface != null && publicInterface.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('publicinterface=' + publicInterface)
|
||||
}
|
||||
|
||||
const privateInterface = values.privateinterface ? values.privateinterface : null
|
||||
if (privateInterface != null && privateInterface.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('privateinterface=' + publicInterface)
|
||||
}
|
||||
|
||||
const usageInterface = values.usageinterface ? values.usageinterface : null
|
||||
if (usageInterface != null && usageInterface.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('usageinterface=' + usageInterface)
|
||||
}
|
||||
|
||||
const numretries = values.numretries ? values.numretries : null
|
||||
if (numretries != null && numretries.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('numretries=' + numretries)
|
||||
}
|
||||
|
||||
const timeout = values.timeout ? values.timeout : null
|
||||
if (timeout != null && timeout.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('timeout=' + timeout)
|
||||
}
|
||||
|
||||
const publicNetwork = values.publicnetwork ? values.publicnetwork : null
|
||||
if (publicNetwork != null && publicNetwork.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('publicnetwork=' + publicNetwork)
|
||||
}
|
||||
|
||||
const privateNetwork = values.privatenetwork ? values.privatenetwork : null
|
||||
if (privateNetwork != null && privateNetwork.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('privatenetwork=' + privateNetwork)
|
||||
}
|
||||
|
||||
const capacity = values.capacity ? values.capacity : null
|
||||
if (capacity != null && capacity.length > 0) {
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('lbdevicecapacity=' + capacity)
|
||||
}
|
||||
|
||||
const dedicated = values.dedicated ? values.dedicated : false
|
||||
if (!isQuestionMarkAdded) {
|
||||
url.push('?')
|
||||
isQuestionMarkAdded = true
|
||||
} else {
|
||||
url.push('&')
|
||||
}
|
||||
url.push('lbdevicededicated=' + dedicated)
|
||||
|
||||
params.url = url.join('')
|
||||
|
||||
this.loading = true
|
||||
|
||||
try {
|
||||
if (!this.nsp.id) {
|
||||
const addParams = {}
|
||||
addParams.name = this.resource.name
|
||||
addParams.physicalnetworkid = this.resource.physicalnetworkid
|
||||
const networkServiceProvider = await this.addNetworkServiceProvider(addParams)
|
||||
this.nsp = { ...this.resource, ...networkServiceProvider }
|
||||
}
|
||||
params.id = this.nsp.id
|
||||
const jobId = await this.addSrxFirewall(params)
|
||||
this.parentPollActionCompletion(jobId, this.action, this.$t(this.nsp.name))
|
||||
this.provideCloseAction()
|
||||
this.loading = false
|
||||
} catch (error) {
|
||||
this.loading = false
|
||||
this.$notification.error({
|
||||
message: this.$t('message.request.failed'),
|
||||
description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
this.formRef.value.scrollToField(error.errorFields[0].name)
|
||||
})
|
||||
},
|
||||
addNetworkServiceProvider (args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
api('addNetworkServiceProvider', args).then(async json => {
|
||||
this.$pollJob({
|
||||
jobId: json.addnetworkserviceproviderresponse.jobid,
|
||||
successMethod: (result) => {
|
||||
resolve(result.jobresult.networkserviceprovider)
|
||||
},
|
||||
errorMethod: (result) => {
|
||||
reject(result.jobresult.errortext)
|
||||
},
|
||||
catchMessage: this.$t('error.fetching.async.job.result'),
|
||||
action: {
|
||||
isFetchData: false
|
||||
}
|
||||
})
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
addSrxFirewall (args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
api('addSrxFirewall', args).then(json => {
|
||||
const jobId = json.addsrxfirewallresponse.jobid || null
|
||||
resolve(jobId)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -55,8 +55,6 @@
|
||||
<span v-if="resource.name==='BigSwitchBcf'">{{ $t('label.delete.bigswitchbcf') }}</span>
|
||||
<span v-else-if="resource.name==='BrocadeVcs'">{{ $t('label.delete.brocadevcs') }}</span>
|
||||
<span v-else-if="resource.name==='NiciraNvp'">{{ $t('label.delete.niciranvp') }}</span>
|
||||
<span v-else-if="resource.name==='F5BigIp'">{{ $t('label.delete.f5') }}</span>
|
||||
<span v-else-if="resource.name==='JuniperSRX'">{{ $t('label.delete.srx') }}</span>
|
||||
<span v-else-if="resource.name==='Netscaler'">{{ $t('label.delete.netscaler') }}</span>
|
||||
<span v-else-if="resource.name==='Opendaylight'">{{ $t('label.delete.opendaylight.device') }}</span>
|
||||
<span v-else-if="resource.name==='PaloAlto'">{{ $t('label.delete.pa') }}</span>
|
||||
@ -232,13 +230,6 @@ export default {
|
||||
confirmation = 'message.confirm.delete.brocadevcs'
|
||||
params.vcsdeviceid = record.vcsdeviceid
|
||||
break
|
||||
case 'JuniperSRX':
|
||||
label = 'label.delete.srx'
|
||||
name = record.ipaddress
|
||||
apiName = 'deleteSrxFirewall'
|
||||
confirmation = 'message.confirm.delete.srx'
|
||||
params.fwdeviceid = record.fwdeviceid
|
||||
break
|
||||
case 'Netscaler':
|
||||
label = 'label.delete.netscaler'
|
||||
name = record.ipaddress
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user