New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing properties of networks.CreateOpts #2843
Comments
@pierreprinetti don't these options available through the extensions? gophercloud$ ls -d openstack/networking/v2/extensions/*
openstack/networking/v2/extensions/agents openstack/networking/v2/extensions/portsbinding
openstack/networking/v2/extensions/attributestags openstack/networking/v2/extensions/portsecurity
openstack/networking/v2/extensions/bgp openstack/networking/v2/extensions/provider
openstack/networking/v2/extensions/delegate.go openstack/networking/v2/extensions/qos
openstack/networking/v2/extensions/dns openstack/networking/v2/extensions/quotas
openstack/networking/v2/extensions/external openstack/networking/v2/extensions/rbacpolicies
openstack/networking/v2/extensions/extradhcpopts openstack/networking/v2/extensions/security
openstack/networking/v2/extensions/fwaas openstack/networking/v2/extensions/subnetpools
openstack/networking/v2/extensions/fwaas_v2 openstack/networking/v2/extensions/testing
openstack/networking/v2/extensions/layer3 openstack/networking/v2/extensions/trunk_details
openstack/networking/v2/extensions/lbaas openstack/networking/v2/extensions/trunks
openstack/networking/v2/extensions/lbaas_v2 openstack/networking/v2/extensions/vlantransparent
openstack/networking/v2/extensions/mtu openstack/networking/v2/extensions/vpnaas
openstack/networking/v2/extensions/networkipavailabilities The same applies for #2844 |
... you are showing me an entire new world to explore |
hmm things get ugly pretty quickly with embedding. Gotta find a better way to combine those createOpts := dns.NetworkCreateOptsExt{
CreateOptsBuilder: mtu.CreateOptsExt{
CreateOptsBuilder: networks.CreateOpts{
AdminStateUp: resource.Spec.Resource.AdminStateUp,
Name: resource.Spec.Resource.Name,
Description: resource.Spec.Resource.Description,
Shared: resource.Spec.Resource.Shared,
TenantID: resource.Spec.Resource.TenantID,
ProjectID: resource.Spec.Resource.ProjectID,
AvailabilityZoneHints: resource.Spec.Resource.AvailabilityZoneHints,
},
MTU: int(resource.Spec.Resource.MTU),
},
DNSDomain: resource.Spec.Resource.DNSDomain,
} |
OK I'm left with these four:
The |
@pierreprinetti you may refer to this comment #2752 (comment):) |
Interesting. Well, that leaves me with: type NetworkCreateOpts struct {
AdminStateUp *bool
Name string
Description string
Shared *bool
TenantID string
ProjectID string
AvailabilityZoneHints []string
MTU int
DNSDomain string
PortSecurityEnabled *bool
QoSPolicyID string
External *bool
ProviderPhysicalNetwork string
ProviderNetworkType string
ProviderSegmentationID int
Segments []provider.Segment
VLANTransparent *bool
IsDefault *bool
}
func (opts *NetworkCreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) {
segment := provider.Segment{
PhysicalNetwork: opts.ProviderPhysicalNetwork,
NetworkType: opts.ProviderNetworkType,
SegmentationID: opts.ProviderSegmentationID,
}
base, err := vlantransparent.CreateOptsExt{
CreateOptsBuilder: provider.CreateOptsExt{
CreateOptsBuilder: external.CreateOptsExt{
CreateOptsBuilder: policies.NetworkCreateOptsExt{
CreateOptsBuilder: portsecurity.NetworkCreateOptsExt{
CreateOptsBuilder: dns.NetworkCreateOptsExt{
CreateOptsBuilder: mtu.CreateOptsExt{
CreateOptsBuilder: networks.CreateOpts{
AdminStateUp: opts.AdminStateUp,
Name: opts.Name,
Description: opts.Description,
Shared: opts.Shared,
TenantID: opts.TenantID,
ProjectID: opts.ProjectID,
AvailabilityZoneHints: opts.AvailabilityZoneHints,
},
MTU: opts.MTU,
},
DNSDomain: opts.DNSDomain,
},
PortSecurityEnabled: opts.PortSecurityEnabled,
},
QoSPolicyID: opts.QoSPolicyID,
},
External: opts.External,
},
Segments: append([]provider.Segment{segment}, opts.Segments...),
},
VLANTransparent: opts.VLANTransparent,
}.ToNetworkCreateMap()
if err != nil {
return nil, err
}
if opts.IsDefault != nil {
providerMap := base["network"].(map[string]interface{})
providerMap["is_default"] = opts.IsDefault
}
return base, nil
} Thanks! |
Incidentally, I wonder if there is any advantage whatsoever in keeping these fields away from the main |
I think it's done due to neutron pluggable extensions (can be listed via https://github.com/gophercloud/gophercloud/blob/master/openstack/networking/v2/extensions/delegate.go). E.g. an ability to explicitly POST/PUT nil to some API endpoints' objects... |
Yep, the extensions might be disabled, so the fields might be unavailable. |
An aggressive use of |
I do think this would be doable on On the other hand they now need to do extension discovery anyway. |
Properties available in the API for
create network
and unavailable innetworks.CreateOpts
:UPDATE: I have removed from this list the fields I could add with the extensions, as pointed out by @kayrus
The text was updated successfully, but these errors were encountered: