Change-Id: I6ee49caeed863e931bb5e5abf17b7b20e75093e4
Reviewed-on: http://photon-jenkins.eng.vmware.com/848
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Mahmoud Bassiouny <mbassiouny@vmware.com>
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
import os |
2 | 2 |
import commons |
3 |
+import random |
|
3 | 4 |
|
4 | 5 |
install_phase = commons.POST_INSTALL |
5 | 6 |
enabled = True |
... | ... |
@@ -7,7 +8,12 @@ enabled = True |
7 | 7 |
def execute(name, ks_config, config, root): |
8 | 8 |
|
9 | 9 |
if ks_config: |
10 |
- config["hostname"] = ks_config["hostname"] |
|
10 |
+ if "hostname" in ks_config: |
|
11 |
+ config['hostname'] = ks_config["hostname"].strip(" ") |
|
12 |
+ if "hostname" not in config or config['hostname'] == "": |
|
13 |
+ random_id = '%12x' % random.randrange(16**12) |
|
14 |
+ config['hostname'] = "photon-" + random_id.strip() |
|
15 |
+ |
|
11 | 16 |
hostname = config['hostname'] |
12 | 17 |
|
13 | 18 |
hostname_file = os.path.join(root, 'etc/hostname') |