support multiple blockchains

This commit is contained in:
David Tai
2018-11-28 15:47:48 -06:00
parent 96bf767a9c
commit 1eafb2ecd7
3 changed files with 33 additions and 12 deletions
+7 -6
View File
@@ -6,6 +6,7 @@ net ?= testnet
cfg := config/$(net)
region := us-central1
zone := us-central1-a
number ?= 047
all: deploy
@@ -52,22 +53,22 @@ status:
kubectl get pods -o yaml
logs:
kubectl logs geth-$(net)-044 -f
kubectl logs geth-$(net)-$(number) -f
ssh:
kubectl exec -it geth-$(net)-047 -- /bin/bash
kubectl exec -it geth-$(net)-$(number) -- /bin/bash
attach:
kubectl exec -it geth-$(net)-01 -- $(geth) attach
kubectl exec -it geth-$(net)-$(number) -- $(geth) attach
nodeinfo:
kubectl exec -it geth-$(net) -- $(geth) attach --exec 'admin.nodeInfo'
kubectl exec -it geth-$(net)-$(number) -- $(geth) attach --exec 'admin.nodeInfo'
syncstatus:
kubectl exec -it geth-$(net)-047 -- $(geth) attach --exec 'eth.syncing'
kubectl exec -it geth-$(net)-$(number) -- $(geth) attach --exec 'eth.syncing'
blocknumber:
kubectl exec -it geth-$(net)-02 -- $(geth) attach --exec 'eth.blockNumber'
kubectl exec -it geth-$(net)-$(number) -- $(geth) attach --exec 'eth.blockNumber'
# Add secret for hanzo-ai gcr.io. This enables our cluster to pull images from
# our shared image repo. This should only be run once after cluster creation.
+24 -6
View File
@@ -147,6 +147,21 @@ class Blockchain(Pod):
super(Blockchain, self).__init__(self.metadata, self.spec)
@classmethod
def to_network_id(cls, network):
return 0
@classmethod
def to_network(cls, network_id):
return
@classmethod
def normalize_network(cls, network):
return None, 0
@classmethod
def is_blockchain(cls, chain):
return
class Ethereum(Blockchain):
def __init__(self, name, network='mainnet',
@@ -217,8 +232,8 @@ class Ethereum(Blockchain):
super(Ethereum, self).__init__(name, 'ethereum', network, image,
command, args, path, requests, limits)
@staticmethod
def to_network_id(network):
@classmethod
def to_network_id(cls, network):
return {
'mainnet': 1,
'frontier': 1,
@@ -235,8 +250,8 @@ class Ethereum(Blockchain):
'4': 4
}.get(str(network).lower())
@staticmethod
def to_network(network_id):
@classmethod
def to_network(cls, network_id):
return {
1: 'mainnet',
2: 'morden',
@@ -244,12 +259,15 @@ class Ethereum(Blockchain):
4: 'rinkeby'
}.get(network_id)
@staticmethod
def normalize_network(network):
@classmethod
def normalize_network(cls, network):
network_id = Ethereum.to_network_id(network)
network = Ethereum.to_network(network_id)
return network, network_id
@classmethod
def is_blockchain(cls, chain):
return chain in ['ethereum', 'eth', 'geth']
class Bitcoin(Blockchain):
def __init__(self, name, network, image, command, args, path,
+2
View File
@@ -66,11 +66,13 @@ def parser():
# Pods
create_pod = subparsers.add_parser('create-pod', help='Create pod')
create_pod.add_argument('chain', help='Name of blockchain to create')
create_pod.add_argument('network', help='Name of network to use')
create_pod.add_argument('name', help='Name of pod')
create_pod.set_defaults(command='create_pod')
delete_pod = subparsers.add_parser('delete-pod', help='Delete pod')
create_pod.add_argument('chain', help='Name of blockchain to delete')
delete_pod.add_argument('network', help='Name of network to use')
delete_pod.add_argument('name', help='Name of pod')
delete_pod.set_defaults(command='delete_pod')