Browse code

OSTree Host and Server installation options in added in ASP Installer.

Touseef Liaqat authored on 2015/07/30 06:46:52
Showing 19 changed files
... ...
@@ -30,7 +30,7 @@
30 30
         "visible" : true,
31 31
         "include" : "none"
32 32
     },
33
-    "ostree_host" : {
33
+    "ostree_server" : {
34 34
         "title" : "5. Photon OSTree Server",
35 35
         "file" : "packages_ostree_server.json",
36 36
         "visible" : true,
... ...
@@ -14,7 +14,12 @@
14 14
                 "gptfdisk", "gzip", "openssl", "python2", "python2-libs", "python-requests",
15 15
                 "pcre",
16 16
                 "libgsystem", "ostree","device-mapper","device-mapper-libs","libsepol","libselinux", 
17
-                "db", "libsolv", "hawkey", "python-hawkey"]
17
+                "db", "libsolv",
18
+                "dracut", "dracut-tools",
19
+                "gpgme", "gpgme-devel", "hawkey", "python-hawkey", "json-glib", "glib",
20
+                "libarchive", "libarchive-devel", "libassuan", "libffi",
21
+                "libgpg-error", "libhif", "libhif-devel",
22
+                "librepo", "librepo-devel", "libsoup", "libsoup-devel",
23
+                "libxml2", "mkinitcpio", "openssl-devel",
24
+                "yum", "ostree"]
18 25
 }
19
-
20
-
... ...
@@ -2,17 +2,14 @@
2 2
     "packages":["glibc","zlib", "filesystem",
3 3
                 "gmp", "mpfr", "libgcc", "libstdc++",
4 4
                 "bzip2", "pkg-config", "ncurses", "cracklib", "cracklib-dicts", "shadow", "procps-ng", "e2fsprogs",
5
-                "iana-etc", "readline", "coreutils", "bash", "bc", "libtool",
5
+                "iana-etc", "readline", "coreutils", "bash",
6 6
                 "inetutils",
7
-                "xz", "grub2", "iproute2", "kbd", "kmod", "libpipeline",
7
+                "xz", "iproute2", "kbd", "kmod", "libpipeline",
8 8
                 "util-linux",
9 9
                 "openssl", "libffi", "expat",
10
-                "linux", "curl",
11
-                "iptables", "ca-certificates",
12
-                "Linux-PAM", "attr", "libcap", "systemd", "dbus",
13
-                "sqlite-autoconf", "elfutils-libelf", "elfutils-libelf-devel",
14
-                "nspr", "nss", "popt", "lua", "rpm", "openssh",
15
-                "db", "libsolv", "libgpg-error", "hawkey", "libassuan", "gpgme", "librepo", "pcre", "glib", "tdnf",
10
+                "linux", "glib",
11
+                "iptables", "ca-certificates", "pcre",
12
+                "Linux-PAM", "attr", "libcap", "systemd", "dbus", "docker",
16 13
                 "photon-release"
17 14
                 ]
18 15
 }
