Package com.vmware.bdd.apitypes

Examples of com.vmware.bdd.apitypes.NetworkRead


      return relevantClusters;
   }

   @Transactional(readOnly = true)
   private NetworkRead convert(NetworkEntity net, boolean withDetails) {
      NetworkRead nr = new NetworkRead();
      nr.setName(net.getName());
      nr.setPortGroup(net.getPortGroup());
      if (net.getAllocType() == AllocType.IP_POOL) {
         nr.setDhcp(false);
         nr.setDns1(net.getDns1());
         nr.setDns2(net.getDns2());
         nr.setGateway(net.getGateway());
         nr.setNetmask(net.getNetmask());

         List<IpBlock> allBlocks = new ArrayList<IpBlock>();
         List<IpBlock> freeBlocks = new ArrayList<IpBlock>();
         List<IpBlock> assignedBlocks = new ArrayList<IpBlock>();
         for (IpBlockEntity blk : networkDao.findAllIpBlocks(net)) {
            IpBlock ib = new IpBlock();
            ib.setBeginIp(blk.getBeginAddress());
            ib.setEndIp(blk.getEndAddress());
            allBlocks.add(ib);
         }

         for (IpBlockEntity blk : networkDao.findAllFreeIpBlocks(net)) {
            IpBlock ib = new IpBlock();
            ib.setBeginIp(blk.getBeginAddress());
            ib.setEndIp(blk.getEndAddress());
            freeBlocks.add(ib);
         }

         for (IpBlockEntity blk : networkDao.findAllAssignedIpBlocks(net)) {
            IpBlock ib = new IpBlock();
            ib.setBeginIp(blk.getBeginAddress());
            ib.setEndIp(blk.getEndAddress());
            assignedBlocks.add(ib);
         }

         nr.setAllIpBlocks(allBlocks);
         nr.setFreeIpBlocks(freeBlocks);
         nr.setAssignedIpBlocks(assignedBlocks);
      } else {
         nr.setDhcp(true);
      }

      if (withDetails) {
         List<IpAllocEntryRead> ipAllocEntries =
               new ArrayList<IpAllocEntryRead>();
         List<NodeEntity> nodes =
               nodeDao.findByNodeGroups(nodeGroupDao.findAllByClusters(findRelevantClusters(net)));

         for (NodeEntity node : nodes) {
            String ip = node.findNic(net).getIpv4Address();
            if (ip == null || ip.equals(Constants.NULL_IPV4_ADDRESS)) {
               // in case of errors during node creation (if possible)
               continue;
            }
            IpAllocEntryRead e = new IpAllocEntryRead();

            e.setClusterId(node.getNodeGroup().getCluster().getId());
            e.setClusterName(node.getNodeGroup().getCluster().getName());
            e.setNodeGroupId(node.getNodeGroup().getId());
            e.setNodeGroupName(node.getNodeGroup().getName());
            e.setNodeId(node.getId());
            e.setNodeName(node.getVmName());
            e.setIpAddress(ip);

            ipAllocEntries.add(e);
         }

         nr.setIpAllocEntries(ipAllocEntries);
      }

      return nr;
   }
View Full Code Here


      networkName = CommonUtil.decode(networkName);
      if (CommonUtil.isBlank(networkName)
            || !CommonUtil.validateResourceName(networkName)) {
         throw BddException.INVALID_PARAMETER("network name", networkName);
      }
      NetworkRead network =
            networkSvc.getNetworkByName(networkName, details != null ? details
                  : false);
      if (network == null) {
         throw NetworkException.NOT_FOUND("Network", networkName);
      }
View Full Code Here

      try {
         if (name == null) {
            NetworkRead[] networks = networkRestClient.getAll(detail);
            prettyOutputNetworksInfo(networks, detail);
         } else {
            NetworkRead network = networkRestClient.get(name, detail);
            prettyOutputNetworkInfo(network, detail);
         }
      }catch (CliRestException e) {
         CommandsUtils.printCmdFailure(Constants.OUTPUT_OBJECT_NETWORK,
               name, Constants.OUTPUT_OP_LIST, Constants.OUTPUT_OP_RESULT_FAIL,
View Full Code Here

   @Test
   public void testGetNetwork() {
      CookieCache.put("Cookie","JSESSIONID=2AAF431F59ACEE1CC68B43C87772C54F");
      ObjectMapper mapper = new ObjectMapper();
      NetworkRead networkRead1 = new NetworkRead();
      networkRead1.setName("name1");
      networkRead1.setPortGroup("portGroup1");
      networkRead1.setDhcp(false);
      networkRead1.setDns1("192.1.1.1");
      networkRead1.setDns2("192.1.2.1");
      List<IpBlock> allIpBlocks = new ArrayList<IpBlock>();
      IpBlock ip1 = new IpBlock();
      ip1.setBeginIp("192.1.1.2");
      ip1.setEndIp("192.1.1.5");
      IpBlock ip2 = new IpBlock();
      ip2.setBeginIp("192.1.1.8");
      ip2.setEndIp("192.1.1.8");
      IpBlock ip3 = new IpBlock();
      ip3.setBeginIp("192.1.1.10");
      ip3.setEndIp("192.1.1.100");
      allIpBlocks.add(ip1);
      allIpBlocks.add(ip2);
      allIpBlocks.add(ip3);
      List<IpBlock> freeIpBlocks = new ArrayList<IpBlock>();
      freeIpBlocks.add(ip1);
      List<IpBlock> assignedIpBlocks = new ArrayList<IpBlock>();
      assignedIpBlocks.add(ip2);
      networkRead1.setAllIpBlocks(allIpBlocks);
      networkRead1.setFreeIpBlocks(freeIpBlocks);
      networkRead1.setAssignedIpBlocks(assignedIpBlocks);
      networkRead1.setGateway("192.1.1.0");
      networkRead1.setNetmask("255.255.0.0");
      List<IpAllocEntryRead> ipAllocEntries1 =
            new ArrayList<IpAllocEntryRead>();
      IpAllocEntryRead ipAllocEntry1 = new IpAllocEntryRead();
      ipAllocEntry1.setIpAddress("192.1.1.3");
      ipAllocEntry1.setNodeName("nodeName1");
      ipAllocEntry1.setNodeGroupName("nodeGroupName1");
      ipAllocEntry1.setClusterName("clusterName1");
      IpAllocEntryRead ipAllocEntry2 = new IpAllocEntryRead();
      ipAllocEntry2.setIpAddress("192.1.1.7");
      ipAllocEntry2.setNodeName("nodeName2");
      ipAllocEntry2.setNodeGroupName("nodeGroupName1");
      ipAllocEntry2.setClusterName("clusterName1");
      ipAllocEntries1.add(ipAllocEntry1);
      ipAllocEntries1.add(ipAllocEntry2);
      networkRead1.setIpAllocEntries(ipAllocEntries1);

      NetworkRead networkRead2 = new NetworkRead();
      networkRead2.setName("name2");
      networkRead2.setPortGroup("portGroup2");
      networkRead2.setDhcp(true);
      List<IpAllocEntryRead> ipAllocEntries2 =
            new ArrayList<IpAllocEntryRead>();
      IpAllocEntryRead ipAllocEntry3 = new IpAllocEntryRead();
      ipAllocEntry3.setIpAddress("192.1.10.3");
      ipAllocEntry3.setNodeName("nodeName3");
      ipAllocEntry3.setNodeGroupName("nodeGroupName2");
      ipAllocEntry3.setClusterName("clusterName2");
      IpAllocEntryRead ipAllocEntry4 = new IpAllocEntryRead();
      ipAllocEntry4.setIpAddress("192.1.10.7");
      ipAllocEntry4.setNodeName("nodeName4");
      ipAllocEntry4.setNodeGroupName("nodeGroupName2");
      ipAllocEntry4.setClusterName("clusterName2");
      ipAllocEntries2.add(ipAllocEntry3);
      ipAllocEntries2.add(ipAllocEntry4);
      networkRead2.setIpAllocEntries(ipAllocEntries2);
      getListNetwork(mapper, new NetworkRead[] { networkRead1, networkRead2 },
            true);
      CookieCache.clear();
   }
View Full Code Here

       DistroRead[] distros = new DistroRead[1];
       DistroRead distro = new DistroRead();
       distro.setName(Constants.DEFAULT_DISTRO);
       distros[0] = distro;
       NetworkRead[] networks = new NetworkRead[1];
       NetworkRead network = new NetworkRead();
       network.setName("dhcp");
       network.setDhcp(true);
       network.setPortGroup("pg1");
       networks[0] = network;

       ObjectMapper mapper = new ObjectMapper();
       buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/appmanager/Default/defaultdistro", HttpMethod.GET, HttpStatus.OK,
             mapper.writeValueAsString(distros[0]));
View Full Code Here

        distros[1] = new DistroRead();
        distros[1].setName(Constants.DEFAULT_DISTRO);
        distros[2] = new DistroRead();
        distros[2].setName(Constants.DEFAULT_DISTRO+2);
        NetworkRead[] networks = new NetworkRead[1];
        NetworkRead network = new NetworkRead();
        network.setName("dhcp");
        network.setDhcp(true);
        network.setPortGroup("pg1");
        networks[0] = network;

        ObjectMapper mapper = new ObjectMapper();
        buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/appmanager/Default/distros", HttpMethod.GET, HttpStatus.OK,
                mapper.writeValueAsString(distros));
View Full Code Here

        DistroRead[] distros = new DistroRead[1];
        DistroRead distro = new DistroRead();
        distro.setName(Constants.DEFAULT_DISTRO);
        distros[0] = distro;
        NetworkRead[] networks = new NetworkRead[1];
        NetworkRead network = new NetworkRead();
        network.setName("dhcp");
        network.setDhcp(true);
        network.setPortGroup("pg1");
        networks[0] = network;

        ObjectMapper mapper = new ObjectMapper();
        buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/appmanager/Default/defaultdistro", HttpMethod.GET, HttpStatus.OK,
              mapper.writeValueAsString(distros[0]));
View Full Code Here

       roles.add("zookeeper");
       roles.add("hadoop_journalnode");
       distro.setRoles(roles);
       distros[0] = distro;
       NetworkRead[] networks = new NetworkRead[1];
       NetworkRead network = new NetworkRead();
       network.setName("dhcp");
       network.setDhcp(true);
       network.setPortGroup("pg1");
       networks[0] = network;

       ValidateResult vr = new ValidateResult();
       vr.setValidated(true);
View Full Code Here

        DistroRead distro = new DistroRead();
        distro.setName(Constants.DEFAULT_DISTRO);
        distros[0] = distro;

        NetworkRead[] networks = new NetworkRead[1];
        NetworkRead network = new NetworkRead();
        network.setName("dhcp");
        network.setDhcp(true);
        network.setPortGroup("pg1");
        networks[0] = network;

        ObjectMapper mapper = new ObjectMapper();
        buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/appmanager/Default/defaultdistro", HttpMethod.GET, HttpStatus.OK,
              mapper.writeValueAsString(distros[0]));
View Full Code Here

TOP

Related Classes of com.vmware.bdd.apitypes.NetworkRead

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.