Skip to content

Fix accessing instance attribute in AdvancedReboot#1918

Merged
vaibhavhd merged 1 commit intosonic-net:masterfrom
vaibhavhd:creds-hot-fix
Jul 17, 2020
Merged

Fix accessing instance attribute in AdvancedReboot#1918
vaibhavhd merged 1 commit intosonic-net:masterfrom
vaibhavhd:creds-hot-fix

Conversation

@vaibhavhd
Copy link
Contributor

Description of PR

Fixes: Error in the tests using AdvancedReboot script

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

Bug during accessing instance attribute in one of the methods of AdvancedReboot class.

How did you do it?

Use self to access the instance attribute creds to obtain the credentials.

How did you verify/test it?

Tested platform_tests/test_advanced_reboot.py::test_fast_reboot on T0 device and the test passed successfully.

Documentation

Snippet of the error that is being fixed:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.common.fixtures.advanced_reboot.AdvancedReboot instance at 0x7f6119dea3f8>

    def __buildTestbedData(self):
        '''
        Build testbed data that are needed by ptf advanced-reboot.ReloadTest class
        '''
        hostFacts = self.duthost.setup()['ansible_facts']
    
        self.mgFacts = self.duthost.minigraph_facts(host=self.duthost.hostname)['ansible_facts']
    
        self.rebootData['arista_vms'] = [
            attr['mgmt_addr'] for dev, attr in self.mgFacts['minigraph_devices'].items() if attr['hwsku'] == 'Arista-VM'
        ]
    
        self.hostMaxLen = len(self.rebootData['arista_vms']) - 1
        self.lagMemberCnt = len(self.mgFacts['minigraph_portchannels'].values()[0]['members'])
        self.vlanMaxCnt = len(self.mgFacts['minigraph_vlans'].values()[0]['members']) - 1
    
        self.rebootData['dut_hostname'] = self.mgFacts['minigraph_mgmt_interface']['addr']
        self.rebootData['dut_mac'] = hostFacts['ansible_Ethernet0']['macaddress']
        self.rebootData['vlan_ip_range'] = self.mgFacts['minigraph_vlan_interfaces'][0]['subnet']
        self.rebootData['dut_vlan_ip'] = self.mgFacts['minigraph_vlan_interfaces'][0]['addr']
    
>       self.rebootData['dut_username'] = creds['sonicadmin_user']
E       NameError: global name 'creds' is not defined

common/fixtures/advanced_reboot.py:125: NameError
========================== 1 failed in 63.12 seconds ===========================

@vaibhavhd vaibhavhd requested review from a team and wangxin July 17, 2020 01:08
@vaibhavhd vaibhavhd merged commit d61eca3 into sonic-net:master Jul 17, 2020
@vaibhavhd vaibhavhd deleted the creds-hot-fix branch September 25, 2020 16:20
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
Commits on Oct 26, 2021
Remove exec from platform_reboot call to prevent reboot hang (sonic-net#1881) 066b5adf6d737a5bd174123d4d00dab4b6110cf6
  
Commits on Nov 17, 2021
[fdbshow]: Handle FDB cleanup gracefully. (sonic-net#1918) c80321c98d0741f340d2900108bad7fed76c80cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants