Package com.xensource.xenapi

Examples of com.xensource.xenapi.Network


        try {
            prepareISO(connection, vmSpec.getName());
            Map<String, String> other = new HashMap<String, String>();
            other.put("live", "true");
            Network networkForSm = getNativeNetworkForTraffic(connection, TrafficType.Storage, null).getNetwork();
            Host host = Host.getByUuid(connection, _host.uuid);
            Map<String,String> token = host.migrateReceive(connection, networkForSm, other);

            // Get the vm to migrate.
            Set<VM> vms = VM.getByNameLabel(connection, vmSpec.getName());
View Full Code Here


            }

            // Get the list of networks to which the vifs will attach.
            Map<NicTO, Object> nicToNetwork = new HashMap<NicTO, Object>();
            for (NicTO nicTo : vmSpec.getNics()) {
                Network network = getNetwork(connection, nicTo);
                nicToNetwork.put(nicTo, network);
            }

            Map<String, String> other = new HashMap<String, String>();
            other.put("live", "true");
            Network network = getNativeNetworkForTraffic(connection, TrafficType.Storage, null).getNetwork();
            Host host = Host.getByUuid(connection, _host.uuid);
            Map<String,String> token = host.migrateReceive(connection, network, other);

            return new MigrateWithStorageReceiveAnswer(cmd, volumeToSr, nicToNetwork, token);
        } catch (CloudRuntimeException e) {
View Full Code Here

            // Create the vif map.
            Map<VIF, Network> vifMap = new HashMap<VIF, Network>();
            for (Map.Entry<NicTO, Object> entry : nicToNetwork.entrySet()) {
                if (entry.getValue() instanceof Network) {
                    Network network = (Network)entry.getValue();
                    VIF vif = getVifByMac(connection, vmToMigrate, entry.getKey().getMac());
                    vifMap.put(vif, network);
                } else {
                    throw new CloudRuntimeException("The object " + entry.getValue() + " passed is not of type Network.");
                }
View Full Code Here

    }

    private synchronized Network setupvSwitchNetwork(Connection conn) {
        try {
            if (_host.vswitchNetwork == null) {
                Network vswitchNw = null;
                Network.Record rec = new Network.Record();
                String nwName = Networks.BroadcastScheme.VSwitch.toString();
                Set<Network> networks = Network.getByNameLabel(conn, nwName);

                if (networks.size() == 0) {
View Full Code Here

     * This method just creates a XenServer network following the tunnel network naming convention
     */
    private synchronized Network findOrCreateTunnelNetwork(Connection conn, long key) {
        try {
            String nwName = "OVSTunnel" + key;
            Network nw = null;
            Network.Record rec = new Network.Record();
            Set<Network> networks = Network.getByNameLabel(conn, nwName);

            if (networks.size() == 0) {
                rec.nameDescription = "tunnel network id# " + key;
View Full Code Here

    /**
     * This method creates a XenServer network and configures it for being used as a L2-in-L3 tunneled network
     */
    private synchronized Network configureTunnelNetwork(Connection conn, long networkId, long hostId, int key) {
        try {
            Network nw = findOrCreateTunnelNetwork(conn, key);
            String nwName = "OVSTunnel" + key;
            //Invoke plugin to setup the bridge which will be used by this network
            String bridge = nw.getBridge(conn);
            Map<String,String> nwOtherConfig = nw.getOtherConfig(conn);
            String configuredHosts = nwOtherConfig.get("ovs-host-setup");
            boolean configured = false;
            if (configuredHosts!=null) {
                String hostIdsStr[] = configuredHosts.split(",");
                for (String hostIdStr:hostIdsStr) {
                    if (hostIdStr.equals(((Long)hostId).toString())) {
                        configured = true;
                        break;
                    }
                }
            }
            if (!configured) {
                // Plug dom0 vif only if not done before for network and host
                enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + key);
                String result = callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge", "bridge", bridge,
                        "key", String.valueOf(key),
                        "xs_nw_uuid", nw.getUuid(conn),
                        "cs_host_id", ((Long)hostId).toString());
                //Note down the fact that the ovs bridge has been setup
                String[] res = result.split(":");
                if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
                    //TODO: Should make this error not fatal?
View Full Code Here

        }
    }

    private synchronized void destroyTunnelNetwork(Connection conn, int key) {
        try {
            Network nw = findOrCreateTunnelNetwork(conn, key);
            String bridge = nw.getBridge(conn);
            String result = callHostPlugin(conn, "ovstunnel", "destroy_ovs_bridge", "bridge", bridge);
            String[] res = result.split(":");
            if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
                //TODO: Should make this error not fatal?
                //Can Concurrent VM shutdown/migration/reboot events can cause this method
View Full Code Here

            }
            nic.setDeviceId(0);
            nic.setNetworkRateMbps(networkRate);
            nic.setName(name);

            Network network = getNetwork(conn, nic);

            // Determine the correct VIF on DomR to associate/disassociate the
            // IP address with
            VIF correctVif = getCorrectVif(conn, router, network);
View Full Code Here

            String msg = "Management interface is on slave(" +mgmtPifRec.uuid + ") of bond("
                    + bond.getUuid(conn) + ") on host(" +_host.uuid + "), please move management interface to bond!";
            s_logger.warn(msg);
            throw new CloudRuntimeException(msg);
        }
        Network nk =  mgmtPifRec.network;
        Network.Record nkRec = nk.getRecord(conn);
        return new XsLocalNetwork(nk, nkRec, mgmtPif, mgmtPifRec);
    }
View Full Code Here


    protected VIF getCorrectVif(Connection conn, VM router, Network network) throws XmlRpcException, XenAPIException {
        Set<VIF> routerVIFs = router.getVIFs(conn);
        for (VIF vif : routerVIFs) {
            Network vifNetwork = vif.getNetwork(conn);
            if (vifNetwork.getUuid(conn).equals(network.getUuid(conn))) {
                return vif;
            }
        }

        return null;
View Full Code Here

TOP

Related Classes of com.xensource.xenapi.Network

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.