blob: 43fb6412d1da83e3bf864c7c13b2d9f65323c688 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package org.openslx.runvirt.plugin.qemu.configuration;
import org.openslx.libvirt.domain.Domain;
import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
import org.openslx.virtualization.configuration.transformation.TransformationException;
import org.openslx.virtualization.configuration.transformation.TransformationGeneric;
/**
* Generic UUID transformation for Libvirt/QEMU virtualization configurations.
*
* @author Manuel Bentele
* @version 1.0
*/
public class TransformationGenericUuid extends TransformationGeneric<Domain, CommandLineArgs>
{
/**
* Name of the configuration transformation.
*/
private static final String NAME = "UUID";
/**
* Creates a new UUID transformation for Libvirt/QEMU virtualization configurations.
*/
public TransformationGenericUuid()
{
super( TransformationGenericUuid.NAME );
}
/**
* Validates a virtualization configuration and input arguments for this transformation.
*
* @param config virtualization configuration for the validation.
* @param args input arguments for the validation.
* @throws TransformationException validation has failed.
*/
private void validateInputs( Domain config, CommandLineArgs args ) throws TransformationException
{
if ( config == null || args == null ) {
throw new TransformationException( "Virtualization configuration or input arguments are missing!" );
} else if ( args.getVmUuid() == null || args.getVmUuid().isEmpty() ) {
throw new TransformationException( "UUID is not specified!" );
}
}
@Override
public void transform( Domain config, CommandLineArgs args ) throws TransformationException
{
// validate configuration and input arguments
this.validateInputs( config, args );
config.setUuid( args.getVmUuid() );
}
}
|