Browse code

Fix a bug in ISO. Update OSTree installation options. Have random hostname prefilled.

Touseef Liaqat authored on 2015/08/13 01:58:24
Showing 3 changed files
... ...
@@ -24,6 +24,7 @@ from windowstringreader import WindowStringReader
24 24
 from jsonwrapper import JsonWrapper
25 25
 from selectdisk import SelectDisk
26 26
 from license import License
27
+import random
27 28
 
28 29
 class IsoInstaller(object):
29 30
 
... ...
@@ -113,13 +114,15 @@ class IsoInstaller(object):
113 113
         # This represents the installer screen, the bool indicated if I can go back to this window or not
114 114
         items = []
115 115
         if not ks_config:
116
+            random_hostname = "photon-" + '%12x' % random.randrange(16**12)
116 117
             install_config = {'iso_system': False}
117 118
             license_agreement = License(self.maxy, self.maxx)
118 119
             select_disk = SelectDisk(self.maxy, self.maxx, install_config)
119 120
             package_selector = PackageSelector(self.maxy, self.maxx, install_config, options_file)
120 121
             hostname_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, 'hostname', False, 'Choose the hostname for your system',
121 122
                 'Hostname:', 
122
-                2, install_config)
123
+                2, install_config,
124
+                random_hostname)
123 125
             root_password_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, 'password', False,  'Set up root password',
124 126
                 'Root password:', 
125 127
                 2, install_config)
... ...
@@ -25,13 +25,29 @@ from windowstringreader import WindowStringReader
25 25
 from window import Window
26 26
 from actionresult import ActionResult
27 27
 from installer import Installer
28
+from menu import Menu
28 29
 
29 30
 class OstreeInstaller(Installer):
30 31
 
31 32
     def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None):
32 33
         Installer.__init__(self, install_config, maxy, maxx, iso_installer, rpm_path, log_path, ks_config)
34
+    
35
+        self.win_height = 13
36
+        self.win_width = 50
37
+        self.menu_starty = self.starty + 3    
38
+        self.ostree_host_menu_items = []
39
+        self.ostree_host_menu_items.append(("Default RPM-OSTree Server", self.default_installation, []))
40
+        self.ostree_host_menu_items.append(("Custom RPM-OSTree Server", self.custom_installation, []))
41
+        self.host_menu = Menu(self.menu_starty,  self.maxx, self.ostree_host_menu_items)
42
+        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Select OSTree Server', True, self.host_menu)
43
+        self.default_repo = True
44
+
45
+    def default_installation(self,  selected_item_params):
46
+        self.default_repo = True
47
+        return ActionResult(True, None)
33 48
 
34
-    def get_ostree_repo_url(self):
49
+    def custom_installation(self,  selected_item_params):
50
+        self.default_repo = False
35 51
         success = False
36 52
         while not success:
37 53
             got_the_url = False
... ...
@@ -42,7 +58,7 @@ class OstreeInstaller(Installer):
42 42
                     "Please provide the URL of OSTree repo",
43 43
                     "OSTree Repo URL:", 2,
44 44
                     self.install_config,
45
-                    "https://dl.bintray.com/vmware/photon/rpms/dev/")
45
+                    "https://dl.bintray.com/vmware/photon/rpm-ostree/dev/x86_64/minimal")
46 46
 
47 47
                 ret = ostree_url_reader.get_user_string(None)
48 48
                 self.ostree_repo_url = ret.result
... ...
@@ -62,6 +78,9 @@ class OstreeInstaller(Installer):
62 62
 
63 63
         return ActionResult(True, None)
64 64
 
65
+    def get_ostree_repo_url(self):
66
+        return self.window.do_action()
67
+
65 68
     def deploy_ostree(self, repo_url, repo_ref):
66 69
         self.run("ostree admin --sysroot={} init-fs {}".format(self.photon_root, self.photon_root), "Initializing OSTree filesystem")
67 70
         self.run("ostree remote add --repo={}/ostree/repo --set=gpg-verify=false photon {}".format(self.photon_root, repo_url), "Adding OSTree remote")
... ...
@@ -36,7 +36,7 @@ class PackageSelector(object):
36 36
         for install_option in options:
37 37
             if install_option[0] == config_type:
38 38
                 if install_option[1]["include"] != "none":
39
-                    for include_type in install_option[1]["include"].split(','):
39
+                    for include_type in install_option[1]["include"]:
40 40
                         package_list = package_list + PackageSelector.get_packages_to_install(options, include_type, output_data_path)
41 41
                 json_wrapper_package_list = JsonWrapper(os.path.join(output_data_path, install_option[1]["file"]))
42 42
                 package_list_json = json_wrapper_package_list.read()