Skip to content

Commit

Permalink
Merge pull request #801 from jtopjian/networkingv2-project-tenant
Browse files Browse the repository at this point in the history
Networking v2: Support both TenantID and ProjectID where applicable
  • Loading branch information
jrperritt committed Mar 5, 2018
2 parents deb2b59 + cb23b19 commit 1eda8f2
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ListOptsBuilder interface {
// `asc' or `desc'. Marker and Limit are used for pagination.
type ListOpts struct {
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Name string `q:"name"`
Description string `q:"description"`
AdminStateUp bool `q:"admin_state_up"`
Expand Down Expand Up @@ -69,6 +70,7 @@ type CreateOpts struct {
// an admin role in order to set this. Otherwise, this field is left unset
// and the caller will be the owner.
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Firewall struct {
Status string `json:"status"`
PolicyID string `json:"firewall_policy_id"`
TenantID string `json:"tenant_id"`
ProjectID string `json:"project_id"`
}

type commonResult struct {
Expand Down
2 changes: 2 additions & 0 deletions openstack/networking/v2/extensions/fwaas/policies/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ListOptsBuilder interface {
// and is either `asc' or `desc'. Marker and Limit are used for pagination.
type ListOpts struct {
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Name string `q:"name"`
Description string `q:"description"`
Shared *bool `q:"shared"`
Expand Down Expand Up @@ -67,6 +68,7 @@ type CreateOpts struct {
// an admin role in order to set this. Otherwise, this field is left unset
// and the caller will be the owner.
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Shared *bool `json:"shared,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Policy struct {
Name string `json:"name"`
Description string `json:"description"`
TenantID string `json:"tenant_id"`
ProjectID string `json:"project_id"`
Audited bool `json:"audited"`
Shared bool `json:"shared"`
Rules []string `json:"firewall_rules,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions openstack/networking/v2/extensions/fwaas/rules/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ListOptsBuilder interface {
// is either `asc' or `desc'. Marker and Limit are used for pagination.
type ListOpts struct {
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Name string `q:"name"`
Description string `q:"description"`
Protocol string `q:"protocol"`
Expand Down Expand Up @@ -96,6 +97,7 @@ type CreateOpts struct {
Protocol Protocol `json:"protocol" required:"true"`
Action string `json:"action" required:"true"`
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
IPVersion gophercloud.IPVersion `json:"ip_version,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions openstack/networking/v2/extensions/fwaas/rules/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Rule struct {
PolicyID string `json:"firewall_policy_id"`
Position int `json:"position"`
TenantID string `json:"tenant_id"`
ProjectID string `json:"project_id"`
}

// RulePage is the page returned by a pager when traversing over a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ListOpts struct {
FixedIP string `q:"fixed_ip_address"`
FloatingIP string `q:"floating_ip_address"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Limit int `q:"limit"`
Marker string `q:"marker"`
SortKey string `q:"sort_key"`
Expand Down Expand Up @@ -55,6 +56,7 @@ type CreateOpts struct {
FixedIP string `json:"fixed_ip_address,omitempty"`
SubnetID string `json:"subnet_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
}

// ToFloatingIPCreateMap allows CreateOpts to satisfy the CreateOptsBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ type FloatingIP struct {
// associated with the floating IP.
FixedIP string `json:"fixed_ip_address"`

// TenantID is the Owner of the floating IP. Only admin users can specify a
// tenant identifier other than its own.
// TenantID is the project owner of the floating IP. Only admin users can
// specify a project identifier other than its own.
TenantID string `json:"tenant_id"`

// ProjectID is the project owner of the floating IP.
ProjectID string `json:"project_id"`

// Status is the condition of the API resource.
Status string `json:"status"`

Expand Down
2 changes: 2 additions & 0 deletions openstack/networking/v2/extensions/layer3/routers/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ListOpts struct {
Distributed *bool `q:"distributed"`
Status string `q:"status"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Limit int `q:"limit"`
Marker string `q:"marker"`
SortKey string `q:"sort_key"`
Expand Down Expand Up @@ -53,6 +54,7 @@ type CreateOpts struct {
AdminStateUp *bool `json:"admin_state_up,omitempty"`
Distributed *bool `json:"distributed,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
AvailabilityZoneHints []string `json:"availability_zone_hints,omitempty"`
}
Expand Down
7 changes: 5 additions & 2 deletions openstack/networking/v2/extensions/layer3/routers/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ type Router struct {
// ID is the unique identifier for the router.
ID string `json:"id"`

// TenantID is the owner of the router. Only admin users can specify a tenant
// identifier other than its own.
// TenantID is the project owner of the router. Only admin users can
// specify a project identifier other than its own.
TenantID string `json:"tenant_id"`

// ProjectID is the project owner of the router.
ProjectID string `json:"project_id"`

// Routes are a collection of static routes that the router will host.
Routes []Route `json:"routes"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ListOpts struct {
Name string `q:"name"`
AdminStateUp *bool `q:"admin_state_up"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
LoadbalancerID string `q:"loadbalancer_id"`
DefaultPoolID string `q:"default_pool_id"`
Protocol string `q:"protocol"`
Expand Down Expand Up @@ -86,9 +87,13 @@ type CreateOpts struct {
ProtocolPort int `json:"protocol_port" required:"true"`

// TenantID is only required if the caller has an admin role and wants
// to create a pool for another tenant.
// to create a pool for another project.
TenantID string `json:"tenant_id,omitempty"`

// ProjectID is only required if the caller has an admin role and wants
// to create a pool for another project.
ProjectID string `json:"project_id,omitempty"`

// Human-readable name for the Listener. Does not have to be unique.
Name string `json:"name,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ListOpts struct {
Description string `q:"description"`
AdminStateUp *bool `q:"admin_state_up"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
ProvisioningStatus string `q:"provisioning_status"`
VipAddress string `q:"vip_address"`
VipPortID string `q:"vip_port_id"`
Expand Down Expand Up @@ -81,10 +82,14 @@ type CreateOpts struct {
// that belong to them or networks that are shared).
VipSubnetID string `json:"vip_subnet_id" required:"true"`

// The UUID of the tenant who owns the Loadbalancer. Only administrative users
// can specify a tenant UUID other than their own.
// TenantID is the UUID of the project who owns the Loadbalancer.
// Only administrative users can specify a project UUID other than their own.
TenantID string `json:"tenant_id,omitempty"`

// ProjectID is the UUID of the project who owns the Loadbalancer.
// Only administrative users can specify a project UUID other than their own.
ProjectID string `json:"project_id,omitempty"`

// The IP address of the Loadbalancer.
VipAddress string `json:"vip_address,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ListOpts struct {
ID string `q:"id"`
Name string `q:"name"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
PoolID string `q:"pool_id"`
Type string `q:"type"`
Delay int `q:"delay"`
Expand Down Expand Up @@ -119,10 +120,14 @@ type CreateOpts struct {
// types.
ExpectedCodes string `json:"expected_codes,omitempty"`

// The UUID of the tenant who owns the Monitor. Only administrative users
// can specify a tenant UUID other than their own.
// TenantID is the UUID of the project who owns the Monitor.
// Only administrative users can specify a project UUID other than their own.
TenantID string `json:"tenant_id,omitempty"`

// ProjectID is the UUID of the project who owns the Monitor.
// Only administrative users can specify a project UUID other than their own.
ProjectID string `json:"project_id,omitempty"`

// The Name of the Monitor.
Name string `json:"name,omitempty"`

Expand Down
17 changes: 13 additions & 4 deletions openstack/networking/v2/extensions/lbaas_v2/pools/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ListOpts struct {
LBMethod string `q:"lb_algorithm"`
Protocol string `q:"protocol"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
AdminStateUp *bool `q:"admin_state_up"`
Name string `q:"name"`
ID string `q:"id"`
Expand Down Expand Up @@ -97,10 +98,14 @@ type CreateOpts struct {
// Note: one of LoadbalancerID or ListenerID must be provided.
ListenerID string `json:"listener_id,omitempty" xor:"LoadbalancerID"`

// The UUID of the tenant who owns the Pool. Only administrative users
// can specify a tenant UUID other than their own.
// TenantID is the UUID of the project who owns the Pool.
// Only administrative users can specify a project UUID other than their own.
TenantID string `json:"tenant_id,omitempty"`

// ProjectID is the UUID of the project who owns the Pool.
// Only administrative users can specify a project UUID other than their own.
ProjectID string `json:"project_id,omitempty"`

// Name of the pool.
Name string `json:"name,omitempty"`

Expand Down Expand Up @@ -257,10 +262,14 @@ type CreateMemberOpts struct {
// Name of the Member.
Name string `json:"name,omitempty"`

// The UUID of the tenant who owns the Member. Only administrative users
// can specify a tenant UUID other than their own.
// TenantID is the UUID of the project who owns the Member.
// Only administrative users can specify a project UUID other than their own.
TenantID string `json:"tenant_id,omitempty"`

// ProjectID is the UUID of the project who owns the Member.
// Only administrative users can specify a project UUID other than their own.
ProjectID string `json:"project_id,omitempty"`

// A positive integer value that indicates the relative portion of traffic
// that this member should receive from the pool. For example, a member with
// a weight of 10 receives five times as much traffic as a member with a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ListOpts struct {
ObjectType string `q:"object_type"`
ObjectID string `q:"object_id"`
Action PolicyAction `q:"action"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Marker string `q:"marker"`
Limit int `q:"limit"`
Expand Down
23 changes: 14 additions & 9 deletions openstack/networking/v2/extensions/security/groups/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
// sort by a particular network attribute. SortDir sets the direction, and is
// either `asc' or `desc'. Marker and Limit are used for pagination.
type ListOpts struct {
ID string `q:"id"`
Name string `q:"name"`
TenantID string `q:"tenant_id"`
Limit int `q:"limit"`
Marker string `q:"marker"`
SortKey string `q:"sort_key"`
SortDir string `q:"sort_dir"`
ID string `q:"id"`
Name string `q:"name"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Limit int `q:"limit"`
Marker string `q:"marker"`
SortKey string `q:"sort_key"`
SortDir string `q:"sort_dir"`
}

// List returns a Pager which allows you to iterate over a collection of
Expand Down Expand Up @@ -45,10 +46,14 @@ type CreateOpts struct {
// Human-readable name for the Security Group. Does not have to be unique.
Name string `json:"name" required:"true"`

// The UUID of the tenant who owns the Group. Only administrative users
// can specify a tenant UUID other than their own.
// TenantID is the UUID of the project who owns the Group.
// Only administrative users can specify a tenant UUID other than their own.
TenantID string `json:"tenant_id,omitempty"`

// ProjectID is the UUID of the project who owns the Group.
// Only administrative users can specify a tenant UUID other than their own.
ProjectID string `json:"project_id,omitempty"`

// Describes the security group.
Description string `json:"description,omitempty"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ type SecGroup struct {
// traffic entering and leaving the group.
Rules []rules.SecGroupRule `json:"security_group_rules"`

// Owner of the security group.
// TenantID is the project owner of the security group.
TenantID string `json:"tenant_id"`

// ProjectID is the project owner of the security group.
ProjectID string `json:"project_id"`
}

// SecGroupPage is the page returned by a pager when traversing over a
Expand Down
7 changes: 4 additions & 3 deletions openstack/networking/v2/extensions/security/rules/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ListOpts struct {
RemoteIPPrefix string `q:"remote_ip_prefix"`
SecGroupID string `q:"security_group_id"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Limit int `q:"limit"`
Marker string `q:"marker"`
SortKey string `q:"sort_key"`
Expand Down Expand Up @@ -118,9 +119,9 @@ type CreateOpts struct {
// specified IP prefix as the source IP address of the IP packet.
RemoteIPPrefix string `json:"remote_ip_prefix,omitempty"`

// The UUID of the tenant who owns the Rule. Only administrative users
// can specify a tenant UUID other than their own.
TenantID string `json:"tenant_id,omitempty"`
// TenantID is the UUID of the project who owns the Rule.
// Only administrative users can specify a project UUID other than their own.
ProjectID string `json:"project_id,omitempty"`
}

// ToSecGroupRuleCreateMap builds a request body from CreateOpts.
Expand Down
5 changes: 4 additions & 1 deletion openstack/networking/v2/extensions/security/rules/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ type SecGroupRule struct {
// matches the specified IP prefix as the source IP address of the IP packet.
RemoteIPPrefix string `json:"remote_ip_prefix"`

// The owner of this security group rule.
// TenantID is the project owner of this security group rule.
TenantID string `json:"tenant_id"`

// ProjectID is the project owner of this security group rule.
ProjectID string `json:"project_id"`
}

// SecGroupRulePage is the page returned by a pager when traversing over a
Expand Down
2 changes: 2 additions & 0 deletions openstack/networking/v2/networks/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ListOpts struct {
Name string `q:"name"`
AdminStateUp *bool `q:"admin_state_up"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Shared *bool `q:"shared"`
ID string `q:"id"`
Marker string `q:"marker"`
Expand Down Expand Up @@ -70,6 +71,7 @@ type CreateOpts struct {
Name string `json:"name,omitempty"`
Shared *bool `json:"shared,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
AvailabilityZoneHints []string `json:"availability_zone_hints,omitempty"`
}

Expand Down
5 changes: 4 additions & 1 deletion openstack/networking/v2/networks/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ type Network struct {
// Subnets associated with this network.
Subnets []string `json:"subnets"`

// Owner of network.
// TenantID is the project owner of the network.
TenantID string `json:"tenant_id"`

// ProjectID is the project owner of the network.
ProjectID string `json:"project_id"`

// Specifies whether the network resource can be accessed by any tenant.
Shared bool `json:"shared"`

Expand Down
2 changes: 2 additions & 0 deletions openstack/networking/v2/ports/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ListOpts struct {
AdminStateUp *bool `q:"admin_state_up"`
NetworkID string `q:"network_id"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
DeviceOwner string `q:"device_owner"`
MACAddress string `q:"mac_address"`
ID string `q:"id"`
Expand Down Expand Up @@ -81,6 +82,7 @@ type CreateOpts struct {
DeviceID string `json:"device_id,omitempty"`
DeviceOwner string `json:"device_owner,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
SecurityGroups *[]string `json:"security_groups,omitempty"`
AllowedAddressPairs []AddressPair `json:"allowed_address_pairs,omitempty"`
}
Expand Down
Loading

0 comments on commit 1eda8f2

Please sign in to comment.