Skip to content

Commit

Permalink
Avoid libvirt domain lookup if VM has not been created
Browse files Browse the repository at this point in the history
  • Loading branch information
sciurus committed Oct 21, 2013
1 parent ca39ab2 commit d89d5db
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/sahara/session/libvirt.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(machine)
@machine=machine
@sandboxname="sahara-sandbox"
@connection=connect_to_libvirt
@domain = @connection.client.lookup_domain_by_uuid(@machine.id)
@domain=get_domain
end

# based on VagrantPlugins::ProviderLibvirt::Action::ConnectLibvirt
Expand Down Expand Up @@ -53,6 +53,14 @@ def connect_to_libvirt
end
end

def get_domain
if is_vm_created?
return @connection.client.lookup_domain_by_uuid(@machine.id)
else
return nil
end
end

def get_snapshot_if_exists
# if we can get snapshot description without exception it exists
begin
Expand Down

0 comments on commit d89d5db

Please sign in to comment.