ustcweizhou commented on issue #2089: vRouters fixes & performance improvement URL: https://github.com/apache/cloudstack/pull/2089#issuecomment-302759739 @wido @rhtyd in shared network VR startup, there are indeed vm_dhcp_entry.json and vm_metadata.json in the cfg file. However, for vpc tier adding, there are more than these configurations, this is what I suggested before. here is an example (I added some debug information in VirtualRoutingResource.java) ``` 2017-05-19 15:02:54,149 DEBUG [resource.virtualnetwork.VirtualRoutingResource] (agentRequest-Handler-4:null) AggregationControlCommand configuration is : #Apache CloudStack Virtual Router Config File <version> 1.0 </version> <file> /var/cache/cloud/ip_associations.json {"ip_address":[{"public_ip":"10.11.115.129","source_nat":true,"add":true,"one_to_one_nat":false,"first_i_p":true,"gateway":"10.11.115.254","netmask":"255.255.255.0","vif_mac_address":"06:82:8e:00:00:28","nic_dev_id":1,"new_nic":false,"is_private_gateway":false}],"type":"ips"} </file> <script> /opt/cloud/bin/update_config.py ip_associations.json </script> <file> /var/cache/cloud/forwarding_rules.json {"rules":[{"revoke":false,"protocol":"tcp","source_ip_address":"10.11.115.129","source_port_range":"22:22","destination_ip_address":"192.168.4.164","destination_port_range":"22:22"}],"type":"forwardrules"} </file> <script> /opt/cloud/bin/update_config.py forwarding_rules.json </script> <file> /var/cache/cloud/ip_associations.json {"ip_address":[{"public_ip":"10.11.115.129","source_nat":true,"add":true,"one_to_one_nat":false,"first_i_p":true,"gateway":"10.11.115.254","netmask":"255.255.255.0","vif_mac_address":"06:82:8e:00:00:28","nic_dev_id":1,"new_nic":false,"is_private_gateway":false}],"type":"ips"} </file> <script> /opt/cloud/bin/update_config.py ip_associations.json </script> <file> /var/cache/cloud/network_acl.json {"device":"eth8","mac_address":"02:00:7c:bd:00:80","private_gateway_acl":false,"nic_ip":"192.168.4.163","nic_netmask":"23","ingress_rules":[{"type":"all","cidr":"0.0.0.0/0","allowed":true}],"egress_rules":[{"type":"all","cidr":"0.0.0.0/0","allowed":true}],"type":"networkacl"} </file> <script> /opt/cloud/bin/update_config.py network_acl.json </script> 2017-05-19 15:02:54,342 DEBUG [kvm.resource.LibvirtComputingResource] (agentRequest-Handler-4:null) Executing: /usr/share/cloudstack-common/scripts/network/domr/router_proxy.sh vr_cfg.sh 169.254.3.190 -c /var/cache/cloud/VR-dfcd4c05-e019-4682-b2c2-3141d34046ca.cfg ``` so I cherrypicked this PR, and made the following change in our fork. it seems fine. ``` diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py index 958f797..556f768 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py @@ -968,10 +968,9 @@ class CsForwardingRules(CsDataBag): def main(argv): # The file we are currently processing, if it is "cmd_line.json" everything will be processed. - process_file = argv[1] - - # process_file can be None, if so assume cmd_line.json - if process_file is None: + if len(sys.argv) > 1: + process_file = argv[1] + else: process_file = "cmd_line.json" # Track if changes need to be committed to NetFilter diff --git a/systemvm/patches/debian/config/opt/cloud/bin/update_config.py b/systemvm/patches/debian/config/opt/cloud/bin/update_config.py index 9806b4e..8680641 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/update_config.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/update_config.py @@ -50,7 +50,7 @@ def process_file(): qf = QueueFile() qf.setFile(sys.argv[1]) qf.load(None) - if not os.environ.get('DEFER_CONFIG', False): + if not os.environ.get('DEFER_CONFIG', False) or sys.argv[1] not in ["vm_dhcp_entry.json", "vm_metadata.json"]: # Converge finish_config() diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh index 01d11ea..f16ffd3 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh @@ -87,6 +87,11 @@ do echo $line >> $file done log_it "VR config: create file success" + filename=$(echo $file |cut -d'/' -f5) + if [ "$filename" == "vm_dhcp_entry.json" ] || [ "$filename" == "vm_metadata.json" ] + then + DEFER_CONFIG2=YESPLZ + fi continue fi done < $cfg @@ -95,8 +100,13 @@ done < $cfg mv $cfg /var/cache/cloud/processed/ unset DEFER_CONFIG -# trigger finish_config() -/opt/cloud/bin/configure.py +if [ "$DEFER_CONFIG2" != "" ] +then + # trigger finish_config() + log_it "VR config: finish configuration" + /opt/cloud/bin/configure.py vm_dhcp_entry.json + /opt/cloud/bin/configure.py vm_metadata.json +fi # Flush kernel conntrack table log_it "VR config: Flushing conntrack table" ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
With regards, Apache Git Services