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

Extend the partition of / filesystem #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

galitf
Copy link

@galitf galitf commented Feb 9, 2020

Signed-off-by: Galit [email protected]

Create a copy of the disk

Args:
dst_img = old disk image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use the docstring format we use in lago?

dst_image,
new_size
]
print(cmd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the logger for that?

)


def resize_image_partition(dst_image, new_dst_image, partition="/dev/sda4", fail_on_error=True):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't put a default value for the partition since it can change between images.

None

"""
cmd = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use os.unlink it will be simpler

@@ -108,6 +109,114 @@ def virt_builder(base_image, dst_image, commands_file, fail_on_error=True):
)


def resize_disk_image(dst_image, new_size, fail_on_error=True):
"""
Create a copy of the disk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstrings are not accurate

new_size=self.spec.size,
)

build_utils.copy_image_with_cp(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? the previous step already creates a copy of the original disk.

partition=self.spec.expand
)

build_utils.remove_disk_image(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be called inside of a finally, just in case the previous commands were failed.

dst_image=self.dst_path,
)

build_utils.copy_image_with_cp(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is needed?

@@ -185,6 +215,36 @@ def custom_build_action(self, *args, **kwargs):
commands_file=self.spec.commands_file
)

if self.spec.size == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be self.spec.size != 0 ?

@@ -185,6 +215,36 @@ def custom_build_action(self, *args, **kwargs):
commands_file=self.spec.commands_file
)

if self.spec.size == 0:
build_utils.resize_disk_image(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this flow is identical to the flow in LibguestFSImage it can be moved to a method in the Image class (or other function that you'll find appropriate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants