Ejemplo n.º 1
0
 def test_remove_ip_remove_port_force(self):
     (self.config.runner.cib.load(
         resources=self.fixture_resources_pre.format(network="""
                     <network
                         ip-range-start="192.168.100.200"
                         control-port="1234"
                     />
                 """)).env.push_cib(
             resources=self.fixture_resources_pre.format(network='')))
     resource.bundle_update(
         self.env_assist.get_env(),
         "B1",
         network_options={
             "ip-range-start": "",
             "control-port": "",
         },
         force_options=True,
     )
     self.env_assist.assert_reports([
         fixture.warn(
             report_codes.RESOURCE_IN_BUNDLE_NOT_ACCESSIBLE,
             bundle_id="B1",
             inner_resource_id="P",
         )
     ])
Ejemplo n.º 2
0
    def test_keep_network_when_port_map_set(self):
        (self.config.runner.cib.load(resources="""
                    <resources>
                        <bundle id="B1">
                            <docker image="pcs:test" />
                            <network host-interface="eth0">
                                <something />
                            </network>
                        </bundle>
                    </resources>
                """).env.push_cib(resources="""
                    <resources>
                        <bundle id="B1">
                            <docker image="pcs:test" />
                            <network>
                                <something />
                            </network>
                        </bundle>
                    </resources>
                """))

        resource.bundle_update(self.env_assist.get_env(),
                               "B1",
                               network_options={
                                   "host-interface": "",
                               })
Ejemplo n.º 3
0
 def test_add_network(self):
     (self.config.runner.cib.load(
         resources=fixture_resources_minimal).env.push_cib(
             resources=self.fixture_cib_interface))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            network_options={
                                "host-interface": "eth0",
                            })
Ejemplo n.º 4
0
 def test_unknown_option_remove(self):
     (self.config.runner.cib.load(
         resources=self.fixture_cib_extra_option).env.push_cib(
             resources=self.fixture_cib_interface))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            network_options={
                                "extra": "",
                            })
Ejemplo n.º 5
0
 def test_add(self):
     (self.config.runner.cib.load(
         resources=self.fixture_cib_port_80).env.push_cib(
             resources=self.fixture_cib_port_80_8080))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            port_map_add=[{
                                "port": "8080",
                            }])
Ejemplo n.º 6
0
 def test_remove(self):
     (self.config.runner.cib.load(
         resources=self.fixture_cib_port_80_8080).env.push_cib(
             resources=self.fixture_cib_port_80))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            port_map_remove=[
                                "B1-port-map-8080",
                            ])
Ejemplo n.º 7
0
 def test_remove_storage(self):
     (self.config.runner.cib.load(
         resources=self.fixture_cib_storage_1).env.push_cib(
             resources=fixture_resources_minimal))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            storage_map_remove=[
                                "B1-storage-map",
                            ])
Ejemplo n.º 8
0
 def test_remove_meta_element(self):
     (self.config.runner.cib.load(
         resources=self.fixture_meta_stopped).env.push_cib(
             resources=self.fixture_no_meta))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            meta_attributes={
                                "target-role": "",
                            })
Ejemplo n.º 9
0
 def test_no_updates(self):
     (self.config.runner.cib.load(resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" />
                     </bundle>
                 </resources>
             """).env.push_cib())
     resource.bundle_update(self.env_assist.get_env(), "B1")
Ejemplo n.º 10
0
 def test_add(self):
     (self.config.runner.cib.load(
         resources=self.fixture_cib_storage_1).env.push_cib(
             resources=self.fixture_cib_storage_1_2))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            storage_map_add=[{
                                "source-dir": "/tmp/docker2a",
                                "target-dir": "/tmp/docker2b",
                            }])
Ejemplo n.º 11
0
 def test_unknown_option_remove(self):
     (self.config.runner.cib.load(
         resources=self.fixture_cib_extra_option).env.push_cib(
             resources=fixture_resources_minimal))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            container_options={
                                "extra": "",
                            },
                            force_options=True)
Ejemplo n.º 12
0
 def test_already_not_accessible(self):
     (self.config.runner.cib.load(
         resources=self.fixture_resources_pre.format(
             network="")).env.push_cib(
                 resources=self.fixture_resources_pre.format(
                     network='<network host-interface="int"/>')))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            network_options={
                                "host-interface": "int",
                            })
Ejemplo n.º 13
0
 def test_remove_ip_add_port(self):
     (self.config.runner.cib.load(
         resources=self.fixture_resources_pre.format(
             network='<network ip-range-start="192.168.100.200"/>')).env.
      push_cib(resources=self.fixture_resources_pre.format(
          network='<network control-port="1234"/>')))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            network_options={
                                "ip-range-start": "",
                                "control-port": "1234",
                            })
Ejemplo n.º 14
0
 def test_cib_upgrade(self):
     (self.config.runner.cib.load(
         filename="cib-empty.xml",
         name="load_cib_old_version").runner.cib.upgrade().runner.cib.load(
             resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" />
                     </bundle>
                 </resources>
             """).env.push_cib())
     resource.bundle_update(self.env_assist.get_env(), "B1")
     self.env_assist.assert_reports([
         (severities.INFO, report_codes.CIB_UPGRADE_SUCCESSFUL, {}, None),
     ])
