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

Dev -> Master #2774

Merged
merged 10 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions management/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,25 @@
<version>${project.version}</version>
</dependency>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<!-- environment-metadata-manager -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>environment-metadata-manager-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>environment-metadata-manager-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>environment-metadata-manager-rest</artifactId>
<version>${project.version}</version>
</dependency>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- host registry -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import org.apache.commons.lang3.StringUtils;

import io.subutai.bazaar.share.common.BazaaarAdapter;
import io.subutai.bazaar.share.event.payload.Payload;
import io.subutai.common.dao.DaoManager;
import io.subutai.common.environment.Environment;
import io.subutai.common.host.ContainerHostInfo;
Expand All @@ -17,17 +19,16 @@
import io.subutai.common.peer.HostNotFoundException;
import io.subutai.common.peer.LocalPeer;
import io.subutai.common.util.ServiceLocator;
import io.subutai.core.environment.api.EnvironmentEventListener;
import io.subutai.core.hostregistry.api.HostListener;
import io.subutai.core.bazaarmanager.api.BazaarManager;
import io.subutai.core.bazaarmanager.api.RestClient;
import io.subutai.core.bazaarmanager.api.RestResult;
import io.subutai.core.bazaarmanager.api.dao.ConfigDataService;
import io.subutai.core.bazaarmanager.impl.dao.ConfigDataServiceImpl;
import io.subutai.core.environment.api.EnvironmentEventListener;
import io.subutai.core.hostregistry.api.HostListener;
import io.subutai.core.identity.api.IdentityManager;
import io.subutai.core.identity.api.model.User;
import io.subutai.core.peer.api.PeerManager;
import io.subutai.bazaar.share.common.BazaaarAdapter;

import static java.lang.String.format;

Expand Down Expand Up @@ -258,6 +259,35 @@ public void notifyContainerDiskUsageExcess( String peerId, String envId, String
}


@Override
public void pushEvent( final Payload message )
{
RestResult result =
getRestClient().post( String.format( "/rest/v1/peers/%s/event", peerId ), message, message.getClass() );

if ( !result.isSuccess() )
{
log.error( "Error pushing event to Bazaar: HTTP {} - {}", result.getStatus(), result.getReasonPhrase() );
}
}


@Override
public Payload getMetaData( final String environmentId, final String type )
{
RestResult result = getRestClient()
.get( String.format( "/rest/v1/peers/%s/meta/%s/%s", peerId, environmentId, type ), Payload.class );

if ( !result.isSuccess() )
{
log.error( "Error retrieving meta data from Bazaar: HTTP {} - {}", result.getStatus(),
result.getReasonPhrase() );
}

return ( Payload ) result.getEntity();
}


private void onContainerStateChange( String envId, String contId, String state )
{
if ( !isRegistered() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,21 @@ public void run()
}


@Override
public void onContainerDestroyed( final ContainerHostInfo containerInfo )
{
try
{
ContainerHost containerHost = peerManager.getLocalPeer().getContainerHostById( containerInfo.getId() );
onContainerDestroyed( containerHost );
}
catch ( HostNotFoundException ignore )
{
//no-op
}
}


protected Long getUserId()
{
return identityManager.getActiveUser().getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.subutai.common.environment.Topology;
import io.subutai.common.host.ContainerHostInfo;
import io.subutai.common.host.ContainerHostState;
import io.subutai.common.host.HostInterfaceModel;
import io.subutai.common.host.ResourceHostInfo;
import io.subutai.common.metric.QuotaAlertValue;
import io.subutai.common.network.SshTunnel;
Expand Down Expand Up @@ -802,27 +801,9 @@ public void onContainerCreated( final ContainerHostInfo containerInfo )


@Override
public void onContainerNetInterfaceChanged( final ContainerHostInfo containerInfo,
final HostInterfaceModel oldNetInterface,
final HostInterfaceModel newNetInterface )
public void onContainerDestroyed( final ContainerHostInfo containerInfo )
{
environmentManager.onContainerNetInterfaceChanged( containerInfo, oldNetInterface, newNetInterface );
}


@Override
public void onContainerNetInterfaceAdded( final ContainerHostInfo containerInfo,
final HostInterfaceModel netInterface )
{
environmentManager.onContainerNetInterfaceAdded( containerInfo, netInterface );
}


@Override
public void onContainerNetInterfaceRemoved( final ContainerHostInfo containerInfo,
final HostInterfaceModel netInterface )
{
environmentManager.onContainerNetInterfaceRemoved( containerInfo, netInterface );
environmentManager.onContainerDestroyed( containerInfo );
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>environment-metadata-manager</artifactId>
<groupId>io.subutai</groupId>
<version>8.2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>environment-metadata-manager-api</artifactId>
<name>Subutai Environment Metadata Manager Api</name>
<description>Subutai Environment Metadata Manager Api</description>
<packaging>bundle</packaging>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>subutai-common</artifactId>
</dependency>

<dependency>
<groupId>io.subutai</groupId>
<artifactId>identity-manager-api</artifactId>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.core.environment.metadata.api</Bundle-SymbolicName>
<Export-Package>
{local-packages};version=${project.version};-noimport:=true
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.subutai.core.environment.metadata.api;


import io.subutai.bazaar.share.event.payload.Payload;
import io.subutai.core.identity.api.exception.TokenCreateException;


public interface EnvironmentMetadataManager
{
void init();

void dispose();

/**
* Issues JWT token for specified container
*/

void issueToken( String containerIp ) throws TokenCreateException;

Payload getEnvironmentInfoDto( String environmentId, String type );

void pushEvent( Payload eventMessage );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>environment-metadata-manager</artifactId>
<groupId>io.subutai</groupId>
<version>8.2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>environment-metadata-manager-impl</artifactId>
<packaging>bundle</packaging>
<name>Subutai Environment Metadata Manager Impl</name>
<description>Subutai Environment Metadata Manager Impl</description>
<dependencies>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>environment-metadata-manager-api</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>peer-manager-api</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>environment-manager-api</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>identity-manager-api</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bazaar-manager-api</artifactId>
</dependency>

<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
</dependency>

<!-- Testing -->

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.core.environment.metadata.impl</Bundle-SymbolicName>
<Export-Package>
{local-packages};version=${project.version};-noimport:=true
</Export-Package>
<Import-Package>*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading