CCI-MOC / hil

Hardware Isolation Layer, formerly Hardware as a Service
Apache License 2.0
24 stars 54 forks source link

Saving to flash memory for all switches #899

Closed naved001 closed 6 years ago

naved001 commented 7 years ago

Old issue #688

We did not add a method for the brocade switch because we thought it automatically saves to the flash memory. The reason for that behavior is that our brocade switches are stacked (logical chassis mode) and in that case all switches sync the running config to startup config automatically.

I think we should always provide a method in our drivers for every switch to save to flash memory because a switch may not always be running in stacked configuration.

I'll make a PR that does this for the brocade and dell s3048-on.

@SahilTikale how does stacking work in the Juniper world? cc: @zenhack

naved001 commented 6 years ago

I haven't really figured out how to do this on the brocade switch using the rest api.

http://www.brocade.com/content/dam/common/documents/content-types/api-reference-guide/nos-700-restapiguide.pdf

    def save_running_config(self):
        url = self.hostname + '/rest/' + 'operational-state/bna-config-cmd'
        body = '<bna-config-cmd><src>running-config</src><dest>startup-config \
                </dest></bna-config-cmd>'
        response = self._make_request('POST', url, data=body)

this doesn't seem to save though and it's not very clear from the docs what bna-cfg is? but this was only command doing something with the running and startup config.

Other than that, I could only read the running-config using the rest api, and not the startup-config. (So we can't implement get_config() for this switch).

@Izhmash do you think you could give a second look at the documentation, maybe I overlooked something? Even if there's a REST API CLI mode that would be helpfui too (that way we can package any cli command in the REST calls, just like the dellnos9 driver)

If there's no way to do this using the rest api then we have the following options:

  1. Document that we don't support saving on this switch.
  2. use pexpect to do it.
naved001 commented 6 years ago

@zenhack any thoughts about how to move forward with this?

zenhack commented 6 years ago

What does the response body from that request look like? From the docs it looks like the call is asynchronus; you may have to poll the id it returns and wait for it to finish.

naved001 commented 6 years ago

yeah, the body returned a status_id to poll on. Here's the code for it. Even after I wait for it to finish, it doesn't look like it saves it. And it's not clear to me from the docs what it is saving.

naved001 commented 6 years ago

ah, just reread the docs and tested this code again and it worked! (don't know what had happened earlier)

The other issue is, I can't read the startup-config file from the switch. How to deal with that?

naved001 commented 6 years ago

See the discussion here https://github.com/CCI-MOC/hil/pull/964#issuecomment-371244248