-
-
Save anonymous/797b46c9ac4c0c3a1095 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _set_network(self, section_name="network"): | |
if "neutron" in self.available_services: | |
neutron = self.clients.neutron() | |
public_net = [net for net in neutron.list_networks()["networks"] if | |
net["status"] == "ACTIVE" and | |
net["router:external"] is True] | |
if public_net: | |
net_id = public_net[0]["id"] | |
self.conf.set(section_name, "public_network_id", net_id) | |
public_router = neutron.list_routers( | |
network_id=net_id)["routers"][0] | |
self.conf.set(section_name, "public_router_id", | |
public_router["id"]) | |
subnets = neutron.list_subnets(network_id=net_id)["subnets"] | |
if subnets: | |
subnet = subnets[0] | |
else: | |
# TODO(akurilin): create public subnet | |
LOG.warn("No public subnet is found.") | |
else: | |
subnets = neutron.list_subnets()["subnets"] | |
if subnets: | |
subnet = subnets[0] | |
else: | |
# TODO(akurilin): create subnet | |
LOG.warn("No subnet is found.") | |
self.conf.set(section_name, "default_network", subnet["cidr"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment