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

fix #29: use the nixops.evaluation module, in stead of Deployment._eval_flags #33

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions nixops_virtd/backends/libvirtd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@

import nixops.known_hosts
import nixops.util
from nixops.backends import MachineDefinition, MachineState


# to prevent libvirt errors from appearing on screen, see
# https://www.redhat.com/archives/libvirt-users/2017-August/msg00011.html


from typing import Optional
from nixops.evaluation import eval_network
from nixops.resources import ResourceOptions
from nixops.backends import MachineOptions
from nixops.backends import MachineOptions, MachineDefinition, MachineState
from nixops.plugins.manager import PluginManager
from typing import Optional
from typing import Sequence


Expand Down Expand Up @@ -231,24 +232,15 @@ def _prepare_storage_volume(self):
newEnv = copy.deepcopy(os.environ)
newEnv["NIXOPS_LIBVIRTD_PUBKEY"] = self.client_public_key

temp_image_path = os.path.join(
self.depl.tempdir, "libvirtd-image-{}".format(self.name)
temp_image_path = nixops.evaluation.eval(
networkExpr=self.depl.network_expr,
uuid=self.depl.uuid,
deploymentName=self.depl.name or "",
checkConfigurationOptions=False,
attr="nodes.{0}.config.deployment.libvirtd.baseImage".format(self.name),
pluginNixExprs=PluginManager.nixexprs(),
build=True
)
self._logged_exec(
["nix-build"]
+ self.depl._eval_flags(self.depl.nix_exprs)
+ [
"--arg",
"checkConfigurationOptions",
"false",
"-A",
"nodes.{0}.config.deployment.libvirtd.baseImage".format(self.name),
"-o",
temp_image_path,
],
capture_stdout=True,
env=newEnv,
).rstrip()

temp_disk_path = os.path.join(temp_image_path, "nixos.qcow2")

Expand Down