cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: updated refs/heads/4.2 to 5a2fd3e
Date Wed, 31 Jul 2013 03:44:29 GMT
Updated Branches:
  refs/heads/4.2 949c088e7 -> 5a2fd3e2a


Summary: Move Xen vmdata to new, non-ssh method

Detail: KVM recently got a patch that did away with a few dozen ssh calls
when programming virtual router (CLOUDSTACK-3163), saving several seconds
for each vm served by the virtual router when the router is rebooted. This
patch updates Xen to use the same method, and cleans up the old script refs.

Reviewed-by: Sheng Yang, Prasanna Santhanam


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

Branch: refs/heads/4.2
Commit: 5a2fd3e2a42587cbcb0d5b6fa153ceb5ae6d9db4
Parents: 949c088
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Tue Jul 30 21:41:11 2013 -0600
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Tue Jul 30 21:41:11 2013 -0600

----------------------------------------------------------------------
 .../virtualnetwork/VirtualRoutingResource.java  |   3 +-
 .../debian/config/opt/cloud/bin/vmdata.py       | 204 +++++++++++++++++++
 .../debian/config/opt/cloud/bin/vmdata_kvm.py   | 204 -------------------
 .../xen/resource/CitrixResourceBase.java        |  29 +--
 scripts/network/domr/vm_data.sh                 | 147 -------------
 scripts/vm/hypervisor/xenserver/vmops           |  51 +----
 scripts/vm/hypervisor/xenserver/xcposs/patch    |   1 -
 scripts/vm/hypervisor/xenserver/xcposs/vmops    |  51 +----
 scripts/vm/hypervisor/xenserver/xcpserver/patch |   1 -
 .../vm/hypervisor/xenserver/xenserver56/patch   |   1 -
 .../hypervisor/xenserver/xenserver56fp1/patch   |   1 -
 .../vm/hypervisor/xenserver/xenserver60/patch   |   1 -
 12 files changed, 217 insertions(+), 477 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index e5f922d..1fb86e0 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -465,7 +465,6 @@ public class VirtualRoutingResource implements Manager {
     }
 
     protected Answer execute(VmDataCommand cmd) {
-        List<String[]> vmData = cmd.getVmData();
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         Map<String, List<String[]>> data = new HashMap<String, List<String[]>>();
         data.put(cmd.getVmIpAddress(), cmd.getVmData());
@@ -477,7 +476,7 @@ public class VirtualRoutingResource implements Manager {
 
         String args = "-d " + json;
 
-        final String result = routerProxy("vmdata_kvm.py", routerIp, args);
+        final String result = routerProxy("vmdata.py", routerIp, args);
         if (result != null) {
             return new Answer(cmd, false, "VmDataCommand failed, check agent logs");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/patches/systemvm/debian/config/opt/cloud/bin/vmdata.py
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vmdata.py b/patches/systemvm/debian/config/opt/cloud/bin/vmdata.py
new file mode 100755
index 0000000..f508032
--- /dev/null
+++ b/patches/systemvm/debian/config/opt/cloud/bin/vmdata.py
@@ -0,0 +1,204 @@
+#!/usr/bin/python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys, getopt, json, os, base64
+from fcntl import flock, LOCK_EX, LOCK_UN
+
+
+def main(argv):
+    fpath =  ''
+    b64data = ''
+
+    try:
+        opts, args = getopt.getopt(argv,"f:d:")
+    except getopt.GetoptError:
+        print 'params: -f <filename> -d <b64jsondata>'
+        sys.exit(2)
+    for opt, arg in opts:
+        if opt == '-f':
+            fpath = arg
+        elif opt == '-d':
+            b64data = arg
+
+    json_data = ''
+    if fpath != '':
+        fh = open(fpath, 'r')
+        json_data = json.loads(fh.read())
+    elif b64data != '':
+        json_data = json.loads(base64.b64decode(b64data))
+    else:
+        print '-f <filename> or -d <b64jsondata> required'
+        sys.exit(2)
+
+    for ip in json_data:
+        for item in json_data[ip]:
+            folder = item[0]
+            file   = item[1]
+            data   = item[2]
+
+            # process only valid data
+            if folder != "userdata" and folder != "metadata":
+                continue
+
+            if file == "":
+                continue
+
+            htaccess(ip, folder, file)
+
+            if data == "":
+                deletefile(ip, folder, file)
+            else:
+                createfile(ip, folder, file, data)
+    
+    if fpath != '':
+        fh.close()
+        os.remove(fpath)
+
+def deletefile(ip, folder, file):
+    datafile = "/var/www/html/" + folder + "/" + ip + "/" + file
+
+    if os.path.exists(datafile):
+        os.remove(datafile)
+
+def createfile(ip, folder, file, data):
+    dest = "/var/www/html/" + folder + "/" + ip + "/" + file
+    metamanifestdir = "/var/www/html/" + folder + "/" + ip 
+    metamanifest =  metamanifestdir + "/meta-data"
+
+    # base64 decode userdata
+    if folder == "userdata" or folder == "user-data":
+        if data is not None:
+            data = base64.b64decode(data)
+
+    fh = open(dest, "w")
+    exflock(fh)
+    if data is not None:
+        fh.write(data)
+    else:
+        fh.write("")
+    unflock(fh)
+    fh.close()
+    os.chmod(dest, 0644)
+
+    if folder == "metadata" or folder == "meta-data":
+        try:
+            os.makedirs(metamanifestdir, 0755)
+        except OSError as e:
+            # error 17 is already exists, we do it this way for concurrency
+            if e.errno != 17:
+                print "failed to make directories " + metamanifestdir + " due to :" +e.strerror
+                sys.exit(1)
+        if os.path.exists(metamanifest):
+            fh = open(metamanifest, "r+a")
+            exflock(fh) 
+            if not file in fh.read():
+                fh.write(file + '\n')
+            unflock(fh)
+            fh.close()
+        else:
+            fh = open(metamanifest, "w")
+            exflock(fh)
+            fh.write(file + '\n')
+            unflock(fh)
+            fh.close()
+
+    if os.path.exists(metamanifest):
+        os.chmod(metamanifest, 0644)
+
+def htaccess(ip, folder, file):
+    entry = "RewriteRule ^" + file + "$  ../" + folder + "/%{REMOTE_ADDR}/" + file + " [L,NC,QSA]"
+    htaccessFolder = "/var/www/html/latest"
+    htaccessFile = htaccessFolder + "/.htaccess"
+
+    try:
+        os.mkdir(htaccessFolder,0755)
+    except OSError as e:
+        # error 17 is already exists, we do it this way for concurrency
+        if e.errno != 17:
+            print "failed to make directories " + htaccessFolder + " due to :" +e.strerror
+            sys.exit(1)
+
+    if os.path.exists(htaccessFile):
+        fh = open(htaccessFile, "r+a")
+        exflock(fh)
+        if not entry in fh.read():
+            fh.write(entry + '\n')
+        unflock(fh) 
+        fh.close()
+    else:
+        fh = open(htaccessFile, "w")
+        exflock(fh)
+        fh.write("Options +FollowSymLinks\nRewriteEngine On\n\n")  
+        fh.write(entry + '\n')
+        unflock(fh)
+        fh.close()
+
+    entry="Options -Indexes\nOrder Deny,Allow\nDeny from all\nAllow from " + ip
+    htaccessFolder = "/var/www/html/" + folder + "/" + ip
+    htaccessFile = htaccessFolder+"/.htaccess"
+
+    try:
+        os.makedirs(htaccessFolder,0755)
+    except OSError as e:
+        # error 17 is already exists, we do it this way for sake of concurrency
+        if e.errno != 17:
+            print "failed to make directories " + htaccessFolder + " due to :" +e.strerror
+            sys.exit(1)
+
+    fh = open(htaccessFile, "w")
+    exflock(fh)
+    fh.write(entry + '\n')
+    unflock(fh)
+    fh.close()
+
+    if folder == "metadata" or folder == "meta-data":
+        entry = "RewriteRule ^meta-data/(.+)$  ../" + folder + "/%{REMOTE_ADDR}/$1 [L,NC,QSA]"
+        htaccessFolder = "/var/www/html/latest"
+        htaccessFile = htaccessFolder + "/.htaccess"
+
+        fh = open(htaccessFile, "r+a")
+        exflock(fh)
+        if not entry in fh.read():
+            fh.write(entry + '\n')
+
+        entry = "RewriteRule ^meta-data/$  ../" + folder + "/%{REMOTE_ADDR}/meta-data [L,NC,QSA]"
+
+        fh.seek(0)
+        if not entry in fh.read():
+            fh.write(entry + '\n')
+        unflock(fh)
+        fh.close()
+
+def exflock(file):
+    try:
+        flock(file, LOCK_EX)
+    except IOError as e:
+        print "failed to lock file" + file.name + " due to : " + e.strerror
+        sys.exit(1)
+    return True
+    
+def unflock(file):
+    try:
+        flock(file, LOCK_UN)
+    except IOError:
+        print "failed to unlock file" + file.name + " due to : " + e.strerror
+        sys.exit(1)
+    return True
+
+if __name__ == "__main__":
+    main(sys.argv[1:])

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/patches/systemvm/debian/config/opt/cloud/bin/vmdata_kvm.py
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vmdata_kvm.py b/patches/systemvm/debian/config/opt/cloud/bin/vmdata_kvm.py
deleted file mode 100755
index f508032..0000000
--- a/patches/systemvm/debian/config/opt/cloud/bin/vmdata_kvm.py
+++ /dev/null
@@ -1,204 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-# 
-#   http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import sys, getopt, json, os, base64
-from fcntl import flock, LOCK_EX, LOCK_UN
-
-
-def main(argv):
-    fpath =  ''
-    b64data = ''
-
-    try:
-        opts, args = getopt.getopt(argv,"f:d:")
-    except getopt.GetoptError:
-        print 'params: -f <filename> -d <b64jsondata>'
-        sys.exit(2)
-    for opt, arg in opts:
-        if opt == '-f':
-            fpath = arg
-        elif opt == '-d':
-            b64data = arg
-
-    json_data = ''
-    if fpath != '':
-        fh = open(fpath, 'r')
-        json_data = json.loads(fh.read())
-    elif b64data != '':
-        json_data = json.loads(base64.b64decode(b64data))
-    else:
-        print '-f <filename> or -d <b64jsondata> required'
-        sys.exit(2)
-
-    for ip in json_data:
-        for item in json_data[ip]:
-            folder = item[0]
-            file   = item[1]
-            data   = item[2]
-
-            # process only valid data
-            if folder != "userdata" and folder != "metadata":
-                continue
-
-            if file == "":
-                continue
-
-            htaccess(ip, folder, file)
-
-            if data == "":
-                deletefile(ip, folder, file)
-            else:
-                createfile(ip, folder, file, data)
-    
-    if fpath != '':
-        fh.close()
-        os.remove(fpath)
-
-def deletefile(ip, folder, file):
-    datafile = "/var/www/html/" + folder + "/" + ip + "/" + file
-
-    if os.path.exists(datafile):
-        os.remove(datafile)
-
-def createfile(ip, folder, file, data):
-    dest = "/var/www/html/" + folder + "/" + ip + "/" + file
-    metamanifestdir = "/var/www/html/" + folder + "/" + ip 
-    metamanifest =  metamanifestdir + "/meta-data"
-
-    # base64 decode userdata
-    if folder == "userdata" or folder == "user-data":
-        if data is not None:
-            data = base64.b64decode(data)
-
-    fh = open(dest, "w")
-    exflock(fh)
-    if data is not None:
-        fh.write(data)
-    else:
-        fh.write("")
-    unflock(fh)
-    fh.close()
-    os.chmod(dest, 0644)
-
-    if folder == "metadata" or folder == "meta-data":
-        try:
-            os.makedirs(metamanifestdir, 0755)
-        except OSError as e:
-            # error 17 is already exists, we do it this way for concurrency
-            if e.errno != 17:
-                print "failed to make directories " + metamanifestdir + " due to :" +e.strerror
-                sys.exit(1)
-        if os.path.exists(metamanifest):
-            fh = open(metamanifest, "r+a")
-            exflock(fh) 
-            if not file in fh.read():
-                fh.write(file + '\n')
-            unflock(fh)
-            fh.close()
-        else:
-            fh = open(metamanifest, "w")
-            exflock(fh)
-            fh.write(file + '\n')
-            unflock(fh)
-            fh.close()
-
-    if os.path.exists(metamanifest):
-        os.chmod(metamanifest, 0644)
-
-def htaccess(ip, folder, file):
-    entry = "RewriteRule ^" + file + "$  ../" + folder + "/%{REMOTE_ADDR}/" + file + " [L,NC,QSA]"
-    htaccessFolder = "/var/www/html/latest"
-    htaccessFile = htaccessFolder + "/.htaccess"
-
-    try:
-        os.mkdir(htaccessFolder,0755)
-    except OSError as e:
-        # error 17 is already exists, we do it this way for concurrency
-        if e.errno != 17:
-            print "failed to make directories " + htaccessFolder + " due to :" +e.strerror
-            sys.exit(1)
-
-    if os.path.exists(htaccessFile):
-        fh = open(htaccessFile, "r+a")
-        exflock(fh)
-        if not entry in fh.read():
-            fh.write(entry + '\n')
-        unflock(fh) 
-        fh.close()
-    else:
-        fh = open(htaccessFile, "w")
-        exflock(fh)
-        fh.write("Options +FollowSymLinks\nRewriteEngine On\n\n")  
-        fh.write(entry + '\n')
-        unflock(fh)
-        fh.close()
-
-    entry="Options -Indexes\nOrder Deny,Allow\nDeny from all\nAllow from " + ip
-    htaccessFolder = "/var/www/html/" + folder + "/" + ip
-    htaccessFile = htaccessFolder+"/.htaccess"
-
-    try:
-        os.makedirs(htaccessFolder,0755)
-    except OSError as e:
-        # error 17 is already exists, we do it this way for sake of concurrency
-        if e.errno != 17:
-            print "failed to make directories " + htaccessFolder + " due to :" +e.strerror
-            sys.exit(1)
-
-    fh = open(htaccessFile, "w")
-    exflock(fh)
-    fh.write(entry + '\n')
-    unflock(fh)
-    fh.close()
-
-    if folder == "metadata" or folder == "meta-data":
-        entry = "RewriteRule ^meta-data/(.+)$  ../" + folder + "/%{REMOTE_ADDR}/$1 [L,NC,QSA]"
-        htaccessFolder = "/var/www/html/latest"
-        htaccessFile = htaccessFolder + "/.htaccess"
-
-        fh = open(htaccessFile, "r+a")
-        exflock(fh)
-        if not entry in fh.read():
-            fh.write(entry + '\n')
-
-        entry = "RewriteRule ^meta-data/$  ../" + folder + "/%{REMOTE_ADDR}/meta-data [L,NC,QSA]"
-
-        fh.seek(0)
-        if not entry in fh.read():
-            fh.write(entry + '\n')
-        unflock(fh)
-        fh.close()
-
-def exflock(file):
-    try:
-        flock(file, LOCK_EX)
-    except IOError as e:
-        print "failed to lock file" + file.name + " due to : " + e.strerror
-        sys.exit(1)
-    return True
-    
-def unflock(file):
-    try:
-        flock(file, LOCK_UN)
-    except IOError:
-        print "failed to unlock file" + file.name + " due to : " + e.strerror
-        sys.exit(1)
-    return True
-
-if __name__ == "__main__":
-    main(sys.argv[1:])

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index fa7f2ec..80bdf42 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.hypervisor.xen.resource;
 
+import com.google.gson.Gson;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
@@ -54,6 +55,7 @@ import javax.naming.ConfigurationException;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import com.cloud.agent.api.to.DhcpTO;
+import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 import org.apache.xmlrpc.XmlRpcException;
 import org.w3c.dom.Document;
@@ -2220,25 +2222,14 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
     protected Answer execute(final VmDataCommand cmd) {
         Connection conn = getConnection();
         String routerPrivateIpAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-        String vmIpAddress = cmd.getVmIpAddress();
-        List<String[]> vmData = cmd.getVmData();
-        String[] vmDataArgs = new String[vmData.size() * 2 + 4];
-        vmDataArgs[0] = "routerIP";
-        vmDataArgs[1] = routerPrivateIpAddress;
-        vmDataArgs[2] = "vmIP";
-        vmDataArgs[3] = vmIpAddress;
-        int i = 4;
-        for (String[] vmDataEntry : vmData) {
-            String folder = vmDataEntry[0];
-            String file = vmDataEntry[1];
-            String contents = (vmDataEntry[2] != null) ? vmDataEntry[2] : "none";
-
-            vmDataArgs[i] = folder + "," + file;
-            vmDataArgs[i + 1] = contents;
-            i += 2;
-        }
-
-        String result = callHostPlugin(conn, "vmops", "vm_data", vmDataArgs);
+        Map<String, List<String[]>> data = new HashMap<String, List<String[]>>();
+        data.put(cmd.getVmIpAddress(), cmd.getVmData());
+        String json = new Gson().toJson(data);
+        json = Base64.encodeBase64String(json.getBytes());
+
+        String args = "vmdata.py " + routerPrivateIpAddress + " -d " + json;
+
+        String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
 
         if (result == null || result.isEmpty()) {
             return new Answer(cmd, false, "vm_data failed");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/network/domr/vm_data.sh
----------------------------------------------------------------------
diff --git a/scripts/network/domr/vm_data.sh b/scripts/network/domr/vm_data.sh
deleted file mode 100644
index c861723..0000000
--- a/scripts/network/domr/vm_data.sh
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/bin/bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-# 
-#   http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-# $Id: vm_data.sh 9307 2010-06-08 00:43:08Z chiradeep $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/hypervisor/xenserver/patch/vm_data.sh
$
-# @VERSION@
-
-usage() {
-  printf "Usage: %s: -r <domr-ip> -v <vm ip> -F <vm data folder> -f <vm
data file> -d <data to put in file> \n" $(basename $0) >&2
-  exit 2
-}
-
-set -x
-cert="/root/.ssh/id_rsa.cloud"
-PORT=3922
-
-create_htaccess() {
-  local domrIp=$1
-  local vmIp=$2
-  local folder=$3
-  local file=$4
-  
-  local result=0
-  #rewrite rule in top level /latest folder to redirect 
-  #to vm specific folder based on source ip
-  entry="RewriteRule ^$file$  ../$folder/%{REMOTE_ADDR}/$file [L,NC,QSA]"
-  htaccessFolder="/var/www/html/latest"
-  htaccessFile=$htaccessFolder/.htaccess
-  ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "mkdir -p $htaccessFolder;
touch $htaccessFile; grep -F \"$entry\" $htaccessFile; if [ \$? -gt 0 ]; then echo -e \"$entry\"
>> $htaccessFile; fi" >/dev/null
-  result=$?
-  
-  if [ $result -eq 0 ]
-  then
-    #ensure that vm specific folder cannot be listed and that only 
-    #the vm that owns the data can access the items in this directory
-    entry="Options -Indexes\\nOrder Deny,Allow\\nDeny from all\\nAllow from $vmIp"
-    htaccessFolder="/var/www/html/$folder/$vmIp"
-    htaccessFile=$htaccessFolder/.htaccess
-    ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "mkdir -p $htaccessFolder;
echo -e \"$entry\" > $htaccessFile" >/dev/null
-    result=$?
-  fi
-  
-  #support access by http://<dhcp server>/latest/<metadata key> (legacy, see
above) also
-  # http://<dhcp server>/latest/meta-data/<metadata key> (correct)
-  if [ "$folder" == "metadata" ] || [ "$folder" == "meta-data" ]
-  then
-    entry="RewriteRule ^meta-data/(.+)$  ../$folder/%{REMOTE_ADDR}/\\\$1 [L,NC,QSA]"
-    htaccessFolder="/var/www/html/latest"
-    htaccessFile=$htaccessFolder/.htaccess
-    ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "grep -F \"$entry\" $htaccessFile;
if [ \$? -gt 0 ]; then echo -e \"$entry\" >> $htaccessFile; fi" >/dev/null
-    entry="RewriteRule ^meta-data/$  ../$folder/%{REMOTE_ADDR}/meta-data [L,NC,QSA]"
-    ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "grep -F \"$entry\" $htaccessFile;
if [ \$? -gt 0 ]; then echo -e \"$entry\" >> $htaccessFile; fi" >/dev/null
-    result=$?
-  fi
-  
-  return $result  
-}
-
-copy_vm_data_file() {
-  local domrIp=$1
-  local vmIp=$2
-  local folder=$3
-  local file=$4
-  local dataFile=$5        
-  
-  dest=/var/www/html/$folder/$vmIp/$file
-  metamanifest=/var/www/html/$folder/$vmIp/meta-data
-  scp -P $PORT -o StrictHostKeyChecking=no -i $cert $dataFile root@$domrIp:$dest >/dev/null
-  ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "chmod 644 $dest" > /dev/null
-  ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "touch $metamanifest; chmod
644 $metamanifest" > /dev/null
-  if [ "$folder" == "metadata" ] || [ "$folder" == "meta-data" ]
-  then
-    ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "sed -i '/$file/d' $metamanifest;
echo $file >> $metamanifest" > /dev/null
-  fi
-  
-  return $?
-}
-
-delete_vm_data_file() {
-  local domrIp=$1
-  local vmIp=$2
-  local folder=$3
-  local file=$4
-  
-  vmDataFilePath="/var/www/html/$folder/$vmIp/$file"
-  ssh -p $PORT -o StrictHostKeyChecking=no -i $cert root@$domrIp "if [ -f $vmDataFilePath
]; then rm -rf $vmDataFilePath; fi" >/dev/null
-  return $?
-}
-
-domrIp=
-vmIp=
-folder=
-file=
-dataFile=
-
-while getopts 'r:v:F:f:d:' OPTION
-do
-  case $OPTION in
-  r)	domrIp="$OPTARG"
-		;;
-  v)	vmIp="$OPTARG"
-		;;
-  F)	folder="$OPTARG"
-  		;;
-  f)	file="$OPTARG"
-  		;;
-  d)	dataFile="$OPTARG"
-  		;;
-  ?)    usage
-		exit 1
-		;;
-  esac
-done
-
-[ "$domrIp" == "" ] || [ "$vmIp" == "" ]  || [ "$folder" == "" ] || [ "$file" == "" ] &&
usage 
-[ "$folder" != "userdata" ] && [ "$folder" != "metadata" ] && usage
-
-if [ "$dataFile" != "" ]
-then
-  create_htaccess $domrIp $vmIp $folder $file
-  
-  if [ $? -gt 0 ]
-  then
-    exit 1
-  fi
-  
-  copy_vm_data_file $domrIp $vmIp $folder $file $dataFile
-else
-  delete_vm_data_file $domrIp $vmIp $folder $file
-fi
-
-exit $?

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/vm/hypervisor/xenserver/vmops
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops
index ff33c2d..928d0af 100755
--- a/scripts/vm/hypervisor/xenserver/vmops
+++ b/scripts/vm/hypervisor/xenserver/vmops
@@ -168,55 +168,6 @@ def pingxenserver(session, args):
     txt = 'success'
     return txt
 
