Commit 1ff3a05a authored by Christos Tranoris's avatar Christos Tranoris
Browse files

fix specs and bootstrap

parent 503279c8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -20,6 +20,15 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class ResourceSpecificationTemplateRegistry {

    /** Spec name for the IETFSloSleTemplateSpec resource specification. */
    public static final String SPEC_SLO_SLE_TEMPLATE       = "IETFSloSleTemplateSpec";

    /** Spec name for the IETFSliceServiceSpec resource specification. */
    public static final String SPEC_SLICE_SERVICE           = "IETFSliceServiceSpec";

    /** Spec name for the IETFNetworkSliceServicesSpec resource specification. */
    public static final String SPEC_NETWORK_SLICE_SERVICES = "IETFNetworkSliceServicesSpec";

    private final Map<String, String> templateIds = new ConcurrentHashMap<>();

    /**
+3 −5
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ public class SloSleTemplateBootstrapService implements CommandLineRunner {
        // Convert fields to ResourceSpecificationCharacteristic entries via mapper
        LogicalResourceSpecification spec = mapper.toLogicalResourceSpec(template);

        spec.setName("IETFSloSleTemplateSpec");
        spec.setName(ResourceSpecificationTemplateRegistry.SPEC_SLO_SLE_TEMPLATE);
        spec.setCategory(categoryConfig.getCategoryForSpecifications());
        spec.setVersion(categoryConfig.getVersion());
        spec.setDescription(
@@ -216,7 +216,7 @@ public class SloSleTemplateBootstrapService implements CommandLineRunner {
        log.info("Creating NetworkSliceService resource specification");

        LogicalResourceSpecification spec = new LogicalResourceSpecification();
        spec.setName("IETFSliceServiceSpec");
        spec.setName(ResourceSpecificationTemplateRegistry.SPEC_SLICE_SERVICE);
        spec.setCategory(categoryConfig.getCategoryForSpecifications());
        spec.setVersion(categoryConfig.getVersion());
        spec.setDescription(
@@ -266,7 +266,7 @@ public class SloSleTemplateBootstrapService implements CommandLineRunner {
        log.info("Creating NetworkSliceServices resource specification");

        LogicalResourceSpecification spec = new LogicalResourceSpecification();
        spec.setName("IETFNetworkSliceServicesSpec");
        spec.setName(ResourceSpecificationTemplateRegistry.SPEC_NETWORK_SLICE_SERVICES);
        spec.setCategory(categoryConfig.getCategoryForSpecifications());
        spec.setVersion(categoryConfig.getVersion());
        spec.setDescription(
@@ -624,8 +624,6 @@ public class SloSleTemplateBootstrapService implements CommandLineRunner {
            // Build and store the RFC 9543 formatted JSON request (slice-service array)
            Map<String, List<SliceService>> sliceServiceWrapper = new HashMap<>();
            sliceServiceWrapper.put("slice-service", sliceServices);
            String jsonRequest = mapper.writeValueAsString(sliceServiceWrapper);
            networkSliceServices.setJsonRequest(jsonRequest);

            log.info("Successfully created NetworkSliceServices with {} service(s)", sliceServices.size());
            return networkSliceServices;
+0 −5
Original line number Diff line number Diff line
@@ -24,11 +24,6 @@ import org.etsi.osl.tmf.ri639.model.ResourceStatusType;
@AllArgsConstructor
public class NetworkSliceServices implements LogicalResourceMappable {

    /**
     * RFC 9543 JSON request containing the slice-service array.
     * Format: { "slice-service": [ {...}, {...} ] }
     */
    private String jsonRequest;

    // 1-to-many relationship: contains multiple SLO/SLE templates
    private List<SloSleTemplate> sloSleTemplates = new ArrayList<>();
+10 −1
Original line number Diff line number Diff line
@@ -72,8 +72,15 @@ public class RestconfClientImpl implements RestconfClient {
    public NetworkSliceServices createNetworkSliceServices(NetworkSliceServices networkSliceServices)
            throws RestconfException {
        String uri = nssUri();
        logger.info("Creating network-slice-services container");
        logger.info("Creating network-slice-services container at {}", uri);
        try {
            // Serialize payload for debugging — visible when log level is DEBUG
            if (logger.isDebugEnabled()) {
                String payloadJson = objectMapper.writerWithDefaultPrettyPrinter()
                        .writeValueAsString(networkSliceServices);
                logger.debug("POST {} — request payload:\n{}", uri, payloadJson);
            }

            ResponseEntity<NetworkSliceServices> resp = restTemplate.exchange(
                    uri, HttpMethod.POST,
                    new HttpEntity<>(networkSliceServices, buildHeaders()),
@@ -81,6 +88,8 @@ public class RestconfClientImpl implements RestconfClient {
            assertSuccess(resp, "create network-slice-services container");
            return resp.getBody();
        } catch (HttpClientErrorException e) {
            logger.error("POST {} — HTTP {} response body:\n{}", uri,
                    e.getStatusCode().value(), e.getResponseBodyAsString());
            throw handleHttpError(e);
        } catch (RestconfException e) {
            throw e;
+27 −0
Original line number Diff line number Diff line
@@ -174,6 +174,33 @@ public class RestconfConsumerService {
        logger.info("Successfully decommissioned service: {}", serviceId);
    }

    /**
     * Provisions the entire RFC 9543 network-slice-services container on the provider.
     *
     * @param networkSliceServices container with slo-sle-templates and slice-services
     * @return the provisioned container as returned by the provider
     * @throws RestconfException if provisioning fails
     */
    public NetworkSliceServices provisionNetworkSliceServices(NetworkSliceServices networkSliceServices)
            throws RestconfException {
        logger.info("Provisioning NetworkSliceServices container ({} template(s), {} service(s))",
                networkSliceServices.getSloSleTemplates().size(),
                networkSliceServices.getSliceServices().size());
        return restconfClient.createNetworkSliceServices(networkSliceServices);
    }

    /**
     * Provisions a single SLO/SLE template on the provider.
     *
     * @param template the SLO/SLE template to create
     * @return the created template as returned by the provider
     * @throws RestconfException if provisioning fails
     */
    public SloSleTemplate provisionSloSleTemplate(SloSleTemplate template) throws RestconfException {
        logger.info("Provisioning SLO/SLE template: {}", template.getId());
        return restconfClient.createSloSleTemplate(template);
    }

    /**
     * Lists all provisioned network slice services.
     *
Loading