Skip to content

Commit b56c6ae

Browse files
authored
Some fixes for old and broken Makefile targets + Updates. (#113)
1 parent 28bbd8d commit b56c6ae

File tree

6 files changed

+30
-35
lines changed

6 files changed

+30
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
**/*.pyc
55
clab-mini-lab
66
.mini-lab.clab.yml
7+
.mini-lab.cumulus.yml
78
ansible-common
89
metal-hammer*
910
requirements.yaml

Makefile

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,6 @@ ssh-leaf02:
153153
start-machines:
154154
docker exec vms /mini-lab/manage_vms.py --names $(LAB_MACHINES) create
155155

156-
.PHONY: _reboot-machine
157-
_reboot-machine:
158-
docker exec vms /mini-lab/manage_vms.py --names $(MACHINE_NAME) kill
159-
docker exec vms /mini-lab/manage_vms.py --names $(MACHINE_NAME) create
160-
161-
.PHONY: reboot-machine01
162-
reboot-machine01:
163-
@$(MAKE) --no-print-directory _reboot-machine MACHINE_NAME=machine01
164-
165-
.PHONY: reboot-machine02
166-
reboot-machine02:
167-
@$(MAKE) --no-print-directory _reboot-machine MACHINE_NAME=machine02
168-
169-
.PHONY: reboot-machine03
170-
reboot-machine03:
171-
@$(MAKE) --no-print-directory _reboot-machine MACHINE_NAME=machine03
172-
173156
.PHONY: _password
174157
_password: env
175158
$(DOCKER_COMPOSE) run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine consolepassword $(MACHINE_UUID)
@@ -189,19 +172,20 @@ password-machine03:
189172
.PHONY: _free-machine
190173
_free-machine: env
191174
$(DOCKER_COMPOSE) run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine rm $(MACHINE_UUID)
192-
@$(MAKE) --no-print-directory reboot-machine MACHINE_NAME=$(MACHINE_NAME)
175+
docker exec vms /mini-lab/manage_vms.py --names $(MACHINE_NAME) kill --with-disks
176+
docker exec vms /mini-lab/manage_vms.py --names $(MACHINE_NAME) create
193177

194178
.PHONY: free-machine01
195179
free-machine01:
196-
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine01
180+
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine01 MACHINE_UUID=e0ab02d2-27cd-5a5e-8efc-080ba80cf258
197181

198182
.PHONY: free-machine02
199183
free-machine02:
200-
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine02
184+
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine02 MACHINE_UUID=2294c949-88f6-5390-8154-fa53d93a3313
201185

202186
.PHONY: free-machine03
203187
free-machine03:
204-
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine03
188+
@$(MAKE) --no-print-directory _free-machine MACHINE_NAME=machine03 MACHINE_UUID=2a92f14d-d3b1-4d46-b813-5d058103743e
205189

206190
.PHONY: _console-machine
207191
_console-machine:

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Here is some code that should help you to set up most of the requirements:
3232

3333
```bash
3434
# If UFW enabled.
35-
# Disable the firewall or allow traffic through Docker network IP range.
35+
# Disable the firewall or allow traffic through Docker network IP range.
3636
sudo ufw status
37-
sudo ufw allow from 172.17.0.0/16
37+
sudo ufw allow from 172.17.0.0/16
3838

3939
# Install kvm
4040
sudo apt install -y git curl qemu qemu-kvm haveged
@@ -201,7 +201,7 @@ docker-compose run --rm metalctl machine reinstall \
201201

202202
### Free machine
203203

204-
Free a machine with
204+
Free a machine with `make free-machine01` or
205205

206206
```bash
207207
docker-compose run --rm metalctl machine rm e0ab02d2-27cd-5a5e-8efc-080ba80cf258
@@ -221,4 +221,3 @@ In order to start specific flavor, you can define the flavor as follows:
221221
export MINI_LAB_FLAVOR=cluster-api
222222
make
223223
```
224-

inventories/group_vars/all/images.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
metal_stack_release_version: v0.11.0
2+
metal_stack_release_version: v0.11.4
33

44
##
55
## for development purposes, you can override releases from our image vector here

inventories/group_vars/control-plane/metal.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ metal_api_admin_key: metal-admin
1212
metal_api_nsq_tcp_address: nsqd:4150
1313

1414
metal_api_images:
15-
- id: firewall-ubuntu-2.0.20220830
16-
name: Firewall 2 Ubuntu 20220830
17-
description: Firewall 2 Ubuntu 20220830
18-
url: http://images.metal-stack.io/metal-os/firewall/2.0-ubuntu/20220830/img.tar.lz4
15+
- id: firewall-ubuntu-2.0.20230110
16+
name: Firewall 2 Ubuntu 20230110
17+
description: Firewall 2 Ubuntu 20230110
18+
url: http://images.metal-stack.io/metal-os/firewall/2.0-ubuntu/20230110/img.tar.lz4
1919
features:
2020
- firewall
21-
- id: ubuntu-20.04.20220830
22-
name: Ubuntu 20.04 20220830
23-
description: Ubuntu 20.04 20220830
24-
url: http://images.metal-stack.io/metal-os/ubuntu/20.04/20220830/img.tar.lz4
21+
- id: ubuntu-20.04.20230110
22+
name: Ubuntu 20.04 20230110
23+
description: Ubuntu 20.04 20230110
24+
url: http://images.metal-stack.io/metal-os/ubuntu/20.04/20230110/img.tar.lz4
2525
features:
2626
- machine
2727

scripts/manage_vms.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def parse_args():
4848

4949
kill = subparsers.add_parser('kill', help='kills vm processes')
5050
kill.set_defaults(entry_function="kill")
51+
kill.add_argument("--with-disks", default=False, action='store_true', help="also deletes the vm's disks")
5152

5253
return parser.parse_args()
5354

@@ -58,6 +59,7 @@ def __init__(self, args):
5859
self.names = []
5960
if args.names:
6061
self.names = args.names.split(",")
62+
self.with_disks = args.with_disks if 'with_disks' in args else False
6163

6264
def run(self):
6365
subcommands = {
@@ -92,6 +94,8 @@ def _create(self):
9294
def _kill(self):
9395
for machine in self._machines_from_cmdline():
9496
Manager._kill_vm_process(machine.get("uuid"))
97+
if self.with_disks:
98+
Manager._delete_vm_disk(machine.get("disk-path"))
9599

96100

97101
@staticmethod
@@ -113,6 +117,13 @@ def _create_vm_disk(path, size):
113117
return
114118
subprocess.run(['qemu-img', 'create', '-f', 'qcow2', path, size])
115119

120+
@staticmethod
121+
def _delete_vm_disk(path):
122+
if not os.path.isfile(path):
123+
print("disk does not exist")
124+
return
125+
os.remove(path)
126+
116127
@staticmethod
117128
def _start_vm(machine):
118129
nics = []
@@ -136,7 +147,7 @@ def _start_vm(machine):
136147
"-cpu", "host",
137148
"-drive", "if=virtio,format=qcow2,file={disk}".format(disk=machine.get("disk-path")),
138149
"-drive", "if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd",
139-
"-drive", "if=pflash,format=raw,file=/usr/share/OVMF/OVMF_VARS.fd",
150+
"-drive", "if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_VARS.fd",
140151
"-serial", "telnet:127.0.0.1:{port},server,nowait".format(port=machine.get("serial-port")),
141152
"-enable-kvm",
142153
"-nographic",

0 commit comments

Comments
 (0)