def create(self, args):
        parser = OptionParser(usage="machine create --host <host> <options>")

        # create options
        parser.add_option('-i', '--host',
                help='ip or hostname from machine to '
                     'create in abiquo [required]',
                action='store', dest='host')
        parser.add_option('-u', '--user', help='user to loggin in the machine',
                action='store', dest='user')
        parser.add_option('-p', '--psswd',
                help='password to loggin in the machine',
                action='store', dest='psswd')
        parser.add_option('-t', '--type',
                help='hypervisor type of the machine',
                action='store', dest='hypervisor')
        parser.add_option('-r', '--rsip',
                help='ip from remote services', action='store',
                dest='remoteservicesip')
        parser.add_option('-d', '--datastore',
                help='datastore to enable on physical machine',
                action='store', dest='datastore')
        parser.add_option('-s', '--vswitch',
                help='virtual switch to select on physical machine',
                action='store',
                dest='vswitch')
        (options, args) = parser.parse_args(args)

        # parse options
        host = options.host
        if not host:
            parser.print_help()
            return

        user = self._getConfig(options, host, "user")
        psswd = self._getConfig(options, host, "psswd")
        rsip = self._getConfig(options, host, "remoteservicesip")
        dsname = self._getConfig(options, host, "datastore")
        vswitch = self._getConfig(options, host, "vswitch")
        hypervisor = options.hypervisor

        try:
            api_context = self._context.getApiContext()
            admin = self._context.getAdministrationService()

            # search or create datacenter
            log.debug("Searching for the datacenter 'kahuna'.")
            dc = admin.findDatacenter(DatacenterPredicates.name('kahuna'))
            if not dc:
                log.debug("No datacenter 'kahuna' found.")
                dc = Datacenter.builder(api_context) \
                        .name('kahuna') \
                        .location('terrassa') \
                        .remoteServices(rsip, AbiquoEdition.ENTERPRISE) \
                        .build()
                try:
                    dc.save()
                except (AbiquoException), ex:
                    if ex.hasError('RS-3'):
                        print ('ip %s to create remote services has been used '
                              'yet, try with another one' % rsip)
                        dc.delete()
                        return
                    else:
                        raise ex
                rack = Rack.builder(api_context, dc).name('rack').build()
                rack.save()
                log.debug("New datacenter 'kahuna' created.")
            else:
                rack = dc.findRack(RackPredicates.name('rack'))
                if not rack:
                    rack = Rack.builder(api_context, dc).name('rack').build()
                    rack.save()
                log.debug("Datacenter 'kahuna' found")

            # discover machine
            if hypervisor:
                hypTypes = [HypervisorType.valueOf(hypervisor)]
            else:
                hypTypes = HypervisorType.values()

            machine = None
            for hyp in hypTypes:
                try:
                    log.debug("Trying hypervisor %s" % hyp.name())
                    machine = dc.discoverSingleMachine(host, hyp, user, psswd)
                    break
                except (AbiquoException, HttpResponseException), ex:
                    if ex.hasError("NC-3") or ex.hasError("RS-2"):
                        print ex.getMessage().replace("\n", "")
                        return
                    log.debug(ex.getMessage().replace("\n", ""))

            if not machine:
                print "Not machine found in %s" % host
                return

            log.debug("Machine %s of type %s found"
                    % (machine.getName(), machine.getType().name()))

            # enabling datastore
            ds = machine.findDatastore(dsname)
            if not ds:
                print "Missing datastore %s in machine" % dsname
                return
            ds.setEnabled(True)

            # setting virtual switch
            vs = machine.findAvailableVirtualSwitch(vswitch)
            if not vs:
                print "Missing virtual switch %s in machine" % vswitch
                return
            nst = dc.defaultNetworkServiceType()
            vs.setNetworkServiceType(nst)

            # saving machine
            machine.setRack(rack)
            machine.save()
            log.debug("Machine saved")
            pprint_machines([machine])

        except (AbiquoException, AuthorizationException), ex:
            if ex.hasError("HYPERVISOR-1") or ex.hasError("HYPERVISOR-2"):
                print "Error: Machine already exists"
            else:
                print "Error: %s " % ex.getMessage()
Test that straight horizontal corridor can be made
dataset/ETHPy150Open nacx/kahuna/kahuna/plugins/machine.py/MachinePlugin.create--crossover with--dataset/ETHPy150Open tuturto/pyherc/src/pyherc/test/unit/test_corridor.py/TestCorridor.test_straight_horizontal