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

Fix vm deploy to accept any network, not just internal #8

Closed
yaroslav-gwit opened this issue Apr 28, 2023 · 1 comment
Closed

Fix vm deploy to accept any network, not just internal #8

yaroslav-gwit opened this issue Apr 28, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@yaroslav-gwit
Copy link
Owner

There is a hardcoded value internal in vm_deploy.go, which needs to be changed to a dynamic value (line 408):

    "networks": [
        {
            "network_adaptor_type": "virtio-net",
            "network_bridge": "internal",
            "network_mac": "{{ .MacAddress }}",
            "ip_address": "{{ .IpAddress }}",
            "comment": "Internal Network"
        }
    ],

This will allow to implement a new flag --use-network in the vm deploy command, but it will pick up the first available network from the list in the network config file by default.

@yaroslav-gwit yaroslav-gwit changed the title Fix network Cloud Init and VM config file to accept any network, not just internal Fix VM config file (when vm deploy is executed) to accept any network, not just internal Apr 28, 2023
@yaroslav-gwit yaroslav-gwit self-assigned this Apr 28, 2023
@yaroslav-gwit yaroslav-gwit added the bug Something isn't working label Apr 28, 2023
@yaroslav-gwit yaroslav-gwit changed the title Fix VM config file (when vm deploy is executed) to accept any network, not just internal Fix vm deploy to accept any network, not just internal May 19, 2023
@yaroslav-gwit
Copy link
Owner Author

yaroslav-gwit commented May 20, 2023

Fix has been implemented using --network-name flag. If it's not supplied vm deploy will still choose a first available network, but now using custom network is possible:

	if len(networkName) < 1 {
		c.NetworkName = networkInfo[0].Name
		c.Subnet = networkInfo[0].Subnet
		c.NakedSubnet = strings.Split(networkInfo[0].Subnet, "/")[1]
		c.Gateway = networkInfo[0].Gateway
		c.NetworkComment = networkInfo[0].Comment
	} else {
		for _, v := range networkInfo {
			if networkName == v.Name {
				c.NetworkName = v.Name
				c.Subnet = v.Subnet
				c.NakedSubnet = strings.Split(v.Subnet, "/")[1]
				c.Gateway = v.Gateway
				c.NetworkComment = v.Comment
			}
		}
		if len(c.NetworkName) < 1 {
			return errors.New("network name supplied doesn't exist")
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant