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

Set Hostname after Image apply and print on Lable #45

Open
maikschauer opened this issue Mar 1, 2024 · 1 comment
Open

Set Hostname after Image apply and print on Lable #45

maikschauer opened this issue Mar 1, 2024 · 1 comment

Comments

@maikschauer
Copy link

Hello,
if I set the host name after writing the image via postscript, I would like to print the new host name on the label. is that possible?

@maxnet
Copy link
Collaborator

maxnet commented Mar 1, 2024

That would be something you would need to develop yourself.
One way is patch our printing code directly.
Another way, would be if you want your changes to survive our future updates, is to write your own custom print label code, that only listen to the CmProvisioningComplete event cmprovision generates, and consult your own database for additional information that should be printed on the label based on serial number or other properties of the CM.

As in create /var/lib/cmprovision/app/Listeners/CustomPrintCode.php

<?php
namespace App\Listeners;

use App\Events\CmProvisioningComplete;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Http;
use App\Models\Cm;
use App\Models\Setting;

class CustomPrintCode implements ShouldQueue
{
    use InteractsWithQueue;

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
    }

    /**
     * Handle the event.
     *
     * @param  App\Events\CmProvisioningComplete  $event
     * @return void
     */
    public function handle(CmProvisioningComplete $event)
    {
        $cm = $event->cm;

        /* $cm contains information about the compute module that just finished provisioning
           Do something useful with it here. */  
    }
}

This way you only need to ADD a single file to cmprovision, and do not have to modify existing code.
Less work to merge changes on updates.

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

No branches or pull requests

2 participants