Skip to content

Disk without source #9

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 14 additions & 2 deletions create-config-drive
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ done
config_image=$1
shift

if [ -z "$config_image" ]; then
echo "The imagename argument must be specified!" >&2
usage >&2
exit 3
fi

if [ $# -ne 0 ]; then
echo "This command requires exactly one positional argument!" >&2
usage >&2
exit 4
fi

if [ "$ssh_key" ] && [ -f "$ssh_key" ]; then
echo "adding pubkey from $ssh_key"
ssh_key_data=$(cat "$ssh_key")
Expand Down Expand Up @@ -83,9 +95,9 @@ if [ "$ssh_key_data" ]; then
fi

echo "generating configuration image at $config_image"
if ! mkisofs -o $config_image -V cidata -r -J --quiet $config_dir; then
if ! mkisofs -o "$config_image" -V cidata -r -J --quiet $config_dir; then
echo "ERROR: failed to create $config_image" >&2
exit 1
fi
chmod a+r $config_image
chmod a+r "$config_image"

9 changes: 8 additions & 1 deletion virt-query
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class Domain (object):
for disk in self.domxml.xpath('/domain/devices/disk'):
if disk.get('type') == 'file':
info = {'type': 'file',
'source': disk.find('source').get('file'),
'target': disk.find('target').get('dev')}

if disk.find('source') is not None:
info['source'] = disk.find('source').get('file')

yield info

def interfaces(self):
Expand Down Expand Up @@ -70,6 +73,10 @@ def main():

if args.what in ['disk', 'disks']:
for disk in dom.disks():
if not 'source' in disk:
disk['source'] = ''
# This won't break scripts iterating the sources like this:
# for disk_path in $(virt-query "$DOMAIN" disks | awk '{print $3}'); do
print '{type} {target} {source}'.format(**disk)
elif args.what in ['net', 'interfaces', 'iface']:
for iface in dom.interfaces():
Expand Down