Class LxcContainerDescriptor
- java.lang.Object
-
- de.iip_ecosphere.platform.ecsRuntime.BasicContainerDescriptor
-
- de.iip_ecosphere.platform.ecsRuntime.lxc.LxcContainerDescriptor
-
- All Implemented Interfaces:
de.iip_ecosphere.platform.ecsRuntime.ContainerDescriptor
public class LxcContainerDescriptor extends de.iip_ecosphere.platform.ecsRuntime.BasicContainerDescriptorImplements a container descriptor for lxc-based container management.- Author:
- Luca Schulz, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<java.lang.String>envprivate java.util.ArrayList<java.lang.String>exposedPortsprivate intinstanceprivate static intinstanceCountprivate java.lang.StringlxcIdprivate java.lang.StringlxcImageAliasprivate java.lang.StringlxcZipprivate java.lang.StringnetworkModestatic java.lang.StringPORT_PLACEHOLDERstatic java.lang.StringPORT_PLACEHOLDER_1
-
Constructor Summary
Constructors Modifier Constructor Description LxcContainerDescriptor()Creates a container descriptor instance.protectedLxcContainerDescriptor(java.lang.String id, java.lang.String name, de.iip_ecosphere.platform.support.iip_aas.Version version, java.net.URI uri)Creates a container descriptor instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ArrayList<java.lang.String>getEnv()Returns the plain environment settings to start the container.java.util.ArrayList<java.lang.String>getExposedPorts()Returns the ports exposed by the container.java.lang.StringgetId()Returns the LXC container's id for LXC its the fingerprint in specific.java.lang.StringgetLxcImageAlias()Returns the name of the LXC image.java.lang.StringgetLxcZip()Returns the name of the LXC image zip.java.lang.StringgetNetKey()Returns the key for the network manager.java.lang.StringgetNetKey1()Returns the key for the network manager.java.lang.StringgetNetworkMode()Returns the network mode.static java.lang.StringgetRegistry(java.lang.String imgName)Turns a full container image name with optional registry, repository and version into its repository/name.static java.lang.StringgetRepository(java.lang.String imgName)Turns a full container image name with optional registry, repository and version into its repository/name.static java.lang.StringgetTag(java.lang.String imgName)Turns a full container image name with optional registry, repository and version into its (version) tag.java.util.List<java.lang.String>instantiateEnv(int port, int port1)Returns the substituted environment variable settings to start the container.static voidmain(java.lang.String[] args)Tests reading a Docker container file.static LxcContainerDescriptorreadFromYaml(java.io.InputStream in, java.net.URI uri)Returns a LxcContainerDescriptor with a information from a yaml file.static LxcContainerDescriptorreadFromYamlFile(java.io.File file)Returns a LxcContainerDescriptor with a information from a yaml file.booleanrequiresPort(java.lang.String placeholder)Returns whether a dynamic port for a placeholder is required.voidsetEnv(java.util.ArrayList<java.lang.String> env)Defines the environment settings to start the container.voidsetExposedPorts(java.util.ArrayList<java.lang.String> exposedPorts)Defines the exposed ports.voidsetId(java.lang.String lxcId)Defines the LXC container's id for LXC its the fingerprint in specific.voidsetLxcImageAlias(java.lang.String lxcImageAlias)Defines the name of the LXC image.voidsetLxcZip(java.lang.String lxcZip)Defines the name of the LXC image zip.voidsetNetworkMode(java.lang.String networkMode)Defines the network mode.
-
-
-
Field Detail
-
PORT_PLACEHOLDER
public static final java.lang.String PORT_PLACEHOLDER
- See Also:
- Constant Field Values
-
PORT_PLACEHOLDER_1
public static final java.lang.String PORT_PLACEHOLDER_1
- See Also:
- Constant Field Values
-
instanceCount
private static int instanceCount
-
instance
private int instance
-
lxcId
private java.lang.String lxcId
-
lxcImageAlias
private java.lang.String lxcImageAlias
-
lxcZip
private java.lang.String lxcZip
-
networkMode
private java.lang.String networkMode
-
exposedPorts
private java.util.ArrayList<java.lang.String> exposedPorts
-
env
private java.util.ArrayList<java.lang.String> env
-
-
Constructor Detail
-
LxcContainerDescriptor
public LxcContainerDescriptor()
Creates a container descriptor instance.
-
LxcContainerDescriptor
protected LxcContainerDescriptor(java.lang.String id, java.lang.String name, de.iip_ecosphere.platform.support.iip_aas.Version version, java.net.URI uri)Creates a container descriptor instance.- Parameters:
id- the container idname- the (file) name of the containerversion- the version of the containeruri- the URI where the descriptor was loaded from- Throws:
java.lang.IllegalArgumentException- ifid,name,versionoruriis invalid, e.g., null or empty
-
-
Method Detail
-
setId
public void setId(java.lang.String lxcId)
Defines the LXC container's id for LXC its the fingerprint in specific.- Overrides:
setIdin classde.iip_ecosphere.platform.ecsRuntime.BasicContainerDescriptor- Parameters:
lxcId-
-
getId
public java.lang.String getId()
Returns the LXC container's id for LXC its the fingerprint in specific.- Specified by:
getIdin interfacede.iip_ecosphere.platform.ecsRuntime.ContainerDescriptor- Overrides:
getIdin classde.iip_ecosphere.platform.ecsRuntime.BasicContainerDescriptor- Returns:
- lxcId
-
setLxcImageAlias
public void setLxcImageAlias(java.lang.String lxcImageAlias)
Defines the name of the LXC image.- Parameters:
lxcImageAlias-
-
getLxcImageAlias
public java.lang.String getLxcImageAlias()
Returns the name of the LXC image.- Returns:
- lxcImageAlias
-
getLxcZip
public java.lang.String getLxcZip()
Returns the name of the LXC image zip.- Returns:
- lxcZip
-
setLxcZip
public void setLxcZip(java.lang.String lxcZip)
Defines the name of the LXC image zip.- Parameters:
lxcZip-
-
setExposedPorts
public void setExposedPorts(java.util.ArrayList<java.lang.String> exposedPorts)
Defines the exposed ports.- Parameters:
exposedPorts- the exposed ports
-
getExposedPorts
public java.util.ArrayList<java.lang.String> getExposedPorts()
Returns the ports exposed by the container.- Returns:
- exposedPorts, the exposed ports
-
setEnv
public void setEnv(java.util.ArrayList<java.lang.String> env)
Defines the environment settings to start the container.- Parameters:
env- the environment settings, may containPORT_PLACEHOLDERto be replaced by the dynamic port of the AAS implementation server of the service manager
-
getNetworkMode
public java.lang.String getNetworkMode()
Returns the network mode.- Returns:
- networkMode, the network mode, may be null for none
-
getEnv
public java.util.ArrayList<java.lang.String> getEnv()
Returns the plain environment settings to start the container.- Returns:
- the environment settings, may contain
PORT_PLACEHOLDER}
-
setNetworkMode
public void setNetworkMode(java.lang.String networkMode)
Defines the network mode. [snakeyaml]- Parameters:
networkMode- the network mode, may be null for none
-
instantiateEnv
public java.util.List<java.lang.String> instantiateEnv(int port, int port1)Returns the substituted environment variable settings to start the container.- Parameters:
port- the port to substitutePORT_PLACEHOLDERport1- the port to substitutePORT_PLACEHOLDER_1- Returns:
- result, the instantiated environment variable settings
-
requiresPort
public boolean requiresPort(java.lang.String placeholder)
Returns whether a dynamic port for a placeholder is required.- Parameters:
placeholder- the name of the placeholder- Returns:
- result,
truefor dynamic port,falseelse
-
getNetKey
public java.lang.String getNetKey()
Returns the key for the network manager.- Returns:
- the key
-
getNetKey1
public java.lang.String getNetKey1()
Returns the key for the network manager.- Returns:
- the key
-
readFromYamlFile
public static LxcContainerDescriptor readFromYamlFile(java.io.File file)
Returns a LxcContainerDescriptor with a information from a yaml file.- Parameters:
file- yaml file- Returns:
- LxcContainerDescriptor (may be null)
-
readFromYaml
public static LxcContainerDescriptor readFromYaml(java.io.InputStream in, java.net.URI uri)
Returns a LxcContainerDescriptor with a information from a yaml file.- Parameters:
in- an inout stream with Yaml contents (may be null)uri- the URI the descriptor was read from- Returns:
- LxcContainerDescriptor (may be null)
-
getRepository
public static java.lang.String getRepository(java.lang.String imgName)
Turns a full container image name with optional registry, repository and version into its repository/name.- Parameters:
imgName- the image name- Returns:
- the repository
-
getRegistry
public static java.lang.String getRegistry(java.lang.String imgName)
Turns a full container image name with optional registry, repository and version into its repository/name.- Parameters:
imgName- the image name- Returns:
- the repository
-
getTag
public static java.lang.String getTag(java.lang.String imgName)
Turns a full container image name with optional registry, repository and version into its (version) tag.- Parameters:
imgName- the image name- Returns:
- the tag, may be empty
-
main
public static void main(java.lang.String[] args)
Tests reading a Docker container file.- Parameters:
args- arguments, first is taken as file name
-
-