-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Galit <[email protected]>
0612d0e
to
94ead10
Compare
Create a copy of the disk | ||
|
||
Args: | ||
dst_img = old disk image |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 = [ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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).
Signed-off-by: Galit [email protected]