@@ -24,7 +24,8 @@ pool_conf = '@ETCXENDIR@/pool.conf'
24
24
inventory_file = '@INVENTORY@'
25
25
management_conf = '/etc/firstboot.d/data/management.conf'
26
26
network_reset = '/var/tmp/network-reset'
27
-
27
+ RENAME_SCRIPT = '/etc/sysconfig/network-scripts/interface-rename.py'
28
+ rename_script_exists = os .path .exists (RENAME_SCRIPT )
28
29
29
30
@contextmanager
30
31
def fsync_write (filename ):
@@ -66,6 +67,15 @@ def valid_vlan(vlan):
66
67
return False
67
68
return True
68
69
70
+ def get_bridge_name (device , vlan ):
71
+ # Construct bridge name for management interface based on convention
72
+ # NOTE: Only correct when interface-rename script exists
73
+ if vlan != None :
74
+ return 'xentemp'
75
+ if device [:3 ] == 'eth' :
76
+ return 'xenbr' + device [3 :]
77
+ return 'br' + device
78
+
69
79
if __name__ == "__main__" :
70
80
parser = OptionParser ()
71
81
parser .add_option ("-m" , "--master" , help = "Master's address" , dest = "address" , default = None )
@@ -208,15 +218,9 @@ Type 'no' to cancel.
208
218
with fsync_write (pool_conf ) as f :
209
219
f .write ('slave:' + address )
210
220
211
- # Construct bridge name for management interface based on convention
212
- if device [:3 ] == 'eth' :
213
- bridge = 'xenbr' + device [3 :]
214
- else :
215
- bridge = 'br' + device
216
-
217
221
# Ensure xapi is not running
218
222
print ("Stopping xapi..." )
219
- os .system ('service xapi stop >/dev/null 2>/dev/null' )
223
+ os .system ('systemctl stop xapi >/dev/null 2>/dev/null' )
220
224
221
225
# Reconfigure new management interface
222
226
print ("Reconfiguring " + device + "..." )
@@ -229,10 +233,10 @@ Type 'no' to cancel.
229
233
# Update interfaces in inventory file
230
234
print ('Updating inventory file...' )
231
235
inventory = read_inventory ()
232
- if vlan != None :
233
- inventory [ 'MANAGEMENT_INTERFACE' ] = 'xentemp'
234
- else :
235
- inventory ['MANAGEMENT_INTERFACE' ] = bridge
236
+ # If rename script does not exist, needn't to set MANAGEMENT_INTERFACE in inventory file
237
+ # Networkd will handle it while replacing the rename script to sort interfaces
238
+ bridge = '' if not rename_script_exists else get_bridge_name ( device , vlan )
239
+ inventory ['MANAGEMENT_INTERFACE' ] = bridge
236
240
inventory ['CURRENT_INTERFACES' ] = ''
237
241
write_inventory (inventory )
238
242
@@ -280,11 +284,11 @@ Type 'no' to cancel.
280
284
f .write ('GATEWAY_V6=' + options .gateway_v6 + '\n ' )
281
285
if is_static and options .dns != '' :
282
286
f .write ('DNS=' + options .dns + '\n ' )
283
-
284
- # Reset the domain 0 network interface naming configuration
285
- # back to a fresh-install state for the currently-installed
286
- # hardware.
287
- os .system ("/etc/sysconfig/network-scripts/interface-rename.py --reset-to-install" )
287
+ if rename_script_exists :
288
+ # Reset the domain 0 network interface naming configuration
289
+ # back to a fresh-install state for the currently-installed
290
+ # hardware.
291
+ os .system (f" { RENAME_SCRIPT } --reset-to-install" )
288
292
289
293
# Reboot
290
294
os .system ("mount -o remount,rw / && reboot -f" )
0 commit comments