19 16
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+{
1
+    "packages":[]
2
+}
3
+
... ...
@@ -1,6 +1,6 @@
1 1
 {
2
-    "packages":["bash", "bzip2", "dracut", "dracut-tools",
3
-                "glib", "glibc", "gpgme", "gpgme-devel", "hawkey", "json-glib",
2
+    "packages":["filesystem", "glibc", "bash", "bzip2", "dracut", "dracut-tools",
3
+                "glib", "gpgme", "gpgme-devel", "hawkey", "json-glib",
4 4
                 "libarchive", "libarchive-devel", "libassuan", "libcap", "libffi",
5 5
                 "libgcc", "libgpg-error", "libgsystem", "libhif", "libhif-devel",
6 6
                 "librepo", "librepo-devel", "libsolv", "libsoup", "libsoup-devel",
... ...
@@ -335,3 +335,13 @@ class Installer(object):
335 335
                 print >> sys.stderr,  "Error: not able to execute module %s" % module
336 336
                 continue
337 337
             mod.execute(module, self.ks_config, self.install_config, self.photon_root)
338
+
339
+    def run(self, command, comment = None):
340
+        if comment != None:
341
+            print >> sys.stderr, "Installer: {} ".format(comment)
342
+            self.progress_bar.show_loading(comment)
343
+
344
+        print >> sys.stderr, "Installer: {} ".format(command)
345
+        process = subprocess.Popen([command], shell=True, stdout=self.output)
346
+        retval = process.wait()
347
+        return retval
338 348
\ No newline at end of file
339 349
new file mode 100644
... ...
@@ -0,0 +1,30 @@
0
+#! /usr/bin/python2
1
+#
2
+#    Copyright (C) 2015 vmware inc.
3
+#
4
+#    Author: Touseef Liaqat <tliaqat@vmware.com>
5
+
6
+from installer import Installer
7
+from ostreeinstaller import OstreeInstaller
8
+from ostreeserverinstaller import OstreeServerInstaller
9
+
10
+class InstallerContainer(object):
11
+    def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None):
12
+        self.install_config = install_config
13
+        self.maxy = maxy
14
+        self.maxx = maxx
15
+        self.ks_config = ks_config
16
+        self.iso_installer = iso_installer
17
+        self.rpm_path = rpm_path
18
+        self.log_path = log_path
19
+
20
+    def install(self, params):
21
+        installer = None
22
+        if self.install_config['type'] == "ostree_host":
23
+            installer = OstreeInstaller(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.ks_config)
24
+        elif self.install_config['type'] == "ostree_server":
25
+            installer = OstreeServerInstaller(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.ks_config)
26
+        else:
27
+            installer = Installer(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.ks_config)
28
+
29
+        return installer.install(params)
0 30
\ No newline at end of file
... ...
@@ -18,6 +18,8 @@ from diskpartitioner import DiskPartitioner
18 18
 from packageselector import PackageSelector
19 19
 from custompackageselector import CustomPackageSelector
20 20
 from installer import Installer
21
+from installercontainer import InstallerContainer
22
+from ostreeinstaller import OstreeInstaller
21 23
 from windowstringreader import WindowStringReader
22 24
 from jsonwrapper import JsonWrapper
23 25
 from selectdisk import SelectDisk
... ...
@@ -116,13 +118,13 @@ class IsoInstaller(object):
116 116
             license_agreement = License(self.maxy, self.maxx)
117 117
             select_disk = SelectDisk(self.maxy, self.maxx, self.install_config)
118 118
             package_selector = PackageSelector(self.maxy, self.maxx, self.install_config, options_file)
119
-            hostname_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, False, False, 'Choose the hostname for your system',
119
+            hostname_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, 'hostname', False, 'Choose the hostname for your system',
120 120
                 'Hostname:', 
121 121
                 2, self.install_config)
122
-            root_password_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, True, False,  'Set up root password',
122
+            root_password_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, 'password', False,  'Set up root password',
123 123
                 'Root password:', 
124 124
                 2, self.install_config)
125
-            confirm_password_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, True, True,  'Confirm root password',
125
+            confirm_password_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, 'password', True,  'Confirm root password',
126 126
                 'Confirm Root password:', 
127 127
                 2, self.install_config)
128 128
             
... ...
@@ -134,7 +136,8 @@ class IsoInstaller(object):
134 134
                     (root_password_reader.get_user_string, True),
135 135
                     (confirm_password_reader.get_user_string, False),
136 136
                  ]
137
-        installer = Installer(self.install_config, self.maxy, self.maxx, True, rpm_path=rpm_path, log_path="/var/log", ks_config=ks_config)
137
+        installer = InstallerContainer(self.install_config, self.maxy, self.maxx, True, rpm_path=rpm_path, log_path="/var/log", ks_config=ks_config)
138
+
138 139
         items = items + [(installer.install, False)]
139 140
 
140 141
         index = 0
141 142
new file mode 100755
... ...
@@ -0,0 +1,25 @@
0
+#!/bin/bash
1
+#################################################
2
+#       Title:  mk-ostree-server                  #
3
+#        Date:  2015-07-15                      #
4
+#     Version:  1.0                             #
5
+#      Author:  tliaqat@vmware.com             #
6
+#     Options:                                  #
7
+#################################################
8
+#   Overview
9
+#       Install OSTree Server
10
+#   End
11
+#
12
+
13
+set -o errexit          # exit if error...insurance ;)
14
+set -o nounset          # exit if variable not initalized
15
+set +h                  # disable hashall
16
+PRGNAME=${0##*/}        # script name minus the path
17
+source config.inc       #   configuration parameters
18
+source function.inc     #   commonn functions
19
+LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"    #   set log file name
20
+
21
+ROOT=$1
22
+
23
+ostree --repo=${ROOT}/srv/rpm-ostree/repo init --mode=archive-z2 >> "${LOGFILE}" 2>&1
24
+rpm-ostree compose tree --repo=${ROOT}/srv/rpm-ostree/repo photon-base.json >> "${LOGFILE}" 2>&1
... ...
@@ -31,4 +31,5 @@ def execute(name, ks_config, config, root):
31 31
     else:
32 32
         #add password hash in shadow file
33 33
         commons.replace_string_in_file(shadow_filename, "root::", "root:"+shadow_password+":")
34
+        commons.replace_string_in_file(shadow_filename, "root:x:", "root:"+shadow_password+":")
34 35
 
35 36
new file mode 100644
... ...
@@ -0,0 +1,177 @@
0
+#!/usr/bin/python2
1
+#
2
+#    Copyright (C) 2015 vmware inc.
3
+#
4
+#    Author: Touseef Liaqat <tliaqat@vmware.com>
5
+
6
+import subprocess
7
+import curses
8
+import os
9
+import crypt
10
+import re
11
+import random
12
+import string
13
+import shutil
14
+import fnmatch
15
+import signal
16
+import sys
17
+import glob
18
+import urllib
19
+import modules.commons
20
+import xml.etree.ElementTree as ET
21
+from jsonwrapper import JsonWrapper
22
+from progressbar import ProgressBar
23
+from windowstringreader import WindowStringReader
24
+from window import Window
25
+from actionresult import ActionResult
26
+from installer import Installer
27
+
28
+class OstreeInstaller(Installer):
29
+
30
+    def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None):
31
+        Installer.__init__(self, install_config, maxy, maxx, iso_installer, rpm_path, log_path, ks_config)
32
+
33
+    def get_ostree_repo_url(self):
34
+        success = False
35
+        while not success:
36
+            got_the_url = False
37
+            while not got_the_url:
38
+                ostree_url_reader = WindowStringReader(
39
+                    self.maxy, self.maxx, 10, 70,
40
+                    "ostree_repo_url", False,
41
+                    "Please provide the URL of OSTree repo",
42
+                    "OSTree Repo URL:", 2,
43
+                    self.install_config,
44
+                    "http://192.168.29.166/")
45
+
46
+                ret = ostree_url_reader.get_user_string(None)
47
+                self.ostree_repo_url = ret.result
48
+                got_the_url = ret.success
49
+
50
+            ostree_ref_reader = WindowStringReader(self.maxy,
51
+                self.maxx, 10, 70,
52
+                "ostree_ref", False,
53
+                "Please provide the Ref in OSTree repo",
54
+                "OSTree Repo Ref:", 2,
55
+                self.install_config,
56
+                "tp2/x86_64/minimal")
57
+
58
+            ret = ostree_ref_reader.get_user_string(None)
59
+            self.ostree_ref = ret.result
60
+            success = ret.success
61
+
62
+        return ActionResult(True, None)
63
+
64
+    def deploy_ostree(self, repo_url, repo_ref):
65
+        self.run("ostree admin --sysroot={} init-fs {}".format(self.photon_root, self.photon_root), "Initializing OSTree filesystem")
66
+        self.run("ostree remote add --repo={}/ostree/repo --set=gpg-verify=false photon {}".format(self.photon_root, repo_url), "Adding OSTree remote")
67
+        self.run("ostree pull --repo={}/ostree/repo photon {}".format(self.photon_root, repo_ref), "Pulling OSTree remote repo")
68
+        self.run("ostree admin --sysroot={} os-init photon ".format(self.photon_root), "OSTree OS Initializing")
69
+        self.run("ostree admin --sysroot={} deploy --os=photon photon/{}".format(self.photon_root, repo_ref), "Deploying")
70
+
71
+    def do_systemd_tmpfiles_commands(self, commit_number):
72
+        prefixes = ["/var/home",
73
+            "/var/roothome",
74
+            "/var/lib/rpm",
75
+            "/var/opt",
76
+            "/var/srv",
77
+            "/var/userlocal",
78
+            "/var/mnt",
79
+            "/var/spool/mail"]
80
+
81
+        for prefix in prefixes:
82
+            command = "systemd-tmpfiles --create --boot --root={}/ostree/deploy/photon/deploy/{}.0 --prefix={}".format(self.photon_root, commit_number, prefix)
83
+            self.run(command)
84
+
85
+    def mount_devices_in_deployment(self, commit_number):
86
+        for command in ["mount -t bind -o bind,defaults /dev  {}/ostree/deploy/photon/deploy/{}.0/dev",
87
+            "mount -t devpts -o gid=5,mode=620 devpts  {}/ostree/deploy/photon/deploy/{}.0/dev/pts",
88
+            "mount -t tmpfs -o defaults tmpfs  {}/ostree/deploy/photon/deploy/{}.0/dev/shm",
89
+            "mount -t proc -o defaults proc  {}/ostree/deploy/photon/deploy/{}.0/proc",
90
+            "mount -t bind -o bind,defaults /run  {}/ostree/deploy/photon/deploy/{}.0/run",
91
+            "mount -t sysfs -o defaults sysfs  {}/ostree/deploy/photon/deploy/{}.0/sys" ]:
92
+            self.run(command.format(self.photon_root, commit_number))
93
+
94
+    def get_commit_number(self, ref):
95
+        fileName = os.path.join(self.photon_root, "ostree/repo/refs/remotes/photon/{}".format(ref))
96
+        commit_number = None
97
+        with open (fileName, "r") as file:
98
+            commit_number = file.read().replace('\n', '')
99
+        return commit_number
100
+
101
+    def unsafe_install(self, params):
102
+        self.org_photon_root = self.photon_root
103
+        sysroot_ostree = os.path.join(self.photon_root, "ostree")
104
+        sysroot_boot = os.path.join(self.photon_root, "boot")
105
+        loader0 = os.path.join(sysroot_boot, "loader.0")
106
+        loader1 = os.path.join(sysroot_boot, "loader.1")
107
+
108
+        boot0 = os.path.join(sysroot_ostree, "boot.0")
109
+        boot1 = os.path.join(sysroot_ostree, "boot.1")
110
+
111
+        boot01 = os.path.join(sysroot_ostree, "boot.0.1")
112
+        boot11 = os.path.join(sysroot_ostree, "boot.1.1")
113
+
114
+        self.get_ostree_repo_url()
115
+
116
+        self.window.show_window()
117
+        self.progress_bar.initialize("Initializing installation...")
118
+        self.progress_bar.show()
119
+
120
+        self.execute_modules(modules.commons.PRE_INSTALL)
121
+
122
+        disk = self.install_config['disk']['disk']
123
+        self.run("sgdisk -d 2 -n 2::+300M -n 3: -p {}".format(disk), "Updating partition table for OSTree")
124
+        self.run("mkfs -t ext4 {}2".format(disk))
125
+        self.run("mkfs -t ext4 {}3".format(disk))
126
+        self.run("mount {}3 {}".format(disk, self.photon_root))
127
+        self.run("mkdir -p {} ".format(sysroot_boot))
128
+        self.run("mount {}2 {}".format(disk, sysroot_boot))
129
+
130
+        self.deploy_ostree(self.ostree_repo_url, self.ostree_ref)
131
+
132
+        commit_number = self.get_commit_number(self.ostree_ref)
133
+        self.do_systemd_tmpfiles_commands(commit_number)
134
+
135
+        self.mount_devices_in_deployment(commit_number)
136
+        deployment = os.path.join(self.photon_root, "ostree/deploy/photon/deploy/" + commit_number + ".0/")
137
+
138
+        deployment_boot = os.path.join(deployment, "boot")
139
+        deployment_sysroot = os.path.join(deployment, "sysroot")
140
+
141
+        self.run("mv {} {}".format(loader1, loader0))
142
+        self.run("mv {} {}".format(boot1, boot0))
143
+        self.run("mv {} {}".format(boot11, boot01))
144
+        self.run("mount --bind {} {}".format(sysroot_boot, deployment_boot))
145
+        self.run("mount --bind {} {}".format(self.photon_root, deployment_sysroot))
146
+        self.run("chroot {} bash -c \"grub2-install /dev/sda\"".format(deployment))
147
+        self.run("chroot {} bash -c \"grub2-mkconfig -o /boot/grub2/grub.cfg\"".format(deployment))
148
+        self.run("mv {} {}".format(loader0, loader1))
149
+        self.run("mv {} {}".format(boot0, boot1))
150
+        self.run("mv {} {}".format(boot01, boot11))
151
+        self.run("chroot {} bash -c \"ostree admin instutil set-kargs root=/dev/sda3 \"".format(deployment))
152
+        sysroot_grub2_grub_cfg = os.path.join(self.photon_root, "boot/grub2/grub.cfg")
153
+        self.run("ln -sf ../loader/grub.cfg {}".format(sysroot_grub2_grub_cfg))
154
+        self.run("mv {} {}".format(loader1, loader0))
155
+        self.run("mv {} {}".format(boot1, boot0))
156
+        self.run("mv {} {}".format(boot11, boot01))
157
+
158
+
159
+        deployment_fstab = os.path.join(deployment, "etc/fstab")
160
+        self.run("echo \"/dev/sda2    /boot    ext4   defaults   1 2  \" >> {} ".format(deployment_fstab), "Adding /boot mount point in fstab")
161
+        self.run("mount --bind {} {}".format(deployment, self.photon_root))
162
+        self.progress_bar.show_loading("Starting post install modules")
163
+        self.execute_modules(modules.commons.POST_INSTALL)
164
+
165
+        self.run("{} {} {}".format(self.unmount_disk_command, '-w', self.photon_root))
166
+
167
+        if self.iso_installer:
168
+            self.progress_bar.show_loading('Press any key to continue to boot')
169
+            self.progress_bar.hide()
170
+            self.window.addstr(0, 0,
171
+                "Congratulations, Photon has been installed in {} secs.\n\nPress any key to continue to boot...".format(self.progress_bar.time_elapsed))
172
+            if self.ks_config == None:
173
+                self.window.content_window().getch()
174
+
175
+        return ActionResult(True, None)
176
+
0 177
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+#!/usr/bin/python2
1
+#
2
+#    Copyright (C) 2015 vmware inc.
3
+#
4
+#    Author: Touseef Liaqat <tliaqat@vmware.com>
5
+
6
+import subprocess
7
+import curses
8
+import os
9
+import crypt
10
+import re
11
+import random
12
+import string
13
+import shutil
14
+import fnmatch
15
+import signal
16
+import sys
17
+import glob
18
+import urllib
19
+import modules.commons
20
+import xml.etree.ElementTree as ET
21
+from jsonwrapper import JsonWrapper
22
+from progressbar import ProgressBar
23
+from windowstringreader import WindowStringReader
24
+from window import Window
25
+from actionresult import ActionResult
26
+from installer import Installer
27
+
28
+class OstreeServerInstaller(Installer):
29
+
30
+    def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None):
31
+        Installer.__init__(self, install_config, maxy, maxx, iso_installer, rpm_path, log_path, ks_config)
32
+
33
+    def finalize_system(self):
34
+        Installer.finalize_system(self)
35
+
36
+        self.run("mkdir -p {}/srv/rpm-ostree/".format(self.photon_root))
37
+        self.run("cp *.inc {}/srv/rpm-ostree/".format(self.photon_root))
38
+        self.run("cp ./mk-ostree-server.sh {}/srv/rpm-ostree/".format(self.photon_root))
39
+        self.run("cp ./photon-base.json {}/srv/rpm-ostree/".format(self.photon_root))
40
+        self.run("cp ./photon-ostree.repo {}/srv/rpm-ostree/".format(self.photon_root))
41
+        self.run("mount /dev/cdrom {}/mnt/cdrom".format(self.photon_root))
42
+        self.run("chroot {} bash -c \"cd /srv/rpm-ostree; ./mk-ostree-server.sh /\"".format(self.photon_root))
... ...
@@ -19,7 +19,7 @@ class PackageSelector(object):
19 19
         self.maxx = maxx
20 20
         self.maxy = maxy
21 21
         self.win_width = 50
22
-        self.win_height = 10
22
+        self.win_height = 13
23 23
 
24 24
         self.win_starty = (self.maxy - self.win_height) / 2
25 25
         self.win_startx = (self.maxx - self.win_width) / 2
26 26
new file mode 100644
... ...
@@ -0,0 +1,33 @@
0
+{
1
+    "comment": "Photon Minimal OSTree",
2
+
3
+    "osname": "photon",
4
+
5
+    "ref": "tp2/x86_64/minimal",
6
+
7
+    "repos": ["photon-ostree"],
8
+
9
+    "selinux": false,
10
+
11
+    "initramfs-args": ["--no-hostonly"],
12
+
13
+    "bootstrap_packages": ["filesystem"],
14
+
15
+    "packages": ["glibc", "zlib", "binutils", "gmp", "mpfr", "libgcc", "libstdc++","libgomp",
16
+                "pkg-config", "ncurses", "bash", "bzip2", "cracklib", "cracklib-dicts", "shadow",
17
+                "procps-ng", "iana-etc", "readline", "coreutils", "bc", "libtool", "inetutils",
18
+                "findutils", "xz", "grub2", "iproute2", "util-linux", "linux",
19
+                "attr", "libcap", "kmod", "expat", "dbus", "file",
20
+                "sed", "grep", "cpio", "gzip",
21
+                "wget", "openssl", "ca-certificates", "curl", "iptables", "Linux-PAM",
22
+                "systemd", "e2fsprogs", "elfutils-libelf", "lua", "popt", "sqlite-autoconf", "nspr", "nss", "rpm",
23
+                "openssh", "libffi", "gdbm", "python2", "python2-libs", "pcre", "glib", "libxml2",
24
+                "photon-release",
25
+                "vim", "db", "libsolv", "libgpg-error", "hawkey", "libassuan", "gpgme", "librepo", "tdnf",
26
+                "libdnet", "xerces-c", "xml-security-c", "libmspack",
27
+                "docker","bridge-utils",
28
+                "libyaml", "PyYAML", "python-requests", "python-prettytable",
29
+                "python-jsonpointer", "python-jsonpatch", "python-six", "python-configobj",
30
+                "krb5", "e2fsprogs-devel",
31
+                "dracut", "dracut-tools", "ostree", "rpm-ostree", "nss-altfiles", "which"]
32
+}
0 33
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+[photon-ostree]
1
+name=VMware Photon Linux 1.0(x86_64)
2
+baseurl=http://192.168.29.140:8090/
3
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
4
+gpgcheck=0
5
+enabled=1
6
+skip_if_unavailable=True
... ...
@@ -9,31 +9,32 @@ import crypt
9 9
 import string
10 10
 import random
11 11
 import cracklib
12
+import sys
12 13
 from actionresult import ActionResult
13 14
 from action import Action
14 15
 from confirmwindow import ConfirmWindow
15 16
 
16 17
 class ReadText(Action):
17
-    def __init__(self, maxy, maxx, textwin, y, install_config, ispassword, confirm_pass):
18
+    def __init__(self, maxy, maxx, textwin, y, install_config, field, confirm_pass, default_string = None):
18 19
         self.textwin = textwin
19 20
         self.maxy = maxy
20 21
         self.maxx = maxx
21 22
         self.y = y
22 23
         self.install_config = install_config
23
-        self.ispassword = ispassword
24
+        self.field = field
24 25
         self.confirm_pass = confirm_pass;
25
-        
26
+        self.default_string = default_string
26 27
         self.textwin_width = self.textwin.getmaxyx()[1] - 1
27 28
         self.visible_text_width = self.textwin_width - 1
28 29
 
29 30
         self.init_text()
30
-        self.maxlength = 255        
31
+        self.maxlength = 255
31 32
 
32 33
         #initialize the accepted characters
33
-        if self.ispassword:
34
+        if self.field == "password":
34 35
             # Adding all the letters
35 36
             self.accepted_chars = range(33, 127)
36
-        else:
37
+        elif self.field == "hostname":
37 38
 
