def _unregister_attributes(self, app, args):
		attributes, __, options = get_extended_attributes(app)
		if attributes or options:
			lo, pos = self._get_ldap_connection(args)
			for attribute in attributes:
				remove_extended_attribute(attribute, lo, pos)
			for option in options:
				remove_extended_option(option, lo, pos)
Example #2
0
	def _unregister_attributes(self, app, args):
		attributes, __ = get_extended_attributes(app)
		if attributes:
			lo, pos = self._get_ldap_connection(args)
			ldap_object = get_app_ldap_object(app, lo, pos)
			if ldap_object.get_siblings():
				self.debug('Not removing attributes, App is still installed somewhere')
				return
			for attribute in attributes:
				remove_extended_attribute(attribute, lo, pos)
Example #3
0
    def _register_attributes(self, app, args):
        # FIXME: there is no better lib function than this snippet
        schema_file = app.get_share_file('schema')
        if os.path.exists(schema_file):
            self.log('Registering schema %s' % schema_file)
            lo, pos = self._get_ldap_connection(args)
            with self._get_password_file(args) as password_file:
                create_recursive_container(
                    'cn=ldapschema,cn=univention,%s' % ucr_get('ldap/base'),
                    lo, pos)
                if app.automatic_schema_creation:
                    schema_obj = UniventionLDAPSchema(ucr_instance())
                    userdn = self._get_userdn(args)
                    udm_passthrough_options = [
                        '--binddn', userdn, '--bindpwdfile', password_file
                    ]
                    opts = Values()
                    opts.packagename = 'appcenter-app-%s' % app.id
                    opts.packageversion = app.version
                    opts.ucsversionstart = None
                    opts.ucsversionend = None
                    os.environ['UNIVENTION_APP_IDENTIFIER'] = app.id
                    try:
                        schema_obj.register(schema_file, opts,
                                            udm_passthrough_options)
                    except SystemExit as exc:
                        if exc.code == 4:
                            self.warn(
                                'A newer version of %s has already been registered. Skipping...'
                                % schema_file)
                        else:
                            raise RegisterSchemaFailed(exc.code)
                    else:
                        if not schema_obj.wait_for_activation():
                            raise RegisterSchemaFileFailed(schema_file)
                    finally:
                        if 'UNIVENTION_APP_IDENTIFIER' in os.environ:
                            del os.environ['UNIVENTION_APP_IDENTIFIER']

                # and this is what should be there after one line of lib.register_schema(schema_file)
                app = app.get_app_cache_obj().copy(
                    locale='en').find_by_component_id(app.component_id)
                attributes, __, options = get_extended_attributes(app)
                for option in options:
                    self.log('Registering option %s' % option.name)
                    create_extended_option(option, app, lo, pos)
                if attributes:
                    for i, attribute in enumerate(attributes):
                        self.log('Registering attribute %s' % attribute.name)
                        create_extended_attribute(attribute, app, i + 1, lo,
                                                  pos)