|
1 | 1 | #! /opt/stack/bin/python
|
2 | 2 | #
|
3 | 3 | # @copyright@
|
4 |
| -# Copyright (c) 2006 - 2019 Teradata |
| 4 | +# Copyright (c) 2006 - 2020 Teradata |
5 | 5 | # All rights reserved. Stacki(r) v5.x stacki.com
|
6 | 6 | # https://github.com/Teradata/stacki/blob/master/LICENSE.txt
|
7 | 7 | # @copyright@
|
|
15 | 15 | import ipaddress
|
16 | 16 | import socket
|
17 | 17 | from xml.etree.ElementTree import Element, SubElement, ElementTree
|
18 |
| - |
| 18 | +import ipaddress |
19 | 19 |
|
20 | 20 | class Attr:
|
21 | 21 | Info_FQDN = ""
|
@@ -131,10 +131,11 @@ def setNetwork(self, interface, mac, addr, netmask):
|
131 | 131 | if os.path.exists(ifDhcpFile):
|
132 | 132 | os.remove(ifDhcpFile)
|
133 | 133 | # Force network reconfiguration
|
134 |
| - cmd = ['/sbin/ifconfig', interface, addr, 'netmask', netmask] |
| 134 | + ip_mask = ipaddress.ip_interface(join(addr,'/',netmask)) |
| 135 | + cmd = ['/sbin/ip', 'addr', 'add', ip_mask.with_prefixlen, 'dev', interface] |
135 | 136 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
136 | 137 | # Bring up network
|
137 |
| - cmd = ['/sbin/ifconfig', interface, 'up'] |
| 138 | + cmd = ['/sbin/ip', 'link', 'set', interface, 'up'] |
138 | 139 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
139 | 140 |
|
140 | 141 | def setHostname(self, hostname):
|
|
0 commit comments