38 39
             self.alpha_chars = range(65, 91)
39 40
             self.alpha_chars.extend(range(97,123))
... ...
@@ -43,7 +44,8 @@ class ReadText(Action):
43 43
             self.accepted_chars.extend(range(48, 58))
44 44
             # Adding the . and -
45 45
             self.accepted_chars.extend([ord('.'), ord('-')])
46
-
46
+        else:
47
+            self.accepted_chars = range(33, 127)
47 48
 
48 49
     def hide(self):
49 50
         return
... ...
@@ -63,6 +65,10 @@ class ReadText(Action):
63 63
         self.init_text()
64 64
         curses.curs_set(1)
65 65
 
66
+        if self.default_string != None:
67
+            self.textwin.addstr(self.y, 0, self.default_string)
68
+            self.str = self.default_string
69
+
66 70
         while True:
67 71
             if len(self.str) > self.visible_text_width:
68 72
                 curs_loc = self.visible_text_width
... ...
@@ -81,18 +87,21 @@ class ReadText(Action):
81 81
                         confrim_window.do_action()
82 82
                         return ActionResult(False, {'goBack': True})
83 83
                     self.install_config['password'] = self.generate_password_hash(self.str)
84
-                elif self.ispassword:
84
+                elif self.field == "password":
85 85
                     err = self.validate_password(self.str)
