Skip to main content

Copying Imaging Profiles

Applies to: Medulla - Medulla Relay
Version:All 
Environment:On-Premise
Category: Imaging

Copy an imaging profile to all servers

Initial information:

  • Profile name
  • server name

Specify the profile

First, you need to gather all the profile information.

Objectives: 1008

  • Ensure that this is indeed the correct profile
  • Retrieve its ID and the server ID
-- Replace <PROFILE_NAME> with its name
-- Replace <SERVER_NAME> with the name of the imaging server
SELECT 
    Profile.id,
    Profile.fk_imagingserver
from Profile 
join ImagingServer ims on ims.id = fk_imagingserver
where Profile.name = "<profile_name>" and ims.name = "<server_name>";
/*
Result:
+----+------------------+
| id | fk_imagingserver |
+----+------------------+
| 34 |                1 |
+----+------------------+
*/

The profile<PROFILE_NAME>has ID34and is associated with imaging server1.

We will also need the list of postinstalls and their order:

-- Replace <profile_id> with the <id> value from the previous result
-- select * from PostInstallInProfile where fk_profile=<profile_id>;
-- Example:
select * from PostInstallInProfile where fk_profile=34;

/*
Result
+------------+------------------------+-------+
| fk_profile | fk_post_install_script | order |
+------------+------------------------+-------+
|         34 |                   1008 |     0 |
|         34 |                   1011 |     1 |
+------------+------------------------+-------+
*/

There are two postinstalls associated with profile 34:

  • postinstall 1008, at order 0,
  • postinstall 1011, at order 1.

This information will be needed later.

Copy the postinstalls

Postinstalls 1008 and 1011 may not be associated with all selected servers.

The first step is to ensure that the postinstall scripts 1008 and 1011 are associated wherever they are needed.

You must repeat this query for all listed postinstall scripts.

begin;

-- Associate all ims with postinstall id=1008
insert into PostInstallScriptOnImagingServer (fk_imaging_server, fk_post_install_script)
select
    ims.id,
    1008
from ImagingServer ims
join Entity e on e.id = ims.fk_entity
where 
    -- If necessary, add filters for the imaging servers here
    ims.id not in (
    select pisois.fk_imaging_server
    from PostInstallScriptOnImagingServer pisois
    where pisois.fk_post_install_script = 1008
);

-- Associate all ims with postinstall id=1011
insert into PostInstallScriptOnImagingServer (fk_imaging_server, fk_post_install_script)
select
    ims.id,
    1011
from ImagingServer ims
join Entity e on e.id = ims.fk_entity
where 
    -- If necessary, add filters for the imaging servers here
    ims.id not in (
    select pisois.fk_imaging_server
    from PostInstallScriptOnImagingServer pisois
    where pisois.fk_post_install_script = 1011
);

Now we have the post-install scripts on all the servers we want.

Create the profiles

A profile is associated with a single imaging server. To copy a profile, you must copy its contents to each target imaging server.

-- Create the <profile_name> profiles for all imaging servers that do not yet have this profile
-- 34 corresponds to the ID of the profile to be copied.
-- Replace <profile_name> with the name of the profile to be copied
insert into Profile (fk_imagingserver, name, description)
select 
    distinct(ims.id),
    (select name from Profile where id=34) as profile_name,
    (select description from Profile where id=34) as profile_desc
from ImagingServer ims
join Entity e on e.id = ims.fk_entity
where 
    -- If necessary, add filters for imaging servers here
    ims.id not in (select fk_imagingserver from Profile where name = "<profile_name>");

Associate a postinstall with the new profiles

The profiles for each server are created but empty. Now you need to copy the content from the original profile.

The query must be adapted and repeated for each postinstall to be copied.

-- Associates the created profiles with postinstall 1008
-- Replace <profile_name> with the profile name
-- 1008 corresponds to the ID of the postinstall found previously
-- 0 corresponds to the order found in the second query (order column)
insert into PostInstallInProfile (fk_profile, fk_post_install_script, `order`)
select 
    id,
    1008,
    0
from Profile 
where name = "<profile_name>" 
and id not in 
    (select fk_profile 
    from PostInstallInProfile 
    where fk_post_install_script = 1008
);


-- Associates the created profiles with postinstall 1011
-- Replace <profile_name> with the profile name
-- 1011 corresponds to the ID of the postinstall found previously
-- 1 corresponds to the order found in the second query (order column)
insert into PostInstallInProfile (fk_profile, fk_post_install_script, `order`)
select 
    id,
    1011,
    1
from Profile 
where name = "<profile_name>" 
and id not in 
    (select fk_profile 
    from PostInstallInProfile 
    where fk_post_install_script = 1011
);