Skip to content

Commit

Permalink
MGMT-16066: Resource Subscription Server
Browse files Browse the repository at this point in the history
Description:
- update the alarm subscription handler to a generic subscription
  handler that can also be used for resource subscriptions
- add a new command for the resource subscription server
- update the alarm and resource subscription servers to also set
  the subscription type
  • Loading branch information
irinamihai committed Jun 21, 2024
1 parent ec8d768 commit b236434
Show file tree
Hide file tree
Showing 10 changed files with 689 additions and 181 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@
"--resource-server-url=${env:RESOURCE_SERVER_URL}",
]
},
{
"name": "start infrastructure-inventory-subscription-server",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": [
"start",
"infrastructure-inventory-subscription-server",
"--log-level=debug",
"--cloud-id=6575154c-72fc-4ed8-9a87-a81885ab38bb"
]
},
{
"name": "test",
"type": "go",
Expand Down
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,79 @@ $ curl -s http://localhost:8002/o2ims-infrastructureInventory/v1/resourcePools/{
/resources | jq
```

#### Infrastructure Inventory Subscription Server (Resource Server)

The infrastructure inventory subscription server exposes endpoints for creating, retrieving
and deleting resource subscriptions.

***Notes:***
- No URL or token are required
- A connection to an ACM hub cluster is required

Start the infrastructure inventory subscription server with a command like this:

```
$ ./oran-o2ims start infrastructure-inventory-subscription-server \
--log-level=debug \
--log-file=stdout \
--log-field="server=resource-subscriptions" \
--api-listener-address=localhost:8004 \
--metrics-listener-address=localhost:8008 \
--cloud-id=123
```

For more information about other command line flags use the `--help` command:

```
$ ./oran-o2ims start infrastructure-inventory-subscription-server --help
```

##### Run and Debug

Inside _VS Code_ use the _Run and Debug_ option with the `start
infrastructure-inventory-subscription-server` [configuration](.vscode/launch.json).

##### Request Examples

###### GET Infrastructure Inventory Subscription List

To get a list of resource subscriptions:
```
$ curl -s http://localhost:8004/o2ims-infrastructureInventory/v1/subscriptions | jq
```

###### GET Infrastructure Inventory Subscription Information

To get all the information about an existing resource subscription:
```
$ curl -s http://localhost:8004/o2ims-infrastructureInventory/v1/subscriptions/<subscription_uuid> | jq
```

###### POST a new Infrastructure Inventory Subscription Information

To add a new resource subscription:
```
$ curl -s -X POST \
--header "Content-Type: application/json" \
-d @infra-sub.json http://127.0.0.1:8004/o2ims-infrastructureInventory/v1/subscriptions | jq
```
Where the content of `infra-sub.json` is as follows:
```
{
"consumerSubscriptionId": "69253c4b-8398-4602-855d-783865f5f25c",
"filter": "(eq,extensions/country,US);",
"callback": "https://128.224.115.15:1081/smo/v1/o2ims_inventory_observer"
}
```

###### DELETE an Infrastructure Inventory Subscription

To delete an existing resource subscription:
```
$ curl -s -X DELETE \
http://localhost:8000/o2ims-infrastructureInventory/v1/subscriptions/<subscription_uuid> | jq
```

#### Alarm server

The alarm server exposes endpoints for retrieving alarms (AlarmEventRecord objects).
Expand Down Expand Up @@ -282,4 +355,4 @@ $ curl -s http://localhost:8001/o2ims-infrastructureMonitoring/v1/alarmSubscript
Above example will get a list of existing alarm subscriptions

Inside _VS Code_ use the _Run and Debug_ option with the `start
alarm-subscription-server` [configuration](.vscode/launch.json).
alarm-subscription-server` [configuration](.vscode/launch.json).
5 changes: 3 additions & 2 deletions internal/cmd/server/start_alarm_subscription_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,13 @@ func (c *AlarmSubscriptionServerCommand) run(cmd *cobra.Command, argv []string)
}

// Create the handler:
handler, err := service.NewAlarmSubscriptionHandler().
handler, err := service.NewSubscriptionHandler().
SetLogger(logger).
SetLoggingWrapper(loggingWrapper).
SetCloudID(cloudID).
SetExtensions(extensions...).
SetKubeClient(kubeClient).
SetSubscriptionType("ALARM").
Build(ctx)

if err != nil {
Expand Down Expand Up @@ -269,7 +270,7 @@ func (c *AlarmSubscriptionServerCommand) run(cmd *cobra.Command, argv []string)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to to create API listener",
"Failed to create API listener",
slog.String("error", err.Error()),
)
return exit.Error(1)
Expand Down
Loading

0 comments on commit b236434

Please sign in to comment.