Exchange2010OrgsUpgrade/ 0000755 0000000 0000000 00000000000 11742717322 013752 5 ustar root root Exchange2010OrgsUpgrade/modules/ 0000755 0000000 0000000 00000000000 11742717401 015420 5 ustar root root Exchange2010OrgsUpgrade/modules/uVZ.py 0000644 0000000 0000000 00000003333 11713723612 016517 0 ustar root root import uSysDB, openapi
from uGenerics import *
from uLogging import notice, err
import PEMVersion
__installed = None
__installTemplatesSupported = None
PKG_TYPE_EZ=2
PKG_TYPE_STD=1
def installed():
global __installed
if __installed is None:
con = uSysDB.connect()
cur = con.cursor()
cur.execute("SELECT 1 FROM service_classes WHERE name='VPSManager'")
__installed = bool(cur.fetchone())
return __installed
def isInstallTemplatesSupported():
global __installTemplatesSupported
if __installTemplatesSupported is None:
__installTemplatesSupported = installed() and PEMVersion.getSCVersion('VPSManager') >= '5.0.0.42'
return __installTemplatesSupported
class VZNotInstalled(Exception):
def __init__(self):
Exception.__init__(self, "VPS Manager is not installed")
def template_installed(host_id, templ):
if not installed():
return False
con = uSysDB.connect()
cur = con.cursor()
cur.execute("SELECT 1 FROM ve_templates vt JOIN vz_templates t ON (t.template_id = vt.template_id) WHERE t.name = %s AND vt.host_id = %s", templ, host_id)
return bool(cur.fetchone())
def import_template(tmpl_url):
if not installed():
raise VZNotInstalled()
api = openapi.OpenAPI()
try:
template_id = api.pem.virtuozzo.importTemplate(url=tmpl_url, platform="Linux")['template_id']
except openapi.OpenAPIError, e:
if e.module_id != "VPSTemplateManagement" or e.extype_id != 8:
raise
template_id = int(e.properties["template_id"])
return template_id
def list_template_urls():
if not installed():
return []
con = uSysDB.connect()
cur = con.cursor()
cur.execute("SELECT url FROM vz_templates WHERE url IS NOT NULL")
return [row[0] for row in cur.fetchall()]
Exchange2010OrgsUpgrade/modules/uDBFixer.py 0000644 0000000 0000000 00000011630 11713723610 017440 0 ustar root root __rcs_id__ = """$Id: uDBFixer.py 303710 2007-08-01 14:19:05Z mkhon $"""
from uDBErrors import *
from uDBSchema import *
class DBFixer:
# public constructor
def __init__(self):
self.target_con = None # connection to target db
self.target_tables = None # (schema name -> schema) mapping in target db, schema names must be unique so that tables from different scs are not welcome to be fixed together
# fix error in target db
# @e - object derived from DBError
def fix(e):
if isinstance(e, DBErrorMissingTable):
uDBSchema.createTable(e.schema, self.target_con)
elif isinstance(e, DBErrorRedundantTable):
uDBSchema.dropTable(e.table, self.target_con)
elif isinstance(e, DBErrorMissingColumn):
uDBSchema.addColumn(e.table, e.column, self.target_self.target_con)
elif isinstance(e, DBErrorNonconformingColumnType):
uDBSchema.changeColumnType(e.table, e.column.name, e.type, self.target_con)
elif isinstance(e, DBErrorColumnMissingNotNull):
uDBSchema.changeNullable(e.table, e.column, False, self.target_con)
elif isinstance(e, DBErrorColumnRedundantNotNull):
uDBSchema.changeNullable(e.table, e.column, True, self.target_con)
elif isinstance(e, DBErrorColumnMissingDefault):
uDBSchema.setDefault(e.table, e.column, e.default, self.target_con)
elif isinstance(e, DBErrorColumnNonconformingDefault):
uDBSchema.setDefault(e.table, e.column, e.default, self.target_con)
elif isinstance(e, DBErrorColumnRedundantDefault):
uDBSchema.setDefault(e.table, e.column, None, self.target_con)
elif isinstance(e, DBErrorRedundantColumn):
uDBSchema.dropColumn(e.table, e.column.name, self.target_con)
elif isinstance(e, DBErrorMissingIndex):
uDBSchema.addIndex(e.table, e.index, self.target_con)
elif isinstance(e, DBErrorNonconformingIndex):
uDBSchema.dropIndex(e.table, e.table_index, self.target_con)
uDBSchema.createIndex(e.table, e.schema_index, self.target_con)
elif isinstance(e, DBErrorRedundantIndex):
uDBSchema.dropIndex(e.table, e.table_index, self.target_con)
elif isinstance(e, DBErrorMissingPrimaryKey):
DBSchema.addConstraint(e.table, e.schema_pk, self.target_con)
elif isinstance(e, DBErrorNonconformingPrimaryKey):
# - determining tables referencing to this pk
# - if found then save and drop those fk constraints
if self.target_tables is not None:
table_fks = {} # (table name -> fk set) mapping in target db
for table in self.target_tables.values():
for constraint in table.constraints:
if isinstance(constraint, ForeignKey) and constraint.reftable == e.table.name and constraint.columns.sort() == e.table_pk.columns.sort():
if table_fks.has_key(constraint.name):
table_fks[constraint.name] = []
table_fks[constraint.name] += constraint
table.dropConstraint(constraint, self.target_con)
uDBSchema.dropConstraint(e.table, e.table_pk, self.target_con)
uDBSchema.addConstraint(e.table, e.schema_pk, self.target_con)
# - restoring dropped fk constraints
if self.target_tables is not None:
for table_name in table_fks.keys():
for fk in table_fks[table_name]:
self.target_tables[table_name].addConstraint(fk)
elif isinstance(e, DBErrorRedundantPrimaryKey):
uDBSchema.dropConstraint(e.table, e.table_pk, self.target_con)
elif isinstance(e, DBErrorMissingUnique):
uDBSchema.addConstraint(e.table, e.schema_unique, self.target_con)
elif isinstance(e, DBErrorNonconformingUnique):
uDBSchema.dropConstraint(e.table, e.table_unique, self.target_con)
uDBSchema.addConstraint(e.table, e.schema_unique, self.target_con)
elif isinstance(e, DBErrorRedundantUnique):
uDBSchema.dropConstraint(e.table, e.table_unique, self.target_con)
elif isinstance(e, DBErrorMissingForeignKey):
uDBSchema.addConstraint(e.table, e.schema_fk, self.target_con)
elif isinstance(e, DBErrorNonconformingForeignKey):
uDBSchema.dropConstraint(e.table, e.table_fk, self.target_con)
uDBSchema.addConstraint(e.table, e.schema_fk, self.target_con)
elif isinstance(e, DBErrorRedundantForeignKey):
uDBSchema.dropConstraint(e.table, e.table_fk, self.target_con)
elif isinstance(e, DBErrorMissingCheck):
uDBSchema.addConstraint(e.table, e.schema_check, self.target_con)
elif isinstance(e, DBErrorNonconformingCheck):
uDBSchema.dropConstraint(e.table, e.table_check, self.target_con)
uDBSchema.addConstraint(e.table, e.schema_check, self.target_con)
elif isinstance(e, DBErrorRedundantCheck):
uDBSchema.dropConstraint(e.table, e.check_fk, self.target_con)
elif isinstance(e, DBErrorMissingSequence):
pass
elif isinstance(e, DBErrorRedundantSequence):
pass
elif isinstance(e, DBErrorRedundantView):
pass
elif isinstance(e, DBErrorRedundantTrigger):
pass
elif isinstance(e, DBErrorNonconformingFunction):
pass
elif isinstance(e, DBErrorRedundantFunction):
pass
elif isinstance(e, DBError):
pass
Exchange2010OrgsUpgrade/modules/snackInstallerUI.py 0000644 0000000 0000000 00000026175 11713723612 021217 0 ustar root root #!/usr/bin/python
import sys
import uLogging, uUtil # to shut them up
import uLinux, socket, os, signal
__pychecker__ = "blacklist=snack"
from snack import *
# we want escape
ESC = chr(27)
hotkeys[ESC] = ord(ESC)
hotkeys[ord(ESC)] = ESC
Ok_Cancel_Names = [ "Ok", ("Cancel", 'cancel', ESC) ]
_screen = None
def scallback():
if _screen is not None:
_screen.suspend()
os.kill(os.getpid(), signal.SIGSTOP)
_screen.resume()
def initScreen():
global _screen
_screen = SnackScreen()
_screen.suspendCallback(scallback)
def askYesNo(question, default = None):
answer = ButtonChoiceWindow(_screen, "?", question, [ "Yes", ("No", "no", ESC)])
if answer:
return answer.lower() == 'yes'
else:
return default
def showLicense(title, text):
initScreen()
try:
width = _screen.width - _screen.width / 6
rv = ButtonChoiceWindow(_screen, title, text, [("I agree", 'ok'), ("I do not agree", 'cancel', ESC) ], width)
return rv.lower() == 'ok'
finally:
_screen.finish()
def message(title, text, btns):
initScreen()
try:
width = _screen.width - _screen.width / 6
ButtonChoiceWindow(_screen, title, text, btns, width)
finally:
_screen.finish()
def congrat(text):
message("CONGRATULATIONS!", text, [("Ok", "ok")])
def error(text):
message("ERROR", text, [("Close", "close")])
class InstallationProgress:
def __init__(self):
self.phase = None
def new_phase(self, phase):
initScreen()
self.phase = phase
self.width = _screen.width * 4 / 5
self.scale = Scale(self.width, 100)
self.percents = 0
self.scale.set(self.percents)
g = Grid(1, 2)
g.setField(self.scale, 0, 0)
self.status = Textbox(self.width, 1, "")
g.setField(self.status, 0, 1)
_screen.gridWrappedWindow(g, self.phase)
self.form = Form()
self.form.add(self.scale)
self.form.add(self.status)
def set_progress(self, pval, what = ""):
self.percents = pval
self.scale.set(self.percents)
if what:
self.status.setText(what)
self.form.draw()
self.form.setTimer(1)
self.form.run()
_screen.refresh()
def end_phase(self):
if _screen:
_screen.finish()
def choose_modules(build, props):
global _screen
try:
mprop = props.get("modules", "")
if mprop.lower() == "all":
default_modules = [ m.name for m in build.modules ]
else:
default_modules = [ m.strip() for m in props.get("modules", "").split(",")]
initScreen()
top_grid = Grid(1, 2)
# buttons_grid = Grid(2, 1)
max_height = _screen.height * 2 / 3
required_height = len(build.modules)
height = min(required_height, max_height)
mcheckboxes = CheckboxTree(height, required_height >= max_height)
for module in build.modules:
if module.name != 'Platform':
mcheckboxes.append(module.description, module.name, module.name in default_modules)
top_grid.setField(mcheckboxes, 0, 0)
ok_cancel = ButtonBar(_screen, Ok_Cancel_Names)
top_grid.setField(ok_cancel, 0, 1)
_screen.gridWrappedWindow(top_grid, "Choose modules you want to install")
form = Form()
form.add(mcheckboxes)
form.add(ok_cancel)
result = form.run()
bpressed = ok_cancel.buttonPressed(result)
if bpressed == 'cancel':
raise Exception("Installation is cancelled")
return mcheckboxes.getSelection()
finally:
_screen.finish()
class InputElement:
def __init__(self, title, inp, width):
self.inp = inp
self.grid = Grid(2, 1)
title_elem = Textbox(width / 2, 1, title + ":")
self.grid.setField(title_elem, 0, 0)
self.grid.setField(inp, 1, 0)
def activate(self, result):
pass
def error(self):
return None
def update_properties(self, properties):
pass
class InputNetiface(InputElement):
def __init__(self, title, variants, prefix, width):
def iface_to_str(iface):
name, ip, mask = iface
return "%s (%s)" % (name, ip)
inp = None
self.prefix = prefix
self.variants = variants
if len(self.variants) == 0:
raise Exception("Could not find any valid net interface")
elif len(self.variants) == 1:
inp = Textbox(width / 2, 1, iface_to_str(self.variants[0]))
else:
inp = Listbox(1, scroll = 0, width = width / 2, showCursor = 1)
for v in self.variants:
inp.append(iface_to_str(v), v)
InputElement.__init__(self, title, inp, width)
def update_properties(self, p):
if len(self.variants) == 1:
chosen = self.variants[0]
else:
chosen = self.inp.current()
p['%s_netiface_name' % self.prefix], p['%s_ip' % self.prefix], p['%s_netmask' % self.prefix] = chosen
class InputText(InputElement):
def __init__(self, title, default, width, password = False, propname = None):
inp = Entry(width / 2, text = default, scroll = 0, password = password)
InputElement.__init__(self, title, inp, width)
self.propname = propname
def update_properties(self, properties):
if self.propname is not None:
properties[self.propname] = self.inp.value()
def error(self):
if self.propname is not None and not self.inp.value():
return "%s is not specified" % self.propname.capitalize()
return None
def cmp_fn(first, second):
if first.endswith('/') and not second.endswith('/'):
return -1
elif not first.endswith('/') and second.endswith('/'):
return 1
else:
return cmp(first, second)
class InputFile(InputElement):
def __init__(self, title, default, width, dialog_title):
inp = Grid(2, 1)
self.filename = Entry(width / 2 - 9, default, scroll = 0)
self.browse_button = CompactButton("Browse")
self.dialog_title = dialog_title
inp.setField(self.filename, 0, 0)
inp.setField(self.browse_button, 1, 0)
if default and os.path.exists(default):
self.cwd = os.path.dirname(default)
if not self.cwd:
self.cwd = os.getcwd()
else:
self.cwd = os.path.realpath(self.cwd)
else:
self.cwd = os.getcwd()
InputElement.__init__(self, title, inp, width)
def activate(self, result):
global _screen
if result != self.browse_button:
return
uLogging.notice("%s", result)
height = _screen.height * 2 / 3;
width = 20
box = Listbox(height, scroll = True, returnExit = 1, width = width)
chosen = None
form = Form()
grid = Grid(1, 1)
grid.setField(box, 0, 0)
form.add(grid)
form.addHotKey(ESC)
_screen.gridWrappedWindow(grid, self.dialog_title)
i = 0;
selected = '..'
while not chosen:
files = os.listdir(self.cwd)
for i, f in enumerate(files):
if os.path.isdir(os.path.join(self.cwd, f)):
files[i] += '/'
files.sort(cmp_fn)
if self.cwd != '/':
files = [ '..' ] + files
for f in files:
box.append(f[0:width], f)
try:
box.setCurrent(selected + '/')
except KeyError:
pass
k = form.run()
if k == ESC:
break
curr = box.current()
selected = '..'
if curr == '..':
selected = os.path.basename(self.cwd)
self.cwd = os.path.dirname(self.cwd)
elif curr.endswith('/'):
self.cwd = os.path.realpath(os.path.join(self.cwd, curr))
else:
chosen = os.path.join(self.cwd, curr)
box.clear()
_screen.popWindow()
if chosen:
self.filename.set(chosen)
from simpleInstallerUI import only_letters_pattern, email_pattern, hostname_pattern
class InputHostname(InputText):
def __init__(self, title, default, propname, width):
InputText.__init__(self, title, default, width, propname = propname)
def error(self):
text = self.inp.value()
if not hostname_pattern.match(text):
return "%s: invalid hostname" % text
return None
class InputInt(InputText):
def __init__(self, title, default, propname, width):
InputText.__init__(self, title, default, width, propname = propname)
def error(self):
text = self.inp.value()
try:
int(text)
except:
return "%s: invalid integer" % text
return None
class InputEmail(InputText):
def __init__(self, title, default, width):
InputText.__init__(self, title, default, width, False, 'email')
def error(self):
text = self.inp.value()
if not email_pattern.match(text):
return "%s: invalid email address" % text
return None
def update_properties(self, properties):
properties['email'] = properties['sc-MailMessenger:messenger_mail.from'] = self.inp.value()
class InputPassword(InputText):
def __init__(self, title, default, propname, width):
InputText.__init__(self, title, default, width, True, propname)
class RepeatPassword(InputText):
def __init__(self, title, default, main_input, width):
InputText.__init__(self, title, default, width, True)
self.main_input = main_input
def error(self):
if self.main_input.inp.value() != self.inp.value():
return "Passwords do not match"
else:
return None
def configure(default_parameters):
try:
rv = default_parameters.copy()
initScreen()
all_net_ifaces = uLinux.listNetifaces()
width = _screen.width * 4 / 5
hostname = socket.gethostname()
good_net_ifaces = [ x for x in all_net_ifaces if x[1] != '127.0.0.1']
ctrls = []
ctrls.append(InputHostname("FQDN of this host", hostname, 'hostname', width))
ctrls.append(InputNetiface("Internal network interface", good_net_ifaces, 'communication', width))
ctrls.append(InputNetiface("External network interface", good_net_ifaces, 'external', width))
ctrls.append(InputText("Administrator login", rv.get("username", "admin"), width))
ctrls.append(InputPassword("Adminstrator password", rv.get("password", ""), 'password', width))
ctrls.append(RepeatPassword("Repeat adminstrator password", rv.get("password", ""), ctrls[-1], width))
ctrls.append(InputEmail('Administrator email', rv.get('email', os.environ.get('USER', 'root') + '@' + hostname), width))
ctrls.append(InputHostname("SMTP server address", hostname, 'sc-MailMessenger:messenger_mail.smtphost', width))
ctrls.append(InputHostname("Database hostname", hostname, 'db_hostname', width))
ctrls.append(InputInt("Database port", rv.get('db_port', '5432'), 'db_port', width))
grid = Grid(1, len(ctrls) + 1)
form = Form()
for i, ctrl in enumerate(ctrls):
grid.setField(ctrl.grid, 0, i)
form.add(ctrl.grid)
ok_cancel = ButtonBar(_screen, Ok_Cancel_Names)
grid.setField(ok_cancel, 0, len(ctrls))
form.add(ok_cancel)
_screen.gridWrappedWindow(grid, "Installation parameters")
done = False
while not done:
runResult = form.run()
bpressed = ok_cancel.buttonPressed(runResult)
if bpressed == 'cancel':
raise Exception("Installation is cancelled")
elif bpressed is None:
for ctrl in ctrls:
ctrl.activate(runResult)
elif bpressed == 'ok':
errors = []
for ctrl in ctrls:
err = ctrl.error()
if err is not None:
errors.append(err)
if errors:
error_text = "Incorrect data:\n"
error_text += '\n'.join(errors)
ButtonChoiceWindow(_screen, "Error", error_text, [ ("Ok", 'ok', ESC) ])
else:
for ctrl in ctrls:
ctrl.update_properties(rv)
done = True
for p in rv:
uLogging.debug("%s = %s", p, rv[p])
return rv
finally:
_screen.finish()
def initialize():
uLogging.log_stderr = False
uUtil.be_quiet = True
if __name__ == '__main__':
print showLicense(sys.argv[1], open(sys.argv[1]).read())
Exchange2010OrgsUpgrade/modules/uActionContext.py 0000644 0000000 0000000 00000002600 11713723610 020734 0 ustar root root """This module keeps context within running atomic action and allows commit/rollback semantics for non-trivial entities.
"""
__rcs_id__ = """$Id: uActionContext.py 583523 2010-06-21 08:26:32Z csvintsoff $"""
__pychecker__ = "blacklist=modules/sets.py unusednames=__rcs_id__,dummy"
from uAction import nothrowable
_action_context = {}
def get(name):
"""Return object from atomic action context by its name, if exists or None."""
global _action_context
return _action_context.get(name)
def put(name, val):
"""Put an object to atomic action context. If object has commit and
rollback methods then those method would be called on successful action
exit or failure respectively."""
global _action_context
_action_context[name] = val
def prepare(action_id):
"""Re-create context for current atomic action.
NOTE: Do not call it, this is called automatically."""
_clear()
put('action_id', action_id)
def action_id():
"""Get current atomic action ID"""
return get('action_id')
def _clear():
global _action_context
_action_context.clear()
def _finish(fn_name, fn_wrap):
global _action_context
for k, v in _action_context.items():
if hasattr(v, fn_name):
m = getattr(v, fn_name)
fn_wrap(m)
_clear()
def commit():
w = lambda f: f()
_finish('commit', w)
def rollback():
w = lambda f: nothrowable(f)()
_finish('rollback', w)
Exchange2010OrgsUpgrade/modules/uWindows.py 0000644 0000000 0000000 00000015364 11713723612 017621 0 ustar root root import pyodbc, os, re, sys
import uUtil
import MSIInstallationProgress
import uLogging
from uAction import *
class MSILogger:
def __init__(self, file):
self.file = open(file, "a", 0)
self.buf = ''
def write(self, text):
# log to file
self.file.write(text)
# append to line buffer and log full lines
self.buf += text
lines = self.buf.splitlines(True)
self.buf = ''
for l in lines:
if l.endswith('\n'):
MSIInstallationProgress.msi_log(l.rstrip('\n'))
else:
self.buf += l
def setupMSILogging(file):
logger = MSILogger(file)
sys.stdout = logger
sys.stderr = logger
class InstallationProgress:
def __init__(self):
self.phase = None
self.ticks = 0
def new_phase(self, phase):
self.phase = phase
self.ticks = 0
MSIInstallationProgress.reset_progress()
MSIInstallationProgress.set_message(phase)
def end_phase(self):
self.phase = None
self.ticks = 0
def set_progress(self, pval, what = ""):
if what:
if self.phase:
msg = self.phase + ': '
else:
msg = ''
msg += what
MSIInstallationProgress.set_message(msg)
ticks = pval - self.ticks
MSIInstallationProgress.increment_progress(ticks)
self.ticks += ticks
def getProgress():
return InstallationProgress()
def createDatabaseAndUser(servername, admin_user, admin_password, dbname, usename, passwd):
connect_string = "DRIVER={SQL Server Native Client 10.0}; SERVER=%s; DATABASE=master; UID=%s; PWD=%s" % (servername, admin_user, admin_password)
con = pyodbc.connect(connect_string, autocommit=True)
cur = con.cursor()
try:
cur.execute("DROP database %s" % dbname)
except Exception, e:
print e
except:
pass
try:
cur.execute("EXEC sp_droplogin %s" % usename)
except Exception, e:
print e
except:
print "Failed to drop", usename
cur.execute("EXEC sp_addlogin @loginame='%s', @passwd='%s'" % (usename, passwd))
cur.execute("CREATE DATABASE %s" % dbname)
cur.execute("ALTER DATABASE [%s] SET READ_COMMITTED_SNAPSHOT ON" % dbname)
cur.execute("ALTER DATABASE %s SET ARITHABORT ON" % dbname)
cur.execute(" EXEC [%s]..sp_changedbowner '%s'" % (dbname, usename))
cur.execute("EXEC sp_defaultdb @loginame = '%s', @defdb = '%s'" % (usename, dbname))
cur.execute("CREATE TABLE [%s]..dual (dummy char(1))" % dbname)
cur.execute("INSERT INTO [%s]..dual (dummy) VALUES ('X')" % dbname)
con.commit()
con.close()
def createDBAndUser(props):
print "Creating database und user"
createDatabaseAndUser(props['db_hostname'], props["admin_db_user"], props["admin_db_passwd"], props["db"], props["dsn_login"], props["dsn_passwd"])
def initSysLog(props):
print "Creating syslog configs"
rootpath = props['rootpath']
syslog_etc = os.path.join(rootpath, 'syslog', 'etc')
syslog_conf = os.path.join(syslog_etc, 'syslog.conf')
syslog_dir = os.path.join(rootpath, 'var', 'log')
try:
os.makedirs(syslog_etc)
except:
pass # probably already exists.
f = open(syslog_conf, 'w')
f.write("""
""" % locals())
f.close()
tarball_pattern = re.compile(r'.+\.(tar\.gz|tgz)$');
def copy_tarballs(to, dirname, fnames):
for fn in fnames:
if tarball_pattern.match(fn):
uUtil.ln_cp(os.path.join(dirname, fn), to)
def createPPMSite(props):
progress.do("creating ppm site")
system_root = os.environ['SystemRoot']
appcmd = os.path.join(system_root, 'System32', 'inetsrv', 'appcmd.exe')
source_dir = props['source_dir']
site_name = "Initial PEM tarballs storage"
tarball_dir = os.path.join(props['rootpath'].replace('/', '\\'), 'install', 'tarballs')
user = props['ipemts_user']
password = props['ipemts_passwd']
port = props['ipemts_port']
ip = props['communication_ip']
if not os.path.exists(appcmd):
uLogging.debug("IIS 6")
out, err, status = uUtil.readCmdExt([os.path.join(source_dir, 'os', 'Win32', 'IISAdministrationTools', '_install.bat')])
uLogging.debug("%s %s %s", out, err, status)
iis_web = os.path.join(system_root, 'System32', 'iisweb.vbs')
out, err, status = uUtil.readCmdExt(['cscript', iis_web, '/delete', site_name])
uLogging.debug("%s %s %s", out, err, status)
out, err, status = uUtil.readCmdExt(['cscript', iis_web, '/create', tarball_dir, site_name, '/b', str(port), '/i', ip])
uLogging.debug("%s %s %s", out, err, status)
out, err, status = uUtil.readCmdExt(['cscript', os.path.join(system_root, 'System32', 'iisvdir.vbs'), '/create', site_name, 'tarballs', tarball_dir])
uLogging.debug("%s %s %s", out, err, status)
else:
uLogging.debug("IIS 7")
out, err, status = uUtil.readCmdExt('%s delete site /site.name:"%s"' % (appcmd, site_name))
uLogging.debug("%s %s %s", out, err, status)
out, err, status = uUtil.readCmdExt('%s add site "/name:%s" /bindings:"http://%s:%s" "/physicalPath:%s"' % (appcmd, site_name, ip, port, tarball_dir))
uLogging.debug("%s %s %s", out, err, status)
out, err, status = uUtil.readCmdExt('%s add vdir "/app.name:%s/" "/physicalPath:%s" /path:/tarballs' % (appcmd, site_name, tarball_dir))
uLogging.debug("%s %s %s", out, err, status)
out, err, status = uUtil.readCmdExt(['net', 'user', user, password, '/ADD', '/EXPIRES:NEVER'])
uLogging.debug("%s %s %s", out, err, status)
try:
os.makedirs(tarball_dir)
except:
pass
out, err, status = uUtil.readCmdExt(["cscript", os.path.join(props['rootpath'], 'install', 'tarball_storage_config.vbs'), site_name, user, password])
uLogging.debug("%s %s %s", out, err, status)
progress.done()
progress.do("copying tarballs")
os.path.walk(source_dir, copy_tarballs, tarball_dir)
progress.done()
out, err, status = uUtil.readCmdExt('wmic UserAccount Where Name="%(ipemts_user)s" Set PasswordExpires=False' % props)
uLogging.debug("%s %s %s", out, err, status) Exchange2010OrgsUpgrade/modules/uDBErrors.py 0000644 0000000 0000000 00000022131 11713723612 017637 0 ustar root root __rcs_id__ = """$Id: uDBErrors.py 314597 2008-04-01 14:27:56Z cs $"""
class DBError:
def __repr__(self):
return "<%s>" % self
class DBErrorMissingTable(DBError):
def __init__(self, _schema):
self.schema = _schema
self.name = "missing table"
def __str__(self):
return "%s '%s'" % (self.name, self.schema.name)
class DBErrorRedundantTable(DBError):
def __init__(self, _table):
self.table = _table
self.name = "redundant table"
def __str__(self):
return "%s '%s'" % (self.name, self.table.name)
class DBErrorMissingColumn(DBError):
def __init__(self, _table, _schema_column):
self.table = _table
self.schema_column = _schema_column
self.name = "missing column"
def __str__(self):
return "%s '%s' in table '%s': \"%s\"" % (self.name, self.schema_column.name, self.table.name, self.schema_column.descr(self.table))
class DBErrorRedundantColumn(DBError):
def __init__(self, _table, _table_column):
self.table = _table
self.table_column = _table_column
self.name = "redundant column"
def __str__(self):
return "%s '%s' in table '%s': \"%s\"" % (self.name, self.table_column.name, self.table.name, self.table_column.descr(self.table))
class DBErrorNonconformingColumnType(DBError):
def __init__(self, _table, _table_column, _schema_column):
self.table = _table
self.table_column = _table_column
self.schema_column = _schema_column
self.name = "nonconforming type of column"
def __str__(self):
return "%s '%s' in table '%s': \"%s\", must be \"%s\"" % (self.name, self.table_column.name, self.table.name, self.table_column.type, self.schema_column.type)
class DBErrorColumnMissingNotNull(DBError):
def __init__(self, _table, _table_column):
self.table = _table
self.table_column = _table_column
self.name = "missing not null constraint"
def __str__(self):
return "%s on column '%s' in table '%s'" % (self.name, self.table_column.name, self.table.name)
class DBErrorColumnRedundantNotNull(DBError):
def __init__(self, _table, _table_column):
self.table = _table
self.table_column = _table_column
self.name = "redundant not null constraint"
def __str__(self):
return "%s on column '%s' in table '%s'" % (self.name, self.table_column.name, self.table.name)
class DBErrorColumnMissingDefault(DBError):
def __init__(self, _table, _table_column, _default):
self.table = _table
self.table_column = _table_column
self.default = _default
self.name = "missing default value"
def __str__(self):
return "%s for column '%s' in table '%s': must be \"%s\"" % (self.name, self.table_column.name, self.table.name, self.default)
class DBErrorColumnNonconformingDefault(DBError):
def __init__(self, _table, _table_column, _default):
self.table = _table
self.table_column = _table_column
self.default = _default
self.name = "nonconforming default value"
def __str__(self):
return "%s for column '%s' in table '%s': \"%s\", must be \"%s\"" % (self.name, self.table_column.name, self.table.name, self.table_column.default, self.default)
class DBErrorColumnRedundantDefault(DBError):
def __init__(self, _table, _table_column):
self.table = _table
self.table_column = _table_column
self.name = "redundant default value"
def __str__(self):
return "%s for column '%s' in table '%s': \"%s\"" % (self.name, self.table_column.name, self.table.name, self.table_column.default)
class DBErrorMissingPrimaryKey(DBError):
def __init__(self, _table, _schema_pk):
self.table = _table
self.schema_pk = _schema_pk
self.name = "missing primary key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.schema_pk.name, self.table.name, self.schema_pk.descr())
class DBErrorNonconformingPrimaryKey(DBError):
def __init__(self, _table, _table_pk, _schema_pk):
self.table = _table
self.table_pk = _table_pk
self.schema_pk = _schema_pk
self.name = "nonconforming primary key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\", must be \"%s\"" % (self.name, self.table_pk.name, self.table.name, self.table_pk.descr(), self.schema_pk.descr())
class DBErrorRedundantPrimaryKey(DBError):
def __init__(self, _table, _table_pk):
self.table = _table
self.table_pk = _table_pk
self.name = "redundant primary key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.table_pk.name, self.table.name, self.table_pk.descr())
class DBErrorMissingForeignKey(DBError):
def __init__(self, _table, _schema_fk):
self.table = _table
self.schema_fk = _schema_fk
self.name = "missing foreign key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.schema_fk.name, self.table.name, self.schema_fk.descr())
class DBErrorNonconformingForeignKey(DBError):
def __init__(self, _table, _table_fk, _schema_fk):
self.table = _table
self.table_fk = _table_fk
self.schema_fk = _schema_fk
self.name = "nonconforming foreign key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\", must be \"%s\"" % (self.name, self.table_fk.name, self.table.name, self.table_fk.descr(), self.schema_fk.descr())
class DBErrorRedundantForeignKey(DBError):
def __init__(self, _table, _table_fk):
self.table = _table
self.table_fk = _table_fk
self.name = "redundant foreign key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.table_fk.name, self.table.name, self.table_fk.descr())
class DBErrorMissingUnique(DBError):
def __init__(self, _table, _schema_unique):
self.table = _table
self.schema_unique = _schema_unique
self.name = "missing unique constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.schema_unique.name, self.table.name, self.schema_unique.descr())
class DBErrorNonconformingUnique(DBError):
def __init__(self, _table, _table_unique, _schema_unique):
self.table = _table
self.table_unique = _table_unique
self.schema_unique = _schema_unique
self.name = "nonconforming unique key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\", must be \"%s\"" % (self.name, self.table_unique.name, self.table.name, self.table_unique.descr(), self.schema_unique.descr())
class DBErrorRedundantUnique(DBError):
def __init__(self, _table, _table_unique):
self.table = _table
self.table_unique = _table_unique
self.name = "redundant unique key constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.table_unique.name, self.table.name, self.table_unique.descr())
class DBErrorMissingCheck(DBError):
def __init__(self, _table, _schema_check):
self.table = _table
self.schema_check = _schema_check
self.name = "missing check constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.schema_check.name, self.table.name, self.schema_check.descr())
class DBErrorNonconformingCheck(DBError):
def __init__(self, _table, _table_check, _schema_check):
self.table = _table
self.table_check = _table_check
self.schema_check = _schema_check
self.name = "nonconforming check constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\", must be \"%s\"" % (self.name, self.table_check.name, self.table.name, self.table_check.descr(), self.schema_check.descr())
class DBErrorRedundantCheck(DBError):
def __init__(self, _table, _table_check):
self.table = _table
self.table_check = _table_check
self.name = "redundant check constraint"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.table_check.name, self.table.name, self.table_check.descr())
class DBErrorMissingIndex(DBError):
def __init__(self, _table, _schema_index):
self.table = _table
self.schema_index = _schema_index
self.name = "missing index"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.schema_index.name, self.table.name, self.schema_index.descr(self.table))
class DBErrorNonconformingIndex(DBError):
def __init__(self, _table, _table_index, _schema_index):
self.table = _table
self.table_index = _table_index
self.schema_index = _schema_index
self.name = "nonconforming index"
def __str__(self):
return "%s '%s' on table '%s': \"%s\", must be \"%s\"" % (self.name, self.table_index.name, self.table.name, self.table_index.descr(self.table), self.schema_index.descr(self.table))
class DBErrorRedundantIndex(DBError):
def __init__(self, _table, _table_index):
self.table = _table
self.table_index = _table_index
self.name = "redundant index"
def __str__(self):
return "%s '%s' on table '%s': \"%s\"" % (self.name, self.table_index.name, self.table.name, self.table_index.descr(self.table))
class DBErrorMissingSequence(DBError): # not used yet
pass
class DBErrorRedundantSequence(DBError): # not used yet
pass
class DBErrorRedundantView(DBError): # not used yet
pass
class DBErrorRedundantTrigger(DBError): # not used yet
pass
class DBErrorNonconformingFunction(DBError): # not used yet
pass
class DBErrorRedundantFunction(DBError): # not used yet
pass
Exchange2010OrgsUpgrade/modules/uDLCommon.py 0000644 0000000 0000000 00000005204 11713723612 017627 0 ustar root root #!/usr/bin/python
MN_pkg = ('chief', 'sc')
UI_pkg = ('chief', 'cp')
class NativePackage:
def __init__(self, name, nptype, host, where, where_vztempl=None, name_x64 = None):
self.name = name # Filename
self.name_x64 = name_x64 or name
self.type = nptype or "rpm"
self.host = host
self.where = where
self.where_vztempl = where_vztempl
self.package_name = None
class PkgInstallation:
def _node_init__(self, node):
self.name = node.getAttribute("name")
self.ctype = node.getAttribute("ctype")
where = node.getAttribute("host")
where_pkg_name = node.getAttribute("where_pkg_name")
if where == "where_pkg":
self.where_pkg = (where_pkg_name, node.getAttribute("where_pkg_ctype") or "service")
elif where == "mn":
self.where_pkg = MN_pkg
elif where == "ui":
self.where_pkg = UI_pkg
elif where == "no":
self.where_pkg = None
elif where_pkg_name:
self.where_pkg = (where_pkg_name, node.getAttribute("where_pkg_ctype") or "service")
else: #upgrade
self.where_pkg = (self.name, self.ctype)
def _pkg_init__(self, name, ctype, where):
self.name = name
self.ctype = ctype
self.where_pkg = where
def __init__(self, node=None, name=None, ctype=None, where=None):
if node:
PkgInstallation._node_init__(self, node)
else:
PkgInstallation._pkg_init__(self, name, ctype, where)
def node(self, doc):
rv = doc.createElement("PACKAGE")
rv.setAttribute("name", self.name)
rv.setAttribute("ctype", self.ctype)
if self.where_pkg == ('chief', 'sc'):
rv.setAttribute("host", "mn")
elif self.where_pkg == ('chief', 'cp'):
rv.setAttribute("host", "ui")
elif self.where_pkg == (self.name, self.ctype):
rv.setAttribute("host", "upgrade")
elif self.where_pkg:
nm, ctype = self.where_pkg
rv.setAttribute("host", "where_pkg")
rv.setAttribute("where_pkg_name", nm)
rv.setAttribute("where_pkg_ctype", ctype)
else:
rv.setAttribute("host", "no")
return rv
def parseNativePackageNode(node):
host = node.getAttribute("host") or "all"
name = node.getAttribute("name")
name_x64 = node.getAttribute("name_x64") or name
ptype = node.getAttribute("type") or "rpm"
where_pkg_name = node.getAttribute("where_pkg_name")
if where_pkg_name:
where = (node.getAttribute("where_pkg_ctype") or "service", where_pkg_name)
else:
where = None # None will mean everywhere.
where_templ = node.getAttribute("where_vztemplate")
if not where_templ:
where_templ = None
return NativePackage(name, ptype, host, where, where_templ, name_x64)
__all__ = [ "PkgInstallation", "NativePackage", "MN_pkg", "UI_pkg", "parseNativePackageNode" ]
Exchange2010OrgsUpgrade/modules/uLogging.py 0000644 0000000 0000000 00000005207 11713723612 017550 0 ustar root root import sys, codecs, time, logging
try:
import syslog
have_syslog = True
prio_syslog = { "ERROR" : syslog.LOG_ERR, "WARNING": syslog.LOG_WARNING, "INFO" : syslog.LOG_INFO, "DEBUG" : syslog.LOG_DEBUG }
except ImportError:
have_syslog = False
def print_log(prio, message, *msg_args):
if len(msg_args) == 0:
msg = message
else:
msg = (message % msg_args)
if prio:
to_write = "%s: %s\n" % (prio, msg)
else:
to_write = msg + '\n'
if do_time:
to_write = time.asctime() + ': ' + to_write
to_write_encoded = to_write.encode('utf8')
if logfile:
logfile.write(to_write_encoded)
logfile.flush()
if do_syslog:
syslog.syslog(prio_syslog[prio], to_write)
if log_stderr:
if isinstance(sys.stderr, codecs.Codec):
sys.stderr.write(to_write)
else:
sys.stderr.write(to_write_encoded)
if ext_log_dump:
ext_log_dump(to_write)
def log_func(prio):
def rv(message, *args):
try:
return print_log(prio, message, *args)
except IOError, (errno, strerror):
if errno != 11:
raise IOError, (errno, strerror)
return rv
warn = log_func("WARNING")
err = log_func("ERROR")
debug = log_func("DEBUG")
notice = log_func("NOTICE")
log = log_func(None)
logfile = None
do_syslog = None
log_stderr = True
do_time = None
ext_log_dump = None
# handler for python logging library
class Handler(logging.Handler):
def __init__(self):
logging.Handler.__init__(self)
def __get_logging_func(self, levelname):
# default python logging doesn't define any more log levels besides standard DEBUG, INFO ..
# but there is for example yum, which defines some more levels like INFO_1, INFO_2
# so here we try to treat all the INFO_X levels as INFO
if levelname.startswith("DEBUG"):
return debug
elif levelname.startswith("INFO"):
return notice
elif levelname.startswith("WARNING"):
return warn
elif levelname.startswith("ERROR"):
return err
elif levelname.startswith("CRITICAL"):
return err
def emit(self, record):
self.__get_logging_func(record.levelname)(record.getMessage())
def init(config):
if have_syslog and config.log.syslog_facility:
if hasattr(syslog, config.log.syslog_facility):
sf = getattr(syslog, config.log.syslog_facility)
print sf, config.log.syslog_ident
syslog.openlog(config.log.syslog_ident, syslog.LOG_PID, sf)
global do_syslog
do_syslog = True
if config.log.file:
global logfile
logfile = file(config.log.file, "a")
if hasattr(config, "verbose") and not config.verbose:
def empty_fun(*args):
pass
global debug
debug = empty_fun
__all__ = [ "warn" , "err", "debug", "notice", "log" ]
Exchange2010OrgsUpgrade/modules/uConfig.pyc 0000644 0000000 0000000 00000013673 11742717401 017541 0 ustar root root ;ò
ˆ§/Oc @ s› d k Z d k Z d k Z d k Z d k Z d k Z d „ Z d f d „ ƒ YZ d „ Z e ƒ Z e i
ƒ Z d Z d „ Z
e
ƒ Z d d d g Z d S( Nc C s" t i | | IJt i d ƒ d S( Ni ( s syss stderrs texts names exit( s texts name( ( s0 /root/Exchange2010OrgsUpgrade/modules/uConfig.pys usage s s Configc B sD t Z g g d e e e f d d „ Z e d „ Z h e d „ Z RS( Ns configs c C sŠ h } h } d } g } x | D]… }
|
\ }
} } } | o | | 7} |
| |