cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [8/8] git commit: updated refs/heads/4.2-workplace to 5d13a07
Date Fri, 15 Nov 2013 18:24:44 GMT
Python can't have - so it has to be _


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

Branch: refs/heads/4.2-workplace
Commit: 5d13a07db819ea18645a65b7da1d4ada9dd2fd1f
Parents: f2bb1ac
Author: Alex Huang <alex.huang@citrix.com>
Authored: Fri Nov 15 10:23:15 2013 -0800
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Fri Nov 15 10:23:15 2013 -0800

----------------------------------------------------------------------
 .../xen/resource/CitrixResourceBase.java        |   5 +-
 .../hypervisor/xenserver/cloud-plugin-generic   |   2 +-
 .../vm/hypervisor/xenserver/cloud-plugin-lib.py | 221 ---------------
 .../hypervisor/xenserver/cloud-plugin-ovs-pvlan |   2 +-
 .../hypervisor/xenserver/cloud-plugin-snapshot  |   2 +-
 .../vm/hypervisor/xenserver/cloud_plugin_lib.py | 221 +++++++++++++++
 .../vm/hypervisor/xenserver/ovs-vif-flows.py    |   2 +-
 .../hypervisor/xenserver/xenserver60/NFSSR.py   | 282 -------------------
 .../vm/hypervisor/xenserver/xenserver60/patch   |   3 +-
 .../vm/hypervisor/xenserver/xenserver62/patch   |   2 +-
 10 files changed, 230 insertions(+), 512 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/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 c27df61..e6453df 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
@@ -5179,10 +5179,11 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
 
                 com.trilead.ssh2.Session session = sshConnection.openSession();
                 
-                String cmd = "mkdir -p /opt/cloudstack/bin";
+                String cmd = "mkdir -p /opt/cloud/bin; mkdir -p /opt/cloud/tools; mkdir -p
/var/log/cloud; mkdir -p /etc/cloud";
                 if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
