侧边栏壁纸
  • 累计撰写 176 篇文章
  • 累计创建 87 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

Ansible Tower 3.8.X版本去掉订阅校验

Z先森
2022-10-10 / 0 评论 / 0 点赞 / 12 阅读 / 0 字 / 正在检测是否收录...

本来准备申请个试用秘钥研究研究新版本,结果红帽子说必须企业账号才能申请,无果。只能找其他方法了,试了一下发现这个方法对于最新版的都能用,仅用于个人研究,记录一下。 ####去掉订阅校验 /var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/utils/licensing.py 大概在409行,原代码如下:

    def validate(self):
        # Return license attributes with additional validation info.
        attrs = copy.deepcopy(self._attrs)
        type = attrs.get('license_type', 'none')

        if (type == 'UNLICENSED' or False):
            attrs.update(dict(valid_key=False, compliant=False))
            return attrs
        attrs['valid_key'] = True
        if Host:
            current_instances = Host.objects.active_count()
        else:
            current_instances = 0
        available_instances = int(attrs.get('instance_count', None) or 0)
        attrs['current_instances'] = current_instances
        attrs['available_instances'] = available_instances
        free_instances = (available_instances - current_instances)
        attrs['free_instances'] = max(0, free_instances)

        license_date = int(attrs.get('license_date', 0) or 0)
        current_date = int(time.time())
        time_remaining = license_date - current_date
        attrs['time_remaining'] = time_remaining
        if attrs.setdefault('trial', False):
            attrs['grace_period_remaining'] = time_remaining
        else:
            attrs['grace_period_remaining'] = (license_date + 2592000) - current_date
        attrs['compliant'] = bool(time_remaining > 0 and free_instances >= 0)
        attrs['date_warning'] = bool(time_remaining < self.SUBSCRIPTION_TIMEOUT)
        attrs['date_expired'] = bool(time_remaining <= 0)
        return attrs

修改成:

    def validate(self):
        # Return license attributes with additional validation info.
        attrs = copy.deepcopy(self._attrs)

        attrs['license_type'] = 'enterprise' # 设置License类型为企业版
        attrs['instance_count'] = MAX_INSTANCES # 设置Host数量为MAX_INSTANCES,即9999999
        attrs['license_date'] = '4102329600' # 设置License过期日期为”2099-12-31 00:00:00“,Unix时间戳
        attrs['subscription_name'] = 'mxd'

        type = attrs.get('license_type', 'none')

        # 注释掉下面的判断
        #if (type == 'UNLICENSED' or False):
            #attrs.update(dict(valid_key=False, compliant=False))
            #return attrs
        attrs['valid_key'] = True # 直接将 valid_key 设为 true
        if Host:
            current_instances = Host.objects.active_count()
        else:
            current_instances = 0
        available_instances = int(attrs.get('instance_count', None) or 0)
        attrs['current_instances'] = current_instances
        attrs['available_instances'] = available_instances
        free_instances = (available_instances - current_instances)
        attrs['free_instances'] = max(0, free_instances)

        license_date = int(attrs.get('license_date', 0) or 0)
        current_date = int(time.time())
        time_remaining = license_date - current_date
        attrs['time_remaining'] = time_remaining
        if attrs.setdefault('trial', False):
            attrs['grace_period_remaining'] = time_remaining
        else:
            attrs['grace_period_remaining'] = (license_date + 2592000) - current_date
        attrs['compliant'] = bool(time_remaining > 0 and free_instances >= 0)
        attrs['date_warning'] = bool(time_remaining < self.SUBSCRIPTION_TIMEOUT)
        attrs['date_expired'] = bool(time_remaining <= 0)
        return attrs

####重启服务

ansible-tower-service restart
0

评论区