-@echo
-def vm_data(session, args):
-    router_ip = args.pop('routerIP')
-    vm_ip = args.pop('vmIP')
-
-    util.SMlog("    adding vmdata for VM with IP: " + vm_ip + " to router with IP: " + router_ip)
-
-    for pair in args:
-        pairList = pair.split(',')
-        vmDataFolder = pairList[0]
-        vmDataFile = pairList[1]
-        vmDataValue = args[pair]
-        cmd = ["/bin/bash", "/opt/xensource/bin/vm_data.sh", "-r", router_ip, "-v", vm_ip,
"-F", vmDataFolder, "-f", vmDataFile]
-        
-        fd = None
-        tmp_path = None
-        
-        try:
-            fd,tmp_path = tempfile.mkstemp()
-            tmpfile = open(tmp_path, 'w')
-
-            if vmDataFolder == "userdata" and vmDataValue != "none":
-                vmDataValue = base64.urlsafe_b64decode(vmDataValue)
-                
-            if vmDataValue != "none":
-                tmpfile.write(vmDataValue)
-                
-            tmpfile.close()
-            cmd.append("-d")
-            cmd.append(tmp_path)
-        except:
-             util.SMlog("  vmdata failed to write tempfile "  )
-             os.close(fd)
-             os.remove(tmp_path)
-             return ''
-
-        try:
-            txt = util.pread2(cmd)
-            txt = 'success'
-        except:
-            util.SMlog("    vmdata failed with folder: " + vmDataFolder + " and file: " +
vmDataFile)
-            txt = ''
-
-        if (fd != None):
-            os.close(fd)
-            os.remove(tmp_path)
-
-    return txt
-
 def pingtest(session, args):
     sargs = args['args']
     cmd = sargs.split(' ')
