Skip to content

Commit a3b6f4c

Browse files
Merge pull request #3121 from Nordix/tero/add-image-server-support-vbmctl
🌱 Add image server management commands to vbmctl
2 parents 3197864 + 0aff3a8 commit a3b6f4c

11 files changed

Lines changed: 717 additions & 17 deletions

File tree

hack/ci-e2e.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@ if [[ ! -f "${IMAGE_DIR}/${IPA_FILE}" ]]; then
167167
fi
168168

169169
## Start the image server
170-
docker start image-server-e2e || docker run --name image-server-e2e -d \
171-
-p 80:8080 \
172-
-v "${IMAGE_DIR}:/usr/share/nginx/html" nginxinc/nginx-unprivileged
170+
./bin/vbmctl create image-server --host-port 80 --image-dir "${IMAGE_DIR}" --name "vbmctl-image-server-e2e"
173171

174172
# Generate ssh key pair for verifying provisioned BMHs
175173
if [[ ! -f "${IMAGE_DIR}/ssh_testkey" ]]; then

hack/clean-e2e.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
44
cd "${REPO_ROOT}" || exit 1
55

66
docker rm -f vbmc
7-
docker rm -f image-server-e2e
7+
docker rm -f vbmctl-image-server-e2e
88
docker rm -f sushy-tools
99

1010
"${REPO_ROOT}/tools/bmh_test/clean_local_bmh_test_setup.sh" "^bmo-e2e-"

test/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ require (
77
github.com/metal3-io/baremetal-operator/apis v0.5.1
88
github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.5.1
99
github.com/metal3-io/ironic-standalone-operator/api v0.8.1
10+
github.com/moby/moby/api v1.54.1
11+
github.com/moby/moby/client v0.4.0
1012
github.com/onsi/ginkgo/v2 v2.28.1
1113
github.com/onsi/gomega v1.39.1
1214
github.com/spf13/cobra v1.10.2
@@ -76,8 +78,6 @@ require (
7678
github.com/mattn/go-isatty v0.0.20 // indirect
7779
github.com/mattn/go-runewidth v0.0.16 // indirect
7880
github.com/moby/docker-image-spec v1.3.1 // indirect
79-
github.com/moby/moby/api v1.54.1 // indirect
80-
github.com/moby/moby/client v0.4.0 // indirect
8181
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
8282
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
8383
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect

test/vbmctl/README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ This tool is under active development.
1616
| VM management (create/delete/list) | ✅ Implemented |
1717
| `vbmctl create bml` / `vbmctl delete bml` | ✅ Implemented |
1818
| `vbmctl status` | ✅ Implemented (basic) |
19-
| Configurable volumes | ❌ TODO (hard-coded to two per VM) |
19+
| Configurable volumes | ✅ Implemented |
2020
| Network management | ⚠️ Partially implemented (only libvirt networks) |
2121
| BMC emulator support | ❌ TODO |
22-
| Image server | ❌ TODO |
22+
| Image server | ✅ Implemented (basic) |
2323
| State management (persistent state) | ❌ TODO |
2424

2525
## Features
@@ -30,6 +30,7 @@ This tool is under active development.
3030
libvirt networks
3131
- **Library Support**: Can be imported as a Go module for programmatic use
3232
- **Libvirt network management**: create and delete libvirt networks
33+
- **Image Server Management**: Create, delete, list image server
3334

3435
## Build Tags
3536

@@ -77,6 +78,10 @@ vbmctl create vm \
7778
# Create a bare metal lab (all VMs and networks defined in spec.vms of the config file)
7879
vbmctl create bml
7980

81+
# Create an image server with default settings. Please note that if
82+
# a name is specified, vbmctl will automatically add the prefix `vbmctl-`.
83+
vbmctl create image-server
84+
8085
# Check status
8186
vbmctl status
8287

@@ -89,6 +94,9 @@ vbmctl delete bml
8994
# Create network with default values
9095
vbmctl delete network
9196

97+
# Delete the image server
98+
vbmctl delete image-server
99+
92100
# Show help
93101
vbmctl --help
94102
```
@@ -157,6 +165,9 @@ spec:
157165
bridge: metal3
158166
address: 192.168.222.1
159167
netmask: 255.255.255.0
168+
imageServer:
169+
dataDir: "/tmp"
170+
port: 80
160171
```
161172
162173
The `spec.vms` section defines the VMs that will be created when you run `vbmctl
@@ -175,6 +186,7 @@ import (
175186
176187
"github.com/metal3-io/baremetal-operator/test/vbmctl/pkg/api"
177188
"github.com/metal3-io/baremetal-operator/test/vbmctl/pkg/libvirt"
189+
"github.com/metal3-io/baremetal-operator/test/vbmctl/pkg/containers"
178190
libvirtgo "libvirt.org/go/libvirt"
179191
)
180192
@@ -233,6 +245,19 @@ func main() {
233245
log.Fatal(err)
234246
}
235247
248+
// Create an Image Server
249+
err = containers.CreateImageServerInstance(ctx, &api.ImageServerConfig{
250+
Image: "nginx:latest",
251+
ContainerName: "image-server",
252+
DataDir: "/var/lib/vbmctl/images",
253+
ContainerDataDir: "/usr/share/nginx/html",
254+
Port: 8080,
255+
ContainerPort: 80,
256+
})
257+
if err != nil {
258+
log.Fatal(err)
259+
}
260+
236261
fmt.Printf("Created VM: %s (UUID: %s)\n", vm.Config.Name, vm.UUID)
237262
}
238263
```

0 commit comments

Comments
 (0)