Package net.juniper.contrail.api.types

Examples of net.juniper.contrail.api.types.InstanceIp


            assertTrue(_api.create(vmi));
            assertTrue(_api.create(net));
        } catch (IOException ex) {
            fail(ex.getMessage());
        }
        InstanceIp ip_obj = new InstanceIp();
        ip_obj.setName(net.getName() + ":0");
        ip_obj.setVirtualNetwork(net);
        ip_obj.setVirtualMachineInterface(vmi);
        try {
            assertTrue(_api.create(ip_obj));
            // Must perform a GET in order to update the object contents.
            assertTrue(_api.read(ip_obj));
            assertNotNull(ip_obj.getAddress());

        } catch (IOException ex) {
            fail(ex.getMessage());
        }
View Full Code Here


            vnet = (VirtualNetwork)api.findById(VirtualNetwork.class, _vmiModel.getNetworkUuid());
        }

        String ipid = api.findByName(InstanceIp.class, null, _name);
        if (ipid == null) {
            InstanceIp ip_obj = new InstanceIp();
            ip_obj.setName(_name);
            ip_obj.setVirtualNetwork(vnet);
            if (_ipAddress != null) {
                ip_obj.setAddress(_ipAddress);
            }
            ip_obj.setVirtualMachineInterface(vmi);
            if (!api.create(ip_obj)) {
                throw new InternalErrorException("Unable to create instance-ip " + _name);
            }
            api.read(ip_obj);
            _uuid = ip_obj.getUuid();
            if (_ipAddress == null) {
                if (!api.read(ip_obj)) {
                    throw new InternalErrorException("Unable to read instance-ip " + _name);
                }
            }
            _ipAddress = ip_obj.getAddress();
        } else {
            // Ensure that the instance-ip has the correct value and is pointing at the VMI.
            InstanceIp ip_obj = (InstanceIp)api.findById(InstanceIp.class, ipid);
            if (ip_obj == null) {
                throw new InternalErrorException("Unable to read instance-ip " + _name);
            }
            boolean update = false;
            String ipnet_id = ObjectReference.getReferenceListUuid(ip_obj.getVirtualNetwork());
            if (ipnet_id == null || !ipnet_id.equals(_vmiModel.getNetworkUuid())) {
                ip_obj.setVirtualNetwork(vnet);
                update = true;
            }

            if (_ipAddress != null && !ip_obj.getAddress().equals(_ipAddress)) {
                ip_obj.setAddress(_ipAddress);
                update = true;
            }

            String vmi_id = ObjectReference.getReferenceListUuid(ip_obj.getVirtualMachineInterface());
            if (vmi_id == null || !vmi_id.equals(_vmiModel.getUuid())) {
                if (vmi != null) {
                    ip_obj.setVirtualMachineInterface(vmi);
                    update = true;
                }
            }

            if (update && !api.update(ip_obj)) {
                throw new InternalErrorException("Unable to update instance-ip: " + ip_obj.getName());
            }
            api.read(ip_obj);
            _uuid = ip_obj.getUuid();
            _ipAddress = ip_obj.getAddress();
        }
    }
View Full Code Here

            vnet = (VirtualNetwork) api.findById(VirtualNetwork.class, _vmiModel.getNetworkUuid());
        }
       
        String ipid = api.findByName(InstanceIp.class, null, _name);
        if (ipid == null) {
            InstanceIp ip_obj = new InstanceIp();
            ip_obj.setName(_name);
            ip_obj.setVirtualNetwork(vnet);
            if (_ipAddress != null) {
                ip_obj.setAddress(_ipAddress);
            }
            ip_obj.setVirtualMachineInterface(vmi);
            if (!api.create(ip_obj)) {
                throw new InternalErrorException("Unable to create instance-ip " +  _name);
            }
            api.read(ip_obj);
            _uuid = ip_obj.getUuid();
            if (_ipAddress == null) {
                if (!api.read(ip_obj)) {
                    throw new InternalErrorException("Unable to read instance-ip " +  _name);
                }
            }
            _ipAddress = ip_obj.getAddress();
        } else {
            // Ensure that the instance-ip has the correct value and is pointing at the VMI.
            InstanceIp ip_obj = (InstanceIp) api.findById(InstanceIp.class, ipid);
            if (ip_obj == null) {
                throw new InternalErrorException("Unable to read instance-ip " +  _name);
            }
            boolean update = false;
            String ipnet_id = ObjectReference.getReferenceListUuid(ip_obj.getVirtualNetwork());
            if (ipnet_id == null || !ipnet_id.equals(_vmiModel.getNetworkUuid())) {
                ip_obj.setVirtualNetwork(vnet);
                update = true;
            }

            if (_ipAddress != null && !ip_obj.getAddress().equals(_ipAddress)) {
                ip_obj.setAddress(_ipAddress);
                update = true;
            }
           
            String vmi_id = ObjectReference.getReferenceListUuid(ip_obj.getVirtualMachineInterface());
            if (vmi_id == null || !vmi_id.equals(_vmiModel.getUuid())) {
                if (vmi != null) {
                    ip_obj.setVirtualMachineInterface(vmi);
                    update = true;
                }
            }

            if (update && !api.update(ip_obj)) {
                throw new InternalErrorException("Unable to update instance-ip: " + ip_obj.getName());
            }
            api.read(ip_obj);
            _uuid = ip_obj.getUuid();
            _ipAddress = ip_obj.getAddress();
        }       
    }
