Skip to content

Openstack multi network support - #36

Open
alkimake wants to merge 2 commits into
rancher:masterfrom
rainlab-inc:openstack-multi-network-support
Open

Openstack multi network support#36
alkimake wants to merge 2 commits into
rancher:masterfrom
rainlab-inc:openstack-multi-network-support

Conversation

@alkimake

Copy link
Copy Markdown

Summary

Openstack supports multiple nova network while creating new instance(server). This PR makes it possible through docker-machine driver for openstack.

How to

Driver takes network-name or network-id as comma seperated lists.
eg;

--openstack-network-id=id1,id2,id3

or

--openstack-network-name=network1,network2

Floating IP

When floating ip pool is given client go through the given networks one by one to find the first port and use this port when updating/creating floating ip.

Parameter list message is also alternated respectively.

   --openstack-net-id        OpenStack comma seperated network id(s) the machine will be connected on. (If floating ip pool is given, driver tries to find connected port in order of given networks to update floating ip) [$OS_NETWORK_ID]
   --openstack-net-name        OpenStack comma seperated network name(s) the machine will be connected on. (If floating ip pool is given, driver tries to find connected port in order of given networks to update floating ip) [$OS_NETWORK_NAME]

This patch is for adding multi networks on openstack
When floating ip pool is given client go through the networks
one by one to find the first port and use this port when
updating/creating floating ip
@daxmc99

daxmc99 commented Sep 3, 2019

Copy link
Copy Markdown

Hi @alkimake,
Is there a rancher/rancher issue for this?
If there isn't could you make one with steps to use this functionality and link it here?
Thanks!

@alkimake

alkimake commented Sep 5, 2019

Copy link
Copy Markdown
Author

@daxmc99 I have created an issue on rancher/rancher

@@ -166,7 +166,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
mcnflag.StringFlag{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You could convert these to mcnflag.StringSlice and avoid all the splits.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have tried mcnflag.StringSliceFlag but it is not working as expected. Does not split with comma.

diff --git a/drivers/openstack/openstack.go b/drivers/openstack/openstack.go
index 48a78a99..b5e99f20 100644
--- a/drivers/openstack/openstack.go
+++ b/drivers/openstack/openstack.go
@@ -163,11 +163,10 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
                        Usage:  "OpenStack keypair to use to SSH to the instance",
                        Value:  "",
                },
-               mcnflag.StringFlag{
+               mcnflag.StringSliceFlag{
                        EnvVar: "OS_NETWORK_ID",
                        Name:   "openstack-net-id",
                        Usage:  "OpenStack comma seperated network id(s) the machine will be connected on. (If floating ip pool is given, driver tries to find connected port in order of given networks to update floating ip)",
-                       Value:  "",
                },
                mcnflag.StringFlag{
                        EnvVar: "OS_PRIVATE_KEY_FILE",
@@ -181,11 +180,10 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
                        Usage:  "File containing an openstack userdata script",
                        Value:  "",
                },
-               mcnflag.StringFlag{
+               mcnflag.StringSliceFlag{
                        EnvVar: "OS_NETWORK_NAME",
                        Name:   "openstack-net-name",
                        Usage:  "OpenStack comma seperated network name(s) the machine will be connected on. (If floating ip pool is given, driver tries to find connected port in order of given networks to update floating ip)",
-                       Value:  "",
                },
                mcnflag.StringFlag{
                        EnvVar: "OS_SECURITY_GROUPS",
@@ -284,12 +282,8 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
        d.FlavorName = flags.String("openstack-flavor-name")
        d.ImageId = flags.String("openstack-image-id")
        d.ImageName = flags.String("openstack-image-name")
-       if flags.String("openstack-net-id") != "" {
-               d.NetworkIds = strings.Split(flags.String("openstack-net-id"), ",")
-       }
-       if flags.String("openstack-net-name") != "" {
-               d.NetworkNames = strings.Split(flags.String("openstack-net-name"), ",")
-       }
+       d.NetworkIds = flags.StringSlice("openstack-net-id")
+       d.NetworkNames = flags.StringSlice("openstack-net-name")
        if flags.String("openstack-sec-groups") != "" {
                d.SecurityGroups = strings.Split(flags.String("openstack-sec-groups"), ",")
        }

Also on this driver openstack-sec-groups are done with splitting way before. Don't know why it is not working as expected

@luthermonson luthermonson Nov 11, 2019

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@alkimake the string slice let's you pass in the same param multiple times. instead of doing ---openstack-net-id="id1,id2,id3" you do --openstack-net-id=id1 --openstack-net-id=id2 --openstack-net-id=id3. it just eliminates the string split on comma and more drivers use that standard than comma sep list

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

But on the UI of Rancher we have only 1 input for each network names and ids. So , separated argument makes more sense.

@maggieliu

Copy link
Copy Markdown

rancher/rancher#22654

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.

4 participants