~ubuntu-branches/ubuntu/raring/virt-manager/raring-proposed

« back to all changes in this revision

Viewing changes to src/virtManager/delete.py

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther, Laurent Léonard, Guido Günther
  • Date: 2009-10-07 14:04:03 UTC
  • mfrom: (2.3.1 experimental)
  • mto: (2.3.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20091007140403-kl9yum4ocrar1acq
Tags: 0.8.0-2
[ Laurent Léonard ]
* [61651ae] Drop ${shlibs:Depends} from dependencies since there is no more
  C code.
* [3319434] Drop redo-patches target from debian/rules. Since gbp-pq
  is used now.
* [b04541e] Clean debian/rules. Drop commented post-patches target
  since there is no more autogen.sh.
* [145ba60] Update french translation.
* [799f18e] Update 0001-use-usr-share-gconf-for-schema-data.patch.
* [052f7bb] Remove XS-Python-Version field from debian/control. Since
  it is deprecated with pysupport.
* [bfb1611][1a66b27][a8ce142][4116d07][31ff60a] Fix some misspellings in
  french translation.
* [6e23aff] Clean build dependencies.
* [b71c8c9] Bump Debhelper version to 7.
* [c614f09] Bump Standards-Version to 3.8.3.
* [99a52c2] Clean debian/rules.
* [52f3b63] Add clean target in debian/rules. To clean automatically
  generated files: - debian/pycompat (see #424898)
* [d5e2ef7] Remove tests/Makefile in the debian/rules clean target. To get a
  clean Debian diff at rebuild time, the file is automatically generated.
* [7da6d9b] Don't close connection on all libvirt errors. Pulled from
  upstream 1c886d1863f7.

[ Guido Günther ]
* upload to unstable
* [464fb65] make package arch all since there is no more C code.
* [25f7663] switch to python-support and use python-distutils
* [c4da06a] bump python-libvirt dependency so we get all of VMs new
  features.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import traceback
26
26
import logging
27
27
 
28
 
import libvirt
29
28
import virtinst
30
29
 
 
30
from virtManager import util
31
31
from virtManager.error import vmmErrorDialog
32
32
from virtManager.asyncjob import vmmAsyncJob
33
33
from virtManager.createmeter import vmmCreateMeter
69
69
            "on_delete_remove_storage_toggled" : self.toggle_remove_storage,
70
70
        })
71
71
 
 
72
        image = gtk.image_new_from_icon_name("vm_delete_wizard",
 
73
                                             gtk.ICON_SIZE_DIALOG)
 
74
        image.show()
 
75
        self.window.get_widget("icon-box").pack_end(image, False)
 
76
 
 
77
 
72
78
        prepare_storage_list(self.window.get_widget("delete-storage-list"))
73
79
 
74
80
    def toggle_remove_storage(self, src):
127
133
    def finish(self, src):
128
134
        devs = self.get_paths_to_delete()
129
135
 
130
 
        self.error_msg = None
131
 
        self.error_details = None
132
136
        self.topwin.set_sensitive(False)
133
137
        self.topwin.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
134
138
 
135
139
        title = _("Deleting virtual machine '%s'") % self.vm.get_name()
136
140
        text = title
137
141
        if devs:
138
 
            text = title + _(" and selected storage (this may take a while")
 
142
            text = title + _(" and selected storage (this may take a while)")
139
143
 
140
144
        progWin = vmmAsyncJob(self.config, self._async_delete, [devs],
141
145
                              title=title, text=text)
142
146
        progWin.run()
 
147
        error, details = progWin.get_error()
143
148
 
144
149
        self.topwin.set_sensitive(True)
145
150
        self.topwin.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.TOP_LEFT_ARROW))
146
151
        self.close()
147
152
 
148
 
        if self.error_msg is not None:
149
 
            self.err.show_err(self.error_msg, self.error_details)
 
153
        if error is not None:
 
154
            self.err.show_err(error, details)
150
155
 
151
156
        self.conn.tick(noStatsUpdate=True)
152
157
 
154
159
    def _async_delete(self, paths, asyncjob):
155
160
        newconn = None
156
161
        storage_errors = []
 
162
        error = None
 
163
        details = None
157
164
 
158
165
        try:
159
166
            # Open a seperate connection to install on since this is async
160
167
            logging.debug("Threading off connection to delete vol.")
161
 
            #newconn = vmmConnection(self.config, self.conn.get_uri(),
162
 
            #                        self.conn.is_read_only())
163
 
            #newconn.open()
164
 
            #newconn.connectThreadEvent.wait()
165
 
            newconn = libvirt.open(self.conn.get_uri())
 
168
            newconn = util.dup_conn(self.config, self.conn)
166
169
            meter = vmmCreateMeter(asyncjob)
167
170
 
168
171
            for path in paths:
179
182
            self.vm.delete()
180
183
 
181
184
        except Exception, e:
182
 
            self.error_msg = (_("Error deleting virtual machine '%s': %s") %
183
 
                              (self.vm.get_name(), str(e)))
184
 
            self.error_details = "".join(traceback.format_exc())
185
 
            logging.error(self.error_msg + "\n" + self.error_details)
 
185
            error = (_("Error deleting virtual machine '%s': %s") %
 
186
                      (self.vm.get_name(), str(e)))
 
187
            details = "".join(traceback.format_exc())
 
188
 
186
189
 
187
190
        storage_errstr = ""
188
191
        for errinfo in storage_errors:
193
196
 
194
197
        # We had extra storage errors. If there was another error message,
195
198
        # errors to it. Otherwise, build the main error around them.
196
 
        if self.error_details:
197
 
            self.error_details += "\n\n"
198
 
            self.error_details += _("Additionally, there were errors removing"
 
199
        if details:
 
200
            details += "\n\n"
 
201
            details += _("Additionally, there were errors removing"
199
202
                                    " certain storage devices: \n")
200
 
            self.error_details += storage_errstr
 
203
            details += storage_errstr
201
204
        else:
202
 
            self.error_msg = _("Errors encountered while removing certain "
 
205
            error = _("Errors encountered while removing certain "
203
206
                               "storage devices.")
204
 
            self.error_details = storage_errstr
 
207
            details = storage_errstr
 
208
 
 
209
        if error:
 
210
            asyncjob.set_error(error, details)
205
211
 
206
212
    def _async_delete_path(self, conn, path, ignore):
207
213
        vol = None