cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [1/5] CLOUDSTACK-6162: add UI for OVS plugin
Date Sat, 01 Mar 2014 09:32:15 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.3-forward 258d8e2a0 -> 065ac54bd


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/065ac54b/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index 9e4cd31..1d4d6e6 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -161,6 +161,7 @@ known_categories = {
     'CacheStores' : 'Cache Stores',
     'CacheStore' : 'Cache Store',
     'StratosphereSsp' : ' Stratosphere SSP'
+    'OvsElement' : 'Ovs Element'
     }
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/065ac54b/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 0c56baf..d82bbc8 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -5705,6 +5705,607 @@
                                 notification: {
                                     poll: pollAsyncJobResult
                                 }
+                            }
+                        }
+                    },
+
+                    //ovs
+                    Ovs: {
+                        id: 'ovsProviders',
+                        label: 'label.ovs',
+                        isMaximized: true,
+                        type: 'detailView',
+                        fields: {
+                            name: {
+                                label: 'label.name'
+                            },
+                            ipaddress: {
+                                label: 'label.ip.address'
+                            },
+                            state: {
+                                label: 'label.status',
+                                indicator: {
+                                    'Enabled': 'on'
+                                }
+                            }
+                        },
+                        tabs: {
+                            network: {
+                                title: 'label.network',
+                                fields: [{
+                                    name: {
+                                        label: 'label.name'
+                                    }
+                                }, {
+                                    id: {
+                                        label: 'label.id'
+                                    },
+                                    state: {
+                                        label: 'label.state'
+                                    },
+                                    physicalnetworkid: {
+                                        label: 'label.physical.network.ID'
+                                    },
+                                    destinationphysicalnetworkid: {
+                                        label: 'label.destination.physical.network.id'
+                                    },
+                                    supportedServices: {
+                                        label: 'label.supported.services'
+                                    }
+                                }],
+                                dataProvider: function (args) {
+                                    refreshNspData("Ovs");
+                                    args.response.success({
+                                        actionFilter: virtualRouterProviderActionFilter,
+                                        data: $.extend(nspMap["Ovs"], {
+                                            supportedServices: nspMap["Ovs"].servicelist.join(', ')
+                                        })
+                                    });
+                                }
+                            },
+
+                            instances: {
+                                title: 'label.instances',
+                                listView: {
+                                    label: 'label.virtual.appliances',
+                                    id: 'routers',
+                                    fields: {
+                                        name: {
+                                            label: 'label.name'
+                                        },
+                                        zonename: {
+                                            label: 'label.zone'
+                                        },
+                                        routerType: {
+                                            label: 'label.type'
+                                        },
+                                        state: {
+                                            converter: function (str) {
+                                                // For localization
+                                                return str;
+                                            },
+                                            label: 'label.status',
+                                            indicator: {
+                                                'Running': 'on',
+                                                'Stopped': 'off',
+                                                'Error': 'off'
+                                            }
+                                        }
+                                    },
+                                    dataProvider: function (args) {
+                                        var array1 = [];
+                                        if (args.filterBy != null) {
+                                            if (args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) {
+                                                switch (args.filterBy.search.by) {
+                                                case "name":
+                                                    if (args.filterBy.search.value.length > 0)
+                                                        array1.push("&keyword=" + args.filterBy.search.value);
+                                                    break;
+                                                }
+                                            }
+                                        }
+
+                                        var data2 = {
+                                            forvpc: false
+                                        };
+                                        var routers = [];
+                                        $.ajax({
+                                            url: createURL("listRouters&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")),
+                                            data: data2,
+                                            success: function (json) {
+                                                var items = json.listroutersresponse.router ?
+                                                    json.listroutersresponse.router : [];
+
+                                                $(items).map(function (index, item) {
+                                                    routers.push(item);
+                                                });
+
+                                                // Get project routers
+                                                $.ajax({
+                                                    url: createURL("listRouters&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"),
+                                                    data: data2,
+                                                    success: function (json) {
+                                                        var items = json.listroutersresponse.router ?
+                                                            json.listroutersresponse.router : [];
+
+                                                        $(items).map(function (index, item) {
+                                                            routers.push(item);
+                                                        });
+                                                        args.response.success({
+                                                            actionFilter: routerActionfilter,
+                                                            data: $(routers).map(mapRouterType)
+                                                        });
+                                                    }
+                                                });
+                                            }
+                                        });
+                                    },
+                                    detailView: {
+                                        name: 'Virtual applicance details',
+                                        actions: {
+                                            start: {
+                                                label: 'label.action.start.router',
+                                                messages: {
+                                                    confirm: function (args) {
+                                                        return 'message.action.start.router';
+                                                    },
+                                                    notification: function (args) {
+                                                        return 'label.action.start.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    $.ajax({
+                                                        url: createURL('startRouter&id=' + args.context.routers[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.startrouterresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid,
+                                                                    getUpdatedItem: function (json) {
+                                                                        return json.queryasyncjobresultresponse.jobresult.domainrouter;
+                                                                    },
+                                                                    getActionFilter: function () {
+                                                                        return routerActionfilter;
+                                                                    }
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            stop: {
+                                                label: 'label.action.stop.router',
+                                                createForm: {
+                                                    title: 'label.action.stop.router',
+                                                    desc: 'message.action.stop.router',
+                                                    fields: {
+                                                        forced: {
+                                                            label: 'force.stop',
+                                                            isBoolean: true,
+                                                            isChecked: false
+                                                        }
+                                                    }
+                                                },
+                                                messages: {
+                                                    notification: function (args) {
+                                                        return 'label.action.stop.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    var array1 = [];
+                                                    array1.push("&forced=" + (args.data.forced == "on"));
+                                                    $.ajax({
+                                                        url: createURL('stopRouter&id=' + args.context.routers[0].id + array1.join("")),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.stoprouterresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid,
+                                                                    getUpdatedItem: function (json) {
+                                                                        return json.queryasyncjobresultresponse.jobresult.domainrouter;
+                                                                    },
+                                                                    getActionFilter: function () {
+                                                                        return routerActionfilter;
+                                                                    }
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            'remove': {
+                                                label: 'label.destroy.router',
+                                                messages: {
+                                                    confirm: function (args) {
+                                                        return 'message.confirm.destroy.router';
+                                                    },
+                                                    notification: function (args) {
+                                                        return 'label.destroy.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("destroyRouter&id=" + args.context.routers[0].id),
+                                                        dataType: "json",
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.destroyrouterresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            migrate: {
+                                                label: 'label.action.migrate.router',
+                                                createForm: {
+                                                    title: 'label.action.migrate.router',
+                                                    desc: '',
+                                                    fields: {
+                                                        hostId: {
+                                                            label: 'label.host',
+                                                            validation: {
+                                                                required: true
+                                                            },
+                                                            select: function (args) {
+                                                                $.ajax({
+                                                                    url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.routers[0].id),
+                                                                    dataType: "json",
+                                                                    async: true,
+                                                                    success: function (json) {
+                                                                        var hostObjs = json.findhostsformigrationresponse.host;
+                                                                        var items = [];
+                                                                        $(hostObjs).each(function () {
+                                                                            items.push({
+                                                                                id: this.id,
+                                                                                description: (this.name + " (" + (this.suitableformigration ? "Suitable" : "Not Suitable") + ")")
+                                                                            });
+                                                                        });
+                                                                        args.response.success({
+                                                                            data: items
+                                                                        });
+                                                                    }
+                                                                });
+                                                            },
+                                                            error: function (XMLHttpResponse) {
+                                                                var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                args.response.error(errorMsg);
+                                                            }
+                                                        }
+                                                    }
+                                                },
+                                                messages: {
+                                                    notification: function (args) {
+                                                        return 'label.action.migrate.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("migrateSystemVm&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.routers[0].id),
+                                                        dataType: "json",
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.migratesystemvmresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid,
+                                                                    getUpdatedItem: function (json) {
+                                                                        //return json.queryasyncjobresultresponse.jobresult.systemvminstance;    //not all properties returned in systemvminstance
+                                                                        $.ajax({
+                                                                            url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+                                                                            dataType: "json",
+                                                                            async: false,
+                                                                            success: function (json) {
+                                                                                var items = json.listroutersresponse.router;
+                                                                                if (items != null && items.length > 0) {
+                                                                                    return items[0];
+                                                                                }
+                                                                            }
+                                                                        });
+                                                                    },
+                                                                    getActionFilter: function () {
+                                                                        return routerActionfilter;
+                                                                    }
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            viewConsole: {
+                                                label: 'label.view.console',
+                                                action: {
+                                                    externalLink: {
+                                                        url: function (args) {
+                                                            return clientConsoleUrl + '?cmd=access&vm=' + args.context.routers[0].id;
+                                                        },
+                                                        title: function (args) {
+                                                            return args.context.routers[0].id.substr(0, 8); //title in window.open() can't have space nor longer than 8 characters. Otherwise, IE browser will have error.
+                                                        },
+                                                        width: 820,
+                                                        height: 640
+                                                    }
+                                                }
+                                            }
+                                        },
+                                        tabs: {
+                                            details: {
+                                                title: 'label.details',
+                                                preFilter: function (args) {
+                                                    var hiddenFields = [];
+                                                    if (!args.context.routers[0].project) {
+                                                        hiddenFields.push('project');
+                                                        hiddenFields.push('projectid');
+                                                    }
+                                                    if (selectedZoneObj.networktype == 'Basic') {
+                                                        hiddenFields.push('publicip'); //In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API.
+                                                    }
+                                                    return hiddenFields;
+                                                },
+                                                fields: [{
+                                                    name: {
+                                                        label: 'label.name'
+                                                    },
+                                                    project: {
+                                                        label: 'label.project'
+                                                    }
+                                                }, {
+                                                    id: {
+                                                        label: 'label.id'
+                                                    },
+                                                    projectid: {
+                                                        label: 'label.project.id'
+                                                    },
+                                                    state: {
+                                                        label: 'label.state'
+                                                    },
+                                                    guestnetworkid: {
+                                                        label: 'label.network.id'
+                                                    },
+                                                    publicip: {
+                                                        label: 'label.public.ip'
+                                                    },
+                                                    guestipaddress: {
+                                                        label: 'label.guest.ip'
+                                                    },
+                                                    linklocalip: {
+                                                        label: 'label.linklocal.ip'
+                                                    },
+                                                    hostname: {
+                                                        label: 'label.host'
+                                                    },
+                                                    serviceofferingname: {
+                                                        label: 'label.compute.offering'
+                                                    },
+                                                    networkdomain: {
+                                                        label: 'label.network.domain'
+                                                    },
+                                                    domain: {
+                                                        label: 'label.domain'
+                                                    },
+                                                    account: {
+                                                        label: 'label.account'
+                                                    },
+                                                    created: {
+                                                        label: 'label.created',
+                                                        converter: cloudStack.converters.toLocalDate
+                                                    },
+                                                    isredundantrouter: {
+                                                        label: 'label.redundant.router',
+                                                        converter: cloudStack.converters.toBooleanText
+                                                    },
+                                                    redundantRouterState: {
+                                                        label: 'label.redundant.state'
+                                                    }
+                                                }],
+                                                dataProvider: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("listRouters&id=" + args.context.routers[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jsonObj = json.listroutersresponse.router[0];
+                                                            addExtraPropertiesToRouterInstanceObject(jsonObj);
+                                                            args.response.success({
+                                                                actionFilter: routerActionfilter,
+                                                                data: jsonObj
+                                                            });
+                                                        }
+                                                    });
+                                                }
+                                            },
+                                            nics: {
+                                                title: 'label.nics',
+                                                multiple: true,
+                                                fields: [{
+                                                    name: {
+                                                        label: 'label.name',
+                                                        header: true
+                                                    },
+                                                    type: {
+                                                        label: 'label.type'
+                                                    },
+                                                    traffictype: {
+                                                        label: 'label.traffic.type'
+                                                    },
+                                                    networkname: {
+                                                        label: 'label.network.name'
+                                                    },
+                                                    netmask: {
+                                                        label: 'label.netmask'
+                                                    },
+                                                    ipaddress: {
+                                                        label: 'label.ip.address'
+                                                    },
+                                                    id: {
+                                                        label: 'label.id'
+                                                    },
+                                                    networkid: {
+                                                        label: 'label.network.id'
+                                                    },
+                                                    isolationuri: {
+                                                        label: 'label.isolation.uri'
+                                                    },
+                                                    broadcasturi: {
+                                                        label: 'label.broadcast.uri'
+                                                    }
+                                                }],
+                                                dataProvider: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("listRouters&id=" + args.context.routers[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jsonObj = json.listroutersresponse.router[0].nic;
+
+                                                            args.response.success({
+                                                                actionFilter: routerActionfilter,
+                                                                data: $.map(jsonObj, function (nic, index) {
+                                                                    var name = 'NIC ' + (index + 1);
+                                                                    if (nic.isdefault) {
+                                                                        name += ' (' + _l('label.default') + ')';
+                                                                    }
+                                                                    return $.extend(nic, {
+                                                                        name: name
+                                                                    });
+                                                                })
+                                                            });
+                                                        }
+                                                    });
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        },
+                        actions: {
+                            enable: {
+                                label: 'label.enable.provider',
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("updateNetworkServiceProvider&id=" + nspMap["Ovs"].id + "&state=Enabled"),
+                                        dataType: "json",
+                                        success: function (json) {
+                                            var jid = json.updatenetworkserviceproviderresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid,
+                                                    getUpdatedItem: function (json) {
+                                                        $(window).trigger('cloudStack.fullRefresh');
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    });
+                                },
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.enable.provider';
+                                    },
+                                    notification: function () {
+                                        return 'label.enable.provider';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            },
+                            disable: {
+                                label: 'label.disable.provider',
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("updateNetworkServiceProvider&id=" + nspMap["Ovs"].id + "&state=Disabled"),
+                                        dataType: "json",
+                                        success: function (json) {
+                                            var jid = json.updatenetworkserviceproviderresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid,
+                                                    getUpdatedItem: function (json) {
+                                                        $(window).trigger('cloudStack.fullRefresh');
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    });
+                                },
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.disable.provider';
+                                    },
+                                    notification: function () {
+                                        return 'label.disable.provider';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        show: cloudStack.uiCustom.physicalResources({
+            sections: {
+                physicalResources: {
+                    type: 'select',
+                    title: 'Physical Resources',
+                    listView: {
+                        zones: {
+                            id: 'physicalResources',
+                            label: 'label.menu.physical.resources',
+                            fields: {
+                                name: {
+                                    label: 'label.zone'
+                                },
+                                networktype: {
+                                    label: 'label.network.type'
+                                },
+                                domainid: {
+                                    label: 'label.public',
+                                    converter: function(args) {
+                                        if (args == null)
+                                            return "Yes";
+                                        else
+                                            return "No";
+                                    }
+                                },
+                                allocationstate: {
+                                    label: 'label.allocation.state',
+                                    converter: function(str) {
+                                        // For localization
+                                        return str;
+                                    },
+                                    indicator: {
+                                        'Enabled': 'on',
+                                        'Disabled': 'off'
+                                    }
+                                }
                             },
                             destroy: {
                                 label: 'label.shutdown.provider',
@@ -18114,48 +18715,45 @@
                 if (items != null) {
                     for (var i = 0; i < items.length; i++) {
                         switch (items[i].name) {
-                            case "VirtualRouter":
-                                nspMap["virtualRouter"] = items[i];
-                                break;
-                            case "InternalLbVm":
-                                nspMap["InternalLbVm"] = items[i];
-                                break;
-                            case "VpcVirtualRouter":
-                                nspMap["vpcVirtualRouter"] = items[i];
-                                break;
-                            case "Ovs":
-                                nspMap["Ovs"] = items[i];
-                                break;      
-                            case "Netscaler":
-                                nspMap["netscaler"] = items[i];
-                                break;
-                            case "MidoNet":
-                                nspMap["midoNet"] = items[i];
-                                break;
-                            case "BaremetalDhcpProvider":
-                                nspMap["BaremetalDhcpProvider"] = items[i];
-                                break;
-                            case "BaremetalPxeProvider":
-                                nspMap["BaremetalPxeProvider"] = items[i];
-                                break;
-                            case "F5BigIp":
-                                nspMap["f5"] = items[i];
-                                break;
-                            case "JuniperSRX":
-                                nspMap["srx"] = items[i];
-                                break;
-                            case "PaloAlto":
-                                nspMap["pa"] = items[i];
-                                break;
-                            case "SecurityGroupProvider":
-                                nspMap["securityGroups"] = items[i];
-                                break;
-                            case "NiciraNvp":
-                                nspMap["niciraNvp"] = items[i];
-                                break;
-                            case "BigSwitchVns":
-                                nspMap["bigswitchVns"] = items[i];
-                                break;
+                        case "VirtualRouter":
+                            nspMap["virtualRouter"] = items[i];
+                            break;
+                        case "Ovs":
+                            nspMap["Ovs"] = items[i];
+                            break;
+                        case "InternalLbVm":
+                            nspMap["InternalLbVm"] = items[i];
+                            break;
+                        case "VpcVirtualRouter":
+                            nspMap["vpcVirtualRouter"] = items[i];
+                            break;
+                        case "Netscaler":
+                            nspMap["netscaler"] = items[i];
+                            break;
+                        case "MidoNet":
+                            nspMap["midoNet"] = items[i];
+                            break;
+                        case "BaremetalDhcpProvider":
+                            nspMap["BaremetalDhcpProvider"] = items[i];
+                            break;
+                        case "BaremetalPxeProvider":
+                            nspMap["BaremetalPxeProvider"] = items[i];
+                            break;
+                        case "F5BigIp":
+                            nspMap["f5"] = items[i];
+                            break;
+                        case "JuniperSRX":
+                            nspMap["srx"] = items[i];
+                            break;
+                        case "SecurityGroupProvider":
+                            nspMap["securityGroups"] = items[i];
+                            break;
+                        case "NiciraNvp":
+                            nspMap["niciraNvp"] = items[i];
+                            break;
+                        case "BigSwitchVns":
+                            nspMap["bigswitchVns"] = items[i];
+                            break;
                         }
                     }
                 }
@@ -18171,6 +18769,10 @@
             name: 'Virtual Router',
             state: nspMap.virtualRouter ? nspMap.virtualRouter.state : 'Disabled'
         }, {
+            id: 'Ovs',
+            name: 'Ovs',
+            state: nspMap.Ovs ? nspMap.Ovs.state : 'Disabled'
+        }, {
             id: 'niciraNvp',
             name: 'Nicira Nvp',
             state: nspMap.niciraNvp ? nspMap.niciraNvp.state : 'Disabled'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/065ac54b/ui/scripts/zoneWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js
index 006bf7d..6bafab4 100755
--- a/ui/scripts/zoneWizard.js
+++ b/ui/scripts/zoneWizard.js
@@ -354,12 +354,12 @@
                         success: function(json) {
                             var items = json.listconfigurationsresponse.configuration; //2 entries returned: 'sdn.ovs.controller', 'sdn.ovs.controller.default.label'
                             $(items).each(function() {
-                                if (this.name == 'sdn.ovs.controller') {
-                                    if (this.value == 'true' || this.value == true) {
-                                        skipGuestTrafficStep = true;
-                                    }
-                                    return false; //break each loop
-                                }
+                   //             if (this.name == 'sdn.ovs.controller') {
+                   //                 if (this.value == 'true' || this.value == true) {
+                   //                     skipGuestTrafficStep = true;
+                   //                 }
+                   //                 return false; //break each loop
+                   //             }
                             });
                         }
                     });
@@ -3021,6 +3021,102 @@
                                                         });
                                                         // ***** Virtual Router ***** (end) *****
 
+                                                        // ***** Ovs ***** (begin) *****
+                                                        var ovsProviderId =  null;
+                                                        $.ajax({
+                                                            url: createURL("listNetworkServiceProviders&name=Ovs&physicalNetworkId=" + thisPhysicalNetwork.id),
+                                                            dataType: "json",
+                                                            async: false,
+                                                            success: function (json) {
+                                                                var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
+                                                                if (items != null && items.length > 0) {
+                                                                    ovsProviderId = items[0].id;
+                                                                }
+                                                            }
+                                                        });
+                                                        if (ovsProviderId != null) {
+                                                            var ovsElementId = null;
+                                                            $.ajax({
+                                                                url: createURL("listOvsElements&nspid=" + ovsProviderId),
+                                                                dataType: "json",
+                                                                async: false,
+                                                                success: function (json) {
+                                                                    var items = json.listovselementsresponse.ovselement;
+                                                                    if (items != null && items.length > 0) {
+                                                                        ovsElementId = items[0].id;
+                                                                    }
+                                                                }
+                                                            });
+                                                            if (ovsElementId != null) {
+                                                                $.ajax({
+                                                                    url: createURL("configureOvsElement&enabled=true&id=" + ovsElementId),
+                                                                    dataType: "json",
+                                                                    async: false,
+                                                                    success: function (json) {
+                                                                        var jobId = json.configureovselementresponse.jobid;
+                                                                        var enableOvsElementIntervalID = setInterval(function () {
+                                                                            $.ajax({
+                                                                                url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                                dataType: "json",
+                                                                                success: function (json) {
+                                                                                    var result = json.queryasyncjobresultresponse;
+                                                                                    if (result.jobstatus == 0) {
+                                                                                        return; //Job has not completed
+                                                                                    } else {
+                                                                                        clearInterval(enableOvsElementIntervalID);
+
+                                                                                        if (result.jobstatus == 1) { //configureOvsElement succeeded
+                                                                                            $.ajax({
+                                                                                                url: createURL("updateNetworkServiceProvider&state=Enabled&id=" + ovsProviderId),
+                                                                                                dataType: "json",
+                                                                                                async: false,
+                                                                                                success: function (json) {
+                                                                                                    var jobId = json.updatenetworkserviceproviderresponse.jobid;
+                                                                                                    var enableOvsProviderIntervalID = setInterval(function () {
+                                                                                                        $.ajax({
+                                                                                                            url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                                                            dataType: "json",
+                                                                                                            success: function (json) {
+                                                                                                                var result = json.queryasyncjobresultresponse;
+                                                                                                                if (result.jobstatus == 0) {
+                                                                                                                    return; //Job has not completed
+                                                                                                                } else {
+                                                                                                                    clearInterval(enableOvsProviderIntervalID);
+
+                                                                                                                    if (result.jobstatus == 2) {
+                                                                                                                        alert("failed to enable Ovs Provider. Error: " + _s(result.jobresult.errortext));
+                                                                                                                    }
+                                                                                                                }
+                                                                                                            },
+                                                                                                            error: function (XMLHttpResponse) {
+                                                                                                                var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                                                                alert("updateNetworkServiceProvider failed. Error: " + errorMsg);
+                                                                                                            }
+                                                                                                        });
+                                                                                                    }, g_queryAsyncJobResultInterval);
+                                                                                                }
+                                                                                            });
+                                                                                        } else if (result.jobstatus == 2) {
+                                                                                            alert("configureOvsElement failed. Error: " + _s(result.jobresult.errortext));
+                                                                                        }
+                                                                                    }
+                                                                                },
+                                                                                error: function (XMLHttpResponse) {
+                                                                                    var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                                    alert("configureOvsElement failed. Error: " + errorMsg);
+                                                                                }
+                                                                            });
+                                                                        }, g_queryAsyncJobResultInterval);
+                                                                    }
+                                                                });
+                                                            }
+
+
+                                                        }
+
+
+                                                        // ***** Ovs ***** (end) *****
+
                                                         // ***** Internal LB ***** (begin) *****
                                                         var internalLbProviderId;
                                                         $.ajax({


Mime
View raw message