Openstack multi network support - #36
Conversation
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
|
Hi @alkimake, |
|
@daxmc99 I have created an issue on |
| @@ -166,7 +166,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { | |||
| mcnflag.StringFlag{ | |||
There was a problem hiding this comment.
You could convert these to mcnflag.StringSlice and avoid all the splits.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
But on the UI of Rancher we have only 1 input for each network names and ids. So , separated argument makes more sense.
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-nameornetwork-idas comma seperated lists.eg;
or
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.