@@ -1714,7 +1665,7 @@ if __name__ == "__main__":
      XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats":
gethostvmstats, 
                             "getvncport": getvncport, "getgateway": getgateway, "preparemigration":
preparemigration, 
                             "setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver":
pingxenserver,  
-                            "vm_data": vm_data, "savePassword": savePassword, 
+                            "savePassword": savePassword, 
                             "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule,
"routerProxy": routerProxy, 
                             "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile,
"deleteFile": deleteFile, 
                             "network_rules":network_rules, 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/vm/hypervisor/xenserver/xcposs/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xcposs/patch b/scripts/vm/hypervisor/xenserver/xcposs/patch
index 4d07c76..6e1002e 100644
--- a/scripts/vm/hypervisor/xenserver/xcposs/patch
+++ b/scripts/vm/hypervisor/xenserver/xcposs/patch
@@ -41,7 +41,6 @@ setup_iscsi.sh=..,0755,/usr/lib/xcp/bin
 pingtest.sh=../../..,0755,/usr/lib/xcp/bin
 dhcp_entry.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin
 ipassoc.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin
-vm_data.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin
 save_password_to_domr.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin
 networkUsage.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin
 call_firewall.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/vm/hypervisor/xenserver/xcposs/vmops
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xcposs/vmops b/scripts/vm/hypervisor/xenserver/xcposs/vmops
index 52625e1..6846e81 100644
--- a/scripts/vm/hypervisor/xenserver/xcposs/vmops
+++ b/scripts/vm/hypervisor/xenserver/xcposs/vmops
@@ -171,55 +171,6 @@ def ipassoc(session, args):
 
     return txt
 
