X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/8d1a2a64c35bc77779b1dce136d1a1595a9c1fe4..911a495b6553598d29c7b23294651be3cb602ce5:/lib/constants.py diff --git a/lib/constants.py b/lib/constants.py index b6305d4..d3a8c10 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -24,11 +24,12 @@ from ganeti import _autoconf # various versions -PROTOCOL_VERSION = 12 +PROTOCOL_VERSION = 13 RELEASE_VERSION = _autoconf.PACKAGE_VERSION OS_API_VERSION = 5 EXPORT_VERSION = 0 + # Format for CONFIG_VERSION: # 01 03 0123 = 01030123 # ^^ ^^ ^^^^ @@ -37,27 +38,63 @@ EXPORT_VERSION = 0 # + Major version # # It stored as an integer. Make sure not to write an octal number. -# + +# BuildVersion and SplitVersion must be in here because we can't import other +# modules. The cfgupgrade tool must be able to read and write version numbers +# and thus requires these functions. To avoid code duplication, they're kept in +# here. + +def BuildVersion(major, minor, revision): + """Calculates int version number from major, minor and revision numbers. + + Returns: int representing version number + + """ + assert isinstance(major, int) + assert isinstance(minor, int) + assert isinstance(revision, int) + return (1000000 * major + + 10000 * minor + + 1 * revision) + + +def SplitVersion(version): + """Splits version number stored in an int. + + Returns: tuple; (major, minor, revision) + + """ + assert isinstance(version, int) + + (major, remainder) = divmod(version, 1000000) + (minor, revision) = divmod(remainder, 10000) + + return (major, minor, revision) + + CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR) CONFIG_MINOR = int(_autoconf.VERSION_MINOR) CONFIG_REVISION = 0 -CONFIG_VERSION = ( - 1000000 * CONFIG_MAJOR + - 10000 * CONFIG_MINOR + - 1 * CONFIG_REVISION) +CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION) # file paths DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti" RUN_DIR = _autoconf.LOCALSTATEDIR + "/run" -BDEV_CACHE_DIR = RUN_DIR + "/ganeti" +RUN_GANETI_DIR = RUN_DIR + "/ganeti" +BDEV_CACHE_DIR = RUN_GANETI_DIR # TODO(2.0): move deeper +DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks" +# keep RUN_GANETI_DIR first here, to make sure all get created when the node +# daemon is started (this takes care of RUN_DIR being tmpfs) +SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ] LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock" CLUSTER_CONF_FILE = DATA_DIR + "/config.data" SSL_CERT_FILE = DATA_DIR + "/server.pem" WATCHER_STATEFILE = DATA_DIR + "/watcher.data" SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts" +QUEUE_DIR = DATA_DIR + "/queue" ETC_HOSTS = "/etc/hosts" DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR -MASTER_SOCKET = RUN_DIR + "/ganeti-master.sock" +MASTER_SOCKET = RUN_GANETI_DIR + "/master.sock" NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti" DEFAULT_NODED_PORT = 1811 @@ -142,6 +179,7 @@ INISECT_INS = "instance" # common exit codes EXIT_SUCCESS = 0 +EXIT_FAILURE = 1 EXIT_NOTMASTER = 11 EXIT_NODESETUP_ERROR = 12 EXIT_CONFIRMATION = 13 # need user confirmation @@ -206,3 +244,21 @@ IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH IARUN_NOTFOUND = 1 IARUN_FAILURE = 2 IARUN_SUCCESS = 3 + +# Job queue +JOB_QUEUE_VERSION = 1 +JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock" +JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version" +JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial" + +# Job status +JOB_STATUS_QUEUED = "queued" +JOB_STATUS_RUNNING = "running" +JOB_STATUS_CANCELED = "canceled" +JOB_STATUS_SUCCESS = "success" +JOB_STATUS_ERROR = "error" + +OP_STATUS_QUEUED = "queued" +OP_STATUS_RUNNING = "running" +OP_STATUS_SUCCESS = "success" +OP_STATUS_ERROR = "error"