package org.opennaas.extensions.router.model.opticalSwitch.dwdm.proteus.cards;
/*
* #%L
* OpenNaaS :: CIM Model
* %%
* Copyright (C) 2007 - 2014 FundaciĆ³ Privada i2CAT, Internet i InnovaciĆ³ a Catalunya
* %%
* Licensed 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.
* #L%
*/
import java.util.List;
import org.opennaas.extensions.router.model.FCPort;
import org.opennaas.extensions.router.model.NetworkPort;
import org.opennaas.extensions.router.model.opticalSwitch.FiberChannel;
/**
* Represents a card that has all ports redirected to the commonPort, and can not be configured. A passive Add card allows adding to a dstPort ALL
* channels within a srcPorts set. If same channel is used more than once per src set, bad things may happen :o
*
* @author isart
*
*/
public class WonesysPassiveAddCard extends ProteusOpticalSwitchCard {
/**
*
*/
private static final long serialVersionUID = -1494149756403636728L;
/**
* Used in order to interlink several modules in a single rack. It is often linked to a drop card.
*/
private FCPort expressPort;
/**
* Is the output of the multiplexed signal going to the network. The only output port of this card.
*/
private FCPort commonPort;
public WonesysPassiveAddCard(int chasis, int slot, int type, int subtype) {
super(chasis, slot, type, subtype);
}
public FCPort getExpressPort() {
return expressPort;
}
public void setExpressPort(FCPort expressPort) {
this.expressPort = expressPort;
}
public FCPort getCommonPort() {
return commonPort;
}
public void setCommonPort(FCPort commonPort) {
this.commonPort = commonPort;
}
public List<FiberChannel> getAvailableChannels(NetworkPort port) {
// If any channel in use in commonPort is reused bad thing may happen
// so they should not be reused
// This kind of cards does not allow to select which port a channel comes from,
// and as any channel is redirectd to commonPort,
// Any channel in use in this card is in use in commonPort
return getFreeChannels(commonPort);
}
@Override
public boolean isPassive() {
return true;
}
@Override
public boolean addSwitchingRule(FiberChannel srcChannel, NetworkPort srcPort, FiberChannel ignoredDstChannel, NetworkPort ignoredDstPort) {
NetworkPort dstPort = getInternalConnections(srcPort).get(0);
// NetworkPort dstPort = (NetworkPort) srcPort.getOutgoingDeviceConnections().get(0);
return super.addSwitchingRule(srcChannel, srcPort, srcChannel, dstPort);
}
}