-@echo
-def vm_data(session, args):
-    router_ip = args.pop('routerIP')
-    vm_ip = args.pop('vmIP')
-
-    util.SMlog("    adding vmdata for VM with IP: " + vm_ip + " to router with IP: " + router_ip)
-
-    for pair in args:
-        pairList = pair.split(',')
-        vmDataFolder = pairList[0]
-        vmDataFile = pairList[1]
-        vmDataValue = args[pair]
-        cmd = ["/bin/bash", "/usr/lib/xcp/bin/vm_data.sh", "-r", router_ip, "-v", vm_ip,
"-F", vmDataFolder, "-f", vmDataFile]
-        
-        fd = None
-        tmp_path = None
-        
-        try:
-            fd,tmp_path = tempfile.mkstemp()
-            tmpfile = open(tmp_path, 'w')
-
-            if vmDataFolder == "userdata" and vmDataValue != "none":
-                vmDataValue = base64.urlsafe_b64decode(vmDataValue)
-                
-            if vmDataValue != "none":
-                tmpfile.write(vmDataValue)
-                
-            tmpfile.close()
-            cmd.append("-d")
-            cmd.append(tmp_path)
-        except:
-             util.SMlog("  vmdata failed to write tempfile "  )
-             os.close(fd)
-             os.remove(tmp_path)
-             return ''
-
-        try:
-            txt = util.pread2(cmd)
-            txt = 'success'
-        except:
-            util.SMlog("    vmdata failed with folder: " + vmDataFolder + " and file: " +
vmDataFile)
-            txt = ''
-
-        if (fd != None):
-            os.close(fd)
-            os.remove(tmp_path)
-
-    return txt
-
 def pingtest(session, args):
     sargs = args['args']
     cmd = sargs.split(' ')
