2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-29 00:31:09 +00:00

Compare commits

..

9 Commits

Author SHA1 Message Date
Jarrod Johnson 0186f002e0 Have configbmc stall on TSM
TSM will stall out for an extended
period of time after a network change.

Accomodate by forcing a pause
on detection of TSM.
2022-01-10 12:02:46 -05:00
Jarrod Johnson 8d80efec64 Correct configbmc misidentification of lan chan
The lan channel get mac address was incorrect, change
to correctly request.
2022-01-10 12:02:14 -05:00
Jarrod Johnson 978b52dbb6 Fix selection of suboptimal alias
When picking deploy server, stop on a close match if net.ipv4_address suggests
a same-subnet match rather than adding the last alias.
2021-12-28 09:47:47 -05:00
Jarrod Johnson d47b088753 Fix mistake in error output 2021-12-22 23:29:21 -05:00
Jarrod Johnson 47a83f4628 Do not trace out if a packet can't be replied to 2021-12-20 12:37:18 -05:00
Jarrod Johnson abec8c498c Break netlink address fetch on invalid rta_len
It is considered valid for kernel to return a null rta_len
in the midst of data and expect the caller to terminate.
2021-12-20 12:28:35 -05:00
Jarrod Johnson a8132d87a7 Blacklist the tianocore default uuid
If a platform doesn't have a uuid, Tiano hardbakes
yet another invalid uuid to ignore.
2021-12-17 09:13:49 -05:00
Jarrod Johnson 65d6ff13fa Ignore and warn on bad gateway
If user specifies a bad gateway,
spare the firmware from seeing
it and log that the gateway is a problem.
2021-12-17 08:44:46 -05:00
Jarrod Johnson 9b178c0653 Provide nicer error message on existing name
Packing ontop of an existing profile is not presently supported,
provide a clearer indication of this.
2021-12-15 13:26:32 -05:00
11 changed files with 54 additions and 19 deletions
@@ -55,10 +55,10 @@ def get_my_addresses():
rta = v[nlhdrsz+ifaddrsz:length]
while len(rta):
rtalen, rtatyp = struct.unpack('HH', rta[:4])
if rtalen < 4:
break
if rtatyp == 1:
addrs.append((fam, rta[4:rtalen], plen, ridx))
if not rtalen:
break
rta = rta[rtalen:]
v = v[length:]
return addrs
@@ -267,7 +267,7 @@ def get_lan_channel(s):
medtype = int(rsp[1]) & 0b1111111
if medtype not in (4, 6):
continue
rsp = s.raw_command(0xc, 2, bytearray([2, chan, 5, 0, 0]))
rsp = s.raw_command(0xc, 2, bytearray([chan, 5, 0, 0]))
if rsp.get('code', 1) == 0:
return chan
return 1
@@ -267,7 +267,7 @@ def get_lan_channel(s):
medtype = int(rsp[1]) & 0b1111111
if medtype not in (4, 6):
continue
rsp = s.raw_command(0xc, 2, bytearray([2, chan, 5, 0, 0]))
rsp = s.raw_command(0xc, 2, bytearray([chan, 5, 0, 0]))
if rsp.get('code', 1) == 0:
return chan
return 1
@@ -165,9 +165,18 @@ def set_port(s, port, vendor, model):
return 1
def get_remote_config_mod(vendor, model):
def get_remote_config_mod(vendor, model, waiters):
if vendor in ('IBM', 'Lenovo'):
if _is_tsm(model):
for waiter in waiters:
if waiter:
sys.stdout.write('Waiting for TSM network to activate')
for x in range(0, 90):
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(1)
sys.stdout.write('Complete\n')
break
return 'tsm'
else:
return 'xcc'
@@ -275,7 +284,7 @@ def get_lan_channel(s):
medtype = int(rsp[1]) & 0b1111111
if medtype not in (4, 6):
continue
rsp = s.raw_command(0xc, 2, bytearray([2, chan, 5, 0, 0]))
rsp = s.raw_command(0xc, 2, bytearray([chan, 5, 0, 0]))
if rsp.get('code', 1) == 0:
return chan
return 1
@@ -415,7 +424,7 @@ def main():
dotwait()
sys.stdout.write('done\n')
sys.stdout.flush()
cfgmod = get_remote_config_mod(vendor, model)
cfgmod = get_remote_config_mod(vendor, model, (awaitip, awaitvlan, awaitprefix, awaitgw))
if cfgmod:
with open('configbmc.configmod', 'w+') as cm:
cm.write('configmod: {0}\n'.format(cfgmod))
+2 -2
View File
@@ -364,7 +364,7 @@ def oslist():
print("Distributions:")
for rsp in c.read('/deployment/distributions'):
if 'error' in rsp:
sys.stderr.write(res['error'] + '\n')
sys.stderr.write(rsp['error'] + '\n')
exitcode = 1
else:
print(" " + rsp['item']['href'].replace('/', ''))
@@ -373,7 +373,7 @@ def oslist():
print("Profiles:")
for rsp in c.read('/deployment/profiles'):
if 'error' in rsp:
sys.stderr.write(res['error'] + '\n')
sys.stderr.write(rsp['error'] + '\n')
exitcode = 1
else:
print(" " + rsp['item']['href'].replace('/', ''))
@@ -205,6 +205,7 @@ def uuid_is_valid(uuid):
return uuid.lower() not in ('00000000-0000-0000-0000-000000000000',
'ffffffff-ffff-ffff-ffff-ffffffffffff',
'00112233-4455-6677-8899-aabbccddeeff',
'03000200-0400-0500-0006-000700080009',
'20202020-2020-2020-2020-202020202020')
def _printable_ip(sa):
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2017 Lenovo
# Copyright 2017-2021 Lenovo
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -664,9 +664,13 @@ def reply_dhcp4(node, info, packet, cfg, reqview, httpboot, cfd, profile):
clipn = socket.inet_aton(niccfg['ipv4_address'])
repview[16:20] = clipn
gateway = niccfg['ipv4_gateway']
netmask = niccfg['prefix']
if gateway:
gateway = socket.inet_aton(gateway)
netmask = niccfg['prefix']
if not netutil.ipn_on_same_subnet(socket.AF_INET, clipn, gateway, netmask):
log.log(
{'warning': 'Ignoring gateway {0} due to mismatch with address {1}/{2}'.format(niccfg['ipv4_gateway'], niccfg['ipv4_address'], netmask)})
gateway = None
netmask = (2**32 - 1) ^ (2**(32 - netmask) - 1)
netmask = struct.pack('!I', netmask)
myipn = niccfg['deploy_server']
@@ -112,7 +112,10 @@ def _parse_slp_packet(packet, peer, rsps, xidmap, defer=None, sock=None):
identifier = addr
else:
probepeer = (peer[0], struct.unpack('H', os.urandom(2))[0] | 1025) + peer[2:]
sock.sendto(b'\x00', probepeer)
try:
sock.sendto(b'\x00', probepeer)
except Exception:
return
defer.append((packet, peer))
return
if (identifier, parsed['xid']) in rsps:
@@ -487,7 +490,10 @@ def snoop(handler, protocol=None):
mac = neighutil.get_hwaddr(peer[0])
if not mac:
probepeer = (peer[0], struct.unpack('H', os.urandom(2))[0] | 1025) + peer[2:]
s.sendto(b'\x00', probepeer)
try:
s.sendto(b'\x00', probepeer)
except Exception:
continue
deferpeers.append(peer)
continue
process_peer(newmacs, known_peers, peerbymacaddress, peer)
@@ -167,7 +167,10 @@ def snoop(handler, byehandler=None, protocol=None, uuidlookup=None):
continue
mac = neighutil.get_hwaddr(peer[0])
if not mac:
s.sendto(b'\x00', peer)
try:
s.sendto(b'\x00', peer)
except Exception:
continue
deferrednotifies.append((peer, rsp))
continue
_process_snoop(peer, rsp, mac, known_peers, newmacs, peerbymacaddress, byehandler, machandlers)
@@ -311,8 +314,11 @@ def _find_service(service, target):
for s in r:
(rsp, peer) = s.recvfrom(9000)
if not neighutil.get_hwaddr(peer[0]):
try:
s.sendto(b'\x00', peer)
except Exception:
continue
deferparse.append((rsp, peer))
s.sendto(b'\x00', peer)
continue
_parse_ssdp(peer, rsp, peerdata)
timeout = deadline - util.monotonic_time()
+10 -4
View File
@@ -398,15 +398,18 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
foundaddr = False
candgws = []
candsrvs = []
bestsrvbyfam = {}
for myaddr in myaddrs:
fam, svrip, prefix = myaddr[:3]
candsrvs.append((fam, svrip, prefix))
if fam == socket.AF_INET:
cfgdata['deploy_server'] = socket.inet_ntop(socket.AF_INET, svrip)
nver = '4'
srvkey = 'deploy_server'
elif fam == socket.AF_INET6:
cfgdata['deploy_server_v6'] = socket.inet_ntop(socket.AF_INET6, svrip)
nver = '6'
srvkey = 'deploy_server_v6'
if fam not in bestsrvbyfam:
cfgdata[srvkey] = socket.inet_ntop(fam, svrip)
for candidate in cfgbyname:
ipmethod = cfgbyname[candidate].get('ipv{}_method'.format(nver), 'static')
if ipmethod == 'dhcp':
@@ -425,6 +428,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
for inf in socket.getaddrinfo(candip, 0, fam, socket.SOCK_STREAM):
candipn = socket.inet_pton(fam, inf[-1][0])
if ipn_on_same_subnet(fam, svrip, candipn, prefix):
bestsrvbyfam[fam] = svrip
cfgdata['ipv{}_address'.format(nver)] = candip
cfgdata['ipv{}_method'.format(nver)] = ipmethod
cfgdata['ipv{}_gateway'.format(nver)] = cfgbyname[candidate].get(
@@ -563,6 +567,8 @@ def get_my_addresses(idx=0, family=0, matchlla=None):
rta = v[nlhdrsz+ifaddrsz:length]
while len(rta):
rtalen, rtatyp = struct.unpack('HH', rta[:4])
if rtalen < 4:
break
if rta[4:rtalen].tobytes() == matchlla:
return get_my_addresses(idx=ridx)
rta = rta[rtalen:]
@@ -570,10 +576,10 @@ def get_my_addresses(idx=0, family=0, matchlla=None):
rta = v[nlhdrsz+ifaddrsz:length]
while len(rta):
rtalen, rtatyp = struct.unpack('HH', rta[:4])
if rtalen < 4:
break
if rtatyp == 1:
addrs.append((fam, rta[4:rtalen].tobytes(), plen, ridx))
if not rtalen:
break
rta = rta[rtalen:]
v = v[length:]
return addrs
+3
View File
@@ -1104,6 +1104,9 @@ def pack_image(args):
raise Exception('Full path not supported, supply only the profile name')
privdir = os.path.join('/var/lib/confluent/private/os/', outdir)
outdir = os.path.join('/var/lib/confluent/public/os/', outdir)
if os.path.exists(outdir):
sys.stderr.write('Profile already exists, select a different name or delete existing {0}\n'.format(outdir))
sys.exit(1)
imginfofile = os.path.join(args.scratchdir, 'etc/confluentimg.buildinfo')
distpath = None
try: