~ubuntu-branches/ubuntu/quantal/virtinst/quantal-proposed

« back to all changes in this revision

Viewing changes to virtinst/cli.py

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther
  • Date: 2009-12-07 10:04:22 UTC
  • mto: (1.6.3 sid)
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: james.westby@ubuntu.com-20091207100422-2izjffd5ljvqun47
Tags: upstream-0.500.1
Import upstream version 0.500.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
    # set up logging
92
92
    vi_dir = os.path.expanduser("~/.virtinst")
93
93
    if not os.access(vi_dir,os.W_OK):
94
 
        try:
95
 
            os.mkdir(vi_dir)
96
 
        except IOError, e:
97
 
            raise RuntimeError, "Could not create %d directory: " % vi_dir, e
 
94
        os.mkdir(vi_dir, 0751)
98
95
 
99
96
    dateFormat = "%a, %d %b %Y %H:%M:%S"
100
97
    fileFormat = "[%(asctime)s " + appname + " %(process)d] %(levelname)s (%(module)s:%(lineno)d) %(message)s"
551
548
    n = VirtualNetworkInterface(**net_kwargs)
552
549
    guest.nics.append(n)
553
550
 
 
551
def set_os_variant(guest, distro_type, distro_variant):
 
552
    if not distro_type and not distro_variant:
 
553
        # Default to distro autodetection
 
554
        guest.set_os_autodetect(True)
 
555
    else:
 
556
        if (distro_type and str(distro_type).lower() != "none"):
 
557
            guest.set_os_type(distro_type)
 
558
 
 
559
        if (distro_variant and str(distro_variant).lower() != "none"):
 
560
            guest.set_os_variant(distro_variant)
 
561
 
554
562
 
555
563
def parse_optstr(optstr, basedict=None):
556
564
    """
638
646
            net = _util.default_network(conn)
639
647
            networks.append(net[0] + ":" + net[1])
640
648
        else:
641
 
            networks.append("user")
 
649
            networks.append(VirtualNetworkInterface.TYPE_USER)
642
650
 
643
651
    # ensure we have less macs then networks, otherwise autofill the mac list
644
652
    if len(macs) > len(networks):
654
662
                net = _util.default_network(conn)
655
663
                networks.append(net[0] + ":" + net[1])
656
664
            else:
657
 
                networks.append("user")
 
665
                networks.append(VirtualNetworkInterface.TYPE_USER)
658
666
            macs.append(None)
659
667
 
660
668
    net_init_dicts = []
666
674
    return net_init_dicts
667
675
 
668
676
def get_graphics(vnc, vncport, vnclisten, nographics, sdl, keymap, guest):
669
 
    if (vnc and nographics) or \
670
 
       (vnc and sdl) or \
671
 
       (sdl and nographics):
 
677
    if ((vnc and nographics) or
 
678
        (vnc and sdl) or
 
679
        (sdl and nographics)):
672
680
        raise ValueError, _("Can't specify more than one of VNC, SDL, "
673
681
                            "or --nographics")
674
682
 
683
691
    if nographics is not None:
684
692
        guest.graphics_dev = None
685
693
        return
 
694
 
686
695
    if sdl is not None:
687
696
        guest.graphics_dev = VirtualGraphics(type=VirtualGraphics.TYPE_SDL)
688
697
        return
 
698
 
689
699
    if vnc is not None:
690
700
        guest.graphics_dev = VirtualGraphics(type=VirtualGraphics.TYPE_VNC)
691
701
        if vncport:
692
702
            guest.graphics_dev.port = vncport
693
703
        if vnclisten:
694
704
            guest.graphics_dev.listen = vnclisten
 
705
 
695
706
    if keymap:
696
 
        checked_keymap = _util.check_keytable(keymap)
697
 
        if checked_keymap:
698
 
            guest.graphics_dev.keymap = checked_keymap
699
 
        else:
700
 
            raise ValueError, _("Didn't match keymap '%s' in keytable!" % keymap)
 
707
        use_keymap = None
 
708
 
 
709
        if keymap.lower() == "local":
 
710
            use_keymap = virtinst.VirtualGraphics.KEYMAP_LOCAL
 
711
 
 
712
        elif keymap.lower() != "none":
 
713
            use_keymap = _util.check_keytable(keymap)
 
714
            if not use_keymap:
 
715
                raise ValueError(_("Didn't match keymap '%s' in keytable!") %
 
716
                                 keymap)
 
717
 
 
718
        guest.graphics_dev.keymap = use_keymap
701
719
 
702
720
def get_sound(sound, guest):
703
721