]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Substituting the vsphere objects from fb_tools.vsphere to the separate fb_vmware...
authorFrank Brehm <frank@brehm-online.com>
Fri, 17 Jun 2022 14:53:33 +0000 (16:53 +0200)
committerFrank Brehm <frank@brehm-online.com>
Fri, 17 Jun 2022 14:53:33 +0000 (16:53 +0200)
bin/create-vmware-template
etc/create-vmware-template.ini.default
lib/cr_vmware_tpl/app.py
lib/cr_vmware_tpl/config.py
lib/cr_vmware_tpl/handler.py

index 63745de486ba9161b593942dd74e67d04b063cb8..38e7507ca2a237f4f4a3c50265c870ca5d19ccc1 100755 (executable)
@@ -52,7 +52,7 @@ app.initialized = True
 if app.verbose > 2:
     print("{c}-Object:\n{a}".format(c=app.__class__.__name__, a=app))
 
-app()
+app()
 
 sys.exit(0)
 
index b90dca3b95604e11c1cc372a5a186bffcc4569a5..a5e3e7dd170c5b73a10abdc031ae0ead44ba4ed5 100644 (file)
 
 # root_dir = /var/lib/cobbler
 
+# templates_tir = templates
+
+# snippets_dir = snippets
+
 # profile = 
 
 # profile_repos = pp-centos8-baseos
index 6bbf6b11a1ccef32d47dff9948b750a5ff6ba837..302cdd5ddaa1d3376735db66f02a2678da9052cb 100644 (file)
@@ -38,7 +38,7 @@ from .xlate import __base_dir__ as __xlate_base_dir__
 from .xlate import __mo_file__ as __xlate_mo_file__
 from .xlate import XLATOR, LOCALE_DIR, DOMAIN
 
-__version__ = '1.3.1'
+__version__ = '1.4.0'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -260,10 +260,10 @@ class CrTplApplication(BaseApplication):
 
         self.perform_arg_parser_vmware()
 
