Ejemplo n.º 1
0
 def test_setup_admin(self, mock_get_pod):
     mock_pod = Mock()
     mock_pod.execute.side_effect = [
         (None, "error"),  # composer card list admin
         ("Create card", None),  # composer card create
         ("Import card", None),  # composer card import admin
         ("a-network_a-version.bna", None),  # ls BNA
     ]
     mock_get_pod.side_effect = [mock_pod]
     setup_admin(self.OPTS)
     mock_get_pod.assert_called_once_with(
         "peer-namespace", "hlc", "hl-composer", verbose=False
     )
     mock_pod.execute.assert_has_calls(
         [
             call("composer card list --card PeerAdmin@hlfv1"),
             call(
                 "composer card create "
                 + "-p /hl_config/hlc-connection/connection.json "
                 + "-u PeerAdmin -c /hl_config/admin/signcerts/cert.pem "
                 + "-k /hl_config/admin/keystore/key.pem "
                 + " -r PeerAdmin -r ChannelAdmin "
                 + "--file /home/composer/PeerAdmin@hlfv1"
             ),
             call(
                 "composer card import "
                 + "--file /home/composer/[email protected]"
             ),
         ]
     )
Ejemplo n.º 2
0
 def test_setup_admin(self, mock_get_pod):
     mock_pod = mock.Mock()
     mock_pod.execute.side_effect = [
         None,  # composer card list admin
         None,  # composer card create
         None,  # composer card import admin
         'a-network_a-version.bna',  # ls BNA
     ]
     mock_get_pod.side_effect = [mock_pod]
     setup_admin(self.OPTS)
     mock_get_pod.assert_called_once_with('peer-namespace',
                                          'hlc',
                                          'hl-composer',
                                          verbose=False)
     mock_pod.execute.assert_has_calls([
         call('composer card list --card PeerAdmin@hlfv1'),
         call('composer card create ' +
              '-p /hl_config/hlc-connection/connection.json ' +
              '-u PeerAdmin -c /hl_config/admin/signcerts/cert.pem ' +
              '-k /hl_config/admin/keystore/key.pem ' +
              ' -r PeerAdmin -r ChannelAdmin ' +
              '--file /home/composer/PeerAdmin@hlfv1'),
         call('composer card import ' +
              '--file /home/composer/[email protected]')
     ])
Ejemplo n.º 3
0
 def test_setup_admin(self, mock_setup_card):
     setup_admin("some-opts", verbose=True)
     mock_setup_card.assert_called_once_with(
         "some-opts",
         msp_path="/hl_config/admin",
         user_name="PeerAdmin",
         roles=("PeerAdmin", "ChannelAdmin"),
         verbose=True,
     )
Ejemplo n.º 4
0
def runner_composer(opts, upgrade=False):
    """Deploy Hyperledger Composer.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
        
    """
    deploy_composer(opts, upgrade=upgrade)
    setup_admin(opts)
    install_network(opts)
Ejemplo n.º 5
0
 def test_setup_admin_again(self, mock_get_pod):
     mock_pod = Mock()
     mock_pod.execute.side_effect = [
         ("an-admin.card", None)  # composer card list admin
     ]
     mock_get_pod.side_effect = [mock_pod]
     setup_admin(self.OPTS, verbose=True)
     mock_get_pod.assert_called_once_with(
         "peer-namespace", "hlc", "hl-composer", verbose=True
     )
     mock_pod.execute.assert_has_calls(
         [call("composer card list --card PeerAdmin@hlfv1")]
     )
Ejemplo n.º 6
0
 def test_setup_admin_again(self, mock_get_pod):
     mock_pod = mock.Mock()
     mock_pod.execute.side_effect = [
         'an-admin.card',  # composer card list admin
     ]
     mock_get_pod.side_effect = [mock_pod]
     setup_admin(self.OPTS, verbose=True)
     mock_get_pod.assert_called_once_with('peer-namespace',
                                          'hlc',
                                          'hl-composer',
                                          verbose=True)
     mock_pod.execute.assert_has_calls(
         [call('composer card list --card PeerAdmin@hlfv1')])
Ejemplo n.º 7
0
def deploy(ctx):  # pragma: no cover
    opts = load_config(ctx.obj['settings_file'])
    # Setup CA
    setup_ca(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    # Crypto material
    admin_msp(opts, opts['orderers']['msp'], verbose=ctx.obj['verbose'])
    admin_msp(opts, opts['peers']['msp'], verbose=ctx.obj['verbose'])
    genesis_block(opts, verbose=ctx.obj['verbose'])
    channel_tx(opts, verbose=ctx.obj['verbose'])
    setup_nodes(opts, 'orderer', verbose=ctx.obj['verbose'])
    setup_nodes(opts, 'peer', verbose=ctx.obj['verbose'])
    # Orderers
    setup_ord(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    # Peers
    setup_peer(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    setup_channel(opts, verbose=ctx.obj['verbose'])
    # Composer
    deploy_composer(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    setup_admin(opts, verbose=ctx.obj['verbose'])
    install_network(opts, verbose=ctx.obj['verbose'])
Ejemplo n.º 8
0
def composer(ctx):  # pragma: no cover
    opts = load_config(ctx.obj['settings_file'])
    deploy_composer(opts, upgrade=ctx.obj['upgrade'], verbose=ctx.obj['verbose'])
    setup_admin(opts, verbose=ctx.obj['verbose'])
    install_network(opts, verbose=ctx.obj['verbose'])