Skip to content

Instantly share code, notes, and snippets.

@drnic
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drnic/8828329 to your computer and use it in GitHub Desktop.
Save drnic/8828329 to your computer and use it in GitHub Desktop.
Navigating around openstack networks

Given a router, get the attached external gateway's pool name:

floating_ip_pool_name = network.networks.get(router.external_gateway_info["network_id"]).name
# => "IO.IP"

Use the pool name to provision a floating IP:

compute.addresses.create(pool: floating_ip_pool_name)

The list of Networks that are external gateways (and have floating IPs):

network.networks.select {|n| n.router_external}
# => <Fog::Network::OpenStack::Networks
    filters={}
    [
      <Fog::Network::OpenStack::Network
        id="18a2e1be-6548-4b41-b707-3640f036e7d9",
        name="IO.IP",
        subnets=["8ea2975c-6352-40ca-b144-740073cb5900"],
        shared=true,
        status="ACTIVE",
        admin_state_up=true,
        tenant_id="e217a0907f5146c185625a004f11b4b4",
        provider_network_type=nil,
        provider_physical_network=nil,
        provider_segmentation_id=nil,
        router_external=true
      >
    ]
  >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment