def ipv6_addr(self, iface): """ PRIV_IPV6_PREFIX:0:1000:ssss:ssss:ssss/64 """ # Hex representation of the needed values nr = '10' + int_to_hex_str(iface.nr, 2) slice_id = int_to_hex_str(iface.sliver.slice_id, 12) ipv6_words = iface.sliver.node.get_priv_ipv6_prefix().split(':')[:3] ipv6_words.extend(['0', nr]) ipv6_words.extend(split_len(slice_id, 4)) return IP(':'.join(ipv6_words))
def ipv6_addr(self, iface): """ DEBUG_IPV6_PREFIX:N:10ii:ssss:ssss:ssss """ # Hex representation of the needed values nr = '10' + int_to_hex_str(iface.nr, 2) node_id = int_to_hex_str(iface.sliver.node_id, 4) slice_id = int_to_hex_str(iface.sliver.slice_id, 12) ipv6_words = DEBUG_IPV6_PREFIX.split(':')[:3] ipv6_words.extend([node_id, nr]) ipv6_words.extend(split_len(slice_id, 4)) return IP(':'.join(ipv6_words))
def addr(self): """ IPV6 management address """ ipv6_words = controller_settings.MGMT_IPV6_PREFIX.split(':')[:3] if self.content_type.model == 'server': # MGMT_IPV6_PREFIX:0:0000:rrrr:rrrr:rrrr/128 ipv6_words.extend(['0', '0000']) ipv6_words.extend(split_len(int_to_hex_str(self.object_id, 12), 4)) return IP(':'.join(ipv6_words)) elif self.content_type.model == 'node': # MGMT_IPV6_PREFIX:N:0000::2/64 i ipv6_words.append(int_to_hex_str(self.object_id, 4)) return IP(':'.join(ipv6_words) + '::2') elif self.content_type.model == 'host': # MGMT_IPV6_PREFIX:0:2000:hhhh:hhhh:hhhh/128 ipv6_words.extend(['0', '2000']) ipv6_words.extend(split_len(int_to_hex_str(self.object_id, 12), 4)) return IP(':'.join(ipv6_words))
def node_mgmt_address(node): ipv6_words = MGMT_IPV6_PREFIX.split(':')[:3] # MGMT_IPV6_PREFIX:N:0000::2/64 ipv6_words.append(int_to_hex_str(node.id, 4)) return IP(':'.join(ipv6_words) + '::2')