Package org.apache.cloudstack.network.contrail.model

Examples of org.apache.cloudstack.network.contrail.model.VMInterfaceModel


    }

    private void buildNicResources(VirtualMachineModel vmModel, VMInstanceVO dbVm, StringBuffer syncLogMsg) throws IOException {
        List<NicVO> nics = _nicDao.listByVmId(dbVm.getId());
        for (NicVO nic : nics) {
            VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
            if (vmiModel == null) {
                vmiModel = new VMInterfaceModel(nic.getUuid());
                NetworkVO network = _networksDao.findById(nic.getNetworkId());
                VirtualNetworkModel vnModel =
                    _manager.getDatabase().lookupVirtualNetwork(network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType());
                if (vnModel == null) {
                    s_logger.warn("Unable to locate virtual-network for network id " + network.getId());
                    continue;
                }
                vmiModel.addToVirtualMachine(vmModel);
                vmiModel.addToVirtualNetwork(vnModel);
            }
            vmiModel.build(_manager.getModelController(), dbVm, nic);
        }
    }
View Full Code Here


            VMInstanceVO vmVo = (VMInstanceVO)vm.getVirtualMachine();
            vmModel = new VirtualMachineModel(vmVo, vm.getUuid());
            vmModel.setProperties(_manager.getModelController(), vmVo);
        }

        VMInterfaceModel vmiModel = vmModel.getVMInterface(nicVO.getUuid());
        if (vmiModel == null) {
            vmiModel = new VMInterfaceModel(nicVO.getUuid());
            vmiModel.addToVirtualMachine(vmModel);
            vmiModel.addToVirtualNetwork(vnModel);
        }
        try {
            vmiModel.build(_manager.getModelController(), (VMInstanceVO)vm.getVirtualMachine(), nicVO);
            vmiModel.setActive();
        } catch (IOException ex) {
            s_logger.error("virtual-machine-interface set", ex);
            return;
        }

        InstanceIpModel ipModel = vmiModel.getInstanceIp();
        if (ipModel == null) {
            ipModel = new InstanceIpModel(vm.getInstanceName(), nic.getDeviceId());
            ipModel.addToVMInterface(vmiModel);
        } else {
            s_logger.debug("Reuse existing instance-ip object on " + ipModel.getName());
        }
        if (nic.getIp4Address() != null) {
            s_logger.debug("Nic using existing IP address " + nic.getIp4Address());
            ipModel.setAddress(nic.getIp4Address());
        }

        try {
            vmModel.update(_manager.getModelController());
        } catch (Exception ex) {
            s_logger.warn("virtual-machine update", ex);
            return;
        }

        _manager.getDatabase().getVirtualMachines().add(vmModel);

        VirtualMachineInterface vmi = vmiModel.getVMInterface();
        // allocate mac address
        if (nic.getMacAddress() == null) {
            MacAddressesType macs = vmi.getMacAddresses();
            if (macs == null) {
                s_logger.debug("no mac address is allocated for Nic " + nicVO.getUuid());
View Full Code Here

        VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid());
        if (vmModel == null) {
            return;
        }
        VMInterfaceModel vmiModel = vmModel.getVMInterface(nicVO.getUuid());
        if (vmiModel == null) {
            return;
        }
        try {
            vmiModel.destroy(_manager.getModelController());
        } catch (IOException ex) {
            return;
        }
        vmModel.removeSuccessor(vmiModel);
View Full Code Here

        }

        NicVO nic = _nicDao.findById(nicProfile.getId());
        assert nic != null;

        VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
        if (vmiModel == null) {
            vmiModel = new VMInterfaceModel(nic.getUuid());
            vmiModel.addToVirtualMachine(vmModel);
            vmiModel.addToVirtualNetwork(vnModel);
        }

        try {
            vmiModel.build(_manager.getModelController(), (VMInstanceVO)vm.getVirtualMachine(), nic);
        } catch (IOException ex) {
            s_logger.warn("vm interface set", ex);
            return false;
        }

        InstanceIpModel ipModel = vmiModel.getInstanceIp();
        if (ipModel == null) {
            ipModel = new InstanceIpModel(vm.getInstanceName(), nic.getDeviceId());
            ipModel.addToVMInterface(vmiModel);
        }
        ipModel.setAddress(nicProfile.getIp4Address());
View Full Code Here

        VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid());
        if (vmModel == null) {
            s_logger.debug("vm " + vm.getInstanceName() + " not in local database");
            return true;
        }
        VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
        if (vmiModel != null) {
            try {
                vmiModel.destroy(_manager.getModelController());
            } catch (IOException ex) {
                s_logger.warn("virtual-machine-interface delete", ex);
            }
            vmModel.removeSuccessor(vmiModel);
        }