Ejemplo n.º 15
0
 def test_success(self):
     fixture_cib_pre = """
         <resources>
             <bundle id="B1">
                 <docker image="pcs:test" />
                 <network host-interface="eth0" control-port="12345" />
             </bundle>
         </resources>
     """
     fixture_cib_post = """
         <resources>
             <bundle id="B1">
                 <docker image="pcs:test" />
                 <network host-interface="eth0" host-netmask="24" />
             </bundle>
         </resources>
     """
     self.assert_command_effect(
         fixture_cib_pre,
         lambda: resource.bundle_update(self.env,
                                        "B1",
                                        network_options={
                                            "control-port": "",
                                            "host-netmask": "24",
                                        }), fixture_cib_post)
Ejemplo n.º 16
0
 def test_keep_network_when_port_map_set(self):
     fixture_cib_pre = """
         <resources>
             <bundle id="B1">
                 <docker image="pcs:test" />
                 <network host-interface="eth0">
                     <something />
                 </network>
             </bundle>
         </resources>
     """
     fixture_cib_post = """
         <resources>
             <bundle id="B1">
                 <docker image="pcs:test" />
                 <network>
                     <something />
                 </network>
             </bundle>
         </resources>
     """
     self.assert_command_effect(
         fixture_cib_pre, lambda: resource.bundle_update(
             self.env, "B1", network_options={
                 "host-interface": "",
             }), fixture_cib_post)
Ejemplo n.º 17
0
 def simple_bundle_update(self, wait=False):
     return resource.bundle_update(
         self.env,
         "B1",
         {"image": "new:image"},
         wait=wait,
     )
Ejemplo n.º 18
0
 def test_add(self):
     self.assert_command_effect(
         self.fixture_cib_storage_1, lambda: resource.bundle_update(
             self.env,
             "B1",
             storage_map_add=[{
                 "source-dir": "/tmp/docker2a",
                 "target-dir": "/tmp/docker2b",
             }]), self.fixture_cib_storage_1_2)
Ejemplo n.º 19
0
 def test_unknown_option_remove(self):
     self.assert_command_effect(
         self.fixture_cib_extra_option,
         lambda: resource.bundle_update(
             self.env, "B1", network_options={
                 "extra": "",
             }),
         self.fixture_cib_interface,
     )
Ejemplo n.º 20
0
 def test_unknown_option_remove(self):
     self.assert_command_effect(
         self.fixture_cib_extra_option,
         lambda: resource.bundle_update(
             self.env, "B1", container_options={
                 "extra": "",
             }),
         self.fixture_cib_minimal,
     )
Ejemplo n.º 21
0
 def test_unknow_option_forced(self):
     (self.config.runner.cib.load(
         resources=self.fixture_cib_interface).env.push_cib(
             resources=self.fixture_cib_extra_option))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            network_options={
                                "extra": "option",
                            },
                            force_options=True)
     self.env_assist.assert_reports([
         (severities.WARNING, report_codes.INVALID_OPTION, {
             "option_names": [
                 "extra",
             ],
             "option_type": "network",
             "allowed": self.allowed_options,
         }, None),
     ])
Ejemplo n.º 22
0
 def test_no_updates(self):
     fixture_cib_pre = """
         <resources>
             <bundle id="B1">
                 <docker image="pcs:test" />
             </bundle>
         </resources>
     """
     self.assert_command_effect(
         fixture_cib_pre, lambda: resource.bundle_update(self.env, "B1"),
         fixture_cib_pre)
Ejemplo n.º 23
0
    def test_cib_upgrade(self):
        fixture_cib_pre = """
            <resources>
                <bundle id="B1">
                    <docker image="pcs:test" />
                </bundle>
            </resources>
        """
        self.runner.set_runs(
            fixture.calls_cib_load_and_upgrade(fixture_cib_pre) +
            fixture.calls_cib(fixture_cib_pre,
                              fixture_cib_pre,
                              cib_base_file=self.cib_base_file))

        resource.bundle_update(self.env, "B1")

        self.env.report_processor.assert_reports([
            (severities.INFO, report_codes.CIB_UPGRADE_SUCCESSFUL, {}, None),
        ])
        self.runner.assert_everything_launched()
