use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig in project netvirt by opendaylight.
the class NeutronPortChangeListener method isSupportedVnicTypeByHost.
private boolean isSupportedVnicTypeByHost(final Port port, final String vnicType) {
Hostconfig hostConfig = getHostConfig(port);
String supportStr = String.format("\"vnic_type\": \"%s\"", vnicType);
if (hostConfig != null && hostConfig.getConfig().contains(supportStr)) {
return true;
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig in project netvirt by opendaylight.
the class NeutronPortChangeListener method add.
@Override
protected void add(InstanceIdentifier<Port> identifier, Port input) {
String portName = input.getUuid().getValue();
LOG.trace("Adding Port : key: {}, value={}", identifier, input);
Network network = neutronvpnUtils.getNeutronNetwork(input.getNetworkId());
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.warn("neutron vpn received a port add() for a network without a provider extension augmentation " + "or with an unsupported network type for the port {} which is part of network {}", portName, network);
return;
}
neutronvpnUtils.addToPortCache(input);
String portStatus = NeutronUtils.PORT_STATUS_DOWN;
if (!Strings.isNullOrEmpty(input.getDeviceOwner()) && !Strings.isNullOrEmpty(input.getDeviceId())) {
if (input.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
handleRouterInterfaceAdded(input);
NeutronUtils.createPortStatus(input.getUuid().getValue(), NeutronUtils.PORT_STATUS_ACTIVE, dataBroker);
return;
}
if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(input.getDeviceOwner())) {
handleRouterGatewayUpdated(input);
portStatus = NeutronUtils.PORT_STATUS_ACTIVE;
} else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(input.getDeviceOwner())) {
handleFloatingIpPortUpdated(null, input);
portStatus = NeutronUtils.PORT_STATUS_ACTIVE;
}
}
// in order to validate the supported vnic types from the hostconfig
if (input.getFixedIps() != null && !input.getFixedIps().isEmpty() && !(isPortTypeSwitchdev(input) && !isPortBound(input))) {
handleNeutronPortCreated(input);
}
NeutronUtils.createPortStatus(input.getUuid().getValue(), portStatus, dataBroker);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig in project netvirt by opendaylight.
the class NeutronHostConfigChangeListener method buildHostConfigInfo.
private Hostconfig buildHostConfigInfo(String hostId, String hostType, String hostConfig) {
HostconfigBuilder hostconfigBuilder = new HostconfigBuilder();
hostconfigBuilder.setHostId(hostId);
hostconfigBuilder.setHostType(hostType);
hostconfigBuilder.setConfig(hostConfig);
return hostconfigBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig in project netvirt by opendaylight.
the class NeutronPortChangeListener method update.
@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
// in order to validate the supported vnic types from the hostconfig
if (isPortTypeSwitchdev(original) && !isPortBound(original) && isPortBound(update)) {
handleNeutronPortCreated(update);
}
final String portName = update.getUuid().getValue();
Network network = neutronvpnUtils.getNeutronNetwork(update.getNetworkId());
LOG.info("Update port {} from network {}", portName, update.getNetworkId().toString());
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.error("neutron vpn received a port update() for a network without a provider extension augmentation " + "or with an unsupported network type for the port {} which is part of network {}", portName, network);
return;
}
neutronvpnUtils.addToPortCache(update);
if ((Strings.isNullOrEmpty(original.getDeviceOwner()) || Strings.isNullOrEmpty(original.getDeviceId()) || NeutronConstants.FLOATING_IP_DEVICE_ID_PENDING.equalsIgnoreCase(original.getDeviceId())) && !Strings.isNullOrEmpty(update.getDeviceOwner()) && !Strings.isNullOrEmpty(update.getDeviceId())) {
if (update.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
handleRouterInterfaceAdded(update);
return;
}
if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(update.getDeviceOwner())) {
handleRouterGatewayUpdated(update);
} else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(update.getDeviceOwner())) {
handleFloatingIpPortUpdated(original, update);
}
} else {
Set<FixedIps> oldIPs = getFixedIpSet(original.getFixedIps());
Set<FixedIps> newIPs = getFixedIpSet(update.getFixedIps());
if (!oldIPs.equals(newIPs)) {
handleNeutronPortUpdated(original, update);
}
}
// check if port security enabled/disabled as part of port update
boolean origSecurityEnabled = NeutronvpnUtils.getPortSecurityEnabled(original);
boolean updatedSecurityEnabled = NeutronvpnUtils.getPortSecurityEnabled(update);
if (origSecurityEnabled || updatedSecurityEnabled) {
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
try {
Optional<Interface> optionalInf = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
if (optionalInf.isPresent()) {
InterfaceBuilder interfaceBuilder = new InterfaceBuilder(optionalInf.get());
InterfaceAcl infAcl = handlePortSecurityUpdated(original, update, origSecurityEnabled, updatedSecurityEnabled, interfaceBuilder).build();
interfaceBuilder.addAugmentation(InterfaceAcl.class, infAcl);
LOG.info("update: Of-port-interface updation for port {}", portName);
// Update OFPort interface for this neutron port
wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, interfaceBuilder.build());
} else {
LOG.warn("update: Interface {} is not present", portName);
}
} catch (ReadFailedException e) {
LOG.error("update: Failed to update interface {}", portName, e);
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
Aggregations