neutron

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: LGPL-3.0 Imports: 6 Imported by: 10

Documentation

Index

Constants

View Source
const (
	ApiApplicationPolicyGroupsV2 = "grouppolicy/application_policy_groups"
	ApiExternalPolicysV2         = "grouppolicy/external_policys"
	ApiExternalSegmentsV2        = "grouppolicy/external_segments"
	ApiL2PolicysV2               = "grouppolicy/l2_policys"
	ApiL3PolicysV2               = "grouppolicy/l3_policys"
	ApiNatPoolsV2                = "grouppolicy/nat_pools"
	ApiNetworkServicePolicysV2   = "grouppolicy/network_service_policys"
	ApiPolicyActionsV2           = "grouppolicy/policy_actions"
	ApiPolicyClassifiersV2       = "grouppolicy/policy_classifiers"
	ApiPolicyRulesV2             = "grouppolicy/policy_rules"
	ApiPolicyRuleSetsV2          = "grouppolicy/policy_rule_sets"
	ApiPolicyTargetsV2           = "grouppolicy/policy_targets"
	ApiPolicyTargetGroupsV2      = "grouppolicy/policy_target_groups"
)
View Source
const (
	ApiFloatingIPsV2        = "floatingips"
	ApiNetworksV2           = "networks"
	ApiPortsV2              = "ports"
	ApiSubnetsV2            = "subnets"
	ApiSecurityGroupsV2     = "security-groups"
	ApiSecurityGroupRulesV2 = "security-group-rules"
)
View Source
const (
	FilterRouterExternal = "router:external" // The router:external
	FilterNetwork        = "name"            // The network name.
	FilterProjectId      = "project_id"      // The project id

	// A list of tags to filter the list result by. Resources that match all tags in this
	// list will be returned. Tags in query must be separated by comma.
	FilterTags = "tags"

	// 	A list of tags to filter the list result by. Resources that match any tag in this list
	// will be returned. Tags in query must be separated by comma.
	FilterTagsAny = "tags-any"

	// A list of tags to filter the list result by. Resources that match all tags in this list
	// will be excluded. Tags in query must be separated by comma.
	FilterNotTags = "not-tags"

	// A list of tags to filter the list result by. Resources that match any tag in this list
	// will be excluded. Tags in query must be separated by comma.
	FilterNotTagsAny = "not-tags-any"
)

Filter keys for Networks. As of the Newton release of OpenStack, Network filter by subnet was not implemented

Variables

This section is empty.

Functions

func NeutronHeaders

func NeutronHeaders(method string, extraHeaders http.Header, contentType, authToken string, payloadExists bool) http.Header

NeutronHeaders creates a set of http.Headers from the given arguments passed in. In this case it applies the headers passed in first, then sets the following:

  • X-Auth-Token
  • Content-Type
  • Accept
  • User-Agent

Types

type Client

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

Client provides a means to access the OpenStack Network Service.

func New

func New(client client.Client) *Client

New creates a new Client.

func (*Client) AllocateFloatingIPV2

func (c *Client) AllocateFloatingIPV2(floatingNetworkId string) (*FloatingIPV2, error)

AllocateFloatingIPV2 allocates a new floating IP address in the given external network.

func (*Client) CreatePolicyTargetV2

func (c *Client) CreatePolicyTargetV2(pt PolicyTargetV2) (*PolicyTargetV2, error)

CreatePolicyTargetV2 creates policy target as declared in pt. It returns policy target with Id field filled.

func (*Client) CreatePortV2

func (c *Client) CreatePortV2(port PortV2) (*PortV2, error)

CreatePortV2 creates a new port.

func (*Client) CreateSecurityGroupRuleV2

func (c *Client) CreateSecurityGroupRuleV2(ruleInfo RuleInfoV2) (*SecurityGroupRuleV2, error)

CreateSecurityGroupRuleV2 creates a security group rule. It can either be an ingress rule or group rule (see the description of SecurityGroupRuleV2).

func (*Client) CreateSecurityGroupV2

func (c *Client) CreateSecurityGroupV2(name, description string) (*SecurityGroupV2, error)

CreateSecurityGroupV2 creates a new security group.

func (*Client) DeleteFloatingIPV2

func (c *Client) DeleteFloatingIPV2(ipId string) error

DeleteFloatingIPV2 deallocates the floating IP address associated with the specified id.

func (*Client) DeletePolicyTargetV2

func (c *Client) DeletePolicyTargetV2(ptId string) error

DeletePolicyTargetV2 deletes policy targed identified by Id.

func (*Client) DeletePortV2

func (c *Client) DeletePortV2(portId string) error

DeletePortV2 deletes the specified port.

func (*Client) DeleteSecurityGroupRuleV2

func (c *Client) DeleteSecurityGroupRuleV2(ruleId string) error

DeleteSecurityGroupRuleV2 deletes the specified security group rule.

func (*Client) DeleteSecurityGroupV2

func (c *Client) DeleteSecurityGroupV2(groupId string) error

