Fix: the update_config.py was not parsing the incoming guest net configuration 
properly

Added comments to the CitrixResourceBase class: do not destroy the cd-rom


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/43c9a25a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/43c9a25a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/43c9a25a

Branch: refs/heads/feature/systemvm-persistent-config
Commit: 43c9a25a1ea8b3a4c1887eb09548f7a51d8c8297
Parents: 355b850
Author: wilderrodrigues <wrodrig...@schubergphilis.com>
Authored: Sat Jan 17 19:50:40 2015 +0100
Committer: wilderrodrigues <wrodrig...@schubergphilis.com>
Committed: Mon Feb 16 16:08:35 2015 +0100

----------------------------------------------------------------------
 .../xenserver/resource/CitrixResourceBase.java  |  1 +
 .../config/opt/cloud/bin/update_config.py       | 61 +++++++++-----------
 2 files changed, 29 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43c9a25a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
 
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index c335572..040607d 100644
--- 
a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ 
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -1612,6 +1612,7 @@ public abstract class CitrixResourceBase implements 
ServerResource, HypervisorRe
             if (result != null) {
                 return new CheckSshAnswer(cmd, "Can not ping System vm " + 
vmName + "due to:" + result);
             }
+            //Do not destroy the disk here! It will stio the patching process. 
Please, don't!
             //destroyPatchVbd(conn, vmName);
         } catch (final Exception e) {
             return new CheckSshAnswer(cmd, e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43c9a25a/systemvm/patches/debian/config/opt/cloud/bin/update_config.py
----------------------------------------------------------------------
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 8bb5916..ea21455 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/update_config.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/update_config.py
@@ -51,52 +51,46 @@ def process_file():
     # Converge
     finish_config()
 
-def is_guestnet_configured(guestnet_dict, key):
+def is_guestnet_configured(guestnet_dict, keys):
     
-    existing_key = None
+    existing_keys = []
     new_eth_key = None
     
-    for k1, v in guestnet_dict.iteritems():
-        for k2 in key:
-            if k1 == k2 and len(guestnet_dict[k1]) > 0:
-                existing_key = k1
-        if existing_key:
-            break
-    
-    if not existing_key:
-        return False
+    for k1, v1 in guestnet_dict.iteritems():
+        if k1 in keys and len(v1) > 0:
+            existing_keys.append(k1)
     
     file = open(jsonCmdConfigPath)
     new_guestnet_dict = json.load(file)
     
-    for k1, v in new_guestnet_dict.iteritems():
-        for k2 in key:
-            if k1 == k2 and len(new_guestnet_dict[k1]) > 0:
-                new_eth_key = k1
-        if new_eth_key:
-            break
+    '''
+    Check if we have a new guest network ready to be setup
+    '''
+    device = new_guestnet_dict['device']
     
-    if not new_eth_key:
+    if device in existing_keys:
         '''
-        Why is the new guest net dictionary empty?
-          1. Might be a bug on the Java side.
-        Return True so we won't process an empty file. However, we have to 
investigate it!
+        Device already configured, ignore.
         '''
         return True
-
-    old_eth = guestnet_dict[existing_key][0]
-    new_eth = new_guestnet_dict[new_eth_key][0]
     
-    new_mac = new_eth["mac_address"].encode('utf-8')
-    old_mac = old_eth["mac_address"].encode('utf-8')
-    new_ip = new_eth["router_guest_ip"].encode('utf-8')
-    old_ip = old_eth["router_guest_ip"].encode('utf-8')
+    exists = False
     
-    if (new_mac == old_mac) and (new_ip == old_ip):
-        print "[WARN] Guest Network already configured. Will skip the file to 
avoid RTNETLINK errors."
-        return True
+    for key in existing_keys:
+        for interface in guestnet_dict[key]:
+            new_mac = new_guestnet_dict["mac_address"].encode('utf-8')
+            old_mac = interface["mac_address"].encode('utf-8')
+            new_ip = new_guestnet_dict["router_guest_ip"].encode('utf-8')
+            old_ip = interface["router_guest_ip"].encode('utf-8')
     
-    return False
+            if (new_mac == old_mac) and (new_ip == old_ip):
+                exists = True
+                break
+        
+        if exists:
+            break
+        
+    return exists
 
 if not (os.path.isfile(jsonCmdConfigPath) and os.access(jsonCmdConfigPath, 
os.R_OK)):
     print "[ERROR]: You are telling me to process %s, but i can't access it" % 
jsonCmdConfigPath
@@ -115,7 +109,8 @@ if sys.argv[1] == "guest_network.json":
         file = open(currentGuestNetConfig)
         guestnet_dict = json.load(file)
     
-        if not is_guestnet_configured(guestnet_dict, ['eth1', 'eth2', 'eth3', 
'eth4', 'eth5']):
+        if not is_guestnet_configured(guestnet_dict, ['eth1', 'eth2', 'eth3', 
'eth4', 'eth5', 'eth6', 'eth7', 'eth8', 'eth9']):
+            print "[INFO] Processing Guest Network."
             process_file()
         else:
             print "[INFO] No need to process Guest Network."

Reply via email to