86 86
                     if err != self.str:
87 87
                         self.init_text()
88 88
                         self.textwin.addstr(self.y + 2, 0, "Error: " + err, curses.color_pair(4))
89 89
                         continue
90 90
                     self.install_config['password'] = self.str;
91
-                else:
91
+                elif self.field == "hostname":
92 92
                     if not self.validate_hostname(self.str):
93 93
                         self.textwin.addstr(self.y + 2, 0, "It should start with alpha char and ends with alpha-numeric char", curses.color_pair(4))
94 94
                         continue
95 95
                     self.install_config['hostname'] = self.str
96
+                else:
97
+                    self.install_config[self.field] = self.str
98
+                    return ActionResult(True, self.str)
96 99
                 curses.curs_set(0)
97 100
                 return ActionResult(True, None)
98 101
             elif ch in [ord('\t')]:
... ...
@@ -113,7 +122,7 @@ class ReadText(Action):
113 113
                     text = self.str[-self.visible_text_width:]
114 114
                 else:
115 115
                     text = self.str
116
-                if self.ispassword:
116
+                if self.field == "password":
117 117
                     text = '*' * len(text)
118 118
                 # Add the dashes
119 119
                 text = text + '_' * (self.visible_text_width - len(self.str))
... ...
@@ -10,6 +10,7 @@ from actionresult import ActionResult
10 10
 from menu import Menu
