~darkmuggle-deactivatedaccount/ubuntu/trusty/cloudinit/lp1316475-1303986

« back to all changes in this revision

Viewing changes to cloudinit/sources/DataSourceOpenNebula.py

  • Committer: Scott Moser
  • Date: 2014-04-01 18:38:24 UTC
  • mfrom: (1.4.17)
  • Revision ID: smoser@ubuntu.com-20140401183824-hjtco4p3wes92rl3
* New upstream release.
  * support base64 encoded user-data in OpenNebula, required
    to allow arbitrary content in user-data (LP: #1300941)
  * pep8 and pylint fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#    Copyright (C) 2012 Yahoo! Inc.
5
5
#    Copyright (C) 2012-2013 CERIT Scientific Cloud
6
6
#    Copyright (C) 2012-2013 OpenNebula.org
 
7
#    Copyright (C) 2014 Consejo Superior de Investigaciones Cientificas
7
8
#
8
9
#    Author: Scott Moser <scott.moser@canonical.com>
9
10
#    Author: Joshua Harlow <harlowja@yahoo-inc.com>
10
11
#    Author: Vlastimil Holer <xholer@mail.muni.cz>
11
12
#    Author: Javier Fontan <jfontan@opennebula.org>
 
13
#    Author: Enol Fernandez <enolfc@ifca.unican.es>
12
14
#
13
15
#    This program is free software: you can redistribute it and/or modify
14
16
#    it under the terms of the GNU General Public License version 3, as
22
24
#    You should have received a copy of the GNU General Public License
23
25
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
26
 
 
27
import base64
25
28
import os
26
29
import pwd
27
30
import re
417
420
    elif "USERDATA" in context:
418
421
        results['userdata'] = context["USERDATA"]
419
422
 
 
423
    # b64decode user data if necessary (default)
 
424
    if 'userdata' in results:
 
425
        encoding = context.get('USERDATA_ENCODING',
 
426
                               context.get('USER_DATA_ENCODING'))
 
427
        if encoding == "base64":
 
428
            try:
 
429
                results['userdata'] = base64.b64decode(results['userdata'])
 
430
            except TypeError:
 
431
                LOG.warn("Failed base64 decoding of userdata")
 
432
 
420
433
    # generate static /etc/network/interfaces
421
434
    # only if there are any required context variables
422
435
    # http://opennebula.org/documentation:rel3.8:cong#network_configuration