DeleteSecurityGroupV2 deletes the specified security group.

func (*Client) GetFloatingIPV2

func (c *Client) GetFloatingIPV2(ipId string) (*FloatingIPV2, error)

GetFloatingIPV2 lists details of the floating IP address associated with specified id.

func (*Client) GetNetworkV2

func (c *Client) GetNetworkV2(netID string) (*NetworkV2, error)

GetNetworkV2 gives details on a specific network

func (*Client) GetPolicyTargetV2

func (c *Client) GetPolicyTargetV2(ptId string) (*PolicyTargetV2, error)

GetPolicyTargetV2 fetches single policy target by id.

func (*Client) GetSubnetV2

func (c *Client) GetSubnetV2(subnetID string) (*SubnetV2, error)

GetSubnetV2 gives details on a specific subnet

func (*Client) ListFloatingIPsV2

func (c *Client) ListFloatingIPsV2(filter ...*Filter) ([]FloatingIPV2, error)

ListFloatingIPsV2 lists floating IP addresses associated with the tenant or account. Zero or one Filters accepted, any more will be ignored.

TODO(hml): when this package revs to a new version, make this the same as other methods with Filters. We don't want to break compatibility at this time or rev the package at this time.

func (*Client) ListNetworksV2

func (c *Client) ListNetworksV2(filter ...*Filter) ([]NetworkV2, error)

ListNetworksV2 gives details on available networks, zero or one Filters accepted, any more will be ignored.

TODO(hml): when this package revs to a new version, make this the same as other methods with Filters. We don't want to break compatibility at this time or rev the package at this time.

func (*Client) ListPolicyTargetsV2

func (c *Client) ListPolicyTargetsV2(filter ...*Filter) ([]PolicyTargetV2, error)

ListPolicyTargetsV2 lists policy targets filtered by filter.

func (*Client) ListPortsV2

func (c *Client) ListPortsV2(filter ...*Filter) ([]PortV2, error)

ListPortsV2 lists NetworkIds, names, and other details for all ports.

func (*Client) ListSecurityGroupsV2

func (c *Client) ListSecurityGroupsV2() ([]SecurityGroupV2, error)

ListSecurityGroupsV2 lists IDs, names, and other details for all security groups.

func (*Client) ListSubnetsV2

func (c *Client) ListSubnetsV2() ([]SubnetV2, error)

ListSubnetsV2 gives details on available subnets

func (*Client) PortByIdV2

func (c *Client) PortByIdV2(portId string) (PortV2, error)

PortByIdV2 returns the port by portId.

func (*Client) SecurityGroupByNameV2

func (c *Client) SecurityGroupByNameV2(name string) ([]SecurityGroupV2, error)

SecurityGroupByNameV2 returns the named security group. OpenStack now supports filtering with API calls. More than one Security Group may be returned, as names are not unique e.g. name=default

func (*Client) UpdateSecurityGroupV2

func (c *Client) UpdateSecurityGroupV2(groupId, name, description string) (*SecurityGroupV2, error)

UpdateSecurityGroupV2 updates the name and description of the given group.

type Filter

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

---------------------------------------------------------------------------- Filter builds filtering parameters to be used in an OpenStack query which supports filtering. For example:

filter := NewFilter()
filter.Set(neutron.FilterRouterExternal, "true")
resp, err := neutron.ListNetworks(filter)

TODO(hml): copied from the nova package. However it should really be pulled out and shared between goose pkgs, but we don't want to break compatibility or rev the package at this time.

func NewFilter

func NewFilter() *Filter

NewFilter creates a new Filter.

func (*Filter) Set

func (f *Filter) Set(filter, value string)

Set sets a value in the filter.

type FloatingIPV2

type FloatingIPV2 struct {
	// FixedIP holds the private IP address of the machine (when assigned)
	FixedIP           string `json:"fixed_ip_address"`
	Id                string `json:"id"`
	IP                string `json:"floating_ip_address"`
	FloatingNetworkId string `json:"floating_network_id"`
}

FloatingIPV2 contains details about a floating ip

type NetworkV2

type NetworkV2 struct {
	Id                  string   `json:"id"` // UUID of the resource
	Name                string   // User-provided name for the network range
	SubnetIds           []string `json:"subnets"`         // an array of subnet UUIDs
	External            bool     `json:"router:external"` // is this network connected to an external router
	AvailabilityZones   []string `json:"availability_zones"`
	TenantId            string   `json:"tenant_id"`
	PortSecurityEnabled *bool    `json:"port_security_enabled"`
}

NetworkV2 contains details about a labeled network

type PolicyTargetV2

type PolicyTargetV2 struct {
	Id                  string   `json:"id,omitempty"`
	Name                string   `json:"name,omitempty"`
	Description         string   `json:"description,omitempty"`
	PolicyTargetGroupId string   `json:"policy_target_group_id"`
	PortId              string   `json:"port_id,omitempty"`
	FixedIps            []string `json:"fixed_ips,omitempty"`
}

type PortFixedIPsV2

