Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issu sw install #606

Merged
merged 9 commits into from
Oct 18, 2016
Merged

Issu sw install #606

merged 9 commits into from
Oct 18, 2016

Conversation

vnitinv
Copy link
Contributor

@vnitinv vnitinv commented Sep 27, 2016

No description provided.

@coveralls
Copy link

coveralls commented Sep 27, 2016

Coverage Status

Coverage increased (+0.1%) to 97.133% when pulling e56e59a on vnitinv:issu-sw-install into 13ad93c on Juniper:master.

@coveralls
Copy link

coveralls commented Sep 28, 2016

Coverage Status

Coverage increased (+0.1%) to 97.133% when pulling 5a4e796 on vnitinv:issu-sw-install into 13ad93c on Juniper:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 97.133% when pulling 5a4e796 on vnitinv:issu-sw-install into 13ad93c on Juniper:master.

package_name=remote_package, **kwargs).getparent()
rc = int(rsp.findtext('package-result'))
if rc != 0:
self.log("software validation message: %s" % rsp.findtext('output'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest unconditionally logging this message, instead of just logging if there's a failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken care. Thanks

package_name=remote_package, **kwargs).getparent()
rc = int(rsp.findtext('package-result'))
if rc != 0:
self.log("software validation message: %s" % rsp.findtext('output'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some cases where the RPC reply contains more than one <output> element.
In those cases, rsp.findtext('output') will only return the first <output> element's text.
Probably need something like this instead:

for output in rsp.findall('output'):
    self.log("software validation message: %s" % (output.text))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken care. Thanks

v_ok = self.validate(remote_package, dev_timeout=timeout)
if v_ok is not True:
return v_ok # will be the string of output
v_ok = self.validate(remote_package, issu, dev_timeout=timeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a general comment on how the timeout argument is handled in the install() method and isn't really specific to this commit...
Should we subtract the time spent in each of the steps (safe_copy(), validate(), and pkg_add()) from timeout? Otherwise the total time spent on the software upgrade could be greater than the timeout value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not change this. Timeout in general meant for per rpc. So it should be individual for each function call internally too, which is happening as of today.

# return True if rc == 0 else got.findtext('output').strip()
return True if rc == 0 else False
if rc != 0:
self.log("software pkgadd message: %s" % got.findtext('output'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest unconditionally logging this message, instead of just logging if there's a failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken care. Thanks

if v_ok is not True:
return v_ok

if issu is True:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISSU and NSSU only make sense when self._multi_RE is True. Currently the code tries them even if self._multi_RE is False. Maybe this is OK because the RPCs themselves will likely fail in this case. However, I'm wondering if it makes more sense for us to only attempt ISSU/NSSU when self._multi_RE is True.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am adding this. The plus point I saw by not putting that condition was even when the device was connected using gather_facts as False or facts gathering failed, this would work perfectly fine. I have added the check for now.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 96.899% when pulling 332ea14 on vnitinv:issu-sw-install into 13ad93c on Juniper:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 96.899% when pulling 332ea14 on vnitinv:issu-sw-install into 13ad93c on Juniper:master.

@coveralls
Copy link

coveralls commented Oct 13, 2016

Coverage Status

Coverage increased (+0.1%) to 97.123% when pulling ce76783 on vnitinv:issu-sw-install into 13ad93c on Juniper:master.

@vnitinv vnitinv merged commit 20990ca into Juniper:master Oct 18, 2016
@vnitinv
Copy link
Contributor Author

vnitinv commented Oct 18, 2016

sample example:

import time
from jnpr.junos import Device
from pprint import pprint
from jnpr.junos.utils.sw import SW
from jnpr.junos.utils.config import Config
from lxml import etree

with Device(host='xxxx’, user=xxxx’, password=xxx’) as dev:
    pprint(dev.facts)
    facts = dev.facts
    # dev.facts_refresh(exception_on_failure=True)
    if not facts['version_RE0'] == facts['version_RE1']:
        raise Exception('Not compatible for ISSU upgrade')

    # Inspired from
    # http://www.juniper.net/documentation/en_US/junos16.1/topics/task/installation/issu-upgrading.html#test1
    set_commands = """
    set chassis redundancy graceful-switchover
    set routing-options nonstop-routing
    set system commit synchronize"""
    # this would take care of lock and unlock
    with Config(dev, mode='exclusive') as cu:
        cu.load(set_commands)
        cu.commit()

    # Verify that NSR is configured on the master Routing Engine (re0) by using the show task replication command.
    op = dev.rpc.get_routing_task_replication_state()
    if not op.findtext('task-gres-state') == 'Enabled' and not op.findtext('') == 'Master':
        raise Exception('"show task replication" is not as per ISSU requirement')

    # Verify that GRES is enabled on the backup Routing Engine (re1) by using the show system switchover command.
    # As I know backup name, below code will work, otherwise I can use startShell to go from master to backup
    with Device(host='xxxx1’, user=xxxx’, password=xxx’, gather_facts=False) as dev1:
        op = dev1.rpc.get_switchover_information()
        if op.findtext('switchover-state').strip().lower() != 'on':
            raise Exception('"switchover-state is not On')

    # Adjusting Timers and Changing Feature-Specific Configuration
    # I am not handling this. Do we need to check this too?

    sw = SW(dev)

    try:
        ok = sw.install(package='junos-install-mx-x86-64-16.1-20160925.0.tgz', issu=True,
                  no_copy=True, validate=True, progress=True)
        if ok is True:
            # below steps is only required you we want to reboot the old master re only
            sw.reboot(all_re=False)
            # device might be pingable for few seconds before it goes for reboot.
            time.sleep(30)
            if dev.probe(1200, 5):
                print "old master is rebooted and is now up"
                dev.open(gather_facts=False)
                #time.sleep(300) # without sleep we get message "Not ready for mastership switch, try after 239 secs."
                print dev.cli("request chassis routing-engine master acquire", warning=False)
                print "Device is UP & ISSU upgrade Done"
            else:
                print "old master is not pingable even after 1200 sec after reboot"
        else:
            "sw.install returned False"
    except Exception as ex:
        print "ERROR: %s" % ex.message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants