Package com.vmware.bdd.apitypes

Examples of com.vmware.bdd.apitypes.NetworkAdd


      for (String networkName : networkNames) {
         NetworkEntity networkEntity =
               networkMgr.getNetworkEntityByName(networkName);

         if (needAllocIp) {
            NetworkAdd network = new NetworkAdd();
            network.setPortGroup(networkEntity.getPortGroup());
            network.setName(networkName);
            network
                  .setDhcp(networkEntity.getAllocType() == NetworkEntity.AllocType.DHCP);
            if (!network.getIsDhcp()) {
               logger.debug("using static ip.");
               List<IpBlockEntity> ipBlockEntities =
                     networkMgr.getAllocatedIpBlocks(networkEntity,
                           clusterEntity.getId());
               long allocatedIpNum = IpBlockEntity.count(ipBlockEntities);
               if (allocatedIpNum < instanceNum) {
                  long newNum = instanceNum - allocatedIpNum;
                  List<IpBlockEntity> newIpBlockEntities =
                        networkMgr.alloc(networkEntity, clusterEntity.getId(),
                              newNum);
                  ipBlockEntities.addAll(newIpBlockEntities);
               }
               network.setDns1(networkEntity.getDns1());
               network.setDns2(networkEntity.getDns2());
               network.setGateway(networkEntity.getGateway());
               network.setNetmask(networkEntity.getNetmask());
               List<IpBlock> ips = new ArrayList<IpBlock>();
               for (IpBlockEntity ipBlockEntity : ipBlockEntities) {
                  IpBlock ip = new IpBlock();
                  ip.setBeginIp(ipBlockEntity.getBeginAddress());
                  ip.setEndIp(ipBlockEntity.getEndAddress());
                  ips.add(ip);
               }
               network.setIpBlocks(ips);
            }
            networkings.add(network);
         }
      }
      return networkings;
View Full Code Here


    */
   private void allocateStaticIp(List<BaseNode> vNodes,
         List<NetworkAdd> networkAdds, Map<String, Set<String>> occupiedIpSets) {
      int i, j;
      for (i = 0; i < networkAdds.size(); i++) {
         NetworkAdd networkAdd = networkAdds.get(i);
         String portGroupName = networkAdd.getPortGroup();
         Set<String> usedIps = null;
         if (occupiedIpSets != null && !occupiedIpSets.isEmpty()) {
            usedIps = occupiedIpSets.get(portGroupName);
         }

         if (networkAdd.getIsDhcp()) {
            // no need to allocate ip for dhcp
            logger.info("using dhcp for network: " + portGroupName);
         } else {
            logger.info("Start to allocate static ip address for each VM's "
                  + i + "th network.");
            List<String> availableIps =
                  IpBlock.getIpAddressFromIpBlock(networkAdd.getIpBlocks());
            if (usedIps != null && !usedIps.isEmpty()) {
               availableIps.removeAll(usedIps);
            }
            AuAssert.check(availableIps.size() == vNodes.size());
            for (j = 0; j < availableIps.size(); j++) {
View Full Code Here

         @CliOption(key = { "name" }, mandatory = true, help = "Customize the network's name") final String name,
         @CliOption(key = { "addIP" }, mandatory = true, help = "The ip information") final String ip) {
      if (!validateIP(ip, Constants.OUTPUT_OP_MODIFY)) {
         return;
      }
      NetworkAdd networkAdd = new NetworkAdd();
      networkAdd.setName(name);
      try {
         networkAdd.setIpBlocks(transferIpInfo(ip));
         networkRestClient.increaseIPs(networkAdd);
         CommandsUtils.printCmdSuccess(Constants.OUTPUT_OBJECT_NETWORK, name,
               Constants.OUTPUT_OP_RESULT_MODIFY);
      } catch (Exception e) {
         CommandsUtils.printCmdFailure(Constants.OUTPUT_OBJECT_NETWORK, name,
View Full Code Here

   }

   private void addNetworkByDHCPModel(NetworkType operType, final String name,
         final String portGroup, final boolean dhcp) {
      NetworkAdd networkAdd = new NetworkAdd();
      networkAdd.setName(name);
      networkAdd.setPortGroup(portGroup);
      networkAdd.setDhcp(true);

      //rest invocation
      try {
      networkRestClient.add(networkAdd);
      CommandsUtils.printCmdSuccess(Constants.OUTPUT_OBJECT_NETWORK, name,
View Full Code Here

         throws UnknownHostException {

      // validate the network add command option.
      networkName = name;
      if (validateAddNetworkOptionByIP(ip, dns, sedDNS, gateway, mask)) {
         NetworkAdd networkAdd = new NetworkAdd();
         networkAdd.setName(name);
         networkAdd.setPortGroup(portGroup);
         networkAdd.setIpBlocks(transferIpInfo(ip));
         networkAdd.setDns1(dns);
         networkAdd.setDns2(sedDNS);
         networkAdd.setGateway(gateway);
         networkAdd.setNetmask(mask);

         //rest invocation
         try {
            networkRestClient.add(networkAdd);
            CommandsUtils.printCmdSuccess(Constants.OUTPUT_OBJECT_NETWORK, name,
View Full Code Here

      Assert.assertTrue(!success, "should get create vm failed.");
   }

   private List<NetworkAdd> createNetworkAdd() {
      List<NetworkAdd> networkAdds = new ArrayList<NetworkAdd>();
      NetworkAdd networkAdd = new NetworkAdd();
      networkAdd.setDhcp(true);
      networkAdd.setPortGroup("testGroup");
      networkAdds.add(networkAdd);
      return networkAdds;
   }
View Full Code Here

   @Test
   public void add() throws Exception {
      CookieCache.put("Cookie","JSESSIONID=2AAF431F59ACEE1CC68B43C87772C54F");
      assertNotNull(networkRestClient);
      NetworkAdd networkAdd =new NetworkAdd();
      addByIP(networkAdd);
      addByDHCP(networkAdd);
      ObjectMapper mapper = new ObjectMapper();

      buildReqRespWithoutRespBody(
View Full Code Here

      group.setName("master");
      group.setCpuNum(2);
      nodeGroups[0] = group;
      spec.setNodeGroups(nodeGroups);
      List<NetworkAdd> networkAdds = new ArrayList<NetworkAdd>();
      NetworkAdd network = new NetworkAdd();
      network.setDhcp(true);
      network.setPortGroup("test-portgroup");
      networkAdds.add(network);
      spec.setNetworkings(networkAdds);
      return spec;
   }
View Full Code Here

TOP

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

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.