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

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


        } 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());
            } else {
                s_logger.info("VMI " + _manager.getVifNameByVmUuid(vm.getUuid(), nicVO.getDeviceId()) + " got mac address: " + macs.getMacAddress().get(0));
                nic.setMacAddress(macs.getMacAddress().get(0));
            }
        }

        if (nic.getIp4Address() == null) {
            s_logger.debug("Allocated IP address " + ipModel.getAddress());
            nic.setIp4Address(ipModel.getAddress());
            if (network.getCidr() != null) {
                nic.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
            }
            nic.setGateway(network.getGateway());
            nic.setFormat(AddressFormat.Ip4);
View Full Code Here


        } 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());

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

      } 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());

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

        } 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());
            } else {
                s_logger.info("VMI " + _manager.getVifNameByVmUuid(vm.getUuid(), nicVO.getDeviceId()) + " got mac address: " +
                        macs.getMacAddress().get(0));
                nic.setMacAddress(macs.getMacAddress().get(0));
            }
        }

        if (nic.getIp4Address() == null) {
            s_logger.debug("Allocated IP address " + ipModel.getAddress());
            nic.setIp4Address(ipModel.getAddress());
            if (network.getCidr() != null) {
                nic.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
            }
            nic.setGateway(network.getGateway());
            nic.setFormat(AddressFormat.Ip4);
View Full Code Here

TOP

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

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.