File: network.go

package info (click to toggle)
lxd 5.0.2%2Bgit20231211.1364ae4-9
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 25,632 kB
  • sloc: sh: 14,272; ansic: 3,112; python: 432; makefile: 265; ruby: 51; sql: 50; javascript: 9; lisp: 6
file content (31 lines) | stat: -rw-r--r-- 568 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main

import (
	"fmt"
	"strings"

	liblxc "gopkg.in/lxc/go-lxc.v2"
)

func networkGet(container *liblxc.Container, index int, configKey string) map[string]string {
	keys := container.ConfigKeys(fmt.Sprintf("%s.%d", configKey, index))
	if len(keys) == 0 {
		return nil
	}

	dev := make(map[string]string)
	for _, k := range keys {
		value := container.ConfigItem(fmt.Sprintf("%s.%d.%s", configKey, index, k))
		if len(value) == 0 || strings.TrimSpace(value[0]) == "" {
			continue
		}

		dev[k] = value[0]
	}

	if len(dev) == 0 {
		return nil
	}

	return dev
}