google-cloud-powershell
google-cloud-powershell copied to clipboard
I can't figure out how to upgrade a machine instance via powershell.
This doc says it's possible via the console and gcloud, so I expect to be able to do it from powershell too.
I naively tried this:
PS C:\Users\rennie> $link
SelfLink
--------
https://www.googleapis.com/compute/v1/projects/surferjeff-test2/zones/us-west1-b/machineTypes/n1-standard-2
PS C:\Users\rennie> $sqlInstance
CanIpForward : False
CpuPlatform : Intel Broadwell
CreationTimestamp : 2016-12-14T14:52:42.150-08:00
Description :
Disks : {}
Id : 7717844925080695766
Kind : compute#instance
MachineType : https://www.googleapis.com/compute/v1/projects/surferjeff-test2/zones/us-west1-b/machineTypes/n1-st
andard-1
Metadata : Google.Apis.Compute.v1.Data.Metadata
Name : sql-server-1
NetworkInterfaces : {nic0}
Scheduling : Google.Apis.Compute.v1.Data.Scheduling
SelfLink : https://www.googleapis.com/compute/v1/projects/surferjeff-test2/zones/us-west1-b/instances/sql-serv
er-1
ServiceAccounts : {Google.Apis.Compute.v1.Data.ServiceAccount}
Status : RUNNING
StatusMessage :
Tags : Google.Apis.Compute.v1.Data.Tags
Zone : https://www.googleapis.com/compute/v1/projects/surferjeff-test2/zones/us-west1-b
ETag :
PS C:\Users\rennie> $sqlInstance.MachineType = $link
PS C:\Users\rennie> $sqlInstance
CanIpForward : False
CpuPlatform : Intel Broadwell
CreationTimestamp : 2016-12-14T14:52:42.150-08:00
Description :
Disks : {}
Id : 7717844925080695766
Kind : compute#instance
MachineType : @{SelfLink=https://www.googleapis.com/compute/v1/projects/surferjeff-test2/zones/us-west1-b/machine
Types/n1-standard-2}
Metadata : Google.Apis.Compute.v1.Data.Metadata
Name : sql-server-1
NetworkInterfaces : {nic0}
Scheduling : Google.Apis.Compute.v1.Data.Scheduling
SelfLink : https://www.googleapis.com/compute/v1/projects/surferjeff-test2/zones/us-west1-b/instances/sql-serv
er-1
ServiceAccounts : {Google.Apis.Compute.v1.Data.ServiceAccount}
Status : RUNNING
StatusMessage :
Tags : Google.Apis.Compute.v1.Data.Tags
Zone : https://www.googleapis.com/compute/v1/projects/surferjeff-test2/zones/us-west1-b
ETag :
PS C:\Users\rennie> Set-GceInstance $sqlInstance
Set-GceInstance : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Set-GceInstance $sqlInstance
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-GceInstance], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Google.PowerShell.ComputeEngine.SetGceInstanceCmdlet
@SurferJeffAtGoogle, this is not supported yet. We can add parameters -MachineType to Set-GceInstance to support this. Will that be sufficient?
Instead of Set-<Every possible attribute>
, could something like Update-GceInstance $sqlInstance
work?
That sounds good. I think you're right, the Update verb makes more sense here.
Hi @SurferJeffAtGoogle, I was doing some more reading and it seems that the Update verb is supposed to be used to bring a resource up-to-date whereas the Set verb is more to modify data on an existing resource. So actually I think in this case, the Set verb makes more sense. What do you think?
The semantics I'm proposing is that:
Update-GceInstance $sqlInstance
takes no other arguments. It observes whatever fields differ in $sqlInstance from the live values, and updates the live values accordingly. With these proposed semantics, the verb Update
seems more appropriate.
Ping? Was this ever resolved?
I understand Jeff's take here, but I think that what he's proposing would be better implemented by a Commit() method on the Instance class. Part of the issue is that a large number of the properties on that class have public setters whereas perhaps they shouldn't. The more PowerShell way to do it in my opinion is as Quoc suggests, and give the settable properties their own parameters on the Set-GceInstance cmdlet