Scripts

Welcome to the Nutanix NEXT community. To get started please read our short welcome post. Thanks!

cancel
Showing results for 
Search instead for 
Did you mean: 

PowerShell and ImageImportSpec

Scout

PowerShell and ImageImportSpec

Hi,

 

We just got a nutanix cluster and i'm trying to write a script that will migrate a machine from Hyper-V to AHV using powershell.

I have used blog from: https://dsronnie.wordpress.com/2017/07/05/migrate-hyper-v-to-nutanix-ahv/  as input for creating the PowerShell script

 

I can't get it to work.... i'm stuck at importing the image. I'm trying to do a "ImageImportSpec" in powershell but i can't figure out. Here's my code:

 

 

#

$ImgCreateSpec = New-NTNXObject -Name ImageImportSpecDTO
$ContainerID = (Get-NTNXContainer -SearchString "Container Name").id

$ImgCreateSpec.containerid = $ContainerID.Substring($ContainerID.IndexOf(":")+2)
$ImgCreateSpec.url = "nfs://127.0.0.1/migration/Test_DISK01.VHDX"

 

New-NTNXImage -Name "Test" -ImageType DISK_IMAGE -ImageImportSpec $ImgCreateSpec

 

I recieve a task-UUID, but in the web console ImageCreate task is failed almost immediatly. Bucnh of errors in create_task.py and modify_task.py. 

 

Any ideas?

 

I will share my powershell script once I got it working

Thanks

 

 

3 REPLIES
Highlighted
Nutanix Employee

Re: PowerShell and ImageImportSpec

@Buch The script you are using is correct. If the image creation fails immediately then it could be the permissions on the image is restrictive. Please use winscp to connect to one of the CVM ip with protocol as sftp and port as 2222, use prism admin usernameto login. Once logged in Navigate to the migration container and check the properties of the vhdx to see if others have read,write bits set?

Nutanix Employee

Re: PowerShell and ImageImportSpec

@Buch

 

As @Chandru mentioned, this looks like a "Permission issue".

Check the image creation task status in Prism tasks.

If this is a permission issue you will receive error similar to the below.

Screen Shot 2017-11-12 at 12.31.39 PM.png

 

or from powershell.

 

Screen Shot 2017-11-12 at 12.43.56 PM.png

Check the file permission and set it to 777.

Screen Shot 2017-11-12 at 12.35.20 PM.png

 

After changing the permission try again and image should get created without any issues.

 

Screen Shot 2017-11-12 at 12.37.13 PM.png

 

Task status:

Screen Shot 2017-11-12 at 12.38.53 PM.png

 

Let us know if you still face any issues.

Nutanix Employee

Re: PowerShell and ImageImportSpec

@Buch

How are you?

Is the issue fixed?

Hope we were able to answer your queries.

If so, please mark the post as resolved