Commit a4417db4 authored by Thomas Thrainer's avatar Thomas Thrainer

Merge branch 'stable-2.10' into master

Merge branch 'stable-2.10' into master

* stable-2.10
  Don't allow optional node parameters
  Move OVS node parameters to the right place
  Make NIC VLAN queryable
  Pass VLAN parameter correctly in moves
  Use constant instead of raw string
  Merge 'hs2py-constants' into 'hs2py'
  Add flag '--opcodes' to 'hs2py'
  Sort design docs alphabetically
  Missing design docs from distribution
  When loading configuration fails, include the reason
  Fixing rapi documentation wrt to storage types
  Move Haskell constants to proper module
  Tear down Py2Hs constant infrastructure
  Hs2Py constants: additional module jstore
  Hs2Py constants: additional module errors
  Hs2Py constants: additional module qlang
  Hs2Py constants: additional module luxi
  Remove module 'ganeti.constants' from 'convert-constants'
  Fix reference to vcs version in query server
  Eliminate unused constants
  Use configure constants instead of generated
  Hs2Py constants: add 'UUID_REGEX'
  Add 'AF_INET*' constants to Haskell's 'AutoConf'
  Python autotool to print socket constants

* stable-2.9
  Bump revision for 2.9.1
  Update NEWS and schedule release for 2.9.1
  Fix retrieval of xen command in class method
  Fix docstring for ganeti.storage.filestorage_unittest.py
  Undo revision bump
  Postpone release of 2.9.1
  Revision bump for 2.9.1
  Update NEWS for 2.9.1 release
  Readd nodes as online
  When verifying BRBD version, ignore missing values

* stable-2.8
  Version bump for 2.8.2
  Update NEWS file for 2.8.2 release
  DRBD: ensure peers are UpToDate for dual-primary

