Skip to content

Commit

Permalink
CLOUDSTACK-8672 : NCC Integration with CloudStack.
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyank Parihar authored and sateesh-chodapuneedi committed Jul 20, 2017
1 parent 884606f commit b2f7f9a
Show file tree
Hide file tree
Showing 20 changed files with 1,880 additions and 807 deletions.
18 changes: 18 additions & 0 deletions api/src/com/cloud/agent/api/to/LoadBalancerTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class LoadBalancerTO {
boolean revoked;
boolean alreadyAdded;
boolean inline;
String srcIpVlan;
Long networkId;
DestinationTO[] destinations;
private StickinessPolicyTO[] stickinessPolicies;
private HealthCheckPolicyTO[] healthCheckPolicies;
Expand Down Expand Up @@ -194,6 +196,22 @@ public LbSslCert getSslCert() {
return this.sslCert;
}

public String getSrcIpVlan() {
return srcIpVlan;
}

public void setSrcIpVlan(String srcIpVlan) {
this.srcIpVlan = srcIpVlan;
}

public Long getNetworkId() {
return networkId;
}

public void setNetworkId(long id) {
this.networkId = id;
}

public static class StickinessPolicyTO {
private String _methodName;
private List<Pair<String, String>> _paramsList;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// 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 org.apache.cloudstack.api.command.admin.address;

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.AcquirePodIpCmdResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;

import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;

@APICommand(name = "acquirePodIpAddresses", description = "Allocates IP addresses in respective Pod of a Zone", responseObject = AcquirePodIpCmdResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class AcquirePodIpCmdByAdmin extends BaseCmd {

public static final Logger s_logger = Logger.getLogger(AcquirePodIpCmdByAdmin.class.getName());
private static final String s_name = "acquirepodipaddress";

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the ID of the zone in which your pod lies")
private Long zoneId;

@Parameter(name = ApiConstants.GUEST_CIDR_ADDRESS, type = CommandType.STRING, entityType = ZoneResponse.class, required = false, description = "CIDR for finding Pod")
private String cidr;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

private long getZoneId() {
return zoneId;
}

private String getCidr() {
return cidr;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public String getCommandName() {
return s_name;
}

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException {
AcquirePodIpCmdResponse pod_ip = null;
pod_ip = _networkService.allocatePodIp(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getCidr());
if (pod_ip != null) {
pod_ip.setResponseName(getCommandName());
pod_ip.setObjectName(getCommandName());
setResponseObject(pod_ip);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign IP address");
}
}

@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return CallContext.current().getCallingAccount().getAccountId();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//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 org.apache.cloudstack.api.command.admin.address;

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.command.admin.vlan.ReleasePublicIpRangeCmd;
import org.apache.cloudstack.api.response.AcquireIPAddressResponse;
import org.apache.cloudstack.api.response.SuccessResponse;

import com.cloud.user.Account;

@APICommand(name = "releasePodIpAddress", description = "Releases a Pod IP back to the Pod", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ReleasePodIpCmdByAdmin extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ReleasePublicIpRangeCmd.class.getName());

private static final String s_name = "releasepodipresponse";

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.LONG, entityType = AcquireIPAddressResponse.class, required = true, description = "UUID of the Pod IP")
private Long id;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public long getId() {
return id;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public String getCommandName() {
return s_name;
}

@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}

@Override
public void execute() {
boolean result = _networkService.releasePodIp(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setDisplayText("IP is released sucessfully");
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release Pod ip ");
}
}
}

0 comments on commit b2f7f9a

Please sign in to comment.