Пример #1
0
  /** add host */
  @RequestMapping(value = "/host/addhost")
  public int checkLogin(
      HttpServletRequest request,
      @RequestParam("hostname") String hostname,
      @RequestParam("ip") String ip,
      @RequestParam("rootpass") String rootpass,
      @RequestParam("cores") String cores,
      @RequestParam("memory") String memory,
      @RequestParam("location") String location) {

    Host host = new Host();
    host.setZoneId(1);
    host.setHostName(hostname);
    host.setIp(ip);
    host.setRootPasswd(rootpass);
    host.setLocation(location);
    host.setCores(Short.parseShort(cores));
    host.setMemory(Integer.parseInt(memory));
    Date curDate = new Date(System.currentTimeMillis()); // 获取当前时间
    host.setLastUpdated(curDate);
    int hostresult = hostService.addHost(host);

    // host.setNote(note);
    // host.setUsageFlag(new Byte(usage_flag));
    // host.setSshLogin(new Byte(ssh_login));
    // host.setClusterId(Integer.parseInt(cluster_id));

    return hostresult;
  }
Пример #2
0
  /** add host */
  @RequestMapping(value = "/hostl")
  public int checkLogin(
      HttpServletRequest request,
      @RequestParam("zone_id") String zone_id,
      @RequestParam("host_name") String host_name,
      @RequestParam("ip") String ip,
      @RequestParam("root_passwd") String root_passwd,
      @RequestParam("location") String location,
      @RequestParam("note") String note,
      @RequestParam("cores") String cores,
      @RequestParam("memory") String memory,
      @RequestParam("usage_flag") String usage_flag,
      @RequestParam("ssh_login") String ssh_login,
      @RequestParam("cluster_id") String cluster_id) {
    Host host = new Host();

    host.setZoneId(Integer.parseInt(zone_id));
    host.setHostName(host_name);
    host.setIp(ip);
    host.setRootPasswd(root_passwd);
    host.setLocation(location);
    host.setNote(note);
    host.setCores(new Byte(cores));
    host.setMemory(Integer.parseInt(memory));
    host.setUsageFlag(new Byte(usage_flag));
    host.setSshLogin(new Byte(ssh_login));
    host.setClusterId(Integer.parseInt(cluster_id));
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date curDate = new Date(System.currentTimeMillis()); // 获取当前时间
    host.setLastUpdated(curDate);
    int a = hostService.setHostNode(host);
    return a;
  }
Пример #3
0
 @RequestMapping(value = "/host/{zoneId}")
 public GridData getProjects(@PathVariable("zoneId") int zoneId) {
   GridData grid = new GridData();
   List<Host> pros = hostService.getHostsByZoneId(zoneId);
   grid.setData(pros);
   return grid;
 }
Пример #4
0
  @RequestMapping(value = "/hostlist/{IdString}")
  public List<InstallNode> getProjects(@PathVariable("IdString") String zoneId) {

    Ku8ClusterTemplate temp = new Ku8ClusterTemplate();
    List<InstallNode> nodes = new LinkedList<InstallNode>();
    InstallNode node = new InstallNode();
    String strList[] = zoneId.split(",");
    for (String s : strList) {
      if (!s.isEmpty()) {
        Host pros = hostService.getHostsByZoneString(Integer.parseInt(s));
        node.setDefautNode(true);
        node.setHostId(pros.getId());
        node.setHostName(pros.getHostName());
        node.setIp(pros.getIp());
        node.getNodeRoleParams().put(Ku8ClusterTemplate.NODE_ROLE_MASTER, initInstallParameter());
        temp.getNodes().add(node);
        nodes.add(node);
      }
    }

    temp.addNewNode("kube-master");
    return nodes;
  }