Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to query a build instance's network info #579

Open
tigarmo opened this issue Jun 17, 2024 · 2 comments
Open

Provide a way to query a build instance's network info #579

tigarmo opened this issue Jun 17, 2024 · 2 comments
Labels
Enhancement New feature or request triaged We will be doing this

Comments

@tigarmo
Copy link
Contributor

tigarmo commented Jun 17, 2024

What needs to get done

Provide API support on the Executor class to retrieve a build instance's networking info. What I need specifically is to know the instance's gateway, but I imagine the info as a whole would have uses.
Currently I'm doing the following (only for LXD instances):

    instance_name = instance.instance_name
    project = instance.project
    output = subprocess.check_output(
        ["lxc", "--project", project, "config", "show", instance_name, "--expanded"],
        text=True,
    )
    config = util.safe_yaml_load(io.StringIO(output))
    network = config["devices"]["eth0"]["network"]

    route = subprocess.check_output(
        ["ip", "route", "show", "dev", network],
        text=True,
    )
    gateway = route.strip().split()[-1]

Why it needs to get done

In my case I need the application inside the instance to be able to talk to a service that is listening on a port on the host.

@tigarmo tigarmo added Enhancement New feature or request triaged We will be doing this labels Jun 17, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3019.

This message was autogenerated

@sergiusens
Copy link
Collaborator

For eventual multipass

sergiusens@cuivienen:~$ multipass info prophetic-marten --format json
{
    "errors": [
    ],
    "info": {
        "prophetic-marten": {
            "cpu_count": "1",
            "disks": {
                "sda1": {
                    "total": "5116440064",
                    "used": "1966147072"
                }
            },
            "image_hash": "32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3",
            "image_release": "24.04 LTS",
            "ipv4": [
                "10.188.41.35"
            ],
            "load": [
                0.04,
                0.01,
                0
            ],
            "memory": {
                "total": 2057912320,
                "used": 300941312
            },
            "mounts": {
            },
            "release": "Ubuntu 24.04 LTS",
            "snapshot_count": "0",
            "state": "Running"
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request triaged We will be doing this
Projects
None yet
Development

No branches or pull requests

2 participants