use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class CreateAAInventory method doExecute.
@Override
public void doExecute(TestContext context) {
final Logger logger = LoggerFactory.getLogger(CreateAAInventory.class);
try {
String stackName = context.getVariable("stackName");
if (stackName != null && stackName.equals("replace_module")) {
String vServerId = "92272b67-d23f-42ca-87fa-7b06a9ec81f3";
AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
AAICommonObjectMapperProvider aaiMapper = new AAICommonObjectMapperProvider();
InputStream vserverFile = new ClassPathResource("openstack/gr_api/CreateAAIInventory.json").getInputStream();
Vserver vserver = aaiMapper.getMapper().readValue(vserverFile, Vserver.class);
AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("cloudOwner", "regionOne").tenant("0422ffb57ba042c0800a29dc85ca70f8").vserver(vServerId));
aaiResourceClient.create(vserverURI, vserver);
}
} catch (Exception e) {
logger.debug("Exception in CreateAAInventory.doExecute", e);
}
}
use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class AaiHelper method createVnfRelationshiptoVserver.
public Relationship createVnfRelationshiptoVserver(String vserverName, String genericVnfId, String vfModuleId) throws HeatBridgeException {
AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId));
AAIResultWrapper vfModule = resourcesClient.get(vfModuleUri);
if (vfModule.hasRelationshipsTo(Types.VNFC)) {
List<AAIResourceUri> vnfcUris = vfModule.getRelationships().get().getRelatedUris(Types.VNFC);
Optional<AAIResourceUri> foundVnfcURI = vnfcUris.stream().filter(resourceUri -> resourceUri.getURIKeys().get("vnfc-name").startsWith(vserverName)).findFirst();
if (!foundVnfcURI.isPresent()) {
throw new HeatBridgeException("Cannot Find VNFC to create edge to VServer");
} else {
return buildRelationship(foundVnfcURI.get());
}
} else {
throw new HeatBridgeException("VF Module contains no relationships to VNFCS, cannot build edge to VServer");
}
}
use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class AaiConnection method receiveVserverNameFromParams.
private String receiveVserverNameFromParams(final String cloudOwner, final String cloudId, final String tenantId, final String vserverId) {
final AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudId).tenant(tenantId).vserver(vserverId));
final Optional<Vserver> response = getResourcesClient().get(Vserver.class, resourceUri);
if (response.isPresent()) {
final Vserver vserver = response.get();
return vserver.getVserverName();
}
return null;
}
use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class HeatBridgeImpl method buildAddVserversToAaiAction.
@Override
public void buildAddVserversToAaiAction(final String genericVnfId, final String vfModuleId, final List<Server> servers) throws HeatBridgeException {
for (Server server : servers) {
Vserver vserver = aaiHelper.buildVserver(server.getId(), server);
// Build vserver relationships to: image, flavor, pserver, vf-module
vserver.setRelationshipList(aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server));
AAIResourceUri vserverUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(vserver.getVserverId()));
if (resourcesClient.exists(vserverUri)) {
AAIResultWrapper existingVserver = resourcesClient.get(vserverUri);
AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId));
if (!existingVserver.hasRelationshipsTo(Types.VNFC)) {
AAIResultWrapper vfModule = resourcesClient.get(vfModuleUri);
if (vfModule.hasRelationshipsTo(Types.VNFC)) {
List<AAIResourceUri> vnfcUris = vfModule.getRelationships().get().getRelatedUris(Types.VNFC);
Optional<AAIResourceUri> foundVnfcURI = vnfcUris.stream().filter(resourceUri -> resourceUri.getURIKeys().get("vnfc-name").startsWith(vserver.getVserverName())).findFirst();
if (foundVnfcURI.isEmpty()) {
throw new HeatBridgeException("Cannot Find VNFC to create edge to VServer");
}
transaction.connect(vserverUri, foundVnfcURI.get());
} else {
/*
* throw new HeatBridgeException(
* "VF Module contains no relationships to VNFCS, cannot build edge to VServer");
*/
}
}
if (!existingVserver.hasRelationshipsTo(Types.VF_MODULE)) {
transaction.connect(vserverUri, vfModuleUri);
}
if (!existingVserver.hasRelationshipsTo(Types.PSERVER)) {
AAIResourceUri pServerUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(server.getHypervisorHostname()));
transaction.connect(vserverUri, pServerUri);
}
} else {
transaction.create(vserverUri, vserver);
}
}
}
use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class HeatBridgeImpl method createVlanAndSriovVF.
protected void createVlanAndSriovVF(final Port port, final LInterface lIf, final String hostName) throws HeatBridgeException {
// add back all vlan logic
Vlan vlan = new Vlan();
Network network = osClient.getNetworkById(port.getNetworkId());
if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) {
vlan.setVlanInterface(port.getName() + network.getProviderSegID());
vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID()));
vlan.setVlanIdInner(0L);
vlan.setInMaint(false);
vlan.setIsIpUnnumbered(false);
vlan.setIsPrivate(false);
transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).vlan(vlan.getVlanInterface())), Optional.of(vlan));
}
if (!lIf.getInterfaceType().equals(SRIOV)) {
if (nodeType == NodeType.GREENFIELD) {
validatePhysicalNetwork(port, network);
processOVS(lIf, hostName, NodeType.GREENFIELD.getInterfaceName());
} else {
processOVS(lIf, hostName, NodeType.BROWNFIELD.getInterfaceName());
}
}
List<String> privateVlans = (ArrayList<String>) port.getProfile().get(PRIVATE_VLANS);
List<String> publicVlans = (ArrayList<String>) port.getProfile().get(PUBLIC_VLANS);
List<String> vlans = null;
if (publicVlans != null && !publicVlans.isEmpty()) {
vlans = publicVlans.stream().filter(publicVlan -> !Strings.isNullOrEmpty(publicVlan)).collect(Collectors.toList());
} else {
vlans = new ArrayList<>();
}
if (privateVlans != null && !privateVlans.isEmpty()) {
List<String> temp = privateVlans.stream().filter(privateVlan -> !Strings.isNullOrEmpty(privateVlan)).collect(Collectors.toList());
vlans.addAll(temp);
}
vlans.stream().forEach(vlanLocal -> logger.debug("Vlan Id: {}", vlanLocal));
processVlanTag(lIf, vlans);
if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
SriovVf sriovVf = new SriovVf();
sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString());
sriovVf.setNeutronNetworkId(port.getNetworkId());
sriovVf.setVfVlanFilter("0");
sriovVf.setVfVlanAntiSpoofCheck(false);
sriovVf.setVfMacAntiSpoofCheck(false);
transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf(sriovVf.getPciId())), Optional.of(sriovVf));
}
}
Aggregations