Prepare all capabilities we will be supporting

Remove the logical router if we are done with it.
This commit is contained in:
Hugo Trippaers 2012-09-27 18:24:19 -07:00
parent fe997651a6
commit 8ba7749869
6 changed files with 715 additions and 475 deletions

View File

@ -382,6 +382,7 @@ public class ApiConstants {
public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid";
public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid";
public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename";
public static final String NICIRA_NVP_GATEWAYSERVICE_UUID = "l3gatewayserviceuuid";
public enum HostDetails {

View File

@ -0,0 +1,32 @@
// 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.agent.api;
/**
*
*/
public class DeleteLogicalRouterAnswer extends Answer {
public DeleteLogicalRouterAnswer(Command command, boolean success,
String details) {
super(command, success, details);
}
public DeleteLogicalRouterAnswer(Command command, Exception e) {
super(command, e);
}
}

View File

@ -0,0 +1,41 @@
// 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.agent.api;
/**
*
*/
public class DeleteLogicalRouterCommand extends Command {
private String _logicalRouterUuid;
public DeleteLogicalRouterCommand(String logicalRouterUuid) {
this._logicalRouterUuid = logicalRouterUuid;
}
/* (non-Javadoc)
* @see com.cloud.agent.api.Command#executeInSequence()
*/
@Override
public boolean executeInSequence() {
return false;
}
public String getLogicalRouterUuid() {
return _logicalRouterUuid;
}
}

View File

@ -67,7 +67,8 @@ public class AddNiciraNvpDeviceCmd extends BaseCmd {
@Parameter(name=ApiConstants.NICIRA_NVP_TRANSPORT_ZONE_UUID, type=CommandType.STRING, required = true, description="The Transportzone UUID configured on the Nicira Controller")
private String transportzoneuuid;
//FIXME add optional gateway service uuid
@Parameter(name=ApiConstants.NICIRA_NVP_GATEWAYSERVICE_UUID, type=CommandType.STRING, required = false, description="The L3 Gateway Service UUID configured on the Nicira Controller")
private String l3gatewayserviceuuid;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -92,6 +93,10 @@ public class AddNiciraNvpDeviceCmd extends BaseCmd {
public String getTransportzoneUuid() {
return transportzoneuuid;
}
public String getL3GatewayServiceUuid() {
return l3gatewayserviceuuid;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -33,6 +33,8 @@ import com.cloud.agent.api.CreateLogicalSwitchAnswer;
import com.cloud.agent.api.CreateLogicalSwitchCommand;
import com.cloud.agent.api.CreateLogicalSwitchPortAnswer;
import com.cloud.agent.api.CreateLogicalSwitchPortCommand;
import com.cloud.agent.api.DeleteLogicalRouterAnswer;
import com.cloud.agent.api.DeleteLogicalRouterCommand;
import com.cloud.agent.api.DeleteLogicalSwitchAnswer;
import com.cloud.agent.api.DeleteLogicalSwitchCommand;
import com.cloud.agent.api.DeleteLogicalSwitchPortAnswer;
@ -211,7 +213,10 @@ public class NiciraNvpResource implements ServerResource {
return executeRequest((FindLogicalSwitchPortCommand) cmd, numRetries);
}
else if (cmd instanceof CreateLogicalRouterCommand) {
return executeRequest((CreateLogicalRouterCommand) cmd, 0); //TODO set to numRetries when done
return executeRequest((CreateLogicalRouterCommand) cmd, numRetries);
}
else if (cmd instanceof DeleteLogicalRouterCommand) {
return executeRequest((DeleteLogicalRouterCommand) cmd, numRetries);
}
s_logger.debug("Received unsupported command " + cmd.toString());
return Answer.createUnsupportedCommandAnswer(cmd);
@ -385,7 +390,7 @@ public class NiciraNvpResource implements ServerResource {
// Create the outside port for the router
LogicalRouterPort lrpo = new LogicalRouterPort();
lrpo.setAdminStatusEnabled(true);
lrpo.setDisplayName(routerName + "-port");
lrpo.setDisplayName(routerName + "-outside-port");
lrpo.setTags(tags);
List<String> outsideIpAddresses = new ArrayList<String>();
outsideIpAddresses.add(publicNetworkIpAddress);
@ -402,7 +407,7 @@ public class NiciraNvpResource implements ServerResource {
// Create the inside port for the router
LogicalRouterPort lrpi = new LogicalRouterPort();
lrpi.setAdminStatusEnabled(true);
lrpi.setDisplayName(routerName + "-port");
lrpi.setDisplayName(routerName + "-inside-port");
lrpi.setTags(tags);
List<String> insideIpAddresses = new ArrayList<String>();
insideIpAddresses.add(internalNetworkAddress);
@ -410,7 +415,7 @@ public class NiciraNvpResource implements ServerResource {
lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi);
// Create the inside port on the lswitch
LogicalSwitchPort lsp = new LogicalSwitchPort(routerName + "-port", tags, true);
LogicalSwitchPort lsp = new LogicalSwitchPort(routerName + "-inside-port", tags, true);
lsp = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
// Attach the inside router port to the lswitch port with a PatchAttachment
@ -449,6 +454,20 @@ public class NiciraNvpResource implements ServerResource {
}
}
private Answer executeRequest(DeleteLogicalRouterCommand cmd, int numRetries) {
try {
_niciraNvpApi.deleteLogicalRouter(cmd.getLogicalRouterUuid());
return new DeleteLogicalRouterAnswer(cmd, true, "Logical Router deleted (uuid " + cmd.getLogicalRouterUuid() + ")");
} catch (NiciraNvpApiException e) {
if (numRetries > 0) {
return retry(cmd, --numRetries);
}
else {
return new DeleteLogicalRouterAnswer(cmd, e);
}
}
}
private Answer executeRequest(ReadyCommand cmd) {
return new ReadyAnswer(cmd);
}