def createMachine(self, args): """ Create a physical machine in abiquo. This method uses configurable constats for default values.""" 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("-c","--port",help="port from machine",action="store",dest="port") 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 context = ContextLoader().load() try: admin = 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(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(context,dc).name('rack').build() rack.save() log.debug("New datacenter 'kahuna' created.") else:
def create_datacenter(self, name, location, rs_address): """ Creates a new datacenter """ log.info("Creating datacenter %s at %s..." % (name, location)) datacenter = Datacenter.builder(self.__context) \ .name(name) \ .location(location) \ .remoteServices(rs_address, AbiquoEdition.ENTERPRISE) \ .build() datacenter.save() return datacenter
def create(self, args): """ Create a physical machine in abiquo """ 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:
def create(self, args): """ Create a physical machine in abiquo """ 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: