~smoser/ubuntu/vivid/cloud-init/snappy

« back to all changes in this revision

Viewing changes to cloudinit/sources/DataSourceAltCloud.py

  • Committer: Scott Moser
  • Date: 2015-02-27 20:55:58 UTC
  • mfrom: (355.2.8 vivid)
  • Revision ID: smoser@ubuntu.com-20150227205558-glrwdgxqkaz6zyxa
* Merge with vivid at 0.7.7~bzr1067-0ubuntu1
* New upstream snapshot.
  * fix broken consumption of gzipped user-data (LP: #1424900)
  * functional user-data on Azure again (LP: #1423972)
  * CloudStack: support fetching password from virtual router (LP: #1422388)
* New upstream snapshot.
  * Fix for ascii decode in DataSourceAzure (LP: #1422993).
* New upstream snapshot.
  * support for gpt partitioning, utilized in Azure [Daniel Watkins]
  * fix bug in exception handling in mount_cb.
* New upstream snapshot.
  * move to python3 (LP: #1247132)
  * systemd: run cloud-init before systemd-user-sessions.service
  * Use the GCE short hostname. (LP: #1383794)
  * Enable user-data encoding support for GCE. (LP: #1404311)
  * Update to use a newer and better OMNIBUS_URL
  * Be more tolerant of 'ssh_authorized_keys' types
  * Fix parse_ssh_config failing in ssh_util.py
  * Increase the robustness/configurability of the chef module.
  * retain trailing newline from template files when using
    jinja2 (LP: #1355343)
  * fix broken output handling (LP: #1387340)
  * digital ocean datasource
  * update url in config drive documentation
  * freebsd: enable correct behavior on Ec2.
  * freebsd: Use the proper virtio FreeBSD network interface name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
CLOUD_INFO_FILE = '/etc/sysconfig/cloud-info'
41
41
 
42
42
# Shell command lists
43
 
CMD_DMI_SYSTEM = ['/usr/sbin/dmidecode', '--string', 'system-product-name']
44
43
CMD_PROBE_FLOPPY = ['/sbin/modprobe', 'floppy']
45
44
CMD_UDEVADM_SETTLE = ['/sbin/udevadm', 'settle', '--quiet', '--timeout=5']
46
45
 
100
99
        '''
101
100
        Description:
102
101
            Get the type for the cloud back end this instance is running on
103
 
            by examining the string returned by:
104
 
            dmidecode --string system-product-name
105
 
 
106
 
            On VMWare/vSphere dmidecode returns: RHEV Hypervisor
107
 
            On VMWare/vSphere dmidecode returns: VMware Virtual Platform
 
102
            by examining the string returned by reading the dmi data.
108
103
 
109
104
        Input:
110
105
            None
117
112
 
118
113
        uname_arch = os.uname()[4]
119
114
        if uname_arch.startswith("arm") or uname_arch == "aarch64":
120
 
            # Disabling because dmidecode in CMD_DMI_SYSTEM crashes kvm process
 
115
            # Disabling because dmi data is not available on ARM processors
121
116
            LOG.debug("Disabling AltCloud datasource on arm (LP: #1243287)")
122
117
            return 'UNKNOWN'
123
118
 
124
 
        cmd = CMD_DMI_SYSTEM
125
 
        try:
126
 
            (cmd_out, _err) = util.subp(cmd)
127
 
        except ProcessExecutionError, _err:
128
 
            LOG.debug(('Failed command: %s\n%s') % \
129
 
                (' '.join(cmd), _err.message))
130
 
            return 'UNKNOWN'
131
 
        except OSError, _err:
132
 
            LOG.debug(('Failed command: %s\n%s') % \
133
 
                (' '.join(cmd), _err.message))
134
 
            return 'UNKNOWN'
135
 
 
136
 
        if cmd_out.upper().startswith('RHEV'):
 
119
        system_name = util.read_dmi_data("system-product-name")
 
120
        if not system_name:
 
121
            return 'UNKNOWN'
 
122
 
 
123
        sys_name = system_name.upper()
 
124
 
 
125
        if sys_name.startswith('RHEV'):
137
126
            return 'RHEV'
138
127
 
139
 
        if cmd_out.upper().startswith('VMWARE'):
 
128
        if sys_name.startswith('VMWARE'):
140
129
            return 'VSPHERE'
141
130
 
142
131
        return 'UNKNOWN'
211
200
            cmd = CMD_PROBE_FLOPPY
212
201
            (cmd_out, _err) = util.subp(cmd)
213
202
            LOG.debug(('Command: %s\nOutput%s') % (' '.join(cmd), cmd_out))
214
 
        except ProcessExecutionError, _err:
 
203
        except ProcessExecutionError as _err:
215
204
            util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd),
216
205
                        _err.message)
217
206
            return False
218
 
        except OSError, _err:
 
207
        except OSError as _err:
219
208
            util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd),
220
209
                        _err.message)
221
210
            return False
228
217
            cmd.append('--exit-if-exists=' + floppy_dev)
229
218
            (cmd_out, _err) = util.subp(cmd)
230
219
            LOG.debug(('Command: %s\nOutput%s') % (' '.join(cmd), cmd_out))
231
 
        except ProcessExecutionError, _err:
 
220
        except ProcessExecutionError as _err:
232
221
            util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd),
233
222
                        _err.message)
234
223
            return False
235
 
        except OSError, _err:
 
224
        except OSError as _err:
236
225
            util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd),
237
226
                        _err.message)
238
227
            return False