Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import new license file to container after the license is expired #1027

Closed
eclipses opened this issue Jun 22, 2020 · 14 comments
Closed

Import new license file to container after the license is expired #1027

eclipses opened this issue Jun 22, 2020 · 14 comments

Comments

@eclipses
Copy link
Contributor

Hi,

I did not notice but one of my docker containers running locally had an expired license.

It took a few minutes to figure out what was the issue then I used the following command to import the new license
Import-NavContainerLicense -licenseFile "C:\Licenses\dev.flf" -containerName helloworld-dev
Unfortunately, it does not work because the BCInstance was not running, here the error retrieved:

ServerInstance 'MicrosoftDynamicsNavServer$BC' is not running.
at <ScriptBlock>, <No file>: line 4
ServerInstance 'MicrosoftDynamicsNavServer$BC' is not running.
At C:\Program Files\WindowsPowerShell\Modules\navcontainerhelper\0.7.0.3\ContainerHandling\Invoke-ScriptInNavContainer.ps1:37 char:13
+             Invoke-Command -Session $session -ScriptBlock $scriptbloc ...

The container was running but the instance cannot be run because the license is expired.

I've imported first the file and then invoked the script in the container to change the license and start the instance.
Here the code:

Copy-FileToNavContainer -containerName helloworld-dev -localPath "C:\Licenses\dev.flf" -containerPath c:\run\dev.flf

Invoke-ScriptInNavContainer -containerName helloworld-dev -scriptblock {
  Import-NAVServerLicense BC -LicenseData ([Byte[]]$(Get-Content -Path "c:\run\dev.flf" -Encoding Byte))
  Start-NAVServerInstance -ServerInstance BC
} 

I was thinking if some extra checks maybe could be inserted in the function Import-NavContainerLicense to handle this scenario as well.

@freddydk
Copy link
Contributor

Thanks, will have a look.

@freddydk
Copy link
Contributor

Shipped in 0.7.0.6

@eclipses
Copy link
Contributor Author

Hi Freddy,

The fix does not seem to work if the BC Instance inside the BC Container is stopped and you run

Import-NavContainerLicense -licenseFile "C:\Licenses\dev.flf" -containerName helloworld-dev -restart

@freddydk
Copy link
Contributor

Ahh - so your point is that

Import-NAVServerLicense -LicenseFile $licensefile -ServerInstance $ServerInstance -Database NavDatabase -WarningAction SilentlyContinue

Doesn't work if the service tier isn't running - you need to do the data thing?
Sorry, didn't see that.

/Freddy

@freddydk freddydk reopened this Jun 24, 2020
@eclipses
Copy link
Contributor Author

Probably what is failing the code is this parameter

-Database NavDatabase

if you remove it should work

@eclipses
Copy link
Contributor Author

rather than the -restart you could insert at the same point a check that if the instance is not running it will be started (just a suggestion)

@freddydk
Copy link
Contributor

I actually cannot make the import-navserverlicense work if I have stopped the service tier - no matter what parameter set I use:-(

@eclipses
Copy link
Contributor Author

But my code worked with Instance stopped:

Copy-FileToNavContainer -containerName helloworld-dev -localPath "C:\Licenses\dev.flf" -containerPath c:\run\dev.flf

Invoke-ScriptInNavContainer -containerName helloworld-dev -scriptblock {
  Import-NAVServerLicense BC -LicenseData ([Byte[]]$(Get-Content -Path "c:\run\dev.flf" -Encoding Byte))
  Start-NAVServerInstance -ServerInstance BC
}

@freddydk
Copy link
Contributor

No - not on the container I am testing this on.

@eclipses
Copy link
Contributor Author

You're right, it is not working on mine as well, it's a mystery how it worked in that container. Sorry about this

@freddydk
Copy link
Contributor

Maybe a servicetier which is out-of-license isn't stopped, but just unresponsive to connections?

@eclipses
Copy link
Contributor Author

Still I cannot explain what happened, Import-NavContainerLicense failed then I run my script and worked. Next time I will investigate further before to open an issue

@TysvdHeuvel
Copy link

For anyone still strugling with outdate licenses in containers, that fail to update when using Import-NavContainerLicense.
I couldn't update with what ever I tried. Updated my container helper. Tried several other approaches found on the web. Nothing worked.
But, if you change your host system date to some point back in time when the current license was still valid. Restart the container, then again apply Import-NavContainerLicense. Change the host date back to today. Restart container again, and now you should be able to get back in.

@freddydk
Copy link
Contributor

Thanks for adding this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants