support for OpenStack security groups

Signed-off-by: Marco Mariani <marco.mariani@alterway.fr>
This commit is contained in:
Marco Mariani 2017-10-26 12:12:45 +02:00
parent 7e7ba6bb17
commit 0a2ce1a357
2 changed files with 9 additions and 5 deletions

View File

@ -65,6 +65,7 @@ linuxkit run openstack \
-password=xxx \ -password=xxx \
-project=linuxkit \ -project=linuxkit \
-keyname=deadline_ed25519 \ -keyname=deadline_ed25519 \
-sec-groups=allow_ssh,nginx \
-network c5d02c5f-c625-4539-8aed-1dab3aa85a0a \ -network c5d02c5f-c625-4539-8aed-1dab3aa85a0a \
LinuxKitTest LinuxKitTest
``` ```

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack"
@ -36,6 +37,7 @@ func runOpenStack(args []string) {
flavorName := flags.String("flavor", defaultOSFlavor, "Instance size (flavor)") flavorName := flags.String("flavor", defaultOSFlavor, "Instance size (flavor)")
instanceName := flags.String("instancename", "", "Name of instance. Defaults to the name of the image if not specified") instanceName := flags.String("instancename", "", "Name of instance. Defaults to the name of the image if not specified")
networkID := flags.String("network", "", "The ID of the network to attach the instance to") networkID := flags.String("network", "", "The ID of the network to attach the instance to")
secGroups := flags.String("sec-groups", "", "Security Group names separated by comma")
keyName := flags.String("keyname", "", "The name of the SSH keypair to associate with the instance") keyName := flags.String("keyname", "", "The name of the SSH keypair to associate with the instance")
passwordFlag := flags.String("password", "", "Password for the specified username") passwordFlag := flags.String("password", "", "Password for the specified username")
projectNameFlag := flags.String("project", "", "Name of the Project (aka Tenant) to be used") projectNameFlag := flags.String("project", "", "Name of the Project (aka Tenant) to be used")
@ -88,11 +90,12 @@ func runOpenStack(args []string) {
var serverOpts servers.CreateOptsBuilder var serverOpts servers.CreateOptsBuilder
serverOpts = &servers.CreateOpts{ serverOpts = &servers.CreateOpts{
FlavorName: *flavorName, FlavorName: *flavorName,
ImageName: name, ImageName: name,
Name: *instanceName, Name: *instanceName,
Networks: []servers.Network{network}, Networks: []servers.Network{network},
ServiceClient: client, ServiceClient: client,
SecurityGroups: strings.Split(*secGroups, ","),
} }
if *keyName != "" { if *keyName != "" {