type PortFixedIPsV2 struct {
	IPAddress string `json:"ip_address,omitempty"`
	SubnetID  string `json:"subnet_id,omitempty"`
}

PortFixedIPsV2 represents a FixedIp with ip addresses and an associated subnet id.

type PortV2

type PortV2 struct {
	AdminStateUp        bool             `json:"admin_state_up,omitempty"`
	Description         string           `json:"description,omitempty"`
	DeviceId            string           `json:"device_id,omitempty"`
	DeviceOwner         string           `json:"device_owner,omitempty"`
	FixedIPs            []PortFixedIPsV2 `json:"fixed_ips,omitempty"`
	Id                  string           `json:"id,omitempty"`
	Name                string           `json:"name,omitempty"`
	NetworkId           string           `json:"network_id,omitempty"`
	PortSecurityEnabled bool             `json:"port_security_enabled,omitempty"`
	SecurityGroups      []string         `json:"security_groups,omitempty"`
	Status              string           `json:"status,omitempty"`
	Tags                []string         `json:"tags,omitempty"`
	TenantId            string           `json:"tenant_id,omitempty"`
	MACAddress          string           `json:"mac_address,omitempty"`
}

PortV2 describes a defined network for administrating a port.

type RuleInfoV2

type RuleInfoV2 struct {
	// Ingress or egress, which is the direction in which the metering
	// rule is applied. Required.
	Direction string `json:"direction"`

	// IPProtocol is optional, and if specified must be "tcp", "udp" or
	// "icmp" (in the case of icmp, both PortRangeMax and PortRangeMin should
	// be blank).
	IPProtocol string `json:"protocol,omitempty"`

	// The maximum port number in the range that is matched by the
	// security group rule. The port_range_min attribute constrains
	// the port_range_max attribute. If the protocol is ICMP, this
	// value must be an ICMP type.
	PortRangeMax int `json:"port_range_max,omitempty"`

	// The minimum port number in the range that is matched by the
	// security group rule. If the protocol is TCP or UDP, this value
	// must be less than or equal to the port_range_max attribute value.
	// If the protocol is ICMP, this value must be an ICMP type.
	PortRangeMin int `json:"port_range_min,omitempty"`

	EthernetType string `json:"ethertype,omitempty"`

	// Cidr for ICMP
	RemoteIPPrefix string `json:"remote_ip_prefix"`

	// ParentGroupId is always required and specifies the group to which
	// the rule is added.
	ParentGroupId string `json:"security_group_id"`
	RemoteGroupId string `json:"remote_group_id,omitempty"`
}

RuleInfoV2 allows the callers of CreateSecurityGroupRuleV2() to create 2 types of security group rules: ingress rules and egress rules. Security Groups are applied on neutron ports.

Each tenant/project has a default security group with a rule which allows intercommunication among hosts associated with the default security group. As a result, all egress traffic and intercommunication in the default group are allowed and all ingress from outside of the default group is dropped by default (in the default security group).

If no ingress rule is defined, all inbound traffic is dropped. If no egress rule is defined, all outbound traffic is dropped.

For more information: http://docs.openstack.org/developer/neutron/devref/security_group_api.html https://wiki.openstack.org/wiki/Neutron/SecurityGroups Neutron source: https://github.com/openstack/neutron.git

type SecurityGroupRuleV2

type SecurityGroupRuleV2 struct {
	PortRangeMax   *int    `json:"port_range_max"` // Can be nil
	PortRangeMin   *int    `json:"port_range_min"` // Can be nil
	IPProtocol     *string `json:"protocol"`       // Can be nil, must be defined if PortRange is used
	ParentGroupId  string  `json:"security_group_id"`
	RemoteIPPrefix string  `json:"remote_ip_prefix"`
	RemoteGroupID  string  `json:"remote_group_id"`
	EthernetType   string  `json:"ethertype"`
	Direction      string  `json:"direction"` // Required
	Id             string  `json:",omitempty"`
	TenantId       string  `json:"tenant_id,omitempty"`
}

SecurityGroupRuleV2 describes a rule of a security group. There are 2 basic rule types: ingress and egress rules (see RuleInfo struct).

type SecurityGroupV2

type SecurityGroupV2 struct {
	Rules       []SecurityGroupRuleV2 `json:"security_group_rules"`
	TenantId    string                `json:"tenant_id"`
	Id          string                `json:"id"`
	Name        string                `json:"name"`
	Description string                `json:"description"`
}

SecurityGroupV2 describes a single security group in OpenStack.

type SubnetV2

type SubnetV2 struct {
	Id              string        `json:"id"`         // UUID of the resource
	NetworkId       string        `json:"network_id"` // UUID of the related network
	Name            string        `json:"name"`       // User-provided name for the subnet
	Cidr            string        `json:"cidr"`       // IP range covered by the subnet
	AllocationPools []interface{} `json:"allocation_pools"`
	TenantId        string        `json:"tenant_id"`
}

SubnetV2 contains details about a labeled subnet

Jump to

Keyboard shortcuts

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