defsecrules

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2019 License: Apache-2.0 Imports: 5 Imported by: 23

Documentation

Overview

Package defsecrules enables management of default security group rules.

Default security group rules are rules that are managed in the "default" security group.

This is only applicable in environments running nova-network. This package will not work if the OpenStack environment is running the OpenStack Networking (Neutron) service.

Example of Listing Default Security Group Rules

allPages, err := defsecrules.List(computeClient).AllPages()
if err != nil {
	panic(err)
}

allDefaultRules, err := defsecrules.ExtractDefaultRules(allPages)
if err != nil {
	panic(err)
}

for _, df := range allDefaultRules {
	fmt.Printf("%+v\n", df)
}

Example of Retrieving a Default Security Group Rule

rule, err := defsecrules.Get(computeClient, "rule-id").Extract()
if err != nil {
	panic(err)
}

Example of Creating a Default Security Group Rule

createOpts := defsecrules.CreateOpts{
	IPProtocol: "TCP",
	FromPort:   80,
	ToPort:     80,
	CIDR:       "10.10.12.0/24",
}

rule, err := defsecrules.Create(computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example of Deleting a Default Security Group Rule

err := defsecrules.Delete(computeClient, "rule-id").ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List will return a collection of default rules.

Types

type CreateOpts

type CreateOpts struct {
	// The lower bound of the port range that will be opened.
	FromPort int `json:"from_port"`

	// The upper bound of the port range that will be opened.
	ToPort int `json:"to_port"`

	// The protocol type that will be allowed, e.g. TCP.
	IPProtocol string `json:"ip_protocol" required:"true"`

	// ONLY required if FromGroupID is blank. This represents the IP range that
	// will be the source of network traffic to your security group.
	//
	// Use 0.0.0.0/0 to allow all IPv4 addresses.
	// Use ::/0 to allow all IPv6 addresses.
	CIDR string `json:"cidr,omitempty"`
}

CreateOpts represents the configuration for adding a new default rule.

func (CreateOpts) ToRuleCreateMap

func (opts CreateOpts) ToRuleCreateMap() (map[string]interface{}, error)

ToRuleCreateMap builds the create rule options into a serializable format.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToRuleCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder builds the create rule options into a serializable format.

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult represents the result of a create operation.

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create is the operation responsible for creating a new default rule.

func (CreateResult) Extract

func (r CreateResult) Extract() (*DefaultRule, error)

Extract will extract a DefaultRule struct from a Create or Get response.

type DefaultRule

type DefaultRule secgroups.Rule

DefaultRule represents a rule belonging to the "default" security group. It is identical to an openstack/compute/v2/extensions/secgroups.Rule.

func ExtractDefaultRules

func ExtractDefaultRules(r pagination.Page) ([]DefaultRule, error)

ExtractDefaultRules returns a slice of DefaultRules contained in a single page of results.

func (*DefaultRule) UnmarshalJSON

func (r *DefaultRule) UnmarshalJSON(b []byte) error

type DefaultRulePage

type DefaultRulePage struct {
	pagination.SinglePageBase
}

DefaultRulePage is a single page of a DefaultRule collection.

func (DefaultRulePage) IsEmpty

func (page DefaultRulePage) IsEmpty() (bool, error)

IsEmpty determines whether or not a page of default rules contains any results.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the response from a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)

Delete will permanently delete a rule the project's default security group.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult represents the result of a get operation.

func Get

func Get(client *gophercloud.ServiceClient, id string) (r GetResult)

Get will return details for a particular default rule.

func (GetResult) Extract

func (r GetResult) Extract() (*DefaultRule, error)

Extract will extract a DefaultRule struct from a Create or Get response.

Directories

Path Synopsis
defsecrules unit tests
defsecrules unit tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL