Package com.cloud.ovm.object

Examples of com.cloud.ovm.object.Connection


  @Override
  public Map<? extends ServerResource, Map<String, String>> find(long dcId,
      Long podId, Long clusterId, URI url, String username,
      String password, List<String> hostTags) throws DiscoveryException {
    Connection conn = null;

    if (!url.getScheme().equals("http")) {
      String msg = "urlString is not http so we're not taking care of the discovery for this: "
          + url;
      s_logger.debug(msg);
      return null;
    }
    if (clusterId == null) {
      String msg = "must specify cluster Id when add host";
      s_logger.debug(msg);
      throw new CloudRuntimeException(msg);
    }

    if (podId == null) {
      String msg = "must specify pod Id when add host";
      s_logger.debug(msg);
      throw new CloudRuntimeException(msg);
    }

    ClusterVO cluster = _clusterDao.findById(clusterId);
    if (cluster == null
        || (cluster.getHypervisorType() != HypervisorType.Ovm)) {
      if (s_logger.isInfoEnabled())
        s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
      return null;
    }

    String agentUsername = _params.get("agentusername");
    if (agentUsername == null) {
      throw new CloudRuntimeException("Agent user name must be specified");
    }

    String agentPassword = _params.get("agentpassword");
    if (agentPassword == null) {
      throw new CloudRuntimeException("Agent password must be specified");
    }

    try {
      String hostname = url.getHost();
      InetAddress ia = InetAddress.getByName(hostname);
      String hostIp = ia.getHostAddress();
      String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();

      if (checkIfExisted(guid)) {
        throw new CloudRuntimeException("The host " + hostIp
            + " has been added before");
      }

      s_logger.debug("Ovm discover is going to disover host having guid "
          + guid);

      ClusterVO clu = _clusterDao.findById(clusterId);
      if (clu.getGuid() == null) {
        clu.setGuid(UUID.randomUUID().toString());
        _clusterDao.update(clusterId, clu);
      }

      com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(
          hostIp, 22);
      sshConnection.connect(null, 60000, 60000);
      sshConnection = SSHCmdHelper.acquireAuthorizedConnection(hostIp,
          username, password);
      if (sshConnection == null) {
        throw new DiscoveryException(
            String.format(
                "Cannot connect to ovm host(IP=%1$s, username=%2$s, password=%3$s, discover failed",
                hostIp, username, password));
      }

      if (!SSHCmdHelper.sshExecuteCmd(sshConnection,
          "[ -f '/etc/ovs-agent/agent.ini' ]")) {
        throw new DiscoveryException(
            "Can not find /etc/ovs-agent/agent.ini " + hostIp);
      }

      Map<String, String> details = new HashMap<String, String>();
      OvmResourceBase ovmResource = new OvmResourceBase();
      details.put("ip", hostIp);
      details.put("username", username);
      details.put("password", password);
      details.put("zone", Long.toString(dcId));
      details.put("guid", guid);
      details.put("pod", Long.toString(podId));
      details.put("cluster", Long.toString(clusterId));
      details.put("agentusername", agentUsername);
      details.put("agentpassword", agentPassword);
      if (_publicNetworkDevice != null) {
        details.put("public.network.device", _publicNetworkDevice);
      }
      if (_privateNetworkDevice != null) {
        details.put("private.network.device", _privateNetworkDevice);
      }
      if (_guestNetworkDevice != null) {
        details.put("guest.network.device", _guestNetworkDevice);
      }

      Map<String, Object> params = new HashMap<String, Object>();
      params.putAll(details);
      ovmResource.configure("Ovm Server", params);
      ovmResource.start();

      conn = new Connection(hostIp, "oracle", agentPassword);
      /* After resource start, we are able to execute our agent api */
      OvmHost.Details d = OvmHost.getDetails(conn);
      details.put("agentVersion", d.agentVersion);
      details.put(HostInfo.HOST_OS_KERNEL_VERSION, d.dom0KernelVersion);
      details.put(HostInfo.HYPERVISOR_VERSION, d.hypervisorVersion);
View Full Code Here


    } catch (Exception e) {
      s_logger.debug("Setup server failed, ip " + _ip, e);
      throw new ConfigurationException("Unable to setup server");
    }
   
        _conn = new Connection(_ip, _agentUserName, _agentPassword);
        try {
      OvmHost.registerAsMaster(_conn);
      OvmHost.registerAsVmServer(_conn);
      _bridges = OvmBridge.getAllBridges(_conn);
    } catch (XmlRpcException e) {
View Full Code Here

    }

    @Override
    public Map<? extends ServerResource, Map<String, String>>
        find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
        Connection conn = null;

        if (!url.getScheme().equals("http")) {
            String msg = "urlString is not http so we're not taking care of the discovery for this: " + url;
            s_logger.debug(msg);
            return null;
        }
        if (clusterId == null) {
            String msg = "must specify cluster Id when add host";
            s_logger.debug(msg);
            throw new CloudRuntimeException(msg);
        }

        if (podId == null) {
            String msg = "must specify pod Id when add host";
            s_logger.debug(msg);
            throw new CloudRuntimeException(msg);
        }

        ClusterVO cluster = _clusterDao.findById(clusterId);
        if (cluster == null || (cluster.getHypervisorType() != HypervisorType.Ovm)) {
            if (s_logger.isInfoEnabled())
                s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
            return null;
        }

        String agentUsername = _params.get("agentusername");
        if (agentUsername == null) {
            throw new CloudRuntimeException("Agent user name must be specified");
        }

        String agentPassword = _params.get("agentpassword");
        if (agentPassword == null) {
            throw new CloudRuntimeException("Agent password must be specified");
        }

        try {
            String hostname = url.getHost();
            InetAddress ia = InetAddress.getByName(hostname);
            String hostIp = ia.getHostAddress();
            String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();

            if (checkIfExisted(guid)) {
                throw new CloudRuntimeException("The host " + hostIp + " has been added before");
            }

            s_logger.debug("Ovm discover is going to disover host having guid " + guid);

            ClusterVO clu = _clusterDao.findById(clusterId);
            if (clu.getGuid() == null) {
                clu.setGuid(UUID.randomUUID().toString());
                _clusterDao.update(clusterId, clu);
            }

            com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(hostIp, 22);
            sshConnection.connect(null, 60000, 60000);
            sshConnection = SSHCmdHelper.acquireAuthorizedConnection(hostIp, username, password);
            if (sshConnection == null) {
                throw new DiscoveryException(String.format("Cannot connect to ovm host(IP=%1$s, username=%2$s, password=%3$s, discover failed", hostIp, username,
                    password));
            }

            if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "[ -f '/etc/ovs-agent/agent.ini' ]")) {
                throw new DiscoveryException("Can not find /etc/ovs-agent/agent.ini " + hostIp);
            }

            Map<String, String> details = new HashMap<String, String>();
            OvmResourceBase ovmResource = new OvmResourceBase();
            details.put("ip", hostIp);
            details.put("username", username);
            details.put("password", password);
            details.put("zone", Long.toString(dcId));
            details.put("guid", guid);
            details.put("pod", Long.toString(podId));
            details.put("cluster", Long.toString(clusterId));
            details.put("agentusername", agentUsername);
            details.put("agentpassword", agentPassword);
            if (_publicNetworkDevice != null) {
                details.put("public.network.device", _publicNetworkDevice);
            }
            if (_privateNetworkDevice != null) {
                details.put("private.network.device", _privateNetworkDevice);
            }
            if (_guestNetworkDevice != null) {
                details.put("guest.network.device", _guestNetworkDevice);
            }

            Map<String, Object> params = new HashMap<String, Object>();
            params.putAll(details);
            ovmResource.configure("Ovm Server", params);
            ovmResource.start();

            conn = new Connection(hostIp, "oracle", agentPassword);
            /* After resource start, we are able to execute our agent api */
            OvmHost.Details d = OvmHost.getDetails(conn);
            details.put("agentVersion", d.agentVersion);
            details.put(HostInfo.HOST_OS_KERNEL_VERSION, d.dom0KernelVersion);
            details.put(HostInfo.HYPERVISOR_VERSION, d.hypervisorVersion);
View Full Code Here

    } catch (Exception e) {
      s_logger.debug("Setup server failed, ip " + _ip, e);
      throw new ConfigurationException("Unable to setup server");
    }
   
        _conn = new Connection(_ip, _agentUserName, _agentPassword);
        try {
      OvmHost.registerAsMaster(_conn);
      OvmHost.registerAsVmServer(_conn);
      _bridges = OvmBridge.getAllBridges(_conn);
    } catch (XmlRpcException e) {
View Full Code Here

  @Override
  public Map<? extends ServerResource, Map<String, String>> find(long dcId,
      Long podId, Long clusterId, URI url, String username,
      String password, List<String> hostTags) throws DiscoveryException {
    Connection conn = null;

    if (!url.getScheme().equals("http")) {
      String msg = "urlString is not http so we're not taking care of the discovery for this: "
          + url;
      s_logger.debug(msg);
      return null;
    }
    if (clusterId == null) {
      String msg = "must specify cluster Id when add host";
      s_logger.debug(msg);
      throw new CloudRuntimeException(msg);
    }

    if (podId == null) {
      String msg = "must specify pod Id when add host";
      s_logger.debug(msg);
      throw new CloudRuntimeException(msg);
    }

    ClusterVO cluster = _clusterDao.findById(clusterId);
    if (cluster == null
        || (cluster.getHypervisorType() != HypervisorType.Ovm)) {
      if (s_logger.isInfoEnabled())
        s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
      return null;
    }

    String agentUsername = _params.get("agentusername");
    if (agentUsername == null) {
      throw new CloudRuntimeException("Agent user name must be specified");
    }

    String agentPassword = _params.get("agentpassword");
    if (agentPassword == null) {
      throw new CloudRuntimeException("Agent password must be specified");
    }

    try {
      String hostname = url.getHost();
      InetAddress ia = InetAddress.getByName(hostname);
      String hostIp = ia.getHostAddress();
      String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();

      if (checkIfExisted(guid)) {
        throw new CloudRuntimeException("The host " + hostIp
            + " has been added before");
      }

      s_logger.debug("Ovm discover is going to disover host having guid "
          + guid);

      ClusterVO clu = _clusterDao.findById(clusterId);
      if (clu.getGuid() == null) {
        clu.setGuid(UUID.randomUUID().toString());
        _clusterDao.update(clusterId, clu);
      }

      com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(
          hostIp, 22);
      sshConnection.connect(null, 60000, 60000);
      sshConnection = SSHCmdHelper.acquireAuthorizedConnection(hostIp,
          username, password);
      if (sshConnection == null) {
        throw new DiscoveryException(
            String.format(
                "Cannot connect to ovm host(IP=%1$s, username=%2$s, password=%3$s, discover failed",
                hostIp, username, password));
      }

      if (!SSHCmdHelper.sshExecuteCmd(sshConnection,
          "[ -f '/etc/ovs-agent/agent.ini' ]")) {
        throw new DiscoveryException(
            "Can not find /etc/ovs-agent/agent.ini " + hostIp);
      }

      Map<String, String> details = new HashMap<String, String>();
      OvmResourceBase ovmResource = new OvmResourceBase();
      details.put("ip", hostIp);
      details.put("username", username);
      details.put("password", password);
      details.put("zone", Long.toString(dcId));
      details.put("guid", guid);
      details.put("pod", Long.toString(podId));
      details.put("cluster", Long.toString(clusterId));
      details.put("agentusername", agentUsername);
      details.put("agentpassword", agentPassword);
      if (_publicNetworkDevice != null) {
        details.put("public.network.device", _publicNetworkDevice);
      }
      if (_privateNetworkDevice != null) {
        details.put("private.network.device", _privateNetworkDevice);
      }
      if (_guestNetworkDevice != null) {
        details.put("guest.network.device", _guestNetworkDevice);
      }

      Map<String, Object> params = new HashMap<String, Object>();
      params.putAll(details);
      ovmResource.configure("Ovm Server", params);
      ovmResource.start();

      conn = new Connection(hostIp, "oracle", agentPassword);
      /* After resource start, we are able to execute our agent api */
      OvmHost.Details d = OvmHost.getDetails(conn);
      details.put("agentVersion", d.agentVersion);
      details.put(HostInfo.HOST_OS_KERNEL_VERSION, d.dom0KernelVersion);
      details.put(HostInfo.HYPERVISOR_VERSION, d.hypervisorVersion);
View Full Code Here

    } catch (Exception e) {
      s_logger.debug("Setup server failed, ip " + _ip, e);
      throw new ConfigurationException("Unable to setup server");
    }
   
        _conn = new Connection(_ip, _agentUserName, _agentPassword);
        try {
      OvmHost.registerAsMaster(_conn);
      OvmHost.registerAsVmServer(_conn);
      _bridges = OvmBridge.getAllBridges(_conn);
    } catch (XmlRpcException e) {
View Full Code Here

        } catch (Exception e) {
            s_logger.debug("Setup server failed, ip " + _ip, e);
            throw new ConfigurationException("Unable to setup server");
        }

        _conn = new Connection(_ip, _agentUserName, _agentPassword);
        try {
            OvmHost.registerAsMaster(_conn);
            OvmHost.registerAsVmServer(_conn);
            _bridges = OvmBridge.getAllBridges(_conn);
        } catch (XmlRpcException e) {
View Full Code Here

    } catch (Exception e) {
      s_logger.debug("Setup server failed, ip " + _ip, e);
      throw new ConfigurationException("Unable to setup server");
    }
   
        _conn = new Connection(_ip, _agentUserName, _agentPassword);
        try {
      OvmHost.registerAsMaster(_conn);
      OvmHost.registerAsVmServer(_conn);
      _bridges = OvmBridge.getAllBridges(_conn);
    } catch (XmlRpcException e) {
View Full Code Here

    }

    @Override
    public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags)
        throws DiscoveryException {
        Connection conn = null;

        if (!url.getScheme().equals("http")) {
            String msg = "urlString is not http so we're not taking care of the discovery for this: " + url;
            s_logger.debug(msg);
            return null;
        }
        if (clusterId == null) {
            String msg = "must specify cluster Id when add host";
            s_logger.debug(msg);
            throw new CloudRuntimeException(msg);
        }

        if (podId == null) {
            String msg = "must specify pod Id when add host";
            s_logger.debug(msg);
            throw new CloudRuntimeException(msg);
        }

        ClusterVO cluster = _clusterDao.findById(clusterId);
        if (cluster == null || (cluster.getHypervisorType() != HypervisorType.Ovm)) {
            if (s_logger.isInfoEnabled())
                s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
            return null;
        }

        String agentUsername = _params.get("agentusername");
        if (agentUsername == null) {
            throw new CloudRuntimeException("Agent user name must be specified");
        }

        String agentPassword = _params.get("agentpassword");
        if (agentPassword == null) {
            throw new CloudRuntimeException("Agent password must be specified");
        }

        try {
            String hostname = url.getHost();
            InetAddress ia = InetAddress.getByName(hostname);
            String hostIp = ia.getHostAddress();
            String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();

            if (checkIfExisted(guid)) {
                throw new CloudRuntimeException("The host " + hostIp + " has been added before");
            }

            s_logger.debug("Ovm discover is going to disover host having guid " + guid);

            ClusterVO clu = _clusterDao.findById(clusterId);
            if (clu.getGuid() == null) {
                clu.setGuid(UUID.randomUUID().toString());
                _clusterDao.update(clusterId, clu);
            }

            com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(hostIp, 22);
            sshConnection.connect(null, 60000, 60000);
            sshConnection = SSHCmdHelper.acquireAuthorizedConnection(hostIp, username, password);
            if (sshConnection == null) {
                throw new DiscoveryException(String.format("Cannot connect to ovm host(IP=%1$s, username=%2$s, password=%3$s, discover failed", hostIp, username, password));
            }

            if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "[ -f '/etc/ovs-agent/agent.ini' ]")) {
                throw new DiscoveryException("Can not find /etc/ovs-agent/agent.ini " + hostIp);
            }

            Map<String, String> details = new HashMap<String, String>();
            OvmResourceBase ovmResource = new OvmResourceBase();
            details.put("ip", hostIp);
            details.put("username", username);
            details.put("password", password);
            details.put("zone", Long.toString(dcId));
            details.put("guid", guid);
            details.put("pod", Long.toString(podId));
            details.put("cluster", Long.toString(clusterId));
            details.put("agentusername", agentUsername);
            details.put("agentpassword", agentPassword);
            if (_publicNetworkDevice != null) {
                details.put("public.network.device", _publicNetworkDevice);
            }
            if (_privateNetworkDevice != null) {
                details.put("private.network.device", _privateNetworkDevice);
            }
            if (_guestNetworkDevice != null) {
                details.put("guest.network.device", _guestNetworkDevice);
            }

            Map<String, Object> params = new HashMap<String, Object>();
            params.putAll(details);
            ovmResource.configure("Ovm Server", params);
            ovmResource.start();

            conn = new Connection(hostIp, "oracle", agentPassword);
            /* After resource start, we are able to execute our agent api */
            OvmHost.Details d = OvmHost.getDetails(conn);
            details.put("agentVersion", d.agentVersion);
            details.put(HostInfo.HOST_OS_KERNEL_VERSION, d.dom0KernelVersion);
            details.put(HostInfo.HYPERVISOR_VERSION, d.hypervisorVersion);
View Full Code Here

    } catch (Exception e) {
      s_logger.debug("Setup server failed, ip " + _ip, e);
      throw new ConfigurationException("Unable to setup server");
    }
   
        _conn = new Connection(_ip, _agentUserName, _agentPassword);
        try {
      OvmHost.registerAsMaster(_conn);
      OvmHost.registerAsVmServer(_conn);
      _bridges = OvmBridge.getAllBridges(_conn);
    } catch (XmlRpcException e) {
View Full Code Here

TOP

Related Classes of com.cloud.ovm.object.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.