-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the agent code and the orchestration code
1. Now the orchestration layer only maintain data in db; 2. Agent layer code will do the real work on platform; 3. Init the structure to support k8s, and also fabric 1.0; 4. Some related documentation is also updated. This patchset helps fix CE-20. https://jira.hyperledger.org/browse/CE-20. Change-Id: Idf87d4041ebb1b5273089e457b2d3da92dfe5fd2 Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
- Loading branch information
Showing
26 changed files
with
405 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This script will help setup Docker at a server, then the server can be used as a worker node. | ||
|
||
# TODO: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This script will help setup a Kubernetes cluster at servers, then the cluster can be used as a worker node. | ||
|
||
# TODO: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This script will help setup a Swarm cluster at servers, then the cluster can be used as a worker node. | ||
|
||
# TODO: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
from .docker_swarm import get_project, \ | ||
# Agent pkg provides drivers to those underly platforms, e.g., swarm/k8s. jAS | ||
|
||
from .docker.docker_swarm import get_project, \ | ||
check_daemon, detect_daemon_type, \ | ||
get_swarm_node_ip, \ | ||
compose_up, compose_clean, compose_start, compose_stop, compose_restart, \ | ||
setup_container_host, cleanup_host, reset_container_host | ||
|
||
from .docker.host import DockerHost | ||
from .docker.cluster import ClusterOnDocker | ||
|
||
from .k8s.host import KubernetesHost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import abc | ||
|
||
|
||
class ClusterBase(object): | ||
__metaclass__ = abc.ABCMeta | ||
|
||
@abc.abstractmethod | ||
def create(self, *args, **kwargs): | ||
""" | ||
Create a new cluster | ||
Args: | ||
*args: args | ||
**kwargs: keyword args | ||
Returns: | ||
""" | ||
return | ||
|
||
@abc.abstractmethod | ||
def delete(self, *args, **kwargs): | ||
return | ||
|
||
@abc.abstractmethod | ||
def start(self, *args, **kwargs): | ||
return | ||
|
||
@abc.abstractmethod | ||
def stop(self, *args, **kwargs): | ||
return |
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import logging | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) | ||
from common import log_handler, LOG_LEVEL | ||
|
||
from agent import compose_up, compose_clean, compose_start, compose_stop, \ | ||
compose_restart | ||
|
||
from common import CONSENSUS_PLUGINS, \ | ||
CONSENSUS_MODES, CLUSTER_SIZES | ||
|
||
from ..cluster_base import ClusterBase | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(LOG_LEVEL) | ||
logger.addHandler(log_handler) | ||
|
||
|
||
class ClusterOnDocker(ClusterBase): | ||
""" Main handler to operate the cluster in pool | ||
""" | ||
def __init__(self): | ||
pass | ||
|
||
def create(self, cid, mapped_ports, host, user_id="", | ||
consensus_plugin=CONSENSUS_PLUGINS[0], | ||
consensus_mode=CONSENSUS_MODES[0], size=CLUSTER_SIZES[0]): | ||
""" Create a cluster based on given data | ||
TODO: maybe need other id generation mechanism | ||
:param name: name of the cluster | ||
:param host_id: id of the host URL | ||
:param start_port: first service port for cluster, will generate | ||
if not given | ||
:param user_id: user_id of the cluster if start to be applied | ||
:param consensus_plugin: type of the consensus type | ||
:param size: size of the cluster, int type | ||
:return: Id of the created cluster or None | ||
""" | ||
|
||
# from now on, we should be safe | ||
|
||
# start compose project, failed then clean and return | ||
logger.debug("Start compose project with name={}".format(cid)) | ||
containers = compose_up( | ||
name=cid, mapped_ports=mapped_ports, host=host, | ||
consensus_plugin=consensus_plugin, consensus_mode=consensus_mode, | ||
cluster_size=size) | ||
if not containers or len(containers) != size: | ||
logger.warning("failed to create cluster, with container={}" | ||
.format(containers)) | ||
return [] | ||
else: | ||
return containers | ||
|
||
def delete(self, id, daemon_url, consensus_plugin): | ||
return compose_clean(id, daemon_url, consensus_plugin) | ||
|
||
def start(self, name, daemon_url, mapped_ports, consensus_plugin, | ||
consensus_mode, log_type, log_level, log_server, cluster_size): | ||
return compose_start(name, daemon_url, mapped_ports, consensus_plugin, | ||
consensus_mode, log_type, log_level, log_server, | ||
cluster_size) | ||
|
||
def restart(self, name, daemon_url, mapped_ports, consensus_plugin, | ||
consensus_mode, log_type, log_level, log_server, cluster_size): | ||
return compose_restart(name, daemon_url, mapped_ports, | ||
consensus_plugin, consensus_mode, log_type, | ||
log_level, log_server, cluster_size) | ||
|
||
def stop(self, name, daemon_url, mapped_ports, consensus_plugin, | ||
consensus_mode, log_type, log_level, log_server, cluster_size): | ||
return compose_stop(name, daemon_url, mapped_ports, consensus_plugin, | ||
consensus_mode, log_type, log_level, log_server, | ||
cluster_size) | ||
|
||
|
||
cluster_on_docker = ClusterOnDocker() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.