Ejemplo n.º 24
0
 def test_nonexisting_id(self):
     self.config.runner.cib.load()
     self.env_assist.assert_raise_library_error(
         lambda: resource.bundle_update(self.env_assist.get_env(), "B1"), [
             (severities.ERROR, report_codes.ID_NOT_FOUND, {
                 "id": "B1",
                 "id_description": "bundle",
                 "context_type": "resources",
                 "context_id": "",
             }, None),
         ],
         expected_in_processor=False)
Ejemplo n.º 25
0
 def test_change_meta(self):
     fixture_cib_pre = """
         <resources>
             <bundle id="B1">
                 <meta_attributes id="B1-meta_attributes">
                 <nvpair id="B1-meta_attributes-target-role"
                     name="target-role" value="Stopped" />
                 <nvpair id="B1-meta_attributes-priority"
                     name="priority" value="15" />
                 <nvpair id="B1-meta_attributes-is-managed"
                     name="is-managed" value="false" />
                 </meta_attributes>
                 <docker image="pcs:test" masters="3" replicas="6"/>
             </bundle>
         </resources>
     """
     fixture_cib_post = """
         <resources>
             <bundle id="B1">
                 <meta_attributes id="B1-meta_attributes">
                 <nvpair id="B1-meta_attributes-target-role"
                     name="target-role" value="Stopped" />
                 <nvpair id="B1-meta_attributes-priority"
                     name="priority" value="10" />
                 <nvpair id="B1-meta_attributes-resource-stickiness"
                     name="resource-stickiness" value="100" />
                 </meta_attributes>
                 <docker image="pcs:test" masters="3" replicas="6"/>
             </bundle>
         </resources>
     """
     (self.config.runner.cib.load(resources=fixture_cib_pre).env.push_cib(
         resources=fixture_cib_post))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            meta_attributes={
                                "priority": "10",
                                "resource-stickiness": "100",
                                "is-managed": "",
                            })
Ejemplo n.º 26
0
 def test_success(self):
     (self.config.runner.cib.load(resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" masters="3" replicas="6"/>
                     </bundle>
                 </resources>
             """).env.push_cib(resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" options="test" replicas="3"
                         />
                     </bundle>
                 </resources>
             """))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            container_options={
                                "options": "test",
                                "replicas": "3",
                                "masters": "",
                            })
Ejemplo n.º 27
0
 def test_remove_missing(self):
     (self.config.runner.cib.load(resources=self.fixture_cib_storage_1))
     self.env_assist.assert_raise_library_error(
         lambda: resource.bundle_update(self.env_assist.get_env(),
                                        "B1",
                                        storage_map_remove=[
                                            "B1-storage-map-1",
                                        ]),
         [(severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "B1-storage-map-1",
             "id_description": "storage-map",
             "context_type": "bundle",
             "context_id": "B1",
         }, None)])
Ejemplo n.º 28
0
 def test_success(self):
     (self.config.runner.cib.load(resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" />
                         <network host-interface="eth0" control-port="12345"
                         />
                     </bundle>
                 </resources>
             """).env.push_cib(resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" />
                         <network host-interface="eth0" host-netmask="24" />
                     </bundle>
                 </resources>
             """))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            network_options={
                                "control-port": "",
                                "host-netmask": "24",
                            })
Ejemplo n.º 29
0
 def test_nonexisting_id(self):
     fixture_cib_pre = "<resources />"
     self.runner.set_runs(
         fixture.call_cib_load(self.fixture_cib_resources(fixture_cib_pre)))
     assert_raise_library_error(
         lambda: resource.bundle_update(self.env, "B1"),
         (severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "B1",
             "id_description": "bundle",
             "context_type": "resources",
             "context_id": "",
         }, None),
     )
     self.runner.assert_everything_launched()
Ejemplo n.º 30
0
 def test_keep_network_when_options_set(self):
     (self.config.runner.cib.load(resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" />
                         <network host-interface="eth0">
                             <port-mapping id="B1-port-map-80" port="80" />
                         </network>
                     </bundle>
                 </resources>
             """).env.push_cib(resources="""
                 <resources>
                     <bundle id="B1">
                         <docker image="pcs:test" />
                         <network host-interface="eth0" />
                     </bundle>
                 </resources>
             """))
     resource.bundle_update(self.env_assist.get_env(),
                            "B1",
                            port_map_remove=[
                                "B1-port-map-80",
                            ])