Beispiel #1
0
    def _toggle_repos(self, on="stable", off="testing", password=None):
        # toggle between testing and stable repos
        ncd = settings.UPDATE_CHANNELS[on]
        fcd = settings.UPDATE_CHANNELS[off]
        try:
            offo = UpdateSubscription.objects.get(name=fcd["name"])
            offo.status = "inactive"
            offo.save()
            switch_repo(offo, on=False)
        except UpdateSubscription.DoesNotExist:
            pass

        try:
            ono = UpdateSubscription.objects.get(name=ncd["name"])
        except UpdateSubscription.DoesNotExist:
            appliance = Appliance.objects.get(current_appliance=True)
            ono = UpdateSubscription(
                name=ncd["name"],
                description=ncd["description"],
                url=ncd["url"],
                appliance=appliance,
                status="active",
            )
        ono.password = password
        status, text = repo_status(ono)
        ono.status = status
        ono.save()
        if status == "inactive":
            e_msg = ("Activation code ({}) could not be authorized for your "
                     "appliance ({}). Verify the code and try again. If the "
                     "problem persists, email [email protected] with this "
                     "message.").format(ono.password, appliance.uuid)
            raise RockStorAPIException(status_code=400, detail=e_msg)
        if status != "active":
            e_msg = (
                "Failed to activate subscription. Status code: {} details: {}"
            ).format(status, text)
            raise Exception(e_msg)
        switch_repo(ono)
        return ono
Beispiel #2
0
    def _toggle_repos(self, on='stable', off='testing', password=None):
        # toggle between testing and stabel repos
        ncd = settings.UPDATE_CHANNELS[on]
        fcd = settings.UPDATE_CHANNELS[off]
        try:
            offo = UpdateSubscription.objects.get(name=fcd['name'])
            offo.status = 'inactive'
            offo.save()
            switch_repo(offo, on=False)
        except UpdateSubscription.DoesNotExist:
            pass

        try:
            ono = UpdateSubscription.objects.get(name=ncd['name'])
        except UpdateSubscription.DoesNotExist:
            appliance = Appliance.objects.get(current_appliance=True)
            ono = UpdateSubscription(name=ncd['name'],
                                     description=ncd['description'],
                                     url=ncd['url'],
                                     appliance=appliance,
                                     status='active')
        ono.password = password
        status, text = repo_status(ono)
        ono.status = status
        ono.save()
        if (status == 'inactive'):
            e_msg = (
                'Activation code({}) could not be authorized for your '
                'appliance({}). Verify the code and try again. If the problem'
                ' persists, email [email protected] with this '
                'message').format(ono.password, appliance.uuid)
            raise RockStorAPIException(status_code=400, detail=e_msg)
        if (status != 'active'):
            e_msg = ('Failed to activate subscription. status code: '
                     '%s details: %s' % (status, text))
            raise Exception(e_msg)
        switch_repo(ono)
        return ono
    def _toggle_repos(self, on='stable', off='testing', password=None):
        # toggle between testing and stable repos
        ncd = settings.UPDATE_CHANNELS[on]
        fcd = settings.UPDATE_CHANNELS[off]
        try:
            offo = UpdateSubscription.objects.get(name=fcd['name'])
            offo.status = 'inactive'
            offo.save()
            switch_repo(offo, on=False)
        except UpdateSubscription.DoesNotExist:
            pass

        try:
            ono = UpdateSubscription.objects.get(name=ncd['name'])
        except UpdateSubscription.DoesNotExist:
            appliance = Appliance.objects.get(current_appliance=True)
            ono = UpdateSubscription(name=ncd['name'],
                                     description=ncd['description'],
                                     url=ncd['url'], appliance=appliance,
                                     status='active')
        ono.password = password
        status, text = repo_status(ono)
        ono.status = status
        ono.save()
        if (status == 'inactive'):
            e_msg = (
                'Activation code ({}) could not be authorized for your '
                'appliance ({}). Verify the code and try again. If the '
                'problem persists, email [email protected] with this '
                'message.').format(ono.password, appliance.uuid)
            raise RockStorAPIException(status_code=400, detail=e_msg)
        if (status != 'active'):
            e_msg = ('Failed to activate subscription. Status code: '
                     '{} details: {}').format(status, text)
            raise Exception(e_msg)
        switch_repo(ono)
        return ono
    def _toggle_repos(self, on='stable', off='testing', password=None):
        #toggle between testing and stabel repos
        ncd = settings.UPDATE_CHANNELS[on]
        fcd = settings.UPDATE_CHANNELS[off]
        try:
            offo = UpdateSubscription.objects.get(name=fcd['name'])
            offo.status = 'inactive'
            offo.save()
            switch_repo(offo, on=False)
        except UpdateSubscription.DoesNotExist:
            pass

        try:
            ono = UpdateSubscription.objects.get(name=ncd['name'])
        except UpdateSubscription.DoesNotExist:
            appliance = Appliance.objects.get(current_appliance=True)
            ono = UpdateSubscription(name=ncd['name'],
                                     description=ncd['description'],
                                     url=ncd['url'], appliance=appliance,
                                     status='active')
        ono.password = password
        status, text = repo_status(ono)
        ono.status = status
        ono.save()
        if (status == 'inactive'):
            e_msg = ('Activation code(%s) could not be authorized. '
                     'Verify the code and try again. If '
                     'the problem persists, contact '
                     '*****@*****.**' % ono.password)
            raise Exception(e_msg)
        if (status != 'active'):
            e_msg = ('Failed to activate subscription. status code: '
                     '%s details: %s' % (status, text))
            raise Exception(e_msg)
        switch_repo(ono)
        return ono