Skip to main content

Hi, 

I have tried API Automation for Move and here is something that I am stuck for Linux based VMs that use SSH Key(PEM) to authenticate to root user.

For the POST API for Preparing the Environment /move/v2/plans/{id}/prepare, I use the payload:
            payload = {
                "APIVersion": "2.2.0",
                "Spec": {
                    "CommonCredentials": {
                    },
                    "GuestPrepMode": "auto",
                    "RunInBackground": True,
                    "VMs":
                        {
                            "PemFile": credentials "lpemfile"],
                            "Password": "",
                            "UserName": "root",
                            "UUID": self.vm_details""uuid"],
                            "VMId": self.vm_detailso"vm_id"]
                        }
                    ]
                },
                "Type": "VM"
            }


The value for lpemfile is "/home/user123/move/linuxauth.pem".
The PEM file itself is valid. I try the manual GUI method and it goes through fine. 

My Windows credentials which use a local admin user work absolutely fine but I always end up with “Error validating credentials for VM txlinux001: 'Invalid VM credentials. AllowUVMOps is set but credentials are not provided.'.”

I tried a few combinations of above payload including adding CommonCredentials but still end up with the same result.

Do i need to upload the file to inside VM and specify that path? I am clueless at this point. 

Never Mind.
After around 30 attempts, I got it working by decoding the PEM file and converting to base64 encoded rather than reading it raw. That helped move the Validation Phase.

pem_content = base64.b64encode(pem_raw_content.encode('utf-8')).decode('utf-8')