Commit 68b4503e authored by Joanne Hugé's avatar Joanne Hugé

cookbook: fix serial certification generation for re6st registry

parent 667d73b1
Pipeline #20577 passed with stage
......@@ -34,6 +34,7 @@ import string, random
import json
import traceback
from slapos import slap
from slapos.util import binFromIpv6
class Recipe(GenericBaseRecipe):
......@@ -54,20 +55,8 @@ class Recipe(GenericBaseRecipe):
return GenericBaseRecipe.__init__(self, buildout, name, options)
def getSerialFromIpv6(self, ipv6):
prefix = ipv6.split('/')[0].lower()
hi, lo = struct.unpack('!QQ', socket.inet_pton(socket.AF_INET6, prefix))
ipv6_int = (hi << 64) | lo
serial = '0x1%x' % ipv6_int
# delete non significant part
for part in prefix.split(':')[::-1]:
if part:
for i in ['0']*(4 - len(part)):
part = i + part
serial = serial.split(part)[0] + part
break
return serial
prefix, prefix_length = ipv6.split('/')
return "0x%x" % int('1%s' % binFromIpv6(prefix)[:int(prefix_length)], 2)
def generateCertificate(self):
key_file = self.options['key-file'].strip()
......
  • mentioned in merge request re6stnet!36 (merged)

    Toggle commit list
  • It seems there's a test that needs to be updated ( https://erp5js.nexedi.net/#/test_result_module/20220331-1E332C923/7 ) :

    ======================================================================
    FAIL: test_getSerialFromIpv6 (test_re6stnet.Re6stnetTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/srv/slapgrid/slappart20/t/cum/i/0/parts/slapos.cookbook/slapos/test/recipe/test_re6stnet.py", line 112, in test_getSerialFromIpv6
        self.assertEqual(serial, '0x1be280db8fe6a0d8504fe054a00ae0aea')
    AssertionError: '0x1be280db8fe6a0d85' != '0x1be280db8fe6a0d8504fe054a00ae0aea'
    - 0x1be280db8fe6a0d85
    + 0x1be280db8fe6a0d8504fe054a00ae0aea
  • Indeed my bad, I updated it.

  • thanks !

Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment