Request #2670

confirmation question for onevm delete command

Added by Hyunwoo Kim over 7 years ago. Updated over 7 years ago.

Status:ClosedStart date:01/22/2014
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Pull request:

Description

We, FermiCloud have been using onevm delete in a different way
by asking for user's confirmation
since one user accidentally deleted a VM that was not meant to be deleted.
I thought this could be useful to others too.

lib/ruby/cli/command_parser.rb

    def run
            comm_name="" 
            if @script
           comm=@script
            elsif
                if @args[0] && !@args[0].match(/^-/)
                    comm_name=@args.shift.to_sym
                    comm=@commands[comm_name]

#HK-new-begin>
#                    puts "debug> description = #{comm[:desc]}" 
# the following 2 lines checks if this command is onevm or not
                    hkarraystring = comm[:desc].split(/\n/)[0].split
                    hklastword = hkarraystring[hkarraystring.length-1]
#                   puts "debug> number of words = #{hklastword}" 
#                    puts "debug> INPUT:  #{STDIN.tty?  ? "regular" : "pipe"}" 
# Below, we ask the users if they really want to delete a VM
# only when the command is onevm, sub command is delta and when it is interactive use;
                    if comm_name == :delete and STDIN.tty? and hklastword.eql?("User")
                        puts "Are you really sure you want to delete this VM? Type a Capital Y" 
                        hkanswer = $stdin.gets
                        if hkanswer.delete("\n") == "Y" 
                           puts "You seem sure, we proceed" 
                        else
                           puts "You did not type in Y, we abort. Think again" 
                           exit -1
                        end
                    end
#HK-new-end>


Related issues

Related to Backlog #2412: Ability to lock VM from accidental actions Pending 10/25/2013

History

#1 Updated by Ruben S. Montero over 7 years ago

  • Related to Backlog #2412: Ability to lock VM from accidental actions added

#2 Updated by Ruben S. Montero over 7 years ago

  • Status changed from Pending to Closed

We have a similar issue open. I am closing this to move all the discussions to the same issue. But definitely, this seems to be a high priority request.

#3 Updated by Hyunwoo Kim over 7 years ago

Hi Ruben,
Please note that the code snippet in command_parser.rb was the only code that I had to hack
in order to achieve this confirmation feature.
Thanks,
HyunWoo

Also available in: Atom PDF