-                    throw new CloudRuntimeException("Cannot create directory /opt/cloudstack/bin
on XenServer hosts");
+                    throw new CloudRuntimeException("Cannot create directory /opt/cloud/bin
on XenServer hosts");
                 }
+
                 SCPClient scp = new SCPClient(sshConnection);
 
                 List<File> files = getPatchFiles();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/cloud-plugin-generic
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/cloud-plugin-generic b/scripts/vm/hypervisor/xenserver/cloud-plugin-generic
index 32c03de..16f2a50 100644
--- a/scripts/vm/hypervisor/xenserver/cloud-plugin-generic
+++ b/scripts/vm/hypervisor/xenserver/cloud-plugin-generic
@@ -30,7 +30,7 @@ import tempfile
 import util
 import subprocess
 import zlib
-import cloud-plugin-lib as lib
+import cloud_plugin_lib as lib
 import logging
 from util import CommandException
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/cloud-plugin-lib.py
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/cloud-plugin-lib.py b/scripts/vm/hypervisor/xenserver/cloud-plugin-lib.py
deleted file mode 100644
index 6b17d0b..0000000
--- a/scripts/vm/hypervisor/xenserver/cloud-plugin-lib.py
+++ /dev/null
@@ -1,221 +0,0 @@
-# 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.
-
-# Common function for Cloudstack's XenAPI plugins
-
-import ConfigParser
-import logging
-import os
-import subprocess
-
-from time import localtime, asctime
-
-DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
-DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
-DEFAULT_LOG_FILE = "/var/log/cloud/cloud-plugins.log"
-
-PLUGIN_CONFIG_PATH = "/etc/cloud/cloud-plugins.conf"
-OVSDB_PID_PATH = "/var/run/openvswitch/ovsdb-server.pid"
-OVSDB_DAEMON_PATH = "ovsdb-server"
-OVS_PID_PATH = "/var/run/openvswitch/ovs-vswitchd.pid"
-OVS_DAEMON_PATH = "ovs-vswitchd"
-VSCTL_PATH = "/usr/bin/ovs-vsctl"
-OFCTL_PATH = "/usr/bin/ovs-ofctl"
-XE_PATH = "/opt/xensource/bin/xe"
-
-
-class PluginError(Exception):
-    """Base Exception class for all plugin errors."""
-    def __init__(self, *args):
-        Exception.__init__(self, *args)
-
-
-def setup_logging(log_file=None):
-    debug = False
-    verbose = False
-    log_format = DEFAULT_LOG_FORMAT
-    log_date_format = DEFAULT_LOG_DATE_FORMAT
-    # try to read plugin configuration file
-    if os.path.exists(PLUGIN_CONFIG_PATH):
-        config = ConfigParser.ConfigParser()
-        config.read(PLUGIN_CONFIG_PATH)
-        try:
-            options = config.options('LOGGING')
-            if 'debug' in options:
-                debug = config.getboolean('LOGGING', 'debug')
-            if 'verbose' in options:
-                verbose = config.getboolean('LOGGING', 'verbose')
-            if 'format' in options:
-                log_format = config.get('LOGGING', 'format')
-            if 'date_format' in options:
-                log_date_format = config.get('LOGGING', 'date_format')
-            if 'file' in options:
-                log_file_2 = config.get('LOGGING', 'file')
-        except ValueError:
-            # configuration file contained invalid attributes
-            # ignore them
-            pass
-        except ConfigParser.NoSectionError:
-            # Missing 'Logging' section in configuration file
-            pass
-
-    root_logger = logging.root
-    if debug:
-        root_logger.setLevel(logging.DEBUG)
-    elif verbose:
-        root_logger.setLevel(logging.INFO)
-    else:
-        root_logger.setLevel(logging.WARNING)
-    formatter = logging.Formatter(log_format, log_date_format)
-
-    log_filename = log_file or log_file_2 or DEFAULT_LOG_FILE
-
-    logfile_handler = logging.FileHandler(log_filename)
-    logfile_handler.setFormatter(formatter)
-    root_logger.addHandler(logfile_handler)
-
-
-def do_cmd(cmd):
-    """Abstracts out the basics of issuing system commands. If the command
-    returns anything in stderr, a PluginError is raised with that information.
-    Otherwise, the output from stdout is returned.
-    """
-
-    pipe = subprocess.PIPE
-    logging.debug("Executing:%s", cmd)
-    proc = subprocess.Popen(cmd, shell=False, stdin=pipe, stdout=pipe,
-                            stderr=pipe, close_fds=True)
-    ret_code = proc.wait()
-    err = proc.stderr.read()
-    if ret_code:
-        logging.debug("The command exited with the error code: " +
-                      "%s (stderr output:%s)" % (ret_code, err))
-        raise PluginError(err)
-    output = proc.stdout.read()
-    if output.endswith('\n'):
-        output = output[:-1]
-    return output
-
-
-def _is_process_run(pidFile, name):
-    try:
-        fpid = open(pidFile, "r")
-        pid = fpid.readline()
-        fpid.close()
-    except IOError, e:
-        return -1
-
-    pid = pid[:-1]
-    ps = os.popen("ps -ae")
-    for l in ps:
-        if pid in l and name in l:
-            ps.close()
-            return 0
-
-    ps.close()
-    return -2
-
-
-def _is_tool_exist(name):
-    if os.path.exists(name):
-        return 0
-    return -1
-
-
-def check_switch():
-    global result
-
-    ret = _is_process_run(OVSDB_PID_PATH, OVSDB_DAEMON_PATH)
-    if ret < 0:
-        if ret == -1:
-            return "NO_DB_PID_FILE"
-        if ret == -2:
-            return "DB_NOT_RUN"
-
-    ret = _is_process_run(OVS_PID_PATH, OVS_DAEMON_PATH)
-    if ret < 0:
-        if ret == -1:
-            return "NO_SWITCH_PID_FILE"
-        if ret == -2:
-            return "SWITCH_NOT_RUN"
-
-    if _is_tool_exist(VSCTL_PATH) < 0:
-        return "NO_VSCTL"
-
-    if _is_tool_exist(OFCTL_PATH) < 0:
-        return "NO_OFCTL"
-
-    return "SUCCESS"
-
-
-def _build_flow_expr(**kwargs):
-    is_delete_expr = kwargs.get('delete', False)
-    flow = ""
-    if not is_delete_expr:
-        flow = "hard_timeout=%s,idle_timeout=%s,priority=%s"\
-                % (kwargs.get('hard_timeout', '0'),
-                   kwargs.get('idle_timeout', '0'),
-                   kwargs.get('priority', '1'))
-    in_port = 'in_port' in kwargs and ",in_port=%s" % kwargs['in_port'] or ''
-    dl_type = 'dl_type' in kwargs and ",dl_type=%s" % kwargs['dl_type'] or ''
-    dl_src = 'dl_src' in kwargs and ",dl_src=%s" % kwargs['dl_src'] or ''
-    dl_dst = 'dl_dst' in kwargs and ",dl_dst=%s" % kwargs['dl_dst'] or ''
-    nw_src = 'nw_src' in kwargs and ",nw_src=%s" % kwargs['nw_src'] or ''
-    nw_dst = 'nw_dst' in kwargs and ",nw_dst=%s" % kwargs['nw_dst'] or ''
-    proto = 'proto' in kwargs and ",%s" % kwargs['proto'] or ''
-    ip = ('nw_src' in kwargs or 'nw_dst' in kwargs) and ',ip' or ''
-    flow = (flow + in_port + dl_type + dl_src + dl_dst +
-            (ip or proto) + nw_src + nw_dst)
-    return flow
-
-
-def add_flow(bridge, **kwargs):
-    """
-    Builds a flow expression for **kwargs and adds the flow entry
-    to an Open vSwitch instance
-    """
-    flow = _build_flow_expr(**kwargs)
-    actions = 'actions' in kwargs and ",actions=%s" % kwargs['actions'] or ''
-    flow = flow + actions
-    addflow = [OFCTL_PATH, "add-flow", bridge, flow]
-    do_cmd(addflow)
-
-
-def del_flows(bridge, **kwargs):
-    """
-    Removes flows according to criteria passed as keyword.
-    """
-    flow = _build_flow_expr(delete=True, **kwargs)
-    # out_port condition does not exist for all flow commands
-    out_port = ("out_port" in kwargs and
-                ",out_port=%s" % kwargs['out_port'] or '')
-    flow = flow + out_port
-    delFlow = [OFCTL_PATH, 'del-flows', bridge, flow]
-    do_cmd(delFlow)
-
-
-def del_all_flows(bridge):
-    delFlow = [OFCTL_PATH, "del-flows", bridge]
-    do_cmd(delFlow)
-
-    normalFlow = "priority=0 idle_timeout=0 hard_timeout=0 actions=normal"
-    add_flow(bridge, normalFlow)
-
-
-def del_port(bridge, port):
-    delPort = [VSCTL_PATH, "del-port", bridge, port]
-    do_cmd(delPort)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/cloud-plugin-ovs-pvlan
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/cloud-plugin-ovs-pvlan b/scripts/vm/hypervisor/xenserver/cloud-plugin-ovs-pvlan
index 32eb794..a3b7067 100644
--- a/scripts/vm/hypervisor/xenserver/cloud-plugin-ovs-pvlan
+++ b/scripts/vm/hypervisor/xenserver/cloud-plugin-ovs-pvlan
@@ -17,7 +17,7 @@
 # under the License.
 
 
-import cloud-plugin-lib as lib
+import cloud_plugin_lib as lib
 import logging
 import os
 import sys

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/cloud-plugin-snapshot
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/cloud-plugin-snapshot b/scripts/vm/hypervisor/xenserver/cloud-plugin-snapshot
index 7ad892d..ae2f9aa 100644
--- a/scripts/vm/hypervisor/xenserver/cloud-plugin-snapshot
+++ b/scripts/vm/hypervisor/xenserver/cloud-plugin-snapshot
@@ -34,7 +34,7 @@ import xs_errors
 import cleanup
 import stat
 import random
-import cloud-plugin-lib as lib
+import cloud_plugin_lib as lib
 import logging
 
 lib.setup_logging("/var/log/cloud/cloud-plugins.log")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/cloud_plugin_lib.py
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/cloud_plugin_lib.py b/scripts/vm/hypervisor/xenserver/cloud_plugin_lib.py
new file mode 100644
index 0000000..6b17d0b
--- /dev/null
+++ b/scripts/vm/hypervisor/xenserver/cloud_plugin_lib.py
@@ -0,0 +1,221 @@
+# 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.
+
+# Common function for Cloudstack's XenAPI plugins
+
+import ConfigParser
+import logging
+import os
+import subprocess
+
+from time import localtime, asctime
+
+DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
+DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
+DEFAULT_LOG_FILE = "/var/log/cloud/cloud-plugins.log"
+
+PLUGIN_CONFIG_PATH = "/etc/cloud/cloud-plugins.conf"
+OVSDB_PID_PATH = "/var/run/openvswitch/ovsdb-server.pid"
+OVSDB_DAEMON_PATH = "ovsdb-server"
+OVS_PID_PATH = "/var/run/openvswitch/ovs-vswitchd.pid"
+OVS_DAEMON_PATH = "ovs-vswitchd"
+VSCTL_PATH = "/usr/bin/ovs-vsctl"
+OFCTL_PATH = "/usr/bin/ovs-ofctl"
+XE_PATH = "/opt/xensource/bin/xe"
+
+
+class PluginError(Exception):
+    """Base Exception class for all plugin errors."""
+    def __init__(self, *args):
+        Exception.__init__(self, *args)
+
+
+def setup_logging(log_file=None):
+    debug = False
+    verbose = False
+    log_format = DEFAULT_LOG_FORMAT
+    log_date_format = DEFAULT_LOG_DATE_FORMAT
+    # try to read plugin configuration file
+    if os.path.exists(PLUGIN_CONFIG_PATH):
+        config = ConfigParser.ConfigParser()
+        config.read(PLUGIN_CONFIG_PATH)
+        try:
+            options = config.options('LOGGING')
+            if 'debug' in options:
+                debug = config.getboolean('LOGGING', 'debug')
+            if 'verbose' in options:
+                verbose = config.getboolean('LOGGING', 'verbose')
+            if 'format' in options:
+                log_format = config.get('LOGGING', 'format')
+            if 'date_format' in options:
+                log_date_format = config.get('LOGGING', 'date_format')
+            if 'file' in options:
+                log_file_2 = config.get('LOGGING', 'file')
+        except ValueError:
+            # configuration file contained invalid attributes
+            # ignore them
+            pass
+        except ConfigParser.NoSectionError:
+            # Missing 'Logging' section in configuration file
+            pass
+
+    root_logger = logging.root
+    if debug:
+        root_logger.setLevel(logging.DEBUG)
+    elif verbose:
+        root_logger.setLevel(logging.INFO)
+    else:
+        root_logger.setLevel(logging.WARNING)
+    formatter = logging.Formatter(log_format, log_date_format)
+
+    log_filename = log_file or log_file_2 or DEFAULT_LOG_FILE
+
+    logfile_handler = logging.FileHandler(log_filename)
+    logfile_handler.setFormatter(formatter)
+    root_logger.addHandler(logfile_handler)
+
+
+def do_cmd(cmd):
+    """Abstracts out the basics of issuing system commands. If the command
+    returns anything in stderr, a PluginError is raised with that information.
+    Otherwise, the output from stdout is returned.
+    """
+
+    pipe = subprocess.PIPE
+    logging.debug("Executing:%s", cmd)
+    proc = subprocess.Popen(cmd, shell=False, stdin=pipe, stdout=pipe,
+                            stderr=pipe, close_fds=True)
+    ret_code = proc.wait()
+    err = proc.stderr.read()
+    if ret_code:
+        logging.debug("The command exited with the error code: " +
+                      "%s (stderr output:%s)" % (ret_code, err))
+        raise PluginError(err)
+    output = proc.stdout.read()
+    if output.endswith('\n'):
+        output = output[:-1]
+    return output
+
+
+def _is_process_run(pidFile, name):
+    try:
+        fpid = open(pidFile, "r")
+        pid = fpid.readline()
+        fpid.close()
+    except IOError, e:
+        return -1
+
+    pid = pid[:-1]
+    ps = os.popen("ps -ae")
+    for l in ps:
+        if pid in l and name in l:
+            ps.close()
+            return 0
+
+    ps.close()
+    return -2
+
+
+def _is_tool_exist(name):
+    if os.path.exists(name):
+        return 0
+    return -1
+
+
+def check_switch():
+    global result
+
+    ret = _is_process_run(OVSDB_PID_PATH, OVSDB_DAEMON_PATH)
+    if ret < 0:
+        if ret == -1:
+            return "NO_DB_PID_FILE"
+        if ret == -2:
+            return "DB_NOT_RUN"
+
+    ret = _is_process_run(OVS_PID_PATH, OVS_DAEMON_PATH)
+    if ret < 0:
+        if ret == -1:
+            return "NO_SWITCH_PID_FILE"
+        if ret == -2:
+            return "SWITCH_NOT_RUN"
+
+    if _is_tool_exist(VSCTL_PATH) < 0:
+        return "NO_VSCTL"
+
+    if _is_tool_exist(OFCTL_PATH) < 0:
+        return "NO_OFCTL"
+
+    return "SUCCESS"
+
+
+def _build_flow_expr(**kwargs):
+    is_delete_expr = kwargs.get('delete', False)
+    flow = ""
+    if not is_delete_expr:
+        flow = "hard_timeout=%s,idle_timeout=%s,priority=%s"\
+                % (kwargs.get('hard_timeout', '0'),
+                   kwargs.get('idle_timeout', '0'),
+                   kwargs.get('priority', '1'))
+    in_port = 'in_port' in kwargs and ",in_port=%s" % kwargs['in_port'] or ''
+    dl_type = 'dl_type' in kwargs and ",dl_type=%s" % kwargs['dl_type'] or ''
+    dl_src = 'dl_src' in kwargs and ",dl_src=%s" % kwargs['dl_src'] or ''
+    dl_dst = 'dl_dst' in kwargs and ",dl_dst=%s" % kwargs['dl_dst'] or ''
+    nw_src = 'nw_src' in kwargs and ",nw_src=%s" % kwargs['nw_src'] or ''
+    nw_dst = 'nw_dst' in kwargs and ",nw_dst=%s" % kwargs['nw_dst'] or ''
+    proto = 'proto' in kwargs and ",%s" % kwargs['proto'] or ''
+    ip = ('nw_src' in kwargs or 'nw_dst' in kwargs) and ',ip' or ''
+    flow = (flow + in_port + dl_type + dl_src + dl_dst +
+            (ip or proto) + nw_src + nw_dst)
+    return flow
+
+
+def add_flow(bridge, **kwargs):
+    """
+    Builds a flow expression for **kwargs and adds the flow entry
+    to an Open vSwitch instance
+    """
+    flow = _build_flow_expr(**kwargs)
+    actions = 'actions' in kwargs and ",actions=%s" % kwargs['actions'] or ''
+    flow = flow + actions
+    addflow = [OFCTL_PATH, "add-flow", bridge, flow]
+    do_cmd(addflow)
+
+
+def del_flows(bridge, **kwargs):
+    """
+    Removes flows according to criteria passed as keyword.
+    """
+    flow = _build_flow_expr(delete=True, **kwargs)
+    # out_port condition does not exist for all flow commands
+    out_port = ("out_port" in kwargs and
+                ",out_port=%s" % kwargs['out_port'] or '')
+    flow = flow + out_port
+    delFlow = [OFCTL_PATH, 'del-flows', bridge, flow]
+    do_cmd(delFlow)
+
+
+def del_all_flows(bridge):
+    delFlow = [OFCTL_PATH, "del-flows", bridge]
+    do_cmd(delFlow)
+
+    normalFlow = "priority=0 idle_timeout=0 hard_timeout=0 actions=normal"
+    add_flow(bridge, normalFlow)
+
+
+def del_port(bridge, port):
+    delPort = [VSCTL_PATH, "del-port", bridge, port]
+    do_cmd(delPort)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/ovs-vif-flows.py
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/ovs-vif-flows.py b/scripts/vm/hypervisor/xenserver/ovs-vif-flows.py
index 58e0a3d..59e9ad3 100644
--- a/scripts/vm/hypervisor/xenserver/ovs-vif-flows.py
+++ b/scripts/vm/hypervisor/xenserver/ovs-vif-flows.py
@@ -21,7 +21,7 @@
 import os
 import sys
 
-import cloud-plugin-lib as pluginlib
+import cloud_plugin_lib as pluginlib
 
 
 def clear_flows(bridge, this_vif_ofport, vif_ofports):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py b/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py
deleted file mode 100755
index 0d6badb..0000000
--- a/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py
+++ /dev/null
@@ -1,282 +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.
-
-# FileSR: local-file storage repository
-
-import SR, VDI, SRCommand, FileSR, util
-import errno
-import os, re, sys
-import xml.dom.minidom
-import xmlrpclib
-import xs_errors
-import nfs
-import vhdutil
-from lock import Lock
-import cleanup
-
-CAPABILITIES = ["SR_PROBE","SR_UPDATE", "SR_CACHING",
-                "VDI_CREATE","VDI_DELETE","VDI_ATTACH","VDI_DETACH",
-                "VDI_UPDATE", "VDI_CLONE","VDI_SNAPSHOT","VDI_RESIZE",
-                "VDI_GENERATE_CONFIG",
-                "VDI_RESET_ON_BOOT", "ATOMIC_PAUSE"]
-
-CONFIGURATION = [ [ 'server', 'hostname or IP address of NFS server (required)' ], \
-                  [ 'serverpath', 'path on remote server (required)' ] ]
-
-                  
-DRIVER_INFO = {
-    'name': 'NFS VHD',
-    'description': 'SR plugin which stores disks as VHD files on a remote NFS filesystem',
-    'vendor': 'The Apache Software Foundation',
-    'copyright': 'Copyright (c) 2012 The Apache Software Foundation',
-    'driver_version': '1.0',
-    'required_api_version': '1.0',
-    'capabilities': CAPABILITIES,
-    'configuration': CONFIGURATION
-    }
-
-DRIVER_CONFIG = {"ATTACH_FROM_CONFIG_WITH_TAPDISK": True}
-
-
-# The mountpoint for the directory when performing an sr_probe.  All probes
-# are guaranteed to be serialised by xapi, so this single mountpoint is fine.
-PROBE_MOUNTPOINT = "probe"
-NFSPORT = 2049
-DEFAULT_TRANSPORT = "tcp"
-
-
-class NFSSR(FileSR.FileSR):
-    """NFS file-based storage repository"""
-    def handles(type):
-        return type == 'nfs'
-    handles = staticmethod(handles)
-
-
-    def load(self, sr_uuid):
-        self.ops_exclusive = FileSR.OPS_EXCLUSIVE
-        self.lock = Lock(vhdutil.LOCK_TYPE_SR, self.uuid)
-        self.sr_vditype = SR.DEFAULT_TAP
-        self.driver_config = DRIVER_CONFIG
-        if not self.dconf.has_key('server'):
-            raise xs_errors.XenError('ConfigServerMissing')
-        self.remoteserver = self.dconf['server']
-        self.path = os.path.join(SR.MOUNT_BASE, sr_uuid)
-
-        # Test for the optional 'nfsoptions' dconf attribute
-        self.transport = DEFAULT_TRANSPORT
-        if self.dconf.has_key('useUDP') and self.dconf['useUDP'] == 'true':
-            self.transport = "udp"
-
-
-    def validate_remotepath(self, scan):
-        if not self.dconf.has_key('serverpath'):
-            if scan:
-                try:
-                    self.scan_exports(self.dconf['server'])
-                except:
-                    pass
-            raise xs_errors.XenError('ConfigServerPathMissing')
-        if not self._isvalidpathstring(self.dconf['serverpath']):
-            raise xs_errors.XenError('ConfigServerPathBad', \
-                  opterr='serverpath is %s' % self.dconf['serverpath'])
-
-    def check_server(self):
-        try:
-            nfs.check_server_tcp(self.remoteserver)
-        except nfs.NfsException, exc:
-            raise xs_errors.XenError('NFSVersion',
-                                     opterr=exc.errstr)
-
-
-    def mount(self, mountpoint, remotepath):
-        try:
-            nfs.soft_mount(mountpoint, self.remoteserver, remotepath, self.transport)
-        except nfs.NfsException, exc:
-            raise xs_errors.XenError('NFSMount', opterr=exc.errstr)
-
-
-    def attach(self, sr_uuid):
-        self.validate_remotepath(False)
-        #self.remotepath = os.path.join(self.dconf['serverpath'], sr_uuid)
-        self.remotepath = self.dconf['serverpath']
-        util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
-        self.mount_remotepath(sr_uuid)
-
-
-    def mount_remotepath(self, sr_uuid):
-        if not self._checkmount():
-            self.check_server()
-            self.mount(self.path, self.remotepath)
-
-        return super(NFSSR, self).attach(sr_uuid)
-
-
-    def probe(self):
-        # Verify NFS target and port
-        util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
-        
-        self.validate_remotepath(True)
-        self.check_server()
-
-        temppath = os.path.join(SR.MOUNT_BASE, PROBE_MOUNTPOINT)
-
-        self.mount(temppath, self.dconf['serverpath'])
-        try:
-            return nfs.scan_srlist(temppath)
-        finally:
-            try:
-                nfs.unmount(temppath, True)
-            except:
-                pass
-
-
-    def detach(self, sr_uuid):
-        """Detach the SR: Unmounts and removes the mountpoint"""
-        if not self._checkmount():
-            return
-        util.SMlog("Aborting GC/coalesce")
-        cleanup.abort(self.uuid)
-
-        # Change directory to avoid unmount conflicts
-        os.chdir(SR.MOUNT_BASE)
-
-        try:
-            nfs.unmount(self.path, True)
-        except nfs.NfsException, exc:
-            raise xs_errors.XenError('NFSUnMount', opterr=exc.errstr)
-
-        return super(NFSSR, self).detach(sr_uuid)
-        
-
-    def create(self, sr_uuid, size):
-        util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
-        self.validate_remotepath(True)
-        if self._checkmount():
-            raise xs_errors.XenError('NFSAttached')
-
-        # Set the target path temporarily to the base dir
-        # so that we can create the target SR directory
-        self.remotepath = self.dconf['serverpath']
-        try:
-            self.mount_remotepath(sr_uuid)
-        except Exception, exn:
-            try:
-                os.rmdir(self.path)
-            except:
-                pass
-            raise exn
-
-        #newpath = os.path.join(self.path, sr_uuid)
-        #if util.ioretry(lambda: util.pathexists(newpath)):
-        #    if len(util.ioretry(lambda: util.listdir(newpath))) != 0:
-        #        self.detach(sr_uuid)
-        #        raise xs_errors.XenError('SRExists')
-        #else:
-        #    try:
-        #        util.ioretry(lambda: util.makedirs(newpath))
-        #    except util.CommandException, inst:
-        #        if inst.code != errno.EEXIST:
-        #            self.detach(sr_uuid)
-        #            raise xs_errors.XenError('NFSCreate', 
-        #                opterr='remote directory creation error is %d' 
-        #                % inst.code)
-        self.detach(sr_uuid)
-
-    def delete(self, sr_uuid):
-        # try to remove/delete non VDI contents first
-        super(NFSSR, self).delete(sr_uuid)
-        try:
-            if self._checkmount():
-                self.detach(sr_uuid)
-
-            # Set the target path temporarily to the base dir
-            # so that we can remove the target SR directory
-            self.remotepath = self.dconf['serverpath']
-            self.mount_remotepath(sr_uuid)
-            newpath = os.path.join(self.path, sr_uuid)
-
-            if util.ioretry(lambda: util.pathexists(newpath)):
-                util.ioretry(lambda: os.rmdir(newpath))
-            self.detach(sr_uuid)
-        except util.CommandException, inst:
-            self.detach(sr_uuid)
-            if inst.code != errno.ENOENT:
-                raise xs_errors.XenError('NFSDelete')
-
-    def vdi(self, uuid, loadLocked = False):
-        if not loadLocked:
-            return NFSFileVDI(self, uuid)
-        return NFSFileVDI(self, uuid)
-    
-    def _checkmount(self):
-        return util.ioretry(lambda: util.pathexists(self.path)) \
-               and util.ioretry(lambda: util.ismount(self.path))
-
-    def scan_exports(self, target):
-        util.SMlog("scanning2 (target=%s)" % target)
-        dom = nfs.scan_exports(target)
-        print >>sys.stderr,dom.toprettyxml()
-
-class NFSFileVDI(FileSR.FileVDI):
-    def attach(self, sr_uuid, vdi_uuid):
-        if self.sr.srcmd.params.has_key("vdi_ref"):
-            try:
-                vdi_ref = self.sr.srcmd.params['vdi_ref']
-                self.session.xenapi.VDI.remove_from_xenstore_data(vdi_ref, \
-                        "vdi-type")
-                self.session.xenapi.VDI.remove_from_xenstore_data(vdi_ref, \
-                        "storage-type")
-                self.session.xenapi.VDI.add_to_xenstore_data(vdi_ref, \
-                        "storage-type", "nfs")
-            except:
-                util.logException("NFSSR:attach")
-                pass
-
-        return super(NFSFileVDI, self).attach(sr_uuid, vdi_uuid)
-
-    def generate_config(self, sr_uuid, vdi_uuid):
-        util.SMlog("NFSFileVDI.generate_config")
-        if not util.pathexists(self.path):
-                raise xs_errors.XenError('VDIUnavailable')
-        resp = {}
-        resp['device_config'] = self.sr.dconf
-        resp['sr_uuid'] = sr_uuid
-        resp['vdi_uuid'] = vdi_uuid
-        resp['command'] = 'vdi_attach_from_config'
-        # Return the 'config' encoded within a normal XMLRPC response so that
-        # we can use the regular response/error parsing code.
-        config = xmlrpclib.dumps(tuple([resp]), "vdi_attach_from_config")
-        return xmlrpclib.dumps((config,), "", True)
-
-    def attach_from_config(self, sr_uuid, vdi_uuid):
-        """Used for HA State-file only. Will not just attach the VDI but
-        also start a tapdisk on the file"""
-        util.SMlog("NFSFileVDI.attach_from_config")
-        try:
-            if not util.pathexists(self.sr.path):
-                self.sr.attach(sr_uuid)
-        except:
-            util.logException("NFSFileVDI.attach_from_config")
-            raise xs_errors.XenError('SRUnavailable', \
-                        opterr='Unable to attach from config')
-
-
-if __name__ == '__main__':
-    SRCommand.run(NFSSR, DRIVER_INFO)
-else:
-    SR.registerSR(NFSSR)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/xenserver60/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/patch b/scripts/vm/hypervisor/xenserver/xenserver60/patch
index 04fea8f..ba3470e 100644
--- a/scripts/vm/hypervisor/xenserver/xenserver60/patch
+++ b/scripts/vm/hypervisor/xenserver/xenserver60/patch
@@ -35,12 +35,11 @@
 # /etc/logrotate.d - All cloud log rotation configuration files.  Every file placed here
must start with "cloud-".
 #
 # All log files should be placed in /var/log/cloud
-NFSSR.py=/opt/xensource/sm
 cloud-plugin-generic=..,0755,/etc/xapi.d/plugins
 xen-ovs-vif-flows.rules=..,0644,/etc/udev/rules.d
 ovs-vif-flows.py=..,0755,/etc/xapi.d/plugins
 cloud-plugins.conf=..,0644,/etc/xensource
-cloud-plugin-lib.py=..,0755,/etc/xapi.d/plugins
+cloud_plugin_lib.py=..,0755,/etc/xapi.d/plugins
 cloud-plugin-ovstunnel=..,0755,/etc/xapi.d/plugins
 cloud-plugin-snapshot=..,0755,/etc/xapi.d/plugins
 systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d13a07d/scripts/vm/hypervisor/xenserver/xenserver62/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver62/patch b/scripts/vm/hypervisor/xenserver/xenserver62/patch
index e8a4ea2..f32f183 100644
--- a/scripts/vm/hypervisor/xenserver/xenserver62/patch
+++ b/scripts/vm/hypervisor/xenserver/xenserver62/patch
@@ -37,7 +37,7 @@
 cloud-plugin-generic=..,0755,/etc/xapi.d/plugins
 xen-ovs-vif-flows.rules=..,0644,/etc/udev/rules.d
 ovs-vif-flows.py=..,0755,/etc/xapi.d/plugins
-cloud-plugin-lib.py=..,0755,/etc/xapi.d/plugins
+cloud_plugin-lib.py=..,0755,/etc/xapi.d/plugins
 cloud-plugin-ovstunnel=..,0755,/etc/xapi.d/plugins
 cloud-plugin-snapshot=..,0755,/etc/xapi.d/plugins
 cloud-plugin-swiftxen=..,0755,/etc/xapi.d/plugins


Mime
View raw message