]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Changing MAC address of first interface
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 30 Oct 2018 14:25:15 +0000 (15:25 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 30 Oct 2018 14:25:15 +0000 (15:25 +0100)
bin/postinst
lib/cr_vmware_tpl/handler.py
python_fb_tools

index 3742e94a3fc57c56d0adb2830ec21785fc19a88f..dda903ffdc380bafa5c92cce89eb17aec4073f2b 100644 (file)
@@ -347,7 +347,12 @@ install_epel() {
         cp -pv "${repo_file}" /etc/yum.repos.d/.old
     done
 
-    for bname in public-yum-ol7.repo epel.repo epel-testing.repo puppet.repo rpm-repo.pixelpark.com.repo ; do
+    local repo_files="epel.repo epel-testing.repo puppet.repo rpm-repo.pixelpark.com.repo"
+    if [[ -f "/etc/oracle-release" ]] ; then
+        repo_files="public-yum-ol7.repo ${repo_files}"
+    fi
+
+    for bname in ${repo_files} ; do
         url="${COBBLER_URL}/custom/create-vmware-tpl/yum.repos/${bname}"
         tgt="/etc/yum.repos.d/${bname}"
         echo
index 12ff07e896b4ef0efdd460e072a086866c11c622..349687916d5be57e37360f5efdbd493cd050451f 100644 (file)
@@ -200,11 +200,11 @@ class CrTplHandler(BaseHandler):
             else:
                 self.post_install_tasks_ssh()
                 if self.postinstall_errors:
-                    #self.purge_template_vm()
+                    self.vsphere.purge_vm(self.tpl_vm)
                     return 10
                 else:
                     self.poweroff_vm()
-                    #self.change_mac_address()
+                    self.change_mac_address()
 
         return 0
 
@@ -670,17 +670,17 @@ class CrTplHandler(BaseHandler):
         if self.postinstall_errors:
             LOG.warn("Template VM {!r} has to be removed.".format(self.config.template_vm))
 
-    # -------------------------------------------------------------------------
-    def purge_template_vm(self):
-
-        self.poweroff_vm()
-
-        LOG.info("Purging VM {!r} because of errors.".format(self.config.template_vm))
-        vm = self.get_temp_tpl_vm()
-        task = vm.Destroy_Task()
-        self.wait_for_tasks([task])
-
-        LOG.warn("Successful removed VM {!r}.".format(self.config.template_vm))
+#    # -------------------------------------------------------------------------
+#    def purge_template_vm(self):
+#
+#        self.vsphere.poweroff_vm(self.tpl_vm)
+#
+#        LOG.info("Purging VM {!r} because of errors.".format(self.config.template_vm))
+#        vm = self.get_temp_tpl_vm()
+#        task = vm.Destroy_Task()
+#        self.wait_for_tasks([task])
+#
+#        LOG.warn("Successful removed VM {!r}.".format(self.config.template_vm))
 
     # -------------------------------------------------------------------------
     def post_install_tasks_ssh(self):
@@ -913,35 +913,7 @@ class CrTplHandler(BaseHandler):
         LOG.debug("New MAC address: {!r}.".format(new_mac))
 
         vm = self.get_temp_tpl_vm()
-
-        virtual_nic_device = None
-        for dev in vm.config.hardware.device:
-            if isinstance(dev, vim.vm.device.VirtualEthernetCard):
-                virtual_nic_device = dev
-                break
-
-        if not virtual_nic_device:
-            raise HandlerError('Could not found virtual EthernetCard.')
-
-        virtual_nic_spec = vim.vm.device.VirtualDeviceSpec()
-        virtual_nic_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.edit
-        virtual_nic_spec.device = virtual_nic_device
-        virtual_nic_spec.device.macAddress = new_mac
-        virtual_nic_spec.device.backing = virtual_nic_device.backing
-        virtual_nic_spec.device.wakeOnLanEnabled = virtual_nic_device.wakeOnLanEnabled
-        virtual_nic_spec.device.connectable = virtual_nic_device.connectable
-
-        dev_changes = []
-        dev_changes.append(virtual_nic_spec)
-        spec = vim.vm.ConfigSpec()
-        spec.deviceChange = dev_changes
-
-        if self.verbose > 2:
-            LOG.debug("Changes of MAC address:\n{}".format(pp(spec)))
-
-        task = vm.ReconfigVM_Task(spec=spec)
-        self.wait_for_tasks([task])
-        LOG.debug("Successful changed MAC address of VM.")
+        self.vsphere.set_mac_of_nic(vm, new_mac, nic_nr=0)
 
     # -------------------------------------------------------------------------
     def rotate_templates(self):
index 04957bbf0e37188bcc008dd8d12ed6643cb03da7..e46d386775b93f051cd5cc81880e94b3ebd4f19b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 04957bbf0e37188bcc008dd8d12ed6643cb03da7
+Subproject commit e46d386775b93f051cd5cc81880e94b3ebd4f19b