ia64/xen-unstable

changeset 12082:59f3891b94b8

[XEND][XENAPI] Split Xend global constants out to its own file.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Oct 05 17:29:19 2006 +0100 (2006-10-05)
parents ddcf2632f448
children ea65d8be211f
files tools/python/xen/xend/XendAPIConstants.py tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendConstants.py tools/python/xen/xend/image.py tools/python/xen/xend/server/tpmif.py
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPIConstants.py	Thu Oct 05 17:29:19 2006 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +#============================================================================
     1.5 +# This library is free software; you can redistribute it and/or
     1.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
     1.7 +# License as published by the Free Software Foundation.
     1.8 +#
     1.9 +# This library is distributed in the hope that it will be useful,
    1.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.12 +# Lesser General Public License for more details.
    1.13 +#
    1.14 +# You should have received a copy of the GNU Lesser General Public
    1.15 +# License along with this library; if not, write to the Free Software
    1.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.17 +#============================================================================
    1.18 +# Copyright (C) 2006 XenSource Ltd.
    1.19 +#============================================================================
    1.20 +
    1.21 +#
    1.22 +# Xen API Enums
    1.23 +#
    1.24 +
    1.25 +XEN_API_VM_POWER_STATE = (
    1.26 +    'Halted',
    1.27 +    'Paused',
    1.28 +    'Running',
    1.29 +    'Suspended',
    1.30 +    'ShuttingDown',
    1.31 +    'Unknown'
    1.32 +)
    1.33 +
    1.34 +XEN_API_VM_POWER_STATE_HALTED = 0
    1.35 +XEN_API_VM_POWER_STATE_PAUSED = 1
    1.36 +XEN_API_VM_POWER_STATE_RUNNING = 2
    1.37 +XEN_API_VM_POWER_STATE_SUSPENDED = 3
    1.38 +XEN_API_VM_POWER_STATE_SHUTTINGDOWN = 4
    1.39 +XEN_API_VM_POWER_STATE_UNKNOWN = 5
    1.40 +
    1.41 +XEN_API_CPU_FEATURE = (
    1.42 +    'FPU', 'VME', 'DE', 'PSE', 'TSC', 'MSR', 'PAE'
    1.43 +    'MCE', 'CX8', 'APIC', 'SEP', 'MTRR', 'PGE', 'MCA',
    1.44 +    'CMOV', 'PAT', 'PSE36', 'PN', 'CLFLSH', 'DTES',
    1.45 +    'ACPI', 'MMX', 'FXCR', 'XMM', 'XMM2', 'SELFSNOOP',
    1.46 +    'HT', 'ACC', 'IA64', 'SYSCALL', 'MP', 'NX', 'MMXEXT',
    1.47 +    'LM', '3DNOWEXT', '3DNOW', 'RECOVERY', 'LONGRUN',
    1.48 +    'LRTI', 'CXMMX', 'K6_MTRR', 'CYRIX_ARR', 'CENTAUR_MCR',
    1.49 +    'K8', 'K7', 'P3', 'P4', 'CONSTANT_TSC', 'FXSAVE_LEAK',
    1.50 +    'XMM3', 'MWAIT', 'DSCPL', 'EST', 'TM2', 'CID', 'CX16',
    1.51 +    'XTPR', 'XSTORE', 'XSTORE_EN', 'XCRYPT', 'XCRYPT_EN',
    1.52 +    'LAHF_LM', 'CMP_LEGACY'
    1.53 +)
    1.54 +
    1.55 +XEN_API_ON_NORMAL_EXIT = (
    1.56 +    'destroy',
    1.57 +    'restart',
    1.58 +)
    1.59 +
    1.60 +XEN_API_ON_CRASH_BEHAVIOUR = (
    1.61 +    'destroy',
    1.62 +    'coredump_and_destroy',
    1.63 +    'restart',
    1.64 +    'coredump_and_restart',
    1.65 +    'preserve',
    1.66 +    'rename_restart'
    1.67 +)
    1.68 +
    1.69 +XEN_API_BOOT_TYPE = (
    1.70 +    'bios',
    1.71 +    'grub',
    1.72 +    'kernel_external',
    1.73 +    'kernel_internal'
    1.74 +)
    1.75 +
    1.76 +XEN_API_VBD_MODE = ('RO', 'RW')
    1.77 +
    1.78 +XEN_API_DRIVER_TYPE = ('ioemu', 'paravirtualised')
     2.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Thu Oct 05 17:29:19 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Thu Oct 05 17:29:19 2006 +0100
     2.3 @@ -18,8 +18,7 @@ import xen.lowlevel.xc
     2.4  from xen.xend import balloon, sxp
     2.5  from xen.xend.XendError import XendError
     2.6  from xen.xend.XendLogging import log
     2.7 -from xen.xend.XendDomainInfo import DEV_MIGRATE_STEP1, DEV_MIGRATE_STEP2
     2.8 -from xen.xend.XendDomainInfo import DEV_MIGRATE_STEP3
     2.9 +from xen.xend.XendConstants import *
    2.10  
    2.11  SIGNATURE = "LinuxGuestRecord"
    2.12  XC_SAVE = "xc_save"
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/python/xen/xend/XendConstants.py	Thu Oct 05 17:29:19 2006 +0100
     3.3 @@ -0,0 +1,96 @@
     3.4 +#============================================================================
     3.5 +# This library is free software; you can redistribute it and/or
     3.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
     3.7 +# License as published by the Free Software Foundation.
     3.8 +#
     3.9 +# This library is distributed in the hope that it will be useful,
    3.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.12 +# Lesser General Public License for more details.
    3.13 +#
    3.14 +# You should have received a copy of the GNU Lesser General Public
    3.15 +# License along with this library; if not, write to the Free Software
    3.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.17 +#============================================================================
    3.18 +# Copyright (C) 2006 XenSource Ltd.
    3.19 +#============================================================================
    3.20 +
    3.21 +from xen.xend.XendAPIConstants import *
    3.22 +
    3.23 +#
    3.24 +# Shutdown codes and reasons.
    3.25 +#
    3.26 +
    3.27 +DOMAIN_POWEROFF = 0 
    3.28 +DOMAIN_REBOOT   = 1
    3.29 +DOMAIN_SUSPEND  = 2
    3.30 +DOMAIN_CRASH    = 3
    3.31 +DOMAIN_HALT     = 4
    3.32 +
    3.33 +DOMAIN_SHUTDOWN_REASONS = {
    3.34 +    DOMAIN_POWEROFF: "poweroff",
    3.35 +    DOMAIN_REBOOT  : "reboot",
    3.36 +    DOMAIN_SUSPEND : "suspend",
    3.37 +    DOMAIN_CRASH   : "crash",
    3.38 +    DOMAIN_HALT    : "halt"
    3.39 +}
    3.40 +
    3.41 +restart_modes = [
    3.42 +    "restart",
    3.43 +    "destroy",
    3.44 +    "preserve",
    3.45 +    "rename-restart"
    3.46 +    ]
    3.47 +
    3.48 +DOM_STATES = [
    3.49 +    'halted',
    3.50 +    'paused',
    3.51 +    'running',
    3.52 +    'suspended',
    3.53 +    'shutdown',
    3.54 +    'unknown',
    3.55 +]
    3.56 +
    3.57 +DOM_STATE_HALTED = XEN_API_VM_POWER_STATE_HALTED
    3.58 +DOM_STATE_PAUSED = XEN_API_VM_POWER_STATE_PAUSED
    3.59 +DOM_STATE_RUNNING = XEN_API_VM_POWER_STATE_RUNNING
    3.60 +DOM_STATE_SUSPENDED = XEN_API_VM_POWER_STATE_SUSPENDED
    3.61 +DOM_STATE_SHUTDOWN = XEN_API_VM_POWER_STATE_SHUTTINGDOWN
    3.62 +DOM_STATE_UNKNOWN = XEN_API_VM_POWER_STATE_UNKNOWN
    3.63 +
    3.64 +DOM_STATES_OLD = [
    3.65 +    'running',
    3.66 +    'blocked',
    3.67 +    'paused',
    3.68 +    'shutdown',
    3.69 +    'crashed',
    3.70 +    'dying'
    3.71 +    ]
    3.72 +
    3.73 +STATE_DOM_OK       = 1
    3.74 +STATE_DOM_SHUTDOWN = 2
    3.75 +
    3.76 +SHUTDOWN_TIMEOUT = 30.0
    3.77 +
    3.78 +ZOMBIE_PREFIX = 'Zombie-'
    3.79 +
    3.80 +"""Minimum time between domain restarts in seconds."""
    3.81 +MINIMUM_RESTART_TIME = 20
    3.82 +
    3.83 +RESTART_IN_PROGRESS = 'xend/restart_in_progress'
    3.84 +
    3.85 +#
    3.86 +# Device migration stages (eg. XendDomainInfo, XendCheckpoint, server.tpmif)
    3.87 +#
    3.88 +
    3.89 +DEV_MIGRATE_TEST  = 0
    3.90 +DEV_MIGRATE_STEP1 = 1
    3.91 +DEV_MIGRATE_STEP2 = 2
    3.92 +DEV_MIGRATE_STEP3 = 3
    3.93 +
    3.94 +#
    3.95 +# Xenstore Constants
    3.96 +#
    3.97 +
    3.98 +XS_VMROOT = "/vm/"
    3.99 +
     4.1 --- a/tools/python/xen/xend/image.py	Thu Oct 05 17:29:19 2006 +0100
     4.2 +++ b/tools/python/xen/xend/image.py	Thu Oct 05 17:29:19 2006 +0100
     4.3 @@ -412,7 +412,7 @@ class HVMImageHandler(ImageHandler):
     4.4          """ watch call back on node control/shutdown,
     4.5              if node changed, this function will be called
     4.6          """
     4.7 -        from xen.xend.XendDomainInfo import shutdown_reasons
     4.8 +        from xen.xend.XendConstants import DOMAIN_SHUTDOWN_REASONS
     4.9          xd = xen.xend.XendDomain.instance()
    4.10          vm = xd.domain_lookup( self.vm.getDomid() )
    4.11  
     5.1 --- a/tools/python/xen/xend/server/tpmif.py	Thu Oct 05 17:29:19 2006 +0100
     5.2 +++ b/tools/python/xen/xend/server/tpmif.py	Thu Oct 05 17:29:19 2006 +0100
     5.3 @@ -22,20 +22,17 @@
     5.4  """
     5.5  
     5.6  from xen.xend import sxp
     5.7 +from xen.xend import XendRoot
     5.8  from xen.xend.XendLogging import log
     5.9  from xen.xend.XendError import XendError
    5.10 -from xen.xend import XendRoot
    5.11 -from xen.xend.XendDomainInfo import DEV_MIGRATE_TEST
    5.12 -
    5.13 +from xen.xend.XendConstants import DEV_MIGRATE_TEST
    5.14  from xen.xend.server.DevController import DevController
    5.15  
    5.16  import os
    5.17  import re
    5.18  
    5.19 -
    5.20  xroot = XendRoot.instance()
    5.21  
    5.22 -
    5.23  class TPMifController(DevController):
    5.24      """TPM interface controller. Handles all TPM devices for a domain.
    5.25      """