Skip to content

Add request to delete iso file#316

Open
sbernhard wants to merge 2 commits intofog:masterfrom
ATIX-AG:delete_iso
Open

Add request to delete iso file#316
sbernhard wants to merge 2 commits intofog:masterfrom
ATIX-AG:delete_iso

Conversation

@sbernhard
Copy link
Contributor

No description provided.

@sbernhard
Copy link
Contributor Author

Added ostruct and base64 for newer ruby version. Otherwise, the test failed.

@stejskalleos stejskalleos self-assigned this Feb 9, 2026
options
end

def destroy_iso(options = {})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the option be actually an empty hash?
What would be working ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as for "upload_iso"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is "merged" with 'default_options" in destroy_iso_check_options and if certain options are missing, it will thrown an exception. As said, it's the "same" implementation as in upload_iso

module Vsphere
class Compute
class Real
def destroy_iso_check_options(options)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see any delete action in the method. What is it for?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I guess it's for destroy_iso.
Then I suggest moving it to private methods and simply renaming it check_options'!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, the structure is the same as upload_iso

required_options.each do |param|
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.key? param
end
raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['datacenter']} Doesn't Exist!" unless get_datacenter(options['datacenter'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, these checks should be implemented as a separate method called from the destroy_iso function.
If both exist, we call the API 4 times. That's not good. We can call the api 2x and get the same results.

Plus, the name destroy_iso_check_options does not indicate that it should check the existence of resources; it should focus on options only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is pretty usual in fog-vsphere. have a look at lib/fog/vsphere/requests/compute/vm_clone.rb

default_options = {
'upload_directory' => 'isos'
}
options = default_options.merge(options)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, we modify the original options by merging default_options.
So we should either rename the method (process_options) or extract the merge into another method or a different place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as said, this is the same way as in upload_iso.rb And I don't think its so bad.

@sbernhard sbernhard force-pushed the delete_iso branch 2 times, most recently from 8518d28 to beef2c1 Compare February 10, 2026 16:07
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