View Full Code Here

      }

      NicVO nic = _nicDao.findById(nicProfile.getId());
      assert nic != null;

      VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
      if (vmiModel == null) {
          vmiModel = new VMInterfaceModel(nic.getUuid());
          vmiModel.addToVirtualMachine(vmModel)
                vmiModel.addToVirtualNetwork(vnModel);         
      }
     
      try {
          vmiModel.build(_manager.getModelController(), (VMInstanceVO) vm.getVirtualMachine(), nic);
      } catch (IOException ex) {
          s_logger.warn("vm interface set", ex);
          return false;
      }

      InstanceIpModel ipModel = vmiModel.getInstanceIp();
      if (ipModel == null) {
          ipModel = new InstanceIpModel(vm.getInstanceName(), nic.getDeviceId());
          ipModel.addToVMInterface(vmiModel);
      }
      ipModel.setAddress(nicProfile.getIp4Address());
View Full Code Here

      VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid());
      if (vmModel == null) {
          s_logger.debug("vm " + vm.getInstanceName() + " not in local database");
          return true;
      }
      VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
      if (vmiModel != null) {
          try {
              vmiModel.destroy(_manager.getModelController());
          } catch (IOException ex) {
              s_logger.warn("virtual-machine-interface delete", ex);
          }
          vmModel.removeSuccessor(vmiModel);
      }
View Full Code Here

    private void buildNicResources(VirtualMachineModel vmModel, VMInstanceVO dbVm, StringBuffer syncLogMsg)
            throws IOException {
        List<NicVO> nics = _nicDao.listByVmId(dbVm.getId());
        for (NicVO nic : nics) {
            VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid());
            if (vmiModel == null) {
                vmiModel = new VMInterfaceModel(nic.getUuid());
                NetworkVO network = _networksDao.findById(nic.getNetworkId());
                VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(
                        network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType());
                if (vnModel == null)  {
                    s_logger.warn("Unable to locate virtual-network for network id " + network.getId());
                    continue;
                }
                vmiModel.addToVirtualMachine(vmModel);
                vmiModel.addToVirtualNetwork(vnModel);
            }
            vmiModel.build(_manager.getModelController(), dbVm, nic);           
        }       
    }
View Full Code Here

            VMInstanceVO vmVo = (VMInstanceVO) vm.getVirtualMachine();
            vmModel = new VirtualMachineModel(vmVo, vm.getUuid());
            vmModel.setProperties(_manager.getModelController(), vmVo);
        }

        VMInterfaceModel vmiModel = vmModel.getVMInterface(nicVO.getUuid());
        if (vmiModel == null) {
            vmiModel = new VMInterfaceModel(nicVO.getUuid());
            vmiModel.addToVirtualMachine(vmModel);
            vmiModel.addToVirtualNetwork(vnModel);
        }
        try {
            vmiModel.build(_manager.getModelController(), (VMInstanceVO) vm.getVirtualMachine(), nicVO);
            vmiModel.setActive();
        } catch (IOException ex) {
            s_logger.error("virtual-machine-interface set", ex);
            return;
        }

        InstanceIpModel ipModel = vmiModel.getInstanceIp();
        if (ipModel == null) {
            ipModel = new InstanceIpModel(vm.getInstanceName(), nic.getDeviceId());
            ipModel.addToVMInterface(vmiModel);
        } else {
            s_logger.debug("Reuse existing instance-ip object on " + ipModel.getName());
        }
        if (nic.getIp4Address() != null) {
            s_logger.debug("Nic using existing IP address " +  nic.getIp4Address());
            ipModel.setAddress(nic.getIp4Address());
        }

        try {
            vmModel.update(_manager.getModelController());
        } catch (Exception ex) {
            s_logger.warn("virtual-machine update", ex);
            return;
        }

        _manager.getDatabase().getVirtualMachines().add(vmModel);  

        VirtualMachineInterface vmi = vmiModel.getVMInterface();
        // allocate mac address
        if (nic.getMacAddress() == null) {
            MacAddressesType macs = vmi.getMacAddresses();
            if (macs == null) {
                s_logger.debug("no mac address is allocated for Nic " + nicVO.getUuid());
View Full Code Here

        VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid());
        if (vmModel == null) {
            return;
        }
        VMInterfaceModel vmiModel = vmModel.getVMInterface(nicVO.getUuid());
        if (vmiModel == null) {
            return;
        }
        try {
            vmiModel.destroy(_manager.getModelController());
        } catch (IOException ex) {
            return;
        }
        vmModel.removeSuccessor(vmiModel);
       
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.network.contrail.model.VMInterfaceModel

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.