Conflicts:
	Makefile.am: Add design docs from both sides (sorted); Remove
                 rules for hs2py-constants
	lib/hypervisor/hv_xen.py: Merge parameter list of
                              GetInstanceConsole
	lib/luxi.py: Use generated constant for REQ_PICKUP_JOB
	src/Ganeti/ConfigReader.hs: trivial
	src/Ganeti/HsConstants.hs: Manually add UserDown and ndSshPort
                               related constants to Constants.hs
	src/Ganeti/Query/Server.hs: trivial
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parents 0808e9d5 adef95a2
......@@ -146,6 +146,5 @@
/src/AutoConf.hs
/src/Ganeti/Curl/Internal.hs
/src/Ganeti/Hs2Py/ListConstants.hs
/src/Ganeti/PyConstants.hs
/src/Ganeti/Version.hs
/test/hs/Test/Ganeti/TestImports.hs
......@@ -36,7 +36,7 @@ CHECK_NEWS = $(top_srcdir)/autotools/check-news
CHECK_IMPORTS = $(top_srcdir)/autotools/check-imports
DOCPP = $(top_srcdir)/autotools/docpp
REPLACE_VARS_SED = autotools/replace_vars.sed
CONVERT_CONSTANTS = $(top_srcdir)/autotools/convert-constants
PRINT_PY_CONSTANTS = $(top_srcdir)/autotools/print-py-constants
BUILD_RPC = $(top_srcdir)/autotools/build-rpc
SHELL_ENV_INIT = autotools/shell-env-init
......@@ -269,7 +269,6 @@ CLEANFILES = \
src/ganeti-confd \
src/ganeti-luxid \
src/ganeti-mond \
src/hs2py-constants \
.hpc/*.mix src/*.tix test/hs/*.tix *.tix \
doc/hs-lint.html
......@@ -488,10 +487,10 @@ utils_PYTHON = \
lib/utils/x509.py
docinput = \
doc/conf.py \
doc/css/style.css \
doc/admin.rst \
doc/cluster-merge.rst \
doc/conf.py \
doc/css/style.css \
doc/design-2.0.rst \
doc/design-2.1.rst \
doc/design-2.2.rst \
......@@ -505,43 +504,46 @@ docinput = \
doc/design-2.10.rst \
doc/design-autorepair.rst \
doc/design-bulk-create.rst \
doc/design-ceph-ganeti-support.rst \
doc/design-chained-jobs.rst \
doc/design-cmdlib-unittests.rst \
doc/design-cpu-pinning.rst \
doc/design-daemons.rst \
doc/design-device-uuid-name.rst \
doc/design-draft.rst \
doc/design-hotplug.rst \
doc/design-glusterfs-ganeti-support.rst \
doc/design-daemons.rst \
doc/design-hotplug.rst \
doc/design-hroller.rst \
doc/design-hsqueeze.rst \
doc/design-htools-2.3.rst \
doc/design-http-server.rst \
doc/design-hugepages-support.rst \
doc/design-impexp2.rst \
doc/design-internal-shutdown.rst \
doc/design-lu-generated-jobs.rst \
doc/design-linuxha.rst \
doc/design-lu-generated-jobs.rst \
doc/design-monitoring-agent.rst \
doc/design-multi-reloc.rst \
doc/design-multi-version-tests.rst \
doc/design-multi-version-tests.rst \
doc/design-network.rst \
doc/design-node-add.rst \
doc/design-oob.rst \
doc/design-openvswitch.rst \
doc/design-ovf-support.rst \
doc/design-opportunistic-locking.rst \
doc/design-optables.rst \
doc/design-ovf-support.rst \
doc/design-partitioned.rst \
doc/design-query-splitting.rst \
doc/design-query2.rst \
doc/design-query-splitting.rst \
doc/design-reason-trail.rst \
doc/design-resource-model.rst \
doc/design-restricted-commands.rst \
doc/design-shared-storage.rst \
doc/design-monitoring-agent.rst \
doc/design-ssh-ports.rst \
doc/design-storagetypes.rst \
doc/design-upgrade.rst \
doc/design-virtual-clusters.rst \
doc/design-x509-ca.rst \
doc/design-hroller.rst \
doc/design-storagetypes.rst \
doc/design-upgrade.rst \
doc/design-hsqueeze.rst \
doc/design-ssh-ports.rst \
doc/devnotes.rst \
doc/glossary.rst \
doc/hooks.rst \
......@@ -599,9 +601,7 @@ HS_DEFAULT_PROGS = \
HS_ALL_PROGS = $(HS_DEFAULT_PROGS) $(HS_MYEXECLIB_PROGS)
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) \
src/mon-collector.hs \
src/hs2py-constants.hs
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) src/mon-collector.hs
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
HFLAGS = \
......@@ -688,7 +688,6 @@ HS_LIB_SRCS = \
src/Ganeti/Hs2Py/GenConstants.hs \
src/Ganeti/Hs2Py/GenOpCodes.hs \
src/Ganeti/Hs2Py/OpDoc.hs \
src/Ganeti/HsConstants.hs \
src/Ganeti/JQueue.hs \
src/Ganeti/JSON.hs \
src/Ganeti/Jobs.hs \
......@@ -785,7 +784,6 @@ HS_BUILT_SRCS = \
test/hs/Test/Ganeti/TestImports.hs \
src/AutoConf.hs \
src/Ganeti/Hs2Py/ListConstants.hs \
src/Ganeti/PyConstants.hs \
src/Ganeti/Curl/Internal.hs \
src/Ganeti/Version.hs
HS_BUILT_SRCS_IN = \
......@@ -988,32 +986,6 @@ HFLAGS += $(if $(HPROFILE),-prof -auto-all,)
HFLAGS += $(if $(HCOVERAGE),-fhpc,)
HFLAGS += $(if $(HTEST),-DTEST,)
HS2PY_CONSTANTS_SRCS = src/hs2py-constants.hs \
src/AutoConf.hs \
src/Ganeti/BasicTypes.hs \
src/Ganeti/ConstantUtils.hs \
src/Ganeti/JSON.hs \
src/Ganeti/THH.hs \
src/Ganeti/Hs2Py/GenConstants.hs \
src/Ganeti/Hs2Py/ListConstants.hs \
src/Ganeti/HsConstants.hs \
src/Ganeti/PyValueInstances.hs
# This target cannot be merged with the '$(HS_ALL_PROGS)' target
# because 'hs2py-constants' cannot depend on 'Ganeti.Constants'. And
# the reason for this is because 'hs2py-constants' needs to generate
# Python code, and 'Ganeti.Constants' is generated by Python.
.NOTPARALLEL: src/hs2py-constants
.PHONY: src/hs2py-constants
src/hs2py-constants: $(HS2PY_CONSTANTS_SRCS) \
| stamp-srclinks
@rm -f $@.tix
$(GHC) --make $(HFLAGS) \
-osuf $(HSUFFIX) \
-hisuf $(patsubst %.o,%.hi,$(HSUFFIX)) \
$(HEXTRA) \
src/hs2py-constants.hs
HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
.NOTPARALLEL: $(HS_ALL_PROGS)
......@@ -1153,9 +1125,9 @@ EXTRA_DIST = \
autotools/check-python-code \
autotools/check-tar \
autotools/check-version \
autotools/convert-constants \
autotools/docpp \
autotools/gen-py-coverage \
autotools/print-py-constants \
autotools/sphinx-wrapper \
autotools/testrunner \
autotools/wrong-hardcoded-paths \
......@@ -1763,11 +1735,11 @@ src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \
sed -e "s/%ver%/$$VCSVER/" < $< > $@
src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \
src/Ganeti/HsConstants.hs \
src/Ganeti/Constants.hs \
| stamp-directories
@echo Generating $@
@set -e; \
## Extract constant names from 'HsConstants.hs' by extracting the left
## Extract constant names from 'Constants.hs' by extracting the left
## side of all lines containing an equal sign (i.e., '=') and
## prepending the apostrophe sign (i.e., "'").
##
......@@ -1775,20 +1747,10 @@ src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \
## adminstDown = ...
## becomes
## 'adminstDown
NAMES=$$(sed -e "/^--/ d" $(abs_top_srcdir)/src/Ganeti/HsConstants.hs |\
NAMES=$$(sed -e "/^--/ d" $(abs_top_srcdir)/src/Ganeti/Constants.hs |\
sed -n -e "/=/ s/\(.*\) =.*/ '\1:/g p"); \
m4 -DPY_CONSTANT_NAMES="$$NAMES" $(abs_top_srcdir)/$< > $@
src/Ganeti/PyConstants.hs: src/Ganeti/PyConstants.hs.in \
lib/constants.py lib/luxi.py lib/errors.py \
lib/jstore.py $(RUN_IN_TEMPDIR) \
$(CONVERT_CONSTANTS) $(built_base_sources) \
| lib/_vcsversion.py
set -e; \
{ cat $< ; \
PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(CONVERT_CONSTANTS); \
} > $@
src/Ganeti/Curl/Internal.hs: src/Ganeti/Curl/Internal.hsc | stamp-directories
hsc2hs -o $@ $<
......@@ -1802,14 +1764,14 @@ test/hs/Test/Ganeti/TestImports.hs: test/hs/Test/Ganeti/TestImports.hs.in \
done ; \
} > $@
lib/_constants.py: Makefile lib/_constants.py.in src/hs2py-constants \
| stamp-directories
lib/_constants.py: Makefile src/hs2py lib/_constants.py.in | stamp-directories
cat $(abs_top_srcdir)/lib/_constants.py.in > $@
src/hs2py-constants >> $@
src/hs2py --constants >> $@
lib/constants.py: lib/_constants.py
src/AutoConf.hs: Makefile src/AutoConf.hs.in | stamp-directories
src/AutoConf.hs: Makefile src/AutoConf.hs.in $(PRINT_PY_CONSTANTS) \
| $(built_base_sources)
@echo "m4 ... >" $@
@m4 -DPACKAGE_VERSION="$(PACKAGE_VERSION)" \
-DVERSION_MAJOR="$(VERSION_MAJOR)" \
......@@ -1874,6 +1836,8 @@ src/AutoConf.hs: Makefile src/AutoConf.hs.in | stamp-directories
-DMAN_PAGES="$$(for i in $(notdir $(man_MANS)); do \
echo -n "$$i" | sed -re 's/^(.*)\.([0-9]+)$$/("\1",\2):/g'; \
done)" \
-DAF_INET4="$$(PYTHONPATH=. python $(PRINT_PY_CONSTANTS) AF_INET4)" \
-DAF_INET6="$$(PYTHONPATH=. python $(PRINT_PY_CONSTANTS) AF_INET6)" \
$(abs_top_srcdir)/src/AutoConf.hs.in > $@
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
......@@ -1897,11 +1861,10 @@ lib/_vcsversion.py: Makefile vcs-version | stamp-directories
echo "VCS_VERSION = '$$VCSVER'"; \
} > $@
lib/opcodes.py: Makefile src/hs2py src/Ganeti/PyConstants.hs \
lib/opcodes.py.in_before lib/opcodes.py.in_after \
| stamp-directories
lib/opcodes.py: Makefile src/hs2py lib/opcodes.py.in_before \
lib/opcodes.py.in_after | stamp-directories
cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
src/hs2py >> $@
src/hs2py --opcodes >> $@
cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
lib/_generated_rpc.py: lib/rpc_defs.py $(BUILD_RPC)
......
......@@ -76,7 +76,7 @@ Misc changes
- Opcodes are entirely generated from Haskell using the tool 'hs2py' and
the module 'src/Ganeti/OpCodes.hs'.
- Constants are also generated from Haskell using the tool
'hs2py-constants' and the module 'src/Ganeti/HsConstants.hs', with the
'hs2py-constants' and the module 'src/Ganeti/Constants.hs', with the
exception of socket related constants, which require changing the
cluster configuration file, and HVS related constants, because they
are part of a port of instance queries to Haskell. As a result, these
......@@ -93,6 +93,18 @@ Python
version 1.0.1. It is still used for testing only.
Version 2.9.1
-------------
*(Released Wed, 13 Nov 2013)*
- fix bug, that kept nodes offline when readding
- when verifying DRBD versions, ignore unavailable nodes
- fix bug that made the console unavailable on kvm in split-user
setup (issue 608)
- DRBD: ensure peers are UpToDate for dual-primary (inherited 2.8.2)
Version 2.9.0
-------------
......@@ -216,6 +228,17 @@ This was the first beta release of the 2.9 series. All important changes
are listed in the latest 2.9 entry.
Version 2.8.2
-------------
*(Released Thu, 07 Nov 2013)*
- DRBD: ensure peers are UpToDate for dual-primary
- Improve error message for replace-disks
- More dependency checks at configure time
- Placate warnings on ganeti.outils_unittest.py
Version 2.8.1
-------------
......
#!/usr/bin/python
#
# Copyright (C) 2011, 2012, 2013 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Script for converting Python constants to Haskell code fragments.
"""
import re
import types
from ganeti import _constants
from ganeti import compat
from ganeti import constants
from ganeti import errors
from ganeti import luxi
from ganeti import qlang
from ganeti import jstore
#: Constant name regex
CONSTANT_RE = re.compile("^[A-Z][A-Z0-9_-]+$")
#: Private name regex
PRIVATE_RE = re.compile("^__.+__$")
#: The type of regex objects
RE_TYPE = type(CONSTANT_RE)
#: Keys which do not declare a value (manually maintained). By adding
# values here, we can make more lists use the actual names; otherwise
# we'll have (e.g.) both DEFAULT_ENABLED_HYPERVISOR and HT_XEN_PVM
# declare the same value, and thus the list of valid hypervisors will
# have strings instead of easily looked-up names.
IGNORED_DECL_NAMES = ["DEFAULT_ENABLED_HYPERVISOR"]
def NameRules(name):
"""Converts the upper-cased Python name to Haskell camelCase.
"""
name = name.replace("-", "_")
elems = name.split("_")
return elems[0].lower() + "".join(e.capitalize() for e in elems[1:])
def StringValueRules(value):
"""Converts a string value from Python to Haskell.
"""
value = value.encode("string_escape") # escapes backslashes
value = value.replace("\"", "\\\"")
return value
def DictKeyName(dict_name, key_name):
"""Converts a dict plus key name to a full name.
"""
return"%s_%s" % (dict_name, str(key_name).upper())
def HaskellTypeVal(value):
"""Returns the Haskell type and value for a Python value.
Note that this only work for 'plain' Python types.
@returns: (string, string) or None, if we can't determine the type.
"""
if isinstance(value, basestring):
return ("String", "\"%s\"" % StringValueRules(value))
elif isinstance(value, bool):
return ("Bool", "%s" % value)
elif isinstance(value, int):
return ("Int", "%d" % value)
elif isinstance(value, long):
return ("Integer", "%d" % value)
elif isinstance(value, float):
return ("Double", "%f" % value)
else:
return None
def IdentifyOrigin(all_items, value):
"""Tries to identify a constant name from a constant's value.
This uses a simple algorithm: is there a constant (and only one)
with the same value? If so, then it returns that constants' name.
@note: it is recommended to use this only for tuples/lists/sets, and
not for individual (top-level) values
@param all_items: a dictionary of name/values for the current module
@param value: the value for which we try to find an origin
"""
found = [name for (name, v) in all_items.items()
if v is value and name not in IGNORED_DECL_NAMES]
if len(found) == 1:
return found[0]
else:
return None
def FormatListElems(all_items, pfx_name, ovals, tvals):
"""Formats a list's elements.
This formats the elements as either values or, if we find all
origins, as names.
@param all_items: a dictionary of name/values for the current module
@param pfx_name: the prefix name currently used
@param ovals: the list of actual (Python) values
@param tvals: the list of values we want to format in the Haskell form
"""
origins = [IdentifyOrigin(all_items, v) for v in ovals]
if compat.all(x is not None for x in origins):
values = [NameRules(pfx_name + origin) for origin in origins]
else:
values = tvals
return ", ".join(values)
def FormatDict(all_items, pfx_name, py_name, hs_name, mydict):
"""Converts a dictionary to a Haskell association list ([(k, v)]),
if possible.
@param all_items: a dictionary of name/values for the current module
@param pfx_name: the prefix name currently used
@param py_name: the Python name
@param hs_name: the Haskell name
@param mydict: a dictonary, unknown yet if homogenous or not
"""
# need this for ordering
orig_list = mydict.items()
list_form = [(HaskellTypeVal(k), HaskellTypeVal(v)) for k, v in orig_list]
if compat.any(v is None or k is None for k, v in list_form):
# type not known
return []
all_keys = [k for k, _ in list_form]
all_vals = [v for _, v in list_form]
key_types = set(k[0] for k in all_keys)
val_types = set(v[0] for v in all_vals)
if not(len(key_types) == 1 and len(val_types) == 1):
# multiple types
return []
# record the key and value Haskell types
key_type = key_types.pop()
val_type = val_types.pop()
# now try to find names for the keys, instead of raw values
key_origins = [IdentifyOrigin(all_items, k) for k, _ in orig_list]
if compat.all(x is not None for x in key_origins):
key_v = [NameRules(pfx_name + origin) for origin in key_origins]
else:
key_v = [k[1] for k in all_keys]
# ... and for values
val_origins = [IdentifyOrigin(all_items, v) for _, v in orig_list]
if compat.all(x is not None for x in val_origins):
val_v = [NameRules(pfx_name + origin) for origin in val_origins]
else:
val_v = [v[1] for v in all_vals]
# finally generate the output
kv_pairs = ["(%s, %s)" % (k, v) for k, v in zip(key_v, val_v)]
return ["-- | Converted from Python dictionary @%s@" % py_name,
"%s :: [(%s, %s)]" % (hs_name, key_type, val_type),
"%s = [%s]" % (hs_name, ", ".join(kv_pairs)),
]
def ConvertVariable(prefix, name, value, all_items):
"""Converts a given variable to Haskell code.
@param prefix: a prefix for the Haskell name (useful for module
identification)
@param name: the Python name
@param value: the value
@param all_items: a dictionary of name/value for the module being
processed
@return: a list of Haskell code lines
"""
lines = []
if prefix:
pfx_name = prefix + "_"
fqn = prefix + "." + name
else:
pfx_name = ""
fqn = name
hs_name = NameRules(pfx_name + name)
hs_typeval = HaskellTypeVal(value)
if (isinstance(value, types.ModuleType) or callable(value) or
PRIVATE_RE.match(name)):
# no sense in marking these, as we don't _want_ to convert them; the
# message in the next if block is for datatypes we don't _know_
# (yet) how to convert
pass
elif not CONSTANT_RE.match(name):
lines.append("-- Skipped %s %s, not constant" % (fqn, type(value)))
elif hs_typeval is not None:
# this is a simple value
(hs_type, hs_val) = hs_typeval
lines.append("-- | Converted from Python constant @%s@" % fqn)
lines.append("%s :: %s" % (hs_name, hs_type))
lines.append("%s = %s" % (hs_name, hs_val))
elif isinstance(value, dict):
if value:
lines.append("-- Following lines come from dictionary %s" % fqn)
# try to build a real map here, if all keys have same type, and
# all values too (i.e. we have a homogeneous dictionary)
lines.extend(FormatDict(all_items, pfx_name, fqn, hs_name, value))
# and now create individual names
for k in sorted(value.keys()):
lines.extend(ConvertVariable(prefix, DictKeyName(name, k),
value[k], all_items))
elif isinstance(value, tuple):
tvs = [HaskellTypeVal(elem) for elem in value]
# Custom rule for special cluster verify error tuples
if name.startswith("CV_E") and len(value) == 3 and tvs[1][0] is not None:
cv_ename = hs_name + "Code"
lines.append("-- | Special cluster verify code %s" % name)
lines.append("%s :: %s" % (cv_ename, tvs[1][0]))
lines.append("%s = %s" % (cv_ename, tvs[1][1]))
lines.append("")
if compat.all(e is not None for e in tvs):
ttypes = ", ".join(e[0] for e in tvs)
tvals = FormatListElems(all_items, pfx_name, value, [e[1] for e in tvs])
lines.append("-- | Converted from Python tuple @%s@" % fqn)
lines.append("%s :: (%s)" % (hs_name, ttypes))
lines.append("%s = (%s)" % (hs_name, tvals))
else:
lines.append("-- Skipped tuple %s, cannot convert all elements" % fqn)
elif isinstance(value, (list, set, frozenset)):
# Lists and frozensets are handled the same in Haskell: as lists,
# since lists are immutable and we don't need for constants the
# high-speed of an actual Set type. However, we can only convert
# them if they have the same type for all elements (which is a
# normal expectation for constants, our code should be well
# behaved); note that this is different from the tuples case,
# where we always (for some values of always) can convert
tvs = [HaskellTypeVal(elem) for elem in value]
if compat.all(e is not None for e in tvs):
ttypes, tvals = zip(*tvs)
uniq_types = set(ttypes)
if len(uniq_types) == 1:
values = FormatListElems(all_items, pfx_name, value, tvals)
lines.append("-- | Converted from Python list or set @%s@" % fqn)
lines.append("%s :: [%s]" % (hs_name, uniq_types.pop()))
lines.append("%s = [%s]" % (hs_name, values))
else:
lines.append("-- | Skipped list/set %s, is not homogeneous" % fqn)
else:
lines.append("-- | Skipped list/set %s, cannot convert all elems" % fqn)
elif isinstance(value, RE_TYPE):
tvs = HaskellTypeVal(value.pattern)
assert tvs is not None
lines.append("-- | Converted from Python RE object @%s@" % fqn)
lines.append("%s :: %s" % (hs_name, tvs[0]))
lines.append("%s = %s" % (hs_name, tvs[1]))
else:
lines.append("-- Skipped %s, %s not handled" % (fqn, type(value)))
return lines
def Convert(module, prefix):
"""Converts the constants to Haskell.
"""
lines = [""]
all_items = dict((name, getattr(module, name))
for name in dir(module)
if name not in dir(_constants))
for name in sorted(all_items.keys()):
value = all_items[name]
new_lines = ConvertVariable(prefix, name, value, all_items)
if new_lines:
lines.extend(new_lines)
lines.append("")
return "\n".join(lines)
def main():
print Convert(constants, "")
print Convert(luxi, "luxi")
print Convert(qlang, "qlang")
print Convert(errors, "errors")
print Convert(jstore, "jstore")
if __name__ == "__main__":
main()
#!/usr/bin/python
#
# Copyright (C) 2013 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Script for printing Python constants related to sockets.
These constants are the remnants of the Haskell to Python constant
generation. This solution is transitional until Ganeti 2.11 because
the solution for eliminating completely the Python to Haskell
conversion requires updating the configuration file.
"""
import socket
import sys
def main():
if len(sys.argv) > 1:
if sys.argv[1] == "AF_INET4":
print "%s" % socket.AF_INET
elif sys.argv[1] == "AF_INET6":
print "%s" % socket.AF_INET6