Compare commits

..

No commits in common. "master" and "v0.1.0-dev4" have entirely different histories.

10 changed files with 18 additions and 38 deletions

View File

@ -15,7 +15,7 @@
"""Compute instances management library."""
__version__ = '0.1.0-dev5'
__version__ = '0.1.0-dev4'
from .config import Config
from .instance import CloudInit, Instance, InstanceConfig, InstanceSchema

View File

@ -788,12 +788,6 @@ class Instance:
disk.source,
)
continue
if volume.storagePoolLookupByVolume().name() == 'images':
log.info(
'Volume %s skipped because it is from images pool',
volume.path(),
)
continue
log.info('Delete volume: %s', volume.path())
volume.delete()
log.info('Undefine instance')

View File

@ -17,7 +17,6 @@
import logging
from contextlib import AbstractContextManager
from pathlib import Path
from types import TracebackType
from typing import Any, NamedTuple
from uuid import uuid4
@ -246,17 +245,11 @@ class Session(AbstractContextManager):
log.info('Volume %s is CDROM device', volume_name)
elif volume.source is not None:
log.info('Using volume %s as source', volume_name)
volume_source = volume.source
if volume.capacity:
capacity = units.to_bytes(
volume.capacity.value, volume.capacity.unit
)
log.info('Getting volume %s', volume.source)
vol = volumes_pool.get_volume(Path(volume_name).name)
log.info(
'Resize volume to specified size: %s',
capacity,
)
vol.resize(capacity, unit=units.DataUnit.BYTES)
else:
capacity = units.to_bytes(
volume.capacity.value, volume.capacity.unit
@ -266,7 +259,7 @@ class Session(AbstractContextManager):
path=str(volumes_pool.path.joinpath(volume_name)),
capacity=capacity,
)
volume.source = volume_config.path
volume_source = volume_config.path
log.debug('Volume config: %s', volume_config)
if volume.is_system is True and data.image:
log.info(
@ -276,20 +269,21 @@ class Session(AbstractContextManager):
image = images_pool.get_volume(data.image)
log.info('Cloning image into volumes pool...')
vol = volumes_pool.clone_volume(image, volume_config)
else:
log.info('Create volume %s', volume_config.name)
volumes_pool.create_volume(volume_config)
if capacity is not None:
log.info(
'Resize cloned volume to specified size: %s',
capacity,
)
vol.resize(capacity, unit=units.DataUnit.BYTES)
else:
log.info('Create volume %s', volume_config.name)
volumes_pool.create_volume(volume_config)
log.info('Attaching volume to instance...')
instance.attach_device(
DiskConfig(
type=volume.type,
device=volume.device,
source=volume.source,
source=volume_source,
target=volume.target,
is_readonly=volume.is_readonly,
bus=volume.bus,

View File

@ -119,7 +119,7 @@ class StoragePool:
'src_pool=%s src_vol=%s dst_pool=%s dst_vol=%s',
src.pool_name,
src.name,
self.pool.name(),
self.pool.name,
dst.name,
)
vol = self.pool.createXMLFrom(
@ -134,9 +134,7 @@ class StoragePool:
def get_volume(self, name: str) -> Volume | None:
"""Lookup and return Volume instance or None."""
log.info(
'Lookup for storage volume vol=%s in pool=%s',
name,
self.pool.name(),
'Lookup for storage volume vol=%s in pool=%s', name, self.pool.name
)
try:
vol = self.pool.storageVolLookupByName(name)

View File

@ -6,7 +6,7 @@ sys.path.insert(0, os.path.abspath('../..'))
project = 'Compute'
copyright = '2023, Compute Authors'
author = 'Compute Authors'
release = '0.1.0-dev5'
release = '0.1.0-dev4'
# Sphinx general settings
extensions = [

View File

@ -19,4 +19,4 @@ build: clean
$(DOCKER_CMD) run --rm -i -v $$PWD/$(BUILDDIR):/mnt --ulimit "nofile=1024:1048576" \
$(DOCKER_IMG) makepkg --nodeps --clean
# Remove unwanted files from build dir
find $(BUILDDIR) ! -name '*.pkg.tar.zst' -type f -exec rm -f {} +
rm $(BUILDDIR)/compute*.tar.gz $(BUILDDIR)/PKGBUILD

View File

@ -1,21 +1,16 @@
pkgname=compute
pkgver='%placeholder%'
pkgver='0.1.0-dev4'
pkgrel=1
pkgdesc='Compute instances management library'
arch=(any)
url=https://get.lulzette.ru/hstack/compute
license=('GPL-3-or-later')
makedepends=(python python-pip)
depends=(python libvirt libvirt-python qemu-base qemu-system-x86 qemu-img)
optdepends=(
'dnsmasq: required for default NAT/DHCP'
'iptables-nft: required for default NAT'
)
depends=(python libvirt libvirt-python qemu-base qemu-system-x86 qemu-img dnsmasq iptables-nft)
provides=(compute)
conflicts=()
package() {
pip install --no-cache-dir --no-deps --root $pkgdir ../$pkgname-*.tar.gz
install -Dm644 ../completion.bash $pkgdir/usr/share/bash-completion/completions/compute
install -Dm644 $pkgdir/usr/lib/*/site-packages/computed.toml $pkgdir/etc/compute/computed.toml
}

View File

@ -16,7 +16,7 @@ build: clean
cp -v ../../dist/compute-*[.tar.gz] $(BUILDDIR)/
cp -r ../../docs $(BUILDDIR)/
cp ../../extra/completion.bash $(BUILDDIR)/compute.bash-completion
if [ -f build.sh.bak ]; then mv build.sh.bak build.sh; fi
if [ -f build.sh.bak ]; then mv build.sh{.bak,}; fi
cp build.sh{,.bak}
awk '/authors/{gsub(/[\[\]]/,"");print $$3" "$$4}' ../pyproject.toml \
| sed "s/['<>]//g" \

View File

@ -38,7 +38,6 @@ Depends:
python3-pydantic,
mtools,
dosfstools,
Recommends:
dnsmasq,
dnsmasq-base
Suggests:

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = 'compute'
version = '0.1.0-dev5'
version = '0.1.0-dev4'
description = 'Compute instances management library'
license = 'GPL-3.0-or-later'
authors = ['ge <ge@nixhacks.net>']