@@ -1549,7 +1500,7 @@ if __name__ == "__main__":
      XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats":
gethostvmstats, 
                             "getvncport": getvncport, "getgateway": getgateway, "preparemigration":
preparemigration, 
                             "setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver":
pingxenserver,  
-                            "ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword,

+                            "ipassoc": ipassoc, "savePassword": savePassword, 
                             "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule,

                             "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile,
"deleteFile": deleteFile, 
                             "networkUsage": networkUsage, "network_rules":network_rules,


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/vm/hypervisor/xenserver/xcpserver/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xcpserver/patch b/scripts/vm/hypervisor/xenserver/xcpserver/patch
index 7e92d5a..443abc1 100644
--- a/scripts/vm/hypervisor/xenserver/xcpserver/patch
+++ b/scripts/vm/hypervisor/xenserver/xcpserver/patch
@@ -43,7 +43,6 @@ dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
 createipAlias.sh=..,0755,/opt/xensource/bin
 deleteipAlias.sh=..,0755,/opt/xensource/bin
 router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin
-vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
 save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/vm/hypervisor/xenserver/xenserver56/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch
index 8abd6b2..87b3937 100644
--- a/scripts/vm/hypervisor/xenserver/xenserver56/patch
+++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch
@@ -41,7 +41,6 @@ pingtest.sh=../../..,0755,/opt/xensource/bin
 createipAlias.sh=..,0755,/opt/xensource/bin
 deleteipAlias.sh=..,0755,/opt/xensource/bin
 dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
-vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
 save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
index 901f6de..6dc9b05 100644
--- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
+++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
@@ -40,7 +40,6 @@ pingtest.sh=../../..,0755,/opt/xensource/bin
 createipAlias.sh=..,0755,/opt/xensource/bin
 deleteipAlias.sh=..,0755,/opt/xensource/bin
 dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
-vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
 save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2fd3e2/scripts/vm/hypervisor/xenserver/xenserver60/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/patch b/scripts/vm/hypervisor/xenserver/xenserver60/patch
index d7da374..60a0643 100644
--- a/scripts/vm/hypervisor/xenserver/xenserver60/patch
+++ b/scripts/vm/hypervisor/xenserver/xenserver60/patch
@@ -45,7 +45,6 @@ deleteipAlias.sh=..,0755,/opt/xensource/bin
 setup_iscsi.sh=..,0755,/opt/xensource/bin
 pingtest.sh=../../..,0755,/opt/xensource/bin
 dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
-vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin
 save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_firewall.sh=../../../../network/domr/,0755,/opt/xensource/bin
 call_loadbalancer.sh=../../../../network/domr/,0755,/opt/xensource/bin


Mime
View raw message