-        if not self.config.password:
+        if not self.config.vsphere_info.password:
             prompt = (_('Enter password for host {h!r} and user {u!r}:') + ' ').format(
-                h=self.config.vsphere_host, u=self.config.vsphere_user)
-            self.config.password = getpass.getpass(prompt=prompt)
+                h=self.config.vsphere_info.host, u=self.config.vsphere_info.user)
+            self.config.vsphere_info.password = getpass.getpass(prompt=prompt)
 
         self.handler = CrTplHandler(
             appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
@@ -375,13 +375,13 @@ class CrTplApplication(BaseApplication):
         """
 
         if self.args.host:
-            self.config.vsphere_host = self.args.host
+            self.config.vsphere_info.host = self.args.host
         if self.args.port:
-            self.config.vsphere_port = self.args.port
+            self.config.vsphere_info.port = self.args.port
         if self.args.user:
-            self.config.vsphere_user = self.args.user
+            self.config.vsphere_info.user = self.args.user
         if self.args.password:
-            self.config.password = self.args.password
+            self.config.vsphere_info.password = self.args.password
         if self.args.cluster:
             self.config.vsphere_cluster = self.args.cluster
         if self.args.folder:
index 51161bf94806604f8eb58e8b0238126987651dbe..1df33fc35be991cd2b3cba505353213695ea3598 100644 (file)
@@ -120,12 +120,7 @@ class CrTplConfiguration(BaseConfiguration):
 
         self.os_id = self.default_os_id
 
-        self.vsphere_host = self.default_vsphere_host
-        self.vsphere_port = self.default_vsphere_port
-        self.vsphere_user = self.default_vsphere_user
         self.vsphere_cluster = self.default_vsphere_cluster
-        self.dc = self.default_dc
-        self.password = None
         self.folder = self.default_folder
         self.template_name = self.default_template_name
         self.data_size_gb = self.default_data_size_gb
@@ -143,11 +138,6 @@ class CrTplConfiguration(BaseConfiguration):
         self.vmware_cfg_version = self.default_vmware_cfg_version
         self.os_version = self.default_os_version
 
-        self.vsphere_info = VSPhereConfigInfo(
-            host=self.default_vsphere_host, port=self.default_vsphere_port, dc=self.default_dc,
-            use_https=True, user=self.default_vsphere_user,
-            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
-
         self.storage_cluster = self.default_storage_cluster
 
         self.tpl_vm_domain = self.default_tpl_vm_domain
@@ -183,6 +173,12 @@ class CrTplConfiguration(BaseConfiguration):
             encoding=encoding, config_dir=config_dir, config_file=config_file, initialized=False,
         )
 
+        self.vsphere_info = VSPhereConfigInfo(
+            host=self.default_vsphere_host, port=self.default_vsphere_port, dc=self.default_dc,
+            use_https=True, user=self.default_vsphere_user,
+            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+            initialized=True)
+
         self.private_ssh_key = str(self.base_dir.joinpath('keys', self.ssh_privkey))
 
         if initialized:
@@ -258,13 +254,6 @@ class CrTplConfiguration(BaseConfiguration):
             else:
                 res['root_password'] = '********'
 
-        res['password'] = None
-        if self.password:
-            if self.verbose > 4:
-                res['password'] = self.password
-            else:
-                res['password'] = '*******'
-
         return res
 
     # -------------------------------------------------------------------------
@@ -328,19 +317,15 @@ class CrTplConfiguration(BaseConfiguration):
         for (key, value) in config.items(section_name):
 
             if key.lower() == 'host':
-                self.vsphere_host = value
                 self.vsphere_info.host = value
                 continue
             elif key.lower() == 'port':
-                self.vsphere_port = int(value)
                 self.vsphere_info.port = value
                 continue
             elif key.lower() == 'user':
-                self.vsphere_user = value
                 self.vsphere_info.user = value
                 continue
             elif key.lower() == 'password':
-                self.password = value
                 self.vsphere_info.password = value
                 continue
             elif key.lower() == 'cluster':
@@ -349,7 +334,6 @@ class CrTplConfiguration(BaseConfiguration):
             elif key.lower() == 'folder':
                 self.folder = value
             elif key.lower() == 'dc':
-                self.dc = value
                 self.vsphere_info.dc = value
 
             elif key.lower() == 'max_nr_templates_stay':
index fbfaa05de0b3dd798627a22ee76bb5f04baaed23..f5f97ce92246ad9493df2ae7680a35592342833f 100644 (file)
@@ -32,11 +32,14 @@ from fb_tools.errors import HandlerError, ExpectedHandlerError
 
 from fb_tools.handler import BaseHandler
 
-from fb_tools.vsphere.errors import VSphereExpectedError
-from fb_tools.vsphere.errors import VSphereDatacenterNotFoundError
-from fb_tools.vsphere.server import VsphereServer
-from fb_tools.vsphere.iface import VsphereVmInterface
-from fb_tools.vsphere.ds import VsphereDatastore
+from fb_vmware.errors import VSphereExpectedError
+from fb_vmware.errors import VSphereDatacenterNotFoundError
+
+# from fb_tools.vsphere.server import VsphereServer
+from fb_vmware.connect import VsphereConnection
+
+from fb_vmware.iface import VsphereVmInterface
+from fb_vmware.datastore import VsphereDatastore
 
 from . import print_section_start, print_section_end
 
@@ -46,7 +49,7 @@ from .cobbler import Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '1.9.0'
+__version__ = '2.0.0'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -147,13 +150,19 @@ class CrTplHandler(BaseHandler):
         self.postinstall_errors = None
         self.cobbler = None
 
-        self.vsphere = VsphereServer(
+        self.vsphere = VsphereConnection(
+            self.config.vsphere_info, cluster=self.config.vsphere_cluster,
             appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
-            host=self.config.vsphere_host, port=self.config.vsphere_port,
-            user=self.config.vsphere_user, password=self.config.password,
-            dc=self.config.dc, cluster=self.config.vsphere_cluster,
             auto_close=True, simulate=self.simulate, force=self.force, tz=TZ,
             terminal_has_colors=self.terminal_has_colors, initialized=False)
+
+#        self.vsphere = VsphereServer(
+#            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+#            host=self.config.vsphere_host, port=self.config.vsphere_port,
+#            user=self.config.vsphere_user, password=self.config.password,
+#            dc=self.config.dc, cluster=self.config.vsphere_cluster,
+#            auto_close=True, simulate=self.simulate, force=self.force, tz=TZ,
+#            terminal_has_colors=self.terminal_has_colors, initialized=False)
         self.cluster = None
 
         self.cobbler = Cobbler(