Lines 46-52
import notifier.threads
|
Link Here
|
---|
|
46 |
from univention.lib.package_manager import PackageManager, LockError |
46 |
from univention.lib.package_manager import PackageManager, LockError |
47 |
from univention.management.console.log import MODULE |
47 |
from univention.management.console.log import MODULE |
48 |
from univention.management.console.modules.decorators import simple_response, sanitize, sanitize_list, multi_response |
48 |
from univention.management.console.modules.decorators import simple_response, sanitize, sanitize_list, multi_response |
49 |
from univention.management.console.modules.sanitizers import PatternSanitizer, MappingSanitizer, DictSanitizer, StringSanitizer, ChoicesSanitizer, ListSanitizer, EmailSanitizer |
49 |
from univention.management.console.modules.sanitizers import PatternSanitizer, MappingSanitizer, DictSanitizer, StringSanitizer, ChoicesSanitizer, ListSanitizer, EmailSanitizer, BooleanSanitizer |
50 |
from univention.updater import UniventionUpdater |
50 |
from univention.updater import UniventionUpdater |
51 |
from univention.updater.errors import ConfigurationError |
51 |
from univention.updater.errors import ConfigurationError |
52 |
import univention.config_registry |
52 |
import univention.config_registry |
Lines 135-176
class Instance(umcm.Base):
|
Link Here
|
---|
|
135 |
return application.to_dict(self.package_manager) |
135 |
return application.to_dict(self.package_manager) |
136 |
return props |
136 |
return props |
137 |
|
137 |
|
138 |
@sanitize( |
|
|
139 |
function=ChoicesSanitizer(['install', 'update'], required=True), |
140 |
application=StringSanitizer(minimum=1, required=True) |
141 |
) |
142 |
def invoke_dry_run(self, request): |
143 |
MODULE.info('invoke_dry_run') |
144 |
function = request.options.get('function') |
145 |
application_id = request.options.get('application') |
146 |
application = Application.find(application_id) |
147 |
|
148 |
if not application: |
149 |
MODULE.info('Application not found') |
150 |
return self.finished(request.id, False) |
151 |
if (function == 'install' and not |
152 |
application.can_be_installed(self.package_manager)): |
153 |
reason = application.cannot_install_reason(self.package_manager) |
154 |
MODULE.info('Application cannot be installed: %s' % (reason, )) |
155 |
return self.finished(request.id, False) |
156 |
if function == 'update' and not application.can_be_updated(): |
157 |
MODULE.info('Application cannot be updated') |
158 |
return self.finished(request.id, False) |
159 |
|
160 |
result = application.install_dry_run(self.package_manager, self.component_manager) |
161 |
self.finished(request.id, result) |
162 |
|
163 |
@sanitize(function=ChoicesSanitizer(['install', 'uninstall', 'update'], required=True), |
138 |
@sanitize(function=ChoicesSanitizer(['install', 'uninstall', 'update'], required=True), |
164 |
application=StringSanitizer(minimum=1, required=True) |
139 |
application=StringSanitizer(minimum=1, required=True), |
|
|
140 |
force=BooleanSanitizer() |
165 |
) |
141 |
) |
166 |
def invoke(self, request): |
142 |
def invoke(self, request): |
167 |
function = request.options.get('function') |
143 |
function = request.options.get('function') |
168 |
application_id = request.options.get('application') |
144 |
application_id = request.options.get('application') |
|
|
145 |
force = request.options.get('force') |
169 |
application = Application.find(application_id) |
146 |
application = Application.find(application_id) |
170 |
try: |
147 |
try: |
171 |
# make sure that the application cane be installed/updated |
148 |
# make sure that the application cane be installed/updated |
172 |
can_continue = application is not None and not (function == 'install' and not application.can_be_installed(self.package_manager)) and not (function == 'update' and not application.can_be_updated()) |
149 |
can_continue = True |
173 |
self.finished(request.id, can_continue) |
150 |
if not application: |
|
|
151 |
MODULE.info('Application not found') |
152 |
can_continue = False |
153 |
if (function == 'install' and not |
154 |
application.can_be_installed(self.package_manager)): |
155 |
reason = application.cannot_install_reason(self.package_manager) |
156 |
MODULE.info('Application cannot be installed: %s' % (reason, )) |
157 |
can_continue = False |
158 |
if function == 'update' and not application.can_be_updated(): |
159 |
MODULE.info('Application cannot be updated') |
160 |
can_continue = False |
161 |
packages = application.install_dry_run(self.package_manager, |
162 |
self.component_manager, |
163 |
remove_component=False) |
164 |
if not force and (packages['remove'] or packages['broken']): |
165 |
can_continue = False |
166 |
|
167 |
result = {'success': can_continue, |
168 |
'packages': packages, } |
169 |
self.finished(request.id, result) |
170 |
|
174 |
if can_continue: |
171 |
if can_continue: |
175 |
def _thread(module, application, function): |
172 |
def _thread(module, application, function): |
176 |
with module.package_manager.locked(reset_status=True, set_finished=True): |
173 |
with module.package_manager.locked(reset_status=True, set_finished=True): |