~cloud-init-dev/cloud-init/trunk

« back to all changes in this revision

Viewing changes to cloudinit/sources/DataSourceOVF.py

Misc fixes for VMware Support.

 - Modified the code to look for customization specification file in
   /var/run/vmware-imc/ directory instead of /tmp
 - Fixed the 'seed file' issue. There was a regression in DataSourceOVF.py
   file. Fixed it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import base64
26
26
import os
27
 
import shutil
28
27
import re
29
28
import time
30
29
 
75
74
        system_type = util.read_dmi_data("system-product-name")
76
75
        if system_type is None:
77
76
            LOG.debug("No system-product-name found")
78
 
        elif 'vmware' in system_type.lower():
 
77
 
 
78
        if seedfile:
 
79
            # Found a seed dir
 
80
            seed = os.path.join(self.paths.seed_dir, seedfile)
 
81
            (md, ud, cfg) = read_ovf_environment(contents)
 
82
            self.environment = contents
 
83
            found.append(seed)
 
84
        elif system_type and 'vmware' in system_type.lower():
79
85
            LOG.debug("VMware Virtualization Platform found")
80
86
            if not util.get_cfg_option_bool(
81
87
                    self.sys_cfg, "disable_vmware_customization", True):
85
91
                    deployPkgPluginPath = search_file("/usr/lib/open-vm-tools",
86
92
                                                      "libdeployPkgPlugin.so")
87
93
                if deployPkgPluginPath:
 
94
                    # When the VM is powered on, the "VMware Tools" daemon
 
95
                    # copies the customization specification file to
 
96
                    # /var/run/vmware-imc directory. cloud-init code needs
 
97
                    # to search for the file in that directory.
88
98
                    vmwareImcConfigFilePath = util.log_time(
89
99
                        logfunc=LOG.debug,
90
100
                        msg="waiting for configuration file",
91
 
                        func=wait_for_imc_cfg_file, args=("/tmp", "cust.cfg"))
 
101
                        func=wait_for_imc_cfg_file,
 
102
                        args=("/var/run/vmware-imc", "cust.cfg"))
92
103
 
93
104
                if vmwareImcConfigFilePath:
94
105
                    LOG.debug("Found VMware DeployPkg Config File at %s" %
112
123
                set_customization_status(
113
124
                    GuestCustStateEnum.GUESTCUST_STATE_RUNNING,
114
125
                    GuestCustEventEnum.GUESTCUST_EVENT_CUSTOMIZE_FAILED)
 
126
                enable_nics(nics)
115
127
                return False
116
128
            finally:
117
 
                dirPath = os.path.dirname(vmwareImcConfigFilePath)
118
 
                shutil.rmtree(dirPath)
 
129
                util.del_dir(os.path.dirname(vmwareImcConfigFilePath))
119
130
 
120
131
            try:
121
132
                LOG.debug("Applying the Network customization")
127
138
                set_customization_status(
128
139
                    GuestCustStateEnum.GUESTCUST_STATE_RUNNING,
129
140
                    GuestCustEventEnum.GUESTCUST_EVENT_NETWORK_SETUP_FAILED)
 
141
                enable_nics(nics)
130
142
                return False
131
143
 
132
144
            vmwarePlatformFound = True
133
 
            enable_nics(nics)
134
145
            set_customization_status(
135
146
                GuestCustStateEnum.GUESTCUST_STATE_DONE,
136
147
                GuestCustErrorEnum.GUESTCUST_ERROR_SUCCESS)
137
 
        elif seedfile:
138
 
            # Found a seed dir
139
 
            seed = os.path.join(self.paths.seed_dir, seedfile)
140
 
            (md, ud, cfg) = read_ovf_environment(contents)
141
 
            self.environment = contents
142
 
            found.append(seed)
 
148
            enable_nics(nics)
143
149
        else:
144
150
            np = {'iso': transport_iso9660,
145
151
                  'vmware-guestd': transport_vmware_guestd, }