use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsCommand method setEncap.
/**
* Sets the encapsulation type for a VPLS.
*
* @param vplsName the name of the VPLS
* @param encap the encapsulation type
*/
protected void setEncap(String vplsName, String encap) {
if (vplsName == null) {
print(INSERT_VPLS_NAME);
return;
}
if (encap == null) {
print(INSERT_ENCAP_TYPE);
return;
}
VplsData vplsData = vpls.getVpls(vplsName);
if (vplsData == null) {
print(VPLS_NOT_FOUND, vplsName);
return;
}
EncapsulationType encapType = EncapsulationType.enumFromString(encap);
if (encapType.equals(EncapsulationType.NONE) && !encapType.toString().equals(encap)) {
print(ENCAP_NOT_FOUND, encap);
return;
}
vpls.setEncapsulationType(vplsData, encapType);
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsCommand method addIface.
/**
* Adds an inteterface to a VPLS.
*
* @param vplsName the name of the VLPS
* @param ifaceName the name of the interface to add
*/
protected void addIface(String vplsName, String ifaceName) {
if (vplsName == null) {
print(INSERT_VPLS_NAME);
return;
}
if (ifaceName == null) {
print(INSERT_INTERFACE);
return;
}
Interface iface = getInterface(ifaceName);
VplsData vplsData = vpls.getVpls(vplsName);
if (vplsData == null) {
print(VPLS_NOT_FOUND, vplsName);
return;
}
if (CHANGING_STATE.contains(vplsData.state())) {
// when a VPLS is updating, we shouldn't try modify it.
print("VPLS %s still updating, please wait it finished", vplsData.name());
return;
}
if (iface == null) {
print(IFACE_NOT_FOUND, ifaceName);
return;
}
if (isIfaceAssociated(iface)) {
print(IFACE_ALREADY_ASSOCIATED, ifaceName, getVplsByInterface(iface).name());
return;
}
vpls.addInterface(vplsData, iface);
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsCommand method create.
/**
* Creates a new VPLS.
*
* @param vplsName the name of the VLPS
*/
protected void create(String vplsName) {
if (vplsName == null || vplsName.isEmpty()) {
print(INSERT_VPLS_NAME);
return;
}
VplsData vplsData = vpls.getVpls(vplsName);
if (vplsData != null) {
print(VPLS_ALREADY_EXISTS, vplsName);
return;
}
vpls.createVpls(vplsName, EncapsulationType.NONE);
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsCommand method delete.
/**
* Deletes a VPLS.
*
* @param vplsName the name of the VLPS
*/
protected void delete(String vplsName) {
if (vplsName == null) {
print(INSERT_VPLS_NAME);
return;
}
VplsData vplsData = vpls.getVpls(vplsName);
if (vplsData == null) {
print(VPLS_NOT_FOUND, vplsName);
return;
}
if (CHANGING_STATE.contains(vplsData.state())) {
// when a VPLS is updating, we shouldn't try modify it.
print("VPLS %s still updating, please wait it finished", vplsData.name());
return;
}
vpls.removeVpls(vplsData);
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsCommand method show.
/**
* Shows the details of one or more VPLSs.
*
* @param vplsName the name of the VPLS
*/
protected void show(String vplsName) {
if (!isNullOrEmpty(vplsName)) {
// A VPLS name is provided. Check first if the VPLS exists
VplsData vplsData = vpls.getVpls(vplsName);
if (vplsData != null) {
Set<String> ifaceNames = vplsData.interfaces().stream().map(Interface::name).collect(Collectors.toSet());
print(VPLS_DISPLAY, vplsName, ifaceNames, vplsData.encapsulationType().toString(), vplsData.state());
} else {
print(VPLS_NOT_FOUND, vplsName);
}
} else {
Collection<VplsData> vplses = vpls.getAllVpls();
// No VPLS names are provided. Display all VPLSs configured
print(SEPARATOR);
vplses.forEach(vplsData -> {
Set<String> ifaceNames = vplsData.interfaces().stream().map(Interface::name).collect(Collectors.toSet());
print(VPLS_DISPLAY, vplsData.name(), ifaceNames, vplsData.encapsulationType().toString(), vplsData.state());
print(SEPARATOR);
});
}
}
Aggregations