~openstack-charmers/charms/trusty/neutron-api/snabbswitch

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/fetch/__init__.py

  • Committer: Edward Hope-Morley
  • Date: 2015-10-23 09:20:10 UTC
  • mfrom: (39.2.114 neutron-api-274709)
  • Revision ID: edward.hope-morley@canonical.com-20151023092010-mjo2mw2h28ta9hh5
synced /next and ch

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    'kilo/proposed': 'trusty-proposed/kilo',
91
91
    'trusty-kilo/proposed': 'trusty-proposed/kilo',
92
92
    'trusty-proposed/kilo': 'trusty-proposed/kilo',
 
93
    # Liberty
 
94
    'liberty': 'trusty-updates/liberty',
 
95
    'trusty-liberty': 'trusty-updates/liberty',
 
96
    'trusty-liberty/updates': 'trusty-updates/liberty',
 
97
    'trusty-updates/liberty': 'trusty-updates/liberty',
 
98
    'liberty/proposed': 'trusty-proposed/liberty',
 
99
    'trusty-liberty/proposed': 'trusty-proposed/liberty',
 
100
    'trusty-proposed/liberty': 'trusty-proposed/liberty',
93
101
}
94
102
 
95
103
# The order of this list is very important. Handlers should be listed in from
215
223
    _run_apt_command(cmd, fatal)
216
224
 
217
225
 
 
226
def apt_mark(packages, mark, fatal=False):
 
227
    """Flag one or more packages using apt-mark"""
 
228
    cmd = ['apt-mark', mark]
 
229
    if isinstance(packages, six.string_types):
 
230
        cmd.append(packages)
 
231
    else:
 
232
        cmd.extend(packages)
 
233
    log("Holding {}".format(packages))
 
234
 
 
235
    if fatal:
 
236
        subprocess.check_call(cmd, universal_newlines=True)
 
237
    else:
 
238
        subprocess.call(cmd, universal_newlines=True)
 
239
 
 
240
 
218
241
def apt_hold(packages, fatal=False):
219
 
    """Hold one or more packages"""
220
 
    cmd = ['apt-mark', 'hold']
221
 
    if isinstance(packages, six.string_types):
222
 
        cmd.append(packages)
223
 
    else:
224
 
        cmd.extend(packages)
225
 
    log("Holding {}".format(packages))
226
 
 
227
 
    if fatal:
228
 
        subprocess.check_call(cmd)
229
 
    else:
230
 
        subprocess.call(cmd)
 
242
    return apt_mark(packages, 'hold', fatal=fatal)
 
243
 
 
244
 
 
245
def apt_unhold(packages, fatal=False):
 
246
    return apt_mark(packages, 'unhold', fatal=fatal)
231
247
 
232
248
 
233
249
def add_source(source, key=None):
370
386
    for handler in handlers:
371
387
        try:
372
388
            installed_to = handler.install(source, *args, **kwargs)
373
 
        except UnhandledSource:
374
 
            pass
 
389
        except UnhandledSource as e:
 
390
            log('Install source attempt unsuccessful: {}'.format(e),
 
391
                level='WARNING')
375
392
    if not installed_to:
376
393
        raise UnhandledSource("No handler found for source {}".format(source))
377
394
    return installed_to