Exemple #1
0
 def pool_new(cls, config):
     try:
         record = sxp2map(config)
         if record.has_key('proposed_CPUs') and \
            not isinstance(record['proposed_CPUs'], types.ListType):
             record['proposed_CPUs'] = [record['proposed_CPUs']]
         new_uuid = cls.create(record)
     except XendAPIError, ex:
         raise VmError(ex.get_api_error())
Exemple #2
0
 def pool_new(cls, config):
     try:
         record = sxp2map(config)
         if record.has_key('proposed_CPUs') and \
            not isinstance(record['proposed_CPUs'], types.ListType):
             record['proposed_CPUs'] = [record['proposed_CPUs']]
         new_uuid = cls.create(record)
     except XendAPIError, ex:
         raise VmError(ex.get_api_error())
Exemple #3
0
 def pool_create(cls, config):
     try:
         record = sxp2map(config)
         if record.has_key('proposed_CPUs') and \
            not isinstance(record['proposed_CPUs'], types.ListType):
             record['proposed_CPUs'] = [record['proposed_CPUs']]
         new_uuid = genuuid.createString()
         pool = XendCPUPool(record, new_uuid, False)
         pool.activate()
     except XendAPIError, ex:
         raise VmError(ex.get_api_error())
Exemple #4
0
 def pool_create(cls, config):
     try:
         record = sxp2map(config)
         if record.has_key('proposed_CPUs') and \
            not isinstance(record['proposed_CPUs'], types.ListType):
             record['proposed_CPUs'] = [record['proposed_CPUs']]
         new_uuid = genuuid.createString()
         pool = XendCPUPool(record, new_uuid, False)
         pool.activate()
     except XendAPIError, ex:
         raise VmError(ex.get_api_error())
Exemple #5
0
from xen.xm.main import serverType, SERVER_XEN_API, server
from xen.xm.cpupool import parseCommandLine, err, help as help_options
from xen.util.sxputils import sxp2map

def help():
    return help_options()


def main(argv):
    try:
        (opts, config) = parseCommandLine(argv)
    except StandardError, ex:
        err(str(ex))

    if not opts:
        return

    if serverType == SERVER_XEN_API:
        record = sxp2map(config)
        if type(record.get('proposed_CPUs', [])) != list:
            record['proposed_CPUs'] = [record['proposed_CPUs']]
        ref = server.xenapi.cpu_pool.create(record)
        if ref:
            server.xenapi.cpu_pool.activate(ref)
    else:
        server.xend.cpu_pool.create(config)

if __name__ == '__main__':
    main(sys.argv)