Examples of NetworkEntity


Examples of com.vmware.bdd.entity.NetworkEntity

      validateNetworkName(name);
      if (!resService.isNetworkExistInVc(portGroup)) {
         throw VcProviderException.NETWORK_NOT_FOUND(portGroup);
      }
      try {
         NetworkEntity network =
               new NetworkEntity(name, portGroup, AllocType.DHCP, null, null,
                     null, null);
         networkDao.insert(network);
         network.validate();
         return network;
      } catch (UniqueConstraintViolationException ex) {
         logger.error("can not add a network with duplicated name");
         throw BddException.ALREADY_EXISTS(ex, "Network", name);
      }
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

      try {
         validateNetworkName(name);
         if (!resService.isNetworkExistInVc(portGroup)) {
            throw VcProviderException.NETWORK_NOT_FOUND(portGroup);
         }
         NetworkEntity network =
               new NetworkEntity(name, portGroup, AllocType.IP_POOL, netmask,
                     gateway, dns1, dns2);
         networkDao.insert(network);
         List<IpBlockEntity> blocks =
               new ArrayList<IpBlockEntity>(ipBlocks.size());
         for (IpBlock ib : ipBlocks) {
            IpBlockEntity blk =
                  new IpBlockEntity(null, IpBlockEntity.FREE_BLOCK_OWNER_ID,
                        BlockType.FREE, IpAddressUtil.getAddressAsLong(ib
                              .getBeginIp()), IpAddressUtil.getAddressAsLong(ib
                              .getEndIp()));
            blocks.add(blk);
         }

         networkDao.addIpBlocks(network, blocks);
         network.validate();
         return network;
      } catch (UniqueConstraintViolationException ex) {
         logger.error("can not add a network with duplicated name");
         throw BddException.ALREADY_EXISTS(ex, "Network", name);
      }
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

    */
   @Override
   @Transactional
   public NetworkRead getNetworkByName(final String name,
         final boolean withDetails) {
      NetworkEntity entity = getNetworkEntityByName(name);

      if (entity != null) {
         return convert(entity, withDetails);
      }
      return null;
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

    */
   @Override
   @Transactional
   public synchronized void increaseIPs(String networkName,
         List<IpBlock> ipBlocks) {
      NetworkEntity network = getNetworkEntityByName(networkName);
      if (network == null) {
         throw NetworkException.NOT_FOUND("Network", networkName);
      }
      if (network.getAllocType().equals(AllocType.DHCP)) {
         throw NetworkException.IP_CONFIG_NOT_USED_FOR_DHCP();
      }
      long netmask = IpAddressUtil.getAddressAsLong(network.getNetmask());
      IpAddressUtil.verifyIPBlocks(ipBlocks, netmask);
      List<IpBlockEntity> blocks =
            new ArrayList<IpBlockEntity>(ipBlocks.size());
      for (IpBlock ib : ipBlocks) {
         IpBlockEntity blk =
               new IpBlockEntity(network, IpBlockEntity.FREE_BLOCK_OWNER_ID,
                     BlockType.FREE, IpAddressUtil.getAddressAsLong(ib
                           .getBeginIp()), IpAddressUtil.getAddressAsLong(ib
                           .getEndIp()));
         blocks.add(blk);
      }
      networkDao.addIpBlocks(network, blocks);
      network.validate();
   }
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

    * com.vmware.bdd.manager.INetworkService#removeNetwork(java.lang.String)
    */
   @Override
   @Transactional
   public synchronized void removeNetwork(final String networkName) {
      NetworkEntity net = getNetworkEntityByName(networkName);
      if (net != null) {
         removeNetwork(net);
      } else {
         throw BddException.NOT_FOUND("Network", networkName);
      }
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

      ipBlocks.add(block);
      networkDao.free(network, clusterId, ipBlocks);
   }

   private void validateNetworkName(final String name) {
      NetworkEntity networkEntity = networkDao.findNetworkByName(name);
      if (networkEntity != null) {
         logger.error("can not add a network with duplicated name");
         throw BddException.ALREADY_EXISTS("Network", name);
      }
   }
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

            distroName);
   }

   private void verifyNetworkNamesExsitInDB(Set<String> networkNames,
         String clusterName) {
      NetworkEntity networkEntity = null;
      for (String networkName : networkNames) {
         networkEntity = networkManager.getNetworkEntityByName(networkName);
         if (networkEntity == null) {
            throw ClusterConfigException.NETWORK_IS_NOT_FOUND(networkName,
                  clusterName);
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

    * @see com.vmware.bdd.service.resmgmt.ResourceManager#getNetworkByName(java.lang.String)
    */
   @Override
   public VcNetwork getNetworkByName(String networkName)
         throws VcProviderException {
      NetworkEntity networkEntity = networkDao.findNetworkByName(networkName);
      return VcResourceUtils.findNetworkInVC(networkEntity.getPortGroup());
   }
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

            vNode.getTargetRp()));

      // set ipconfigs field even IPs are not yet retrieved, otherwise if
      // Tomcat crashes, we will lost the ipconfigs template
      for (NicSpec nicSpec : vNode.getNics().values()) {
         NetworkEntity networkEntity =
               networkMgr.getNetworkEntityByName(nicSpec.getNetworkName());
         NicEntity nicEntity = nodeEntity.findNic(networkEntity);
         if (nicEntity == null) {
            nicEntity = new NicEntity();
            nodeEntity.getNics().add(nicEntity);
         }
         nicEntity.setIpv4Address(nicSpec.getIpv4Address());
         nicEntity.setIpv6Address(nicSpec.getIpv6Address());
         nicEntity.setMacAddress(nicSpec.getMacAddress());
         nicEntity.setNetTrafficDefs(nicSpec.getNetTrafficDefinitionSet());
         nicEntity.setNetworkEntity(networkEntity);
         nicEntity.setNodeEntity(nodeEntity);
         if (vNode.getVmMobId() != null) {
            VcVmUtil.populateNicInfo(nicEntity, vNode.getVmMobId(),
                  networkEntity.getPortGroup());
         }
      }

      if (vNode.isFinished()) {
         nodeEntity.setActionFailed(!vNode.isSuccess());
View Full Code Here

Examples of com.vmware.bdd.entity.NetworkEntity

   private List<NetworkAdd> allocatNetworkIp(List<String> networkNames,
         ClusterEntity clusterEntity, long instanceNum, boolean needAllocIp) {
      List<NetworkAdd> networkings = new ArrayList<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());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.