Skip to content
This repository
Browse code

Ensure configuration uses correct HTTP methods as per RFC 3253. Provi…

…de configuration upgrade path.
  • Loading branch information...
commit 299a8cabf87e91c73c0ae34dfcca683b1277d6e1 1 parent 444bf1e
David Beitey authored September 24, 2012
30  admin/config_version.py
@@ -71,6 +71,32 @@ def upgrade_to_1_0_13 (cfg):
71 71
                 elif val == '0':
72 72
                     del(cfg[key])
73 73
 
  74
+# Converts to 1.2.102
  75
+METHODS_MAP = {'baseline_control': 'baseline-control',
  76
+               'version_control': 'version-control'
  77
+              }
  78
+def update_rules_methods(cfg, key, node):
  79
+    if node.value == 'method':
  80
+        method_key = '%s!method' % key
  81
+        method_value = cfg.get_val(method_key)
  82
+        # Check rule's method key value and replace if problematic
  83
+        if method_value in METHODS_MAP:
  84
+            cfg[method_key] = METHODS_MAP[method_value]
  85
+    else:
  86
+        for k in node.keys():
  87
+            child_key = '%s!%s' % (key, k)
  88
+            child_node = cfg[child_key]
  89
+            update_rules_methods(cfg, child_key, child_node)
  90
+
  91
+def upgrade_to_1_2_102 (cfg):
  92
+    # Update HTTP method specifications for those that were incorrect
  93
+
  94
+    for v in cfg.keys('vserver'):
  95
+        for r in cfg.keys('vserver!%s!rule' % (v)):
  96
+            # Traverse rules and look for HTTP method 'match' elements
  97
+            rule_key = 'vserver!%s!rule!%s!match' % (v,r)
  98
+            rule_node = cfg[rule_key]
  99
+            update_rules_methods(cfg, rule_key, rule_node)
74 100
 
75 101
 def config_version_get_current():
76 102
     ver = configured.VERSION.split ('b')[0]
@@ -145,5 +171,9 @@ def config_version_update_cfg (cfg):
145 171
     if ver_config_i < 1000013:
146 172
         upgrade_to_1_0_13 (cfg)
147 173
 
  174
+    # Update to.. 1.2.102
  175
+    if ver_config_i < 1002102:
  176
+        upgrade_to_1_2_102 (cfg)
  177
+
148 178
     cfg["config!version"] = ver_release_s
149 179
     return True
4  admin/plugins/method.py
@@ -52,7 +52,7 @@
52 52
     ('unsubscribe',      'UNSUBSCRIBE'),
53 53
     ('report',           'REPORT'),
54 54
     ('patch',            'PATCH'),
55  
-    ('version_control',  'VERSION_CONTROL'),
  55
+    ('version-control',  'VERSION-CONTROL'),
56 56
     ('checkout',         'CHECKOUT'),
57 57
     ('uncheckout',       'UNCHECKOUT'),
58 58
     ('checkin',          'CHECKIN'),
@@ -60,7 +60,7 @@
60 60
     ('label',            'LABEL'),
61 61
     ('mkworkspace',      'MKWORKSPACE'),
62 62
     ('mkactivity',       'MKACTIVITY'),
63  
-    ('baseline_control', 'BASELINE_CONTROL'),
  63
+    ('baseline-control', 'BASELINE-CONTROL'),
64 64
     ('merge',            'MERGE')
65 65
 ]
66 66
 

0 notes on commit 299a8ca

Please sign in to comment.
Something went wrong with that request. Please try again.