Exemplo n.º 1
0
def config_setup(env, booth_configuration, overwrite_existing=False):
    """
    create boot configuration
    list site_list contains site adresses of multisite
    list arbitrator_list contains arbitrator adresses of multisite
    """

    config_content = config_exchange.from_exchange_format(booth_configuration)
    config_structure.validate_peers(
        *config_structure.take_peers(config_content))

    env.booth.create_key(config_files.generate_key(), overwrite_existing)
    config_content = config_structure.set_authfile(config_content,
                                                   env.booth.key_path)
    env.booth.create_config(build(config_content), overwrite_existing)
Exemplo n.º 2
0
 def test_refuse_problem_combination(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1"],
             arbitrator_list=["1.1.1.1"]
         ),
         (
             severities.ERROR,
             report_codes.BOOTH_LACK_OF_SITES,
             {
                 "sites": ["1.1.1.1"],
             }
         ),
         (
             severities.ERROR,
             report_codes.BOOTH_EVEN_PEERS_NUM,
             {
                 "number": 2,
             }
         ),
         (
             severities.ERROR,
             report_codes.BOOTH_ADDRESS_DUPLICATION,
             {
                 "addresses": set(["1.1.1.1"]),
             }
         ),
     )
Exemplo n.º 3
0
 def test_refuse_even_number_peers(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1", "2.2.2.2"], arbitrator_list=[]),
         (severities.ERROR, report_codes.BOOTH_EVEN_PEERS_NUM, {
             "number": 2,
         }),
     )
Exemplo n.º 4
0
 def test_refuse_less_than_2_sites(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1"], arbitrator_list=["3.3.3.3", "4.4.4.4"]),
         (severities.ERROR, report_codes.BOOTH_LACK_OF_SITES, {
             "sites": ["1.1.1.1"],
         }),
     )
Exemplo n.º 5
0
 def test_refuse_address_duplication(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1", "1.1.1.1", "1.1.1.1"],
             arbitrator_list=["3.3.3.3", "4.4.4.4"]),
         (severities.ERROR, report_codes.BOOTH_ADDRESS_DUPLICATION, {
             "addresses": set(["1.1.1.1"]),
         }),
     )
Exemplo n.º 6
0
def config_setup(env, booth_configuration, overwrite_existing=False):
    """
    create boot configuration
    list site_list contains site adresses of multisite
    list arbitrator_list contains arbitrator adresses of multisite
    """

    config_content = config_exchange.from_exchange_format(booth_configuration)
    config_structure.validate_peers(
        *config_structure.take_peers(config_content)
    )

    env.booth.create_key(config_files.generate_key(), overwrite_existing)
    config_content = config_structure.set_authfile(
        config_content,
        env.booth.key_path
    )
    env.booth.create_config(build(config_content), overwrite_existing)
Exemplo n.º 7
0
 def test_refuse_address_duplication(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1", "1.1.1.1", "1.1.1.1"],
             arbitrator_list=["3.3.3.3", "4.4.4.4"]
         ),
         (
             severities.ERROR,
             report_codes.BOOTH_ADDRESS_DUPLICATION,
             {
                 "addresses": set(["1.1.1.1"]),
             }
         ),
     )
Exemplo n.º 8
0
 def test_refuse_even_number_peers(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1", "2.2.2.2"],
             arbitrator_list=[]
         ),
         (
             severities.ERROR,
             report_codes.BOOTH_EVEN_PEERS_NUM,
             {
                 "number": 2,
             }
         ),
     )
Exemplo n.º 9
0
 def test_refuse_less_than_2_sites(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1"],
             arbitrator_list=["3.3.3.3", "4.4.4.4"]
         ),
         (
             severities.ERROR,
             report_codes.BOOTH_LACK_OF_SITES,
             {
                 "sites": ["1.1.1.1"],
             }
         ),
     )
Exemplo n.º 10
0
 def test_refuse_problem_combination(self):
     assert_raise_library_error(
         lambda: config_structure.validate_peers(
             site_list=["1.1.1.1"], arbitrator_list=["1.1.1.1"]),
         (severities.ERROR, report_codes.BOOTH_LACK_OF_SITES, {
             "sites": ["1.1.1.1"],
         }),
         (severities.ERROR, report_codes.BOOTH_EVEN_PEERS_NUM, {
             "number": 2,
         }),
         (severities.ERROR, report_codes.BOOTH_ADDRESS_DUPLICATION, {
             "addresses": set(["1.1.1.1"]),
         }),
     )
Exemplo n.º 11
0
 def test_do_no_raises_on_correct_args(self):
     config_structure.validate_peers(
         site_list=["1.1.1.1", "2.2.2.2"],
         arbitrator_list=["3.3.3.3"]
     )
Exemplo n.º 12
0
 def test_do_no_raises_on_correct_args(self):
     config_structure.validate_peers(site_list=["1.1.1.1", "2.2.2.2"],
                                     arbitrator_list=["3.3.3.3"])