Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions sunbeam-python/sunbeam/core/juju.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,44 @@ def charm_trust(self, application_name: str, model: str) -> None:
with self._model(model) as juju:
juju.trust(application_name, scope="cluster")

def attach_resource(
self,
application_name: str,
model: str,
resource_name: str,
resource_path: str,
) -> None:
"""Upload a file resource to a deployed application.

:param application_name: Name of the application
:param model: Name of the model
:param resource_name: Name of the resource as defined in the charm metadata
:param resource_path: Local path to the resource file to upload
"""
with self._model(model) as juju:
juju.cli(
"attach-resource",
application_name,
f"{resource_name}={resource_path}",
)

def get_application_resources(
self,
application_name: str,
model: str,
) -> list[dict]:
"""Return the resources defined for a deployed application.

:param application_name: Name of the application
:param model: Name of the model
:returns: List of resource dicts sorted by name, each containing at
minimum the keys ``name``, ``type``, and ``description``.
"""
with self._model(model) as juju:
raw = juju.cli("resources", "--format", "json", application_name)
data = json.loads(raw)
return sorted(data.get("resources", []), key=lambda r: r["name"])

def charm_refresh(
self,
application_name: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ resource "juju_integration" "observability-agent-integrations" {
}
}

resource "juju_integration" "observability-agent-integrations-juju-info" {
for_each = toset(var.observability-agent-integration-apps-juju-info)
model_uuid = data.juju_model.principal_application_model.uuid

application {
name = juju_application.observability-agent.name
endpoint = "juju-info"
}

application {
name = each.value
endpoint = "juju-info"
}
}

resource "juju_integration" "observability-agent-to-cos-prometheus" {
count = var.receive-remote-write-offer-url != null ? 1 : 0
model_uuid = data.juju_model.principal_application_model.uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
# SPDX-License-Identifier: Apache-2.0

variable "observability-agent-integration-apps" {
description = "List of the deployed principal applications that integrate with opentelemetry collector"
description = "List of the deployed principal applications that integrate with opentelemetry collector via cos_agent interface"
type = list(string)
default = []
}

variable "observability-agent-integration-apps-juju-info" {
description = "List of the deployed principal applications that integrate with opentelemetry collector via juju-info interface"
type = list(string)
default = []
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Terraform manifest for deployment of Hardware Observer
#
# SPDX-FileCopyrightText: 2024 - Canonical Ltd
# SPDX-License-Identifier: Apache-2.0

terraform {
required_providers {
juju = {
source = "juju/juju"
version = "= 1.3.1"
}
}
}

provider "juju" {}

data "juju_model" "principal_application_model" {
uuid = var.principal-application-model-uuid
}

resource "juju_application" "hardware-observer" {
name = "hardware-observer"
model_uuid = data.juju_model.principal_application_model.uuid

charm {
name = "hardware-observer"
channel = var.hardware-observer-channel
revision = var.hardware-observer-revision
base = var.hardware-observer-base
}

config = var.hardware-observer-config
}

resource "juju_integration" "hardware-observer-to-observability-agent" {
model_uuid = data.juju_model.principal_application_model.uuid

application {
name = juju_application.hardware-observer.name
endpoint = "cos-agent"
}

application {
name = var.observability-agent-app
endpoint = "cos-agent"
}
}

resource "juju_integration" "hardware-observer-principal-integrations" {
for_each = toset(var.principal-applications)
model_uuid = data.juju_model.principal_application_model.uuid

application {
name = juju_application.hardware-observer.name
endpoint = "general-info"
}

application {
name = each.value
endpoint = "juju-info"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Terraform manifest for deployment of Hardware Observer
#
# SPDX-FileCopyrightText: 2024 - Canonical Ltd
# SPDX-License-Identifier: Apache-2.0

variable "principal-application-model-uuid" {
description = "UUID of the Juju model principal application is deployed in"
type = string
}

variable "principal-applications" {
description = "List of the deployed principal applications that hardware-observer integrates with via juju-info"
type = list(string)
default = []
}

variable "observability-agent-app" {
description = "Name of the observability agent application to integrate with"
type = string
default = "opentelemetry-collector"
}

variable "hardware-observer-channel" {
description = "Channel to use when deploying hardware-observer charm"
type = string
default = "latest/stable"
}

variable "hardware-observer-revision" {
description = "Channel revision to use when deploying hardware-observer charm"
type = number
default = null
}

variable "hardware-observer-base" {
description = "Base to use when deploying hardware-observer charm"
type = string
default = "ubuntu@24.04"
}

variable "hardware-observer-config" {
description = "Config to use when deploying hardware-observer charm"
type = map(string)
default = {}
}
Loading
Loading