@@ -5875,24 +5875,315 @@ exports.init = function (cli) {
5875
5875
vmssvm . command ( 'list' )
5876
5876
. description ( $ ( 'list method to manage your virtual machine scale set vm.' ) )
5877
5877
. usage ( '[options]' )
5878
- . option ( '--expand-expression <expand-expression>' , $ ( 'expand-expression' ) )
5879
- . option ( '--filter-expression <filter-expression>' , $ ( 'filter-expression' ) )
5880
- . option ( '--resource-group-name <resource-group-name>' , $ ( 'resource-group-name' ) )
5881
- . option ( '--select-expression <select-expression>' , $ ( 'select-expression' ) )
5882
- . option ( '--virtual-machine-scale-set-name <virtual-machine-scale-set-name>' , $ ( 'virtual-machine-scale-set-name' ) )
5878
+ . option ( '--parameters <parameters>' , $ ( 'parameters' ) )
5883
5879
. option ( '--parameter-file <parameter-file>' , $ ( 'the input parameter file' ) )
5884
5880
. option ( '-s, --subscription <subscription>' , $ ( 'the subscription identifier' ) )
5885
- . execute ( function ( expandExpression , filterExpression , resourceGroupName , selectExpression , virtualMachineScaleSetName , options , _ ) {
5886
- cli . output . info ( 'expandExpression = ' + options . expandExpression ) ;
5887
- cli . output . info ( 'filterExpression = ' + options . filterExpression ) ;
5888
- cli . output . info ( 'resourceGroupName = ' + options . resourceGroupName ) ;
5889
- cli . output . info ( 'selectExpression = ' + options . selectExpression ) ;
5890
- cli . output . info ( 'virtualMachineScaleSetName = ' + options . virtualMachineScaleSetName ) ;
5881
+ . execute ( function ( parameters , options , _ ) {
5882
+ cli . output . info ( 'parameters = ' + options . parameters ) ;
5883
+ if ( options . parameterFile ) {
5884
+ cli . output . info ( "Reading file content from: \"" + options . parameterFile + "\"" ) ;
5885
+ var fileContent = fs . readFileSync ( options . parameterFile , 'utf8' ) ;
5886
+ var parametersObj = JSON . parse ( fileContent ) ;
5887
+ }
5888
+ else {
5889
+ var parametersObj = JSON . parse ( options . parameters ) ;
5890
+ }
5891
+ cli . output . info ( 'parametersObj = ' + JSON . stringify ( parametersObj ) ) ;
5891
5892
var subscription = profile . current . getSubscription ( options . subscription ) ;
5892
5893
var computeManagementClient = utils . createComputeResourceProviderClient ( subscription ) ;
5893
- var result = computeManagementClient . virtualMachineScaleSetVMs . list ( options . expandExpression , options . filterExpression , options . resourceGroupName , options . selectExpression , options . virtualMachineScaleSetName , _ ) ;
5894
+ var result = computeManagementClient . virtualMachineScaleSetVMs . list ( parametersObj , _ ) ;
5894
5895
cli . output . json ( result ) ;
5895
5896
} ) ;
5897
+ var parameters = vmssvm . category ( 'parameters' )
5898
+ . description ( $ ( 'Commands to manage parameter for your virtual machine scale set vm.' ) ) ;
5899
+ var generate = parameters . category ( 'generate' )
5900
+ . description ( $ ( 'Commands to generate parameter file for your virtual machine scale set vm.' ) ) ;
5901
+ generate . command ( 'list' )
5902
+ . description ( $ ( 'Generate vmssvm parameter string or files.' ) )
5903
+ . usage ( '[options]' )
5904
+ . option ( '--parameter-file <parameter-file>' , $ ( 'The parameter file path.' ) )
5905
+ . execute ( function ( parameterFile , options , _ ) {
5906
+ cli . output . info ( "{\"expandExpression\":\"\",\"filterExpression\":\"\",\"resourceGroupName\":\"\",\"selectExpression\":\"\",\"virtualMachineScaleSetName\":\"\"}" ) ;
5907
+ var filePath = "vmssvm_list.json" ;
5908
+ if ( options . parameterFile ) { filePath = options . parameterFile ; } ;
5909
+ fs . writeFileSync ( filePath , beautify ( "{\r\n\"expandExpression\":\"\",\r\n\"filterExpression\":\"\",\r\n\"resourceGroupName\":\"\",\r\n\"selectExpression\":\"\",\r\n\"virtualMachineScaleSetName\":\"\"\r\n}" ) ) ;
5910
+ cli . output . info ( "=====================================" ) ;
5911
+ cli . output . info ( "Parameter file output to: " + filePath ) ;
5912
+ cli . output . info ( "=====================================" ) ;
5913
+ } ) ;
5914
+
5915
+ parameters . command ( 'patch' )
5916
+ . description ( $ ( 'Command to patch vmssvm parameter JSON file.' ) )
5917
+ . usage ( '[options]' )
5918
+ . option ( '--parameter-file <parameter-file>' , $ ( 'The parameter file path.' ) )
5919
+ . option ( '--operation <operation>' , $ ( 'The JSON patch operation: add, remove, or replace.' ) )
5920
+ . option ( '--path <path>' , $ ( 'The JSON data path, e.g.: \"foo/1\".' ) )
5921
+ . option ( '--value <value>' , $ ( 'The JSON value.' ) )
5922
+ . option ( '--parse' , $ ( 'Parse the JSON value to object.' ) )
5923
+ . execute ( function ( parameterFile , operation , path , value , parse , options , _ ) {
5924
+ cli . output . info ( options . parameterFile ) ;
5925
+ cli . output . info ( options . operation ) ;
5926
+ cli . output . info ( options . path ) ;
5927
+ cli . output . info ( options . value ) ;
5928
+ cli . output . info ( options . parse ) ;
5929
+ if ( options . parse ) {
5930
+ options . value = JSON . parse ( options . value ) ;
5931
+ }
5932
+ cli . output . info ( options . value ) ;
5933
+ cli . output . info ( "=====================================" ) ;
5934
+ cli . output . info ( "Reading file content from: \"" + options . parameterFile + "\"" ) ;
5935
+ cli . output . info ( "=====================================" ) ;
5936
+ var fileContent = fs . readFileSync ( options . parameterFile , 'utf8' ) ;
5937
+ var parametersObj = JSON . parse ( fileContent ) ;
5938
+ cli . output . info ( "JSON object:" ) ;
5939
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
5940
+ if ( options . operation == 'add' ) {
5941
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : options . path , value : options . value } ] ) ;
5942
+ }
5943
+ else if ( options . operation == 'remove' ) {
5944
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : options . path } ] ) ;
5945
+ }
5946
+ else if ( options . operation == 'replace' ) {
5947
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : options . path , value : options . value } ] ) ;
5948
+ }
5949
+ var updatedContent = JSON . stringify ( parametersObj ) ;
5950
+ cli . output . info ( "=====================================" ) ;
5951
+ cli . output . info ( "JSON object (updated):" ) ;
5952
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
5953
+ cli . output . info ( "=====================================" ) ;
5954
+ fs . writeFileSync ( options . parameterFile , beautify ( updatedContent ) ) ;
5955
+ cli . output . info ( "=====================================" ) ;
5956
+ cli . output . info ( "Parameter file updated at: " + options . parameterFile ) ;
5957
+ cli . output . info ( "=====================================" ) ;
5958
+ } ) ;
5959
+
5960
+ //parameters set virtual-machine-scale-set-vm-list-parameters
5961
+ var parameters = vmssvm . category ( 'parameters' )
5962
+ . description ( $ ( 'Commands to manage parameter for your virtual-machine-scale-set-vm.' ) ) ;
5963
+ var set = parameters . category ( 'set' )
5964
+ . description ( $ ( 'Commands to set parameter file for your virtual-machine-scale-set-vm.' ) ) ;
5965
+ set . command ( 'virtual-machine-scale-set-vm-list-parameters' )
5966
+ . description ( $ ( 'Set vmssvm parameter string or files.' ) )
5967
+ . usage ( '[options]' )
5968
+ . option ( '--parameter-file <parameter-file>' , $ ( 'The parameter file path.' ) )
5969
+ . option ( '--value <value>' , $ ( 'The JSON value.' ) )
5970
+ . option ( '--parse' , $ ( 'Parse the JSON value to object.' ) )
5971
+ . option ( '--expand-expression <expandExpression>' , $ ( 'Set the expand-expression value.' ) )
5972
+ . option ( '--filter-expression <filterExpression>' , $ ( 'Set the filter-expression value.' ) )
5973
+ . option ( '--resource-group-name <resourceGroupName>' , $ ( 'Set the resource-group-name value.' ) )
5974
+ . option ( '--select-expression <selectExpression>' , $ ( 'Set the select-expression value.' ) )
5975
+ . option ( '--virtual-machine-scale-set-name <virtualMachineScaleSetName>' , $ ( 'Set the virtual-machine-scale-set-name value.' ) )
5976
+ . execute ( function ( parameterFile , options , _ ) {
5977
+ cli . output . info ( options ) ;
5978
+ cli . output . info ( options . parameterFile ) ;
5979
+ cli . output . info ( options . value ) ;
5980
+ cli . output . info ( options . parse ) ;
5981
+ if ( options . parse && options . value ) {
5982
+ options . value = JSON . parse ( options . value ) ;
5983
+ }
5984
+ cli . output . info ( options . value ) ;
5985
+ cli . output . info ( "=====================================" ) ;
5986
+ cli . output . info ( "Reading file content from: \"" + options . parameterFile + "\"" ) ;
5987
+ cli . output . info ( "=====================================" ) ;
5988
+ var fileContent = fs . readFileSync ( options . parameterFile , 'utf8' ) ;
5989
+ var parametersObj = JSON . parse ( fileContent ) ;
5990
+ cli . output . info ( "JSON object:" ) ;
5991
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
5992
+ options . operation = 'replace' ;
5993
+ options . path = "" ;
5994
+ var paramPath = options . path + "/" + "expandExpression" ;
5995
+ cli . output . info ( "================================================" ) ;
5996
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
5997
+ cli . output . info ( "================================================" ) ;
5998
+ if ( options . expandExpression ) {
5999
+ if ( options . parse && options . expandExpression ) {
6000
+ options . expandExpression = JSON . parse ( options . expandExpression ) ;
6001
+ }
6002
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . expandExpression } ] ) ;
6003
+ }
6004
+ var paramPath = options . path + "/" + "filterExpression" ;
6005
+ cli . output . info ( "================================================" ) ;
6006
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6007
+ cli . output . info ( "================================================" ) ;
6008
+ if ( options . filterExpression ) {
6009
+ if ( options . parse && options . filterExpression ) {
6010
+ options . filterExpression = JSON . parse ( options . filterExpression ) ;
6011
+ }
6012
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . filterExpression } ] ) ;
6013
+ }
6014
+ var paramPath = options . path + "/" + "resourceGroupName" ;
6015
+ cli . output . info ( "================================================" ) ;
6016
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6017
+ cli . output . info ( "================================================" ) ;
6018
+ if ( options . resourceGroupName ) {
6019
+ if ( options . parse && options . resourceGroupName ) {
6020
+ options . resourceGroupName = JSON . parse ( options . resourceGroupName ) ;
6021
+ }
6022
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . resourceGroupName } ] ) ;
6023
+ }
6024
+ var paramPath = options . path + "/" + "selectExpression" ;
6025
+ cli . output . info ( "================================================" ) ;
6026
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6027
+ cli . output . info ( "================================================" ) ;
6028
+ if ( options . selectExpression ) {
6029
+ if ( options . parse && options . selectExpression ) {
6030
+ options . selectExpression = JSON . parse ( options . selectExpression ) ;
6031
+ }
6032
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . selectExpression } ] ) ;
6033
+ }
6034
+ var paramPath = options . path + "/" + "virtualMachineScaleSetName" ;
6035
+ cli . output . info ( "================================================" ) ;
6036
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6037
+ cli . output . info ( "================================================" ) ;
6038
+ if ( options . virtualMachineScaleSetName ) {
6039
+ if ( options . parse && options . virtualMachineScaleSetName ) {
6040
+ options . virtualMachineScaleSetName = JSON . parse ( options . virtualMachineScaleSetName ) ;
6041
+ }
6042
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . virtualMachineScaleSetName } ] ) ;
6043
+ }
6044
+ var updatedContent = JSON . stringify ( parametersObj ) ;
6045
+ cli . output . info ( "=====================================" ) ;
6046
+ cli . output . info ( "JSON object (updated):" ) ;
6047
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
6048
+ cli . output . info ( "=====================================" ) ;
6049
+ fs . writeFileSync ( options . parameterFile , beautify ( updatedContent ) ) ;
6050
+ cli . output . info ( "=====================================" ) ;
6051
+ cli . output . info ( "Parameter file updated at: " + options . parameterFile ) ;
6052
+ cli . output . info ( "=====================================" ) ;
6053
+ } ) ;
6054
+
6055
+ //parameters remove virtual-machine-scale-set-vm-list-parameters
6056
+ var parameters = vmssvm . category ( 'parameters' )
6057
+ . description ( $ ( 'Commands to remove parameter for your virtual-machine-scale-set-vm.' ) ) ;
6058
+ var remove = parameters . category ( 'remove' )
6059
+ . description ( $ ( 'Commands to remove values in the parameter file for your virtual-machine-scale-set-vm.' ) ) ;
6060
+ remove . command ( 'virtual-machine-scale-set-vm-list-parameters' )
6061
+ . description ( $ ( 'Remove vmssvm parameter string or files.' ) )
6062
+ . usage ( '[options]' )
6063
+ . option ( '--parameter-file <parameter-file>' , $ ( 'The parameter file path.' ) )
6064
+ . execute ( function ( parameterFile , options , _ ) {
6065
+ cli . output . info ( options ) ;
6066
+ cli . output . info ( options . parameterFile ) ;
6067
+ cli . output . info ( "=====================================" ) ;
6068
+ cli . output . info ( "Reading file content from: \"" + options . parameterFile + "\"" ) ;
6069
+ cli . output . info ( "=====================================" ) ;
6070
+ var fileContent = fs . readFileSync ( options . parameterFile , 'utf8' ) ;
6071
+ var parametersObj = JSON . parse ( fileContent ) ;
6072
+ cli . output . info ( "JSON object:" ) ;
6073
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
6074
+ options . operation = 'remove' ;
6075
+ options . path = "" ;
6076
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : options . path } ] ) ;
6077
+ var updatedContent = JSON . stringify ( parametersObj ) ;
6078
+ cli . output . info ( "=====================================" ) ;
6079
+ cli . output . info ( "JSON object (updated):" ) ;
6080
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
6081
+ cli . output . info ( "=====================================" ) ;
6082
+ fs . writeFileSync ( options . parameterFile , beautify ( updatedContent ) ) ;
6083
+ cli . output . info ( "=====================================" ) ;
6084
+ cli . output . info ( "Parameter file updated at: " + options . parameterFile ) ;
6085
+ cli . output . info ( "=====================================" ) ;
6086
+ } ) ;
6087
+ //parameters add virtual-machine-scale-set-vm-list-parameters
6088
+ var parameters = vmssvm . category ( 'parameters' )
6089
+ . description ( $ ( 'Commands to add parameter for your virtual-machine-scale-set-vm.' ) ) ;
6090
+ var add = parameters . category ( 'add' )
6091
+ . description ( $ ( 'Commands to add values in the parameter file for your virtual-machine-scale-set-vm.' ) ) ;
6092
+ add . command ( 'virtual-machine-scale-set-vm-list-parameters' )
6093
+ . description ( $ ( 'Remove vmssvm parameter string or files.' ) )
6094
+ . usage ( '[options]' )
6095
+ . option ( '--parameter-file <parameter-file>' , $ ( 'The parameter file path.' ) )
6096
+ . option ( '--key <key>' , $ ( 'The JSON key.' ) )
6097
+ . option ( '--value <value>' , $ ( 'The JSON value.' ) )
6098
+ . option ( '--parse' , $ ( 'Parse the JSON value to object.' ) )
6099
+ . option ( '--expand-expression <expandExpression>' , $ ( 'Add the expand-expression value.' ) )
6100
+ . option ( '--filter-expression <filterExpression>' , $ ( 'Add the filter-expression value.' ) )
6101
+ . option ( '--resource-group-name <resourceGroupName>' , $ ( 'Add the resource-group-name value.' ) )
6102
+ . option ( '--select-expression <selectExpression>' , $ ( 'Add the select-expression value.' ) )
6103
+ . option ( '--virtual-machine-scale-set-name <virtualMachineScaleSetName>' , $ ( 'Add the virtual-machine-scale-set-name value.' ) )
6104
+ . execute ( function ( parameterFile , options , _ ) {
6105
+ cli . output . info ( options ) ;
6106
+ cli . output . info ( options . parameterFile ) ;
6107
+ cli . output . info ( options . key ) ;
6108
+ cli . output . info ( options . value ) ;
6109
+ cli . output . info ( options . parse ) ;
6110
+ if ( options . parse && options . value ) {
6111
+ options . value = JSON . parse ( options . value ) ;
6112
+ }
6113
+ cli . output . info ( options . value ) ;
6114
+ cli . output . info ( "=====================================" ) ;
6115
+ cli . output . info ( "Reading file content from: \"" + options . parameterFile + "\"" ) ;
6116
+ cli . output . info ( "=====================================" ) ;
6117
+ var fileContent = fs . readFileSync ( options . parameterFile , 'utf8' ) ;
6118
+ var parametersObj = JSON . parse ( fileContent ) ;
6119
+ cli . output . info ( "JSON object:" ) ;
6120
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
6121
+ options . operation = 'add' ;
6122
+ options . path = "" + "/" + options . key ;
6123
+ cli . output . info ( "options.path = " + options . path ) ;
6124
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : options . path , value : options . value } ] ) ;
6125
+ var paramPath = "" + "/" + "expandExpression" ;
6126
+ cli . output . info ( "================================================" ) ;
6127
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6128
+ cli . output . info ( "================================================" ) ;
6129
+ if ( options . expandExpression ) {
6130
+ if ( options . parse && options . expandExpression ) {
6131
+ options . expandExpression = JSON . parse ( options . expandExpression ) ;
6132
+ }
6133
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . expandExpression } ] ) ;
6134
+ }
6135
+ var paramPath = "" + "/" + "filterExpression" ;
6136
+ cli . output . info ( "================================================" ) ;
6137
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6138
+ cli . output . info ( "================================================" ) ;
6139
+ if ( options . filterExpression ) {
6140
+ if ( options . parse && options . filterExpression ) {
6141
+ options . filterExpression = JSON . parse ( options . filterExpression ) ;
6142
+ }
6143
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . filterExpression } ] ) ;
6144
+ }
6145
+ var paramPath = "" + "/" + "resourceGroupName" ;
6146
+ cli . output . info ( "================================================" ) ;
6147
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6148
+ cli . output . info ( "================================================" ) ;
6149
+ if ( options . resourceGroupName ) {
6150
+ if ( options . parse && options . resourceGroupName ) {
6151
+ options . resourceGroupName = JSON . parse ( options . resourceGroupName ) ;
6152
+ }
6153
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . resourceGroupName } ] ) ;
6154
+ }
6155
+ var paramPath = "" + "/" + "selectExpression" ;
6156
+ cli . output . info ( "================================================" ) ;
6157
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6158
+ cli . output . info ( "================================================" ) ;
6159
+ if ( options . selectExpression ) {
6160
+ if ( options . parse && options . selectExpression ) {
6161
+ options . selectExpression = JSON . parse ( options . selectExpression ) ;
6162
+ }
6163
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . selectExpression } ] ) ;
6164
+ }
6165
+ var paramPath = "" + "/" + "virtualMachineScaleSetName" ;
6166
+ cli . output . info ( "================================================" ) ;
6167
+ cli . output . info ( "JSON Parameters Path:" + paramPath ) ;
6168
+ cli . output . info ( "================================================" ) ;
6169
+ if ( options . virtualMachineScaleSetName ) {
6170
+ if ( options . parse && options . virtualMachineScaleSetName ) {
6171
+ options . virtualMachineScaleSetName = JSON . parse ( options . virtualMachineScaleSetName ) ;
6172
+ }
6173
+ jsonpatch . apply ( parametersObj , [ { op : options . operation , path : paramPath , value : options . virtualMachineScaleSetName } ] ) ;
6174
+ }
6175
+ var updatedContent = JSON . stringify ( parametersObj ) ;
6176
+ cli . output . info ( "=====================================" ) ;
6177
+ cli . output . info ( "JSON object (updated):" ) ;
6178
+ cli . output . info ( JSON . stringify ( parametersObj ) ) ;
6179
+ cli . output . info ( "=====================================" ) ;
6180
+ fs . writeFileSync ( options . parameterFile , beautify ( updatedContent ) ) ;
6181
+ cli . output . info ( "=====================================" ) ;
6182
+ cli . output . info ( "Parameter file updated at: " + options . parameterFile ) ;
6183
+ cli . output . info ( "=====================================" ) ;
6184
+ } ) ;
6185
+
6186
+
5896
6187
//virtualMachineScaleSetVM -> PowerOff
5897
6188
var vmssvm = cli . category ( 'vmssvm' ) . description ( $ ( 'Commands to manage your virtual machine scale set vm.' ) ) ;
5898
6189
vmssvm . command ( 'power-off' )
0 commit comments