11 11
 from confirmwindow import ConfirmWindow
12 12
 import modules.commons
13
+from progressbar import ProgressBar
13 14
 
14 15
 class SelectDisk(object):
15 16
     def __init__(self,  maxy, maxx, install_config):
... ...
@@ -26,6 +27,9 @@ class SelectDisk(object):
26 26
 
27 27
         self.menu_starty = self.win_starty + 6
28 28
         self.menu_height = 5
29
+        self.progress_padding = 5
30
+        self.progress_width = self.win_width - self.progress_padding
31
+        self.progress_bar = ProgressBar(self.win_starty + 6, self.win_startx + self.progress_padding / 2, self.progress_width)
29 32
 
30 33
         self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Setup your disk', True)
31 34
         self.devices = Device.refresh_devices()
... ...
@@ -36,10 +40,14 @@ class SelectDisk(object):
36 36
         menu_starty = (self.maxy - menu_height) / 2 + 5
37 37
         confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
38 38
         confirmed = confrim_window.do_action().result['yes']
39
-        
39
+
40 40
         if not confirmed:
41 41
             return ActionResult(confirmed, None)
42
-        
42
+
43
+        self.progress_bar.initialize('Partitioning...')
44
+        self.progress_bar.show()
45
+        self.progress_bar.show_loading('Partitioning')
46
+
43 47
         # Do the partitioning
44 48
         self.window.clearerror()
45 49
         partitions_data = modules.commons.partition_disk(self.devices[device_index].path)
... ...
@@ -48,6 +56,7 @@ class SelectDisk(object):
48 48
         else:
49 49
             self.install_config['disk'] = partitions_data
50 50
 
51
+        self.progress_bar.hide()
51 52
         return ActionResult(partitions_data != None, None)
52 53
 
53 54
     def display(self, params):
... ...
@@ -69,7 +78,6 @@ class SelectDisk(object):
69 69
         self.disk_menu = Menu(self.menu_starty,  self.maxx, self.disk_menu_items, self.menu_height)
70 70
 
71 71
         self.window.set_action_panel(self.disk_menu)
72
-
73 72
         return self.window.do_action()
74 73
 
75 74
 
... ...
@@ -9,7 +9,7 @@ from window import Window
9 9
 from readtext import ReadText
10 10
 
11 11
 class WindowStringReader(object):
12
-    def __init__(self, maxy, maxx, height, width, ispassword, confirm_password, title, display_string, inputy, install_config):
12
+    def __init__(self, maxy, maxx, height, width, field, confirm_password, title, display_string, inputy, install_config, default_string = None):
13 13
         self.title = title
14 14
         self.display_string = display_string
15 15
         self.inputy = inputy
... ...
@@ -23,7 +23,7 @@ class WindowStringReader(object):
23 23
         self.starty = (self.maxy - self.height) / 2
24 24
 
25 25
         self.window = Window(self.height, self.width, self.maxy, self.maxx, self.title, True)
26
-        self.read_text = ReadText(maxy, maxx, self.window.content_window(), self.inputy, install_config, ispassword, confirm_password)
26
+        self.read_text = ReadText(maxy, maxx, self.window.content_window(), self.inputy, install_config, field, confirm_password, default_string)
27 27
         self.window.set_action_panel(self.read_text)
28 28
         self.window.addstr(0, 0, self.display_string)
29 29
 
30 30
old mode 100755
31 31
new mode 100644