cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From miguelaferreira <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-9074: Support shared networkin...
Date Mon, 30 Nov 2015 07:36:47 GMT
Github user miguelaferreira commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1094#discussion_r46114748
  
    --- Diff: plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/resource/wrapper/NiciraNvpConfigureSharedNetworkVlanIdCommandWrapper.java
---
    @@ -0,0 +1,93 @@
    +//
    +// 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.resource.wrapper;
    +
    +import static com.cloud.network.resource.NiciraNvpResource.NAME_MAX_LEN;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +import org.apache.log4j.Logger;
    +
    +import com.cloud.agent.api.Answer;
    +import com.cloud.agent.api.ConfigureSharedNetworkVlanIdAnswer;
    +import com.cloud.agent.api.ConfigureSharedNetworkVlanIdCommand;
    +import com.cloud.network.nicira.L2GatewayAttachment;
    +import com.cloud.network.nicira.LogicalSwitchPort;
    +import com.cloud.network.nicira.NiciraNvpApi;
    +import com.cloud.network.nicira.NiciraNvpApiException;
    +import com.cloud.network.nicira.NiciraNvpTag;
    +import com.cloud.network.resource.NiciraNvpResource;
    +import com.cloud.resource.CommandWrapper;
    +import com.cloud.resource.ResourceWrapper;
    +
    +@ResourceWrapper(handles =  ConfigureSharedNetworkVlanIdCommand.class)
    +public class NiciraNvpConfigureSharedNetworkVlanIdCommandWrapper extends CommandWrapper<ConfigureSharedNetworkVlanIdCommand,
Answer, NiciraNvpResource>{
    +
    +    private static final Logger s_logger = Logger.getLogger(NiciraNvpConfigureSharedNetworkVlanIdCommandWrapper.class);
    +
    +    @Override
    +    public Answer execute(ConfigureSharedNetworkVlanIdCommand command, NiciraNvpResource
niciraNvpResource) {
    +        final String logicalSwitchUuid = command.getLogicalSwitchUuid();
    +        final String l2GatewayServiceUuid = command.getL2GatewayServiceUuid();
    +        long vlanId = command.getVlanId();
    +        final List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
    +        tags.add(new NiciraNvpTag("cs_account", command.getOwnerName()));
    +        final long networkId = command.getNetworkId();
    +
    +        s_logger.debug("Connecting Logical Switch " + logicalSwitchUuid + " to L2 Gateway
Service " + l2GatewayServiceUuid + ", vlan id " + vlanId + " network " + networkId);
    +        final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
    +
    +        LogicalSwitchPort lsp = null;
    +        try {
    +            // Create the outside port for the router
    +            lsp = new LogicalSwitchPort();
    +            lsp.setAdminStatusEnabled(true);
    +            lsp.setDisplayName(niciraNvpResource.truncate(networkId + "-l2Gateway-port",
NAME_MAX_LEN));
    +            lsp.setTags(tags);
    +            lsp = niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
    +
    +            try {
    +                // Attach the outside port to the gateway service on the correct VLAN
    +                final L2GatewayAttachment attachment = new L2GatewayAttachment(l2GatewayServiceUuid);
    +                if (command.getVlanId() != 0) {
    +                    attachment.setVlanId(command.getVlanId());
    +                }
    +                niciraNvpApi.updateLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(),
attachment);
    +            }
    +            catch (NiciraNvpApiException e){
    +                try {
    +                    niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
    +                } catch (NiciraNvpApiException e1) {
    +                }
    +                throw e;
    +            }
    +        }
    +        catch (NiciraNvpApiException e){
    +            try {
    +                throw e;
    --- End diff --
    
    You except an exception when throwing an exception?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message