public Hashtable runFunc(String function, Vector params) {
    Hashtable h = null;
    Object o = null;
    try {
      System.out.println("RPCClient: running function: " + function);
      o = xmlrpc.execute(function, params);
    } catch (XmlRpcException e) {
      h = new Hashtable();
      h.put("status", "error");
      h.put("error", "Cannot execute XML-RPC query: (" + e.getCause() + ":" + e.toString() + ")");
      return h;
    } catch (IOException e) {
      h = new Hashtable();
      h.put("status", "error");
      h.put("error", "IO Exception executing XML-RPC query: " + e.toString());
      return h;
    }
    if (o == null) {
      h = new Hashtable();
      h.put("status", "error");
      h.put("error", "Object is NULL");
      return h;
    }

    if (!o.getClass().isInstance(new Hashtable())) {
      h = new Hashtable();
      h.put("status", "error");
      h.put("error", "Returned object is not a Hashtable - it is a " + o.getClass().getName());
      return h;
    }
    h = (Hashtable) o;

    if (!h.containsKey("status")) {
      h.put("status", "error");
      h.put("error", "No status in result hash");
      return h;
    }

    String status = (String) h.get("status");
    if (status.equals("error") && !h.containsKey("error")) {
      h.put("error", "Unknown error - no error key found in hash");
    }

    return h;
  }
  @Override
  public Answer execute(
      final PvlanSetupCommand command, final CitrixResourceBase citrixResourceBase) {
    final Connection conn = citrixResourceBase.getConnection();

    final String primaryPvlan = command.getPrimary();
    final String isolatedPvlan = command.getIsolated();
    final String op = command.getOp();
    final String dhcpName = command.getDhcpName();
    final String dhcpMac = command.getDhcpMac();
    final String dhcpIp = command.getDhcpIp();
    final String vmMac = command.getVmMac();
    final String networkTag = command.getNetworkTag();

    String nwNameLabel = null;
    try {
      final XsLocalNetwork nw =
          citrixResourceBase.getNativeNetworkForTraffic(conn, TrafficType.Guest, networkTag);
      if (nw == null) {
        s_logger.error("Network is not configured on the backend for pvlan " + primaryPvlan);
        throw new CloudRuntimeException(
            "Network for the backend is not configured correctly for pvlan primary: "
                + primaryPvlan);
      }
      nwNameLabel = nw.getNetwork().getNameLabel(conn);
    } catch (final XenAPIException e) {
      s_logger.warn("Fail to get network", e);
      return new Answer(command, false, e.toString());
    } catch (final XmlRpcException e) {
      s_logger.warn("Fail to get network", e);
      return new Answer(command, false, e.toString());
    }

    String result = null;
    if (command.getType() == PvlanSetupCommand.Type.DHCP) {
      result =
          citrixResourceBase.callHostPlugin(
              conn,
              "ovs-pvlan",
              "setup-pvlan-dhcp",
              "op",
              op,
              "nw-label",
              nwNameLabel,
              "primary-pvlan",
              primaryPvlan,
              "isolated-pvlan",
              isolatedPvlan,
              "dhcp-name",
              dhcpName,
              "dhcp-ip",
              dhcpIp,
              "dhcp-mac",
              dhcpMac);

      if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
        s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac);
        return new Answer(command, false, result);
      } else {
        s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac);
      }
    } else if (command.getType() == PvlanSetupCommand.Type.VM) {
      result =
          citrixResourceBase.callHostPlugin(
              conn,
              "ovs-pvlan",
              "setup-pvlan-vm",
              "op",
              op,
              "nw-label",
              nwNameLabel,
              "primary-pvlan",
              primaryPvlan,
              "isolated-pvlan",
              isolatedPvlan,
              "vm-mac",
              vmMac);

      if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
        s_logger.warn("Failed to program pvlan for vm with mac " + vmMac);
        return new Answer(command, false, result);
      } else {
        s_logger.info("Programmed pvlan for vm with mac " + vmMac);
      }
    }
    return new Answer(command, true, result);
  }