@arg('--flavor',
         default = None,
         metavar = '<flavor>',
         help = "Flavor ID (see 'cloudservers flavors'). Defaults to 256MB RAM instance.")
    @arg('--image',
         default = None,
         metavar = '<image>',
         help = "Image ID (see 'cloudservers images'). Defaults to Ubuntu 10.04 LTS.")
    @arg('--ipgroup',
         default = None,
         metavar = '<group>',
         help = "IP group name or ID (see 'cloudservers ipgroup-list'). DEPRICATED in OpenStack")
    @arg('--meta',
         metavar = "<key=value>",
         action = 'append',
         default = [],
         help = "Record arbitrary key/value metadata. May be give multiple times.")
    @arg('--file',
         metavar = "<dst-path=src-path>",
         action = 'append',
         dest = 'files',
         default = [],
         help = "Store arbitrary files from <src-path> locally to <dst-path> "\
                "on the new server. You may store up to 5 files.")
    @arg('--key',
         metavar = '<path>',
         nargs = '?',
         const = AUTO_KEY,
         help = "Key the server with an SSH keypair. Looks in ~/.ssh for a key, "\
                "or takes an explicit <path> to one.")
    @arg('name', metavar='<name>', help='Name for the new server')
    def do_boot(self, args):
        """Boot a new server."""
        flavor = args.flavor or self.compute.flavors.find(ram=256)
        image = args.image or self.compute.images.find(name="Ubuntu 10.04 LTS (lucid)")

        # Map --ipgroup <name> to an ID.
        # XXX do this for flavor/image?
        if args.ipgroup:
            ipgroup = self._find_ipgroup(args.ipgroup)
        else:
            ipgroup = None

        metadata = dict(v.split('=') for v in args.meta)

        files = {}
        for f in args.files:
            dst, src = f.split('=', 1)
            try:
                files[dst] = open(src)
            except __HOLE__, e:
                raise CommandError("Can't open '%s': %s" % (src, e))

        if args.key is AUTO_KEY:
            possible_keys = [os.path.join(os.path.expanduser('~'), '.ssh', k)
                             for k in ('id_dsa.pub', 'id_rsa.pub')]
            for k in possible_keys:
                if os.path.exists(k):
                    keyfile = k
                    break
            else:
                raise CommandError("Couldn't find a key file: tried ~/.ssh/id_dsa.pub or ~/.ssh/id_rsa.pub")
        elif args.key:
            keyfile = args.key
        else:
            keyfile = None

        if keyfile:
            try:
                files['/root/.ssh/authorized_keys2'] = open(keyfile)
            except IOError, e:
                raise CommandError("Can't open '%s': %s" % (keyfile, e))

        server = self.compute.servers.create(args.name, image, flavor, ipgroup, metadata, files)
        print_dict(server._info)
dataset/ETHPy150Open jacobian-archive/openstack.compute/openstack/compute/shell.py/ComputeShell.do_boot