|
3060 | 3060 | notification: { |
3061 | 3061 | poll: pollAsyncJobResult |
3062 | 3062 | } |
3063 | | - } |
| 3063 | + }, |
| 3064 | + |
| 3065 | + migrate: { |
| 3066 | + label: 'Migrate LB VM', |
| 3067 | + createForm: { |
| 3068 | + title: 'Migrate LB VM', |
| 3069 | + fields: { |
| 3070 | + hostId: { |
| 3071 | + label: 'label.host', |
| 3072 | + validation: { required: true }, |
| 3073 | + select: function(args) { |
| 3074 | + $.ajax({ |
| 3075 | + url: createURL("listHosts&VirtualMachineId=" + args.context.internallbinstances[0].id), |
| 3076 | + dataType: "json", |
| 3077 | + async: true, |
| 3078 | + success: function(json) { |
| 3079 | + var hostObjs = json.listhostsresponse.host; |
| 3080 | + var items = []; |
| 3081 | + $(hostObjs).each(function() { |
| 3082 | + items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable": "Not Suitable") + ")")}); |
| 3083 | + }); |
| 3084 | + args.response.success({data: items}); |
| 3085 | + } |
| 3086 | + }); |
| 3087 | + }, |
| 3088 | + error: function(XMLHttpResponse) { |
| 3089 | + var errorMsg = parseXMLHttpResponse(XMLHttpResponse); |
| 3090 | + args.response.error(errorMsg); |
| 3091 | + } |
| 3092 | + } |
| 3093 | + } |
| 3094 | + }, |
| 3095 | + messages: { |
| 3096 | + notification: function(args) { |
| 3097 | + return 'Migrate LB VM'; |
| 3098 | + } |
| 3099 | + }, |
| 3100 | + action: function(args) { |
| 3101 | + $.ajax({ |
| 3102 | + url: createURL("migrateSystemVm&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.internallbinstances[0].id), |
| 3103 | + dataType: "json", |
| 3104 | + async: true, |
| 3105 | + success: function(json) { |
| 3106 | + var jid = json.migratesystemvmresponse.jobid; |
| 3107 | + args.response.success({ |
| 3108 | + _custom: { |
| 3109 | + jobId: jid, |
| 3110 | + getUpdatedItem: function(json) { |
| 3111 | + //return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance |
| 3112 | + $.ajax({ |
| 3113 | + url: createURL("listInternalLoadBalancerVMs&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id), |
| 3114 | + dataType: "json", |
| 3115 | + async: false, |
| 3116 | + success: function(json) { |
| 3117 | + var items = json.listinternallbvmssresponse.internalloadbalancervm; |
| 3118 | + if(items != null && items.length > 0) { |
| 3119 | + return items[0]; |
| 3120 | + } |
| 3121 | + } |
| 3122 | + }); |
| 3123 | + }, |
| 3124 | + getActionFilter: function() { |
| 3125 | + return internallbinstanceActionfilter; |
| 3126 | + } |
| 3127 | + } |
| 3128 | + }); |
| 3129 | + } |
| 3130 | + }); |
| 3131 | + }, |
| 3132 | + notification: { |
| 3133 | + poll: pollAsyncJobResult |
| 3134 | + } |
| 3135 | + }, |
| 3136 | + |
| 3137 | + viewConsole: { |
| 3138 | + label: 'label.view.console', |
| 3139 | + action: { |
| 3140 | + externalLink: { |
| 3141 | + url: function(args) { |
| 3142 | + return clientConsoleUrl + '?cmd=access&vm=' + args.context.internallbinstances[0].id; |
| 3143 | + }, |
| 3144 | + title: function(args) { |
| 3145 | + return args.context.internallbinstances[0].id.substr(0,8); //title in window.open() can't have space nor longer than 8 characters. Otherwise, IE browser will have error. |
| 3146 | + }, |
| 3147 | + width: 820, |
| 3148 | + height: 640 |
| 3149 | + } |
| 3150 | + } |
| 3151 | + } |
3064 | 3152 | }, |
3065 | 3153 | tabs: { |
3066 | 3154 | details: { |
|
14797 | 14885 |
|
14798 | 14886 | if (jsonObj.state == 'Running') { |
14799 | 14887 | allowedActions.push("stop"); |
| 14888 | + |
| 14889 | + allowedActions.push("viewConsole"); |
| 14890 | + if (isAdmin()) |
| 14891 | + allowedActions.push("migrate"); |
14800 | 14892 | } |
14801 | 14893 | else if (jsonObj.state == 'Stopped') { |
14802 | 14894 | allowedActions.push("start"); |
|
0 commit comments