|
175 |
with open(udm_hook_messagecatalog, 'r') as f: |
175 |
with open(udm_hook_messagecatalog, 'r') as f: |
176 |
common_udm_options.extend(["--append", "messagecatalog=%s %s" % (language, base64.b64encode(f.read()),), ]) |
176 |
common_udm_options.extend(["--append", "messagecatalog=%s %s" % (language, base64.b64encode(f.read()),), ]) |
177 |
|
177 |
|
|
|
178 |
if self.udm_module_name == "settings/listener": |
179 |
for servers in options.listenerservers: |
180 |
common_udm_options.extend(["--append", "servers=%s" % (servers), ]) |
181 |
|
182 |
if self.udm_module_name == "settings/ucr_extension": |
183 |
for servers in options.ucrservers: |
184 |
common_udm_options.extend(["--append", "servers=%s" % (servers), ]) |
185 |
|
178 |
rc, self.object_dn, stdout = self.udm_find_object_dn() |
186 |
rc, self.object_dn, stdout = self.udm_find_object_dn() |
179 |
if not self.object_dn: |
187 |
if not self.object_dn: |
180 |
|
188 |
|
|
785 |
return True |
793 |
return True |
786 |
|
794 |
|
787 |
|
795 |
|
|
|
796 |
class UniventionListener(UniventionLDAPExtension): |
797 |
__metaclass__ = ABCMeta |
798 |
|
799 |
target_container_name = "listener" |
800 |
udm_module_name = "settings/listener" |
801 |
active_flag_attribute = "univentionListenerActive" |
802 |
filesuffix = ".py" |
803 |
|
804 |
#def register(self, filename, options, udm_passthrough_options, target_filename=None): |
805 |
# # Determine UDM module name |
806 |
# saved_value = sys.dont_write_bytecode |
807 |
# sys.dont_write_bytecode = True |
808 |
# sys.dont_write_bytecode = saved_value |
809 |
# |
810 |
# UniventionLDAPExtension.register(self, filename, options, udm_passthrough_options, target_filename=module_name + ".py") |
811 |
|
812 |
def wait_for_activation(self, timeout=180): |
813 |
if not UniventionLDAPExtension.wait_for_activation(self, timeout): |
814 |
return False |
815 |
|
816 |
timeout = 60 |
817 |
print "Waiting for file %s:" % (self.filename,), |
818 |
t0 = time.time() |
819 |
while not os.path.exists(self.filename): |
820 |
if time.time() - t0 > timeout: |
821 |
print "ERROR" |
822 |
print >>sys.stderr, "ERROR: Timout waiting for %s." % (self.filename,) |
823 |
return False |
824 |
sys.stdout.write(".") |
825 |
sys.stdout.flush() |
826 |
time.sleep(3) |
827 |
print "OK" |
828 |
return True |
829 |
|
830 |
|
788 |
class UniventionUDMModule(UniventionUDMExtension): |
831 |
class UniventionUDMModule(UniventionUDMExtension): |
789 |
target_container_name = "udm_module" |
832 |
target_container_name = "udm_module" |
790 |
udm_module_name = "settings/udm_module" |
833 |
udm_module_name = "settings/udm_module" |
|
846 |
|
889 |
|
847 |
|
890 |
|
848 |
class UCSOption (Option): |
891 |
class UCSOption (Option): |
849 |
TYPES = Option.TYPES + ("existing_filename", "ucs_version", ) |
892 |
TYPES = Option.TYPES + ("existing_filename", "ucs_version", ) |
850 |
TYPE_CHECKER = copy(Option.TYPE_CHECKER) |
893 |
TYPE_CHECKER = copy(Option.TYPE_CHECKER) |
851 |
TYPE_CHECKER["existing_filename"] = option_validate_existing_filename |
894 |
TYPE_CHECKER["existing_filename"] = option_validate_existing_filename |
852 |
TYPE_CHECKER["ucs_version"] = option_validate_ucs_version |
895 |
TYPE_CHECKER["ucs_version"] = option_validate_ucs_version |
853 |
TYPE_CHECKER["gnu_message_catalogfile"] = option_validate_gnu_message_catalogfile |
896 |
TYPE_CHECKER["gnu_message_catalogfile"] = option_validate_gnu_message_catalogfile |
854 |
|
897 |
|
855 |
|
898 |
|
856 |
def option_callback_udm_passthrough_options(option, opt_str, value, parser, *args): |
899 |
def option_callback_udm_passthrough_options(option, opt_str, value, parser, *args): |
|
927 |
action="append", type="existing_filename", default=[], |
970 |
action="append", type="existing_filename", default=[], |
928 |
help="UDM hook", metavar="<filename>") |
971 |
help="UDM hook", metavar="<filename>") |
929 |
|
972 |
|
|
|
973 |
parser.add_option("--listener", dest="listener", |
974 |
action="append", type="existing_filename", default=[], |
975 |
help="Listener module", metavar="<filename>") |
976 |
|
977 |
parser.add_option("--ucr", dest="ucr", |
978 |
action="append", type="existing_filename", default=[], |
979 |
help="UCR extension", metavar="<filename>") |
980 |
|
930 |
parser.add_option("--packagename", dest="packagename", |
981 |
parser.add_option("--packagename", dest="packagename", |
931 |
help="Package name") |
982 |
help="Package name") |
932 |
parser.add_option("--packageversion", dest="packageversion", |
983 |
parser.add_option("--packageversion", dest="packageversion", |
|
989 |
help="File containing LDAP bindpwd", metavar="<filename>") |
1040 |
help="File containing LDAP bindpwd", metavar="<filename>") |
990 |
parser.add_option_group(auth_options) |
1041 |
parser.add_option_group(auth_options) |
991 |
|
1042 |
|
|
|
1043 |
listener_options = OptionGroup(parser, "Listener specific options") |
1044 |
listener_options.add_option("--listenerservers", dest="listenerservers", |
1045 |
default=[], action="append", |
1046 |
help="Specify servers (FQDN) on which the listener module has to be installed", metavar='<Servers>') |
1047 |
parser.add_option_group(listener_options) |
1048 |
|
1049 |
ucr_options = OptionGroup(parser, "UCR specific options") |
1050 |
ucr_options.add_option("--ucrservers", dest="ucrservers", |
1051 |
default=[], action="append", |
1052 |
help="Specify servers (FQDN) on which the UCR extension has to be installed", metavar='<Servers>') |
1053 |
parser.add_option_group(ucr_options) |
1054 |
|
992 |
opts, args = parser.parse_args() |
1055 |
opts, args = parser.parse_args() |
993 |
if len(opts.udm_module) > 1: |
1056 |
if len(opts.udm_module) > 1: |
994 |
parser.error('--udm_module option can be given once only.') |
1057 |
parser.error('--udm_module option can be given once only.') |
|
997 |
if not opts.packageversion: |
1060 |
if not opts.packageversion: |
998 |
parser.error('--packageversion option is required.') |
1061 |
parser.error('--packageversion option is required.') |
999 |
|
1062 |
|
1000 |
if not (opts.schemafile or opts.aclfile or opts.udm_syntax or opts.udm_hook or opts.udm_module): |
1063 |
if not (opts.schemafile or opts.aclfile or opts.udm_syntax or opts.udm_hook or opts.udm_module or opts.listener or opts.ucr): |
1001 |
parser.print_help() |
1064 |
parser.print_help() |
1002 |
sys.exit(2) |
1065 |
sys.exit(2) |
1003 |
|
1066 |
|
|
1050 |
univentionUDMModule.register(udm_module, opts, udm_passthrough_options) |
1113 |
univentionUDMModule.register(udm_module, opts, udm_passthrough_options) |
1051 |
objects.append(univentionUDMModule) |
1114 |
objects.append(univentionUDMModule) |
1052 |
|
1115 |
|
|
|
1116 |
if opts.listener: |
1117 |
if UniventionListener.create_base_container(ucr, udm_passthrough_options) != 0: |
1118 |
sys.exit(1) |
1119 |
|
1120 |
for listener in opts.listener: |
1121 |
univentionListener = UniventionListener(ucr) |
1122 |
univentionListener.register(listener, opts, udm_passthrough_options) |
1123 |
objects.append(univentionListener) |
1124 |
|
1125 |
if opts.ucr: |
1126 |
if UniventionUCR.create_base_container(ucr, udm_passthrough_options) != 0: |
1127 |
sys.exit(1) |
1128 |
|
1129 |
for ucrextension in opts.ucr: |
1130 |
univentionUCR = UniventionUCR(ucr) |
1131 |
univentionUCR.register(ucrextension, opts, udm_passthrough_options) |
1132 |
objects.append(univentionUCR) |
1133 |
|
1053 |
for obj in objects: |
1134 |
for obj in objects: |
1054 |
if not obj.wait_for_activation(): |
1135 |
if not obj.wait_for_activation(): |
1055 |
print "%s: registraton of %s failed." % (functionname, obj.filename) |
1136 |
print "%s: registraton of %s failed." % (functionname, obj.filename) |