MCPcopy Create free account
hub / github.com/apache/cloudstack / post_config_change

Method post_config_change

systemvm/debian/opt/cloud/bin/cs/CsAddress.py:794–891  ·  view source on GitHub ↗
(self, method)

Source from the content-addressed store, hash-verified

792
793
794 def post_config_change(self, method):
795 route = CsRoute()
796 tableName = "Table_" + self.dev
797
798 if method == "add":
799 if not self.config.is_vpc():
800 if self.get_type() in ["public"]:
801 route.set_route("table %s throw %s proto static" % (tableName, self.config.address().dbag['eth0'][0]['network']))
802 route.set_route("table %s throw %s proto static" % (tableName, self.config.address().dbag['eth1'][0]['network']))
803
804 # add 'default via gateway' rule in the device specific routing table
805 if "gateway" in self.address and self.address["gateway"] and self.address["gateway"] != "None":
806 route.add_route(self.dev, self.address["gateway"])
807 if "network" in self.address and self.address["network"]:
808 route.add_network_route(self.dev, str(self.address["network"]))
809
810 if self.get_type() in ["public"]:
811 CsRule(self.dev).addRule("from " + str(self.address["network"]))
812
813 if self.config.is_vpc():
814 if self.get_type() in ["public"] and "gateway" in self.address and self.address["gateway"] and self.address["gateway"] != "None":
815 route.add_route(self.dev, self.address["gateway"])
816 for inf, addresses in self.config.address().dbag.items():
817 if not inf.startswith("eth"):
818 continue
819 for address in addresses:
820 if "nw_type" in address and address["nw_type"] == "guest":
821 route.add_network_route(self.dev, str(address["network"]))
822
823 if self.get_type() in ["public"]:
824 CsRule(self.dev).addRule("from " + str(self.address["network"]))
825
826 route.add_network_route(self.dev, str(self.address["network"]))
827
828 CsHelper.execute("sudo ip route flush cache")
829
830 elif method == "delete":
831 # treat the last IP to be dis-associated with interface as special case to clean up the routing rules
832 if self.get_type() in ["public"] and (not self.config.is_vpc()) and (len(self.iplist) == 0):
833 CsHelper.execute("sudo ip rule delete table " + tableName)
834 CsHelper.execute("sudo ip route flush table " + tableName)
835 CsHelper.execute("sudo ip route flush cache")
836 CsRule(self.dev).delMark()
837
838 self.fw_router()
839 self.fw_vpcrouter()
840 self.fw_router_routing()
841 self.fw_vpcrouter_routing()
842 self.fw_dhcpserver()
843
844 cmdline = self.config.cmdline()
845
846 # On deletion nw_type will no longer be known
847 if self.get_type() in ('guest'):
848 if self.config.is_vpc() or self.config.is_router():
849 CsDevice(self.dev, self.config).configure_rp()
850
851 logging.error(

Callers 2

post_configureMethod · 0.95
deleteMethod · 0.95

Calls 15

get_typeMethod · 0.95
set_routeMethod · 0.95
add_routeMethod · 0.95
add_network_routeMethod · 0.95
fw_routerMethod · 0.95
fw_vpcrouterMethod · 0.95
fw_router_routingMethod · 0.95
fw_vpcrouter_routingMethod · 0.95
fw_dhcpserverMethod · 0.95
add_firewall_rulesMethod · 0.95
setupMethod · 0.95
removeMethod · 0.95

Tested by

no test coverage detected