View Full Code Here

            assertTrue(_api.create(vmi));
            assertTrue(_api.create(net));
        } catch (IOException ex) {
            fail(ex.getMessage());
        }
        InstanceIp ip_obj = new InstanceIp();
        ip_obj.setName(net.getName() + ":0");
        ip_obj.setVirtualNetwork(net);
        ip_obj.setVirtualMachineInterface(vmi);
        try {
            assertTrue(_api.create(ip_obj));
            // Must perform a GET in order to update the object contents.
            assertTrue(_api.read(ip_obj));
            assertNotNull(ip_obj.getAddress());

        } catch (IOException ex) {
            fail(ex.getMessage());
        }
View Full Code Here

                ": " + vmInterfaceUuid + "vmiUuid :" + vmiUuid);

        // Instance Ip
        String instanceIpName = "ip-" + vmName;
        String instIpUuid = UUID.randomUUID().toString();
        InstanceIp instanceIp = new InstanceIp();
        //instanceIp.setParent(vm);   SAS_FIXME
        instanceIp.setDisplayName(instanceIpName);
        instanceIp.setUuid(instIpUuid);
        instanceIp.setName(instIpUuid);
        instanceIp.setVirtualNetwork(network);
        instanceIp.setVirtualMachineInterface(vmInterface);
        apiConnector.create(instanceIp);

        // Read back to get assigned IP address
        //instanceIp = (InstanceIp) apiConnector.find(InstanceIp.class, vm,
         //                                           instanceIp.getName());
        apiConnector.read(instanceIp);
        String vmIpAddress = instanceIp.getAddress();
        s_logger.info("Create instance IP:" + instanceIp.getName() + ": " +
                vmIpAddress);

        // Plug notification to vrouter
        if (vrouterIpAddress == null) {
            s_logger.info("Virtual machine: " + vmName + " host: " + hostName
View Full Code Here

        // Instance Ip
        // Read back to get assigned IP address
        List<ObjectReference<ApiPropertyBase>> instanceIpBackRefs =
                vmInterface.getInstanceIpBackRefs();
        InstanceIp instanceIp = null;
        for (ObjectReference<ApiPropertyBase> instanceIpRef :
                Utils.safe(instanceIpBackRefs)) {
            instanceIp = (InstanceIp)
                    apiConnector.findById(InstanceIp.class,
                            instanceIpRef.getUuid());
        }

        if (instanceIp == null) {
            s_logger.info("Virtual machine interface: " + vmInterface.getName()
                          + " has no ip address");
            return;
        }

        String vmIpAddress = instanceIp.getAddress();

        // Plug notification to vrouter
        if (vrouterIpAddress == null) {
            s_logger.info("Virtual machine: " + vmName + " host: " + hostName
                + " create notification NOT sent");
View Full Code Here

            assertTrue(_api.create(net));
        } catch (IOException ex) {
            fail(ex.getMessage());
        }

        InstanceIp ip_obj = new InstanceIp();
        ip_obj.setName(net.getName() + ":0");
        ip_obj.setVirtualNetwork(net);
        ip_obj.setVirtualMachineInterface(vmi);
        try {
            assertTrue(_api.create(ip_obj));
            // Must perform a GET in order to update the object contents.
            assertTrue(_api.read(ip_obj));
            assertNotNull(ip_obj.getAddress());

            _api.delete(ip_obj);
            _api.delete(net);

        } catch (IOException ex) {
View Full Code Here

TOP

Related Classes of net.juniper.contrail.api.types.InstanceIp

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.