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

Renaming devices #21

Closed
grossmj opened this issue Sep 22, 2013 · 7 comments
Closed

Renaming devices #21

grossmj opened this issue Sep 22, 2013 · 7 comments
Assignees
Milestone

Comments

@grossmj
Copy link
Member

grossmj commented Sep 22, 2013

Right now when a user rename a device in GNS3, the device is deleted and recreated with the new name.

Here is an example of what happens when you change the hostname for a router from R1 to R2. Everything (all the parameters, UDP NIOs if there are connections etc.) has to be sent again. Surely this is not efficient.

15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm delete R1
15:02:23: DEBUG (1): returned -> ["100-VM 'R1' deleted"]
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm create R2 1 c3725
15:02:23: DEBUG (1): returned -> ["100-VM 'R2' created"]
15:02:23: DEBUG (1): PORT TRACKER: allocate port 2102
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_con_tcp_port R2 2102
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): PORT TRACKER: allocate port 2502
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_aux_tcp_port R2 2502
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_ios R2 "c3725-adventerprisek9-mz.124-15.T14.image"
15:02:23: DEBUG (1): returned -> ["100-IOS image set for 'R2'"]
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_ram R2 128
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_sparse_mem R2 1
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_idle_pc R2 0x60c086a8
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_ghost_status R2 2
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_ghost_file R2 "c3725-adventerprisek9-mz.124-15.T14.image-127.0.0.1.ghost"
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_con_tcp_port R2 2101
15:02:23: DEBUG (1): returned -> ['100-OK']
15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm set_aux_tcp_port R2 2501
15:02:23: DEBUG (1): returned -> ['100-OK']

There is the same issue with all other Dynamips devices (Ethernet, ATM, Frame-relay switches, ATM bridge, Ethernet hub)

What I propose is to add new hypervisor commands to simply rename devices internally in Dynamips.

IOS device: vm rename old_hostname new_hostname
Ethernet switch: ethsw rename old_hostname new_hostname
Ethernet hub: nio_bridge rename old_hostname new_hostname
Frame-relay switch: frsw rename old_hostname new_hostname
ATM bridge: atm_bridge rename old_hostname new_hostname
ATM switch: atmsw rename old_hostname new_hostname

Thus for instance, the only command needed to rename a router from R1 to R2 would become the following:

15:02:23: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm rename R1 R2
15:02:23: DEBUG (1): returned -> ["100-VM 'R1' renamed 'R2'"]
@ghost ghost assigned flaviojs Sep 22, 2013
@flaviojs
Copy link
Contributor

Sounds good. =)

There is another type of object for the undocumented module object_store, which allows you to store arbitrary text information in the hypervisor.
For completeness i'll be adding a rename command there too:

object_store rename old_name new_name

@flaviojs
Copy link
Contributor

Btw, to see if a command is present, I recommend using "hypervisor cmd_list module" instead of checking the version.

@grossmj
Copy link
Member Author

grossmj commented Sep 27, 2013

Good idea. This is way better! 👍

@flaviojs
Copy link
Contributor

Done.

@flaviojs
Copy link
Contributor

flaviojs commented Oct 8, 2013

As noted in #26 , vm rename is bugged.
It's using log/lock file names with the old name. (unless the command line option -N 1 is used)
Needs to create new ones.

It also doesn't rename the old files.

@flaviojs flaviojs reopened this Oct 8, 2013
@grossmj
Copy link
Member Author

grossmj commented Oct 8, 2013

As said in #26, I think you should just go for the -N1 by default first and for you solution second.

flaviojs added a commit that referenced this issue Oct 8, 2013
The vm name is used in the file names by default in hypervisor mode.
They we left alone and, with the vm stopped, the log file and the
lock file remain open.
This means that the vm would keep using 2 files with the old name.

Now it renames all related files. (best effort)
NOTE - will also rename unrelated files that have the old prefix.

Re-closes issue #21 - Renaming devices
@flaviojs
Copy link
Contributor

flaviojs commented Oct 8, 2013

Done, it's renaming all related files. =)

@flaviojs flaviojs closed this as completed Oct 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants