~ubuntu-branches/ubuntu/precise/virt-manager/precise-updates

« back to all changes in this revision

Viewing changes to src/virt-manager.py.in

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Léonard
  • Date: 2010-03-25 09:14:38 UTC
  • mto: (1.2.1 upstream) (2.1.15 sid)
  • mto: This revision was merged to the branch mainline in revision 31.
  • Revision ID: james.westby@ubuntu.com-20100325091438-03vv382wj8jqgr26
Tags: upstream-0.8.4
Import upstream version 0.8.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
203
203
 
204
204
    return optParser.parse_args()
205
205
 
206
 
def default_uri():
207
 
    tryuri = None
208
 
    if os.path.exists("/var/lib/xend") and os.path.exists("/proc/xen"):
209
 
        tryuri = "xen:///"
210
 
    elif (os.path.exists("/usr/bin/qemu") or
211
 
          os.path.exists("/usr/bin/qemu-kvm") or
212
 
          os.path.exists("/usr/bin/kvm")):
213
 
        tryuri = "qemu:///system"
214
 
 
215
 
    return tryuri
216
 
 
217
206
def launch_specific_window(engine, show, uri, uuid):
218
207
    if not engine.wait_for_open(uri):
219
208
        # Connection failed, don't attempt to continue
238
227
                                  args=(engine, show, uri, uuid),
239
228
                                  name="Launching '%s' window" % show)
240
229
        thread.start()
 
230
 
241
231
    elif show=='summary' or uri:
242
232
        engine.connect_to_uri(uri)
243
233
    else:
244
 
        if engine.config.get_connections() is None \
245
 
           or len(engine.config.get_connections()) == 0:
246
 
 
247
 
            tryuri = default_uri()
248
 
            if tryuri is not None:
249
 
                engine.add_connection(tryuri, autoconnect=True)
250
234
        engine.show_manager()
251
235
 
252
236
    if not no_conn_auto:
356
340
    from virtManager.engine import vmmEngine
357
341
    from virtManager.remote import vmmRemote
358
342
 
359
 
    gtk.window_set_default_icon_from_file(icon_dir + "/" + appname + "-icon.svg")
 
343
    gtk.window_set_default_icon_from_file(icon_dir + "/" +
 
344
                                          appname + "-icon.svg")
360
345
 
361
346
    if options.show and options.uri==None:
362
347
        raise OptionValueError("can't use --show-* options without --connect")
363
348
 
364
349
    engine = vmmEngine(config)
365
350
 
366
 
    if not(options.nodbus) and not( (os.getenv("DBUS_SESSION_BUS_ADDRESS") is None ) and ( os.getenv("DBUS_STARTER_ADDRESS") is None ) ):
 
351
    if (not (options.nodbus) and
 
352
        not ((os.getenv("DBUS_SESSION_BUS_ADDRESS") is None) and
 
353
             (os.getenv("DBUS_STARTER_ADDRESS") is None))):
 
354
 
367
355
        try:
368
356
            bus = None
369
357
            if os.getenv("DBUS_STARTER_ADDRESS") is None:
371
359
            else:
372
360
                bus = dbus.StarterBus()
373
361
 
374
 
            dbusProxy = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
 
362
            dbusProxy = bus.get_object("org.freedesktop.DBus",
 
363
                                       "/org/freedesktop/DBus")
375
364
            dbusObj = dbus.Interface(dbusProxy, "org.freedesktop.DBus")
376
365
 
377
366
            if dbusObj.NameHasOwner("com.redhat.virt.manager"):
378
367
                # We're already running, so just talk to existing process
379
 
                managerProxy = bus.get_object("com.redhat.virt.manager", "/com/redhat/virt/manager")
380
 
                managerObj = dbus.Interface(managerProxy, "com.redhat.virt.manager")
381
 
 
382
 
                show_remote(managerObj, options.show, options.uri, options.uuid)
 
368
 
 
369
                managerProxy = bus.get_object("com.redhat.virt.manager",
 
370
                                              "/com/redhat/virt/manager")
 
371
                managerObj = dbus.Interface(managerProxy,
 
372
                                            "com.redhat.virt.manager")
 
373
 
 
374
                show_remote(managerObj, options.show,
 
375
                            options.uri, options.uuid)
383
376
 
384
377
                # yes, we exit completely now - remote service is in charge
 
378
                logging.debug("Connected to already running instance.")
385
379
                return
 
380
 
386
381
            else:
387
382
                # Grab the service to allow others to talk to us later
388
383
                name = dbus.service.BusName("com.redhat.virt.manager", bus=bus)
389
384
                vmmRemote(engine, name)
 
385
 
390
386
        except:
391
387
            # Something went wrong doing dbus setup, just ignore & carry on
392
 
            logging.warning("Could not get connection to session bus, disabling DBus service " + \
393
 
                            str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
 
388
            logging.warning("Could not get connection to session bus, "
 
389
                            "disabling DBus service " +
 
390
                            str(sys.exc_info()[0]) + " " +
 
391
                            str(sys.exc_info()[1]))
394
392
 
395
393
    # At this point we're either starting a brand new controlling instance,
396
394
    # or the dbus comms to existing instance has failed