def check_rule_operation_fail(self, rule_type, rules):
        fake_client = self.generate_client()
        fake_ctx = self.generate_context_for_security_group()
        fake_ctx._target.node.properties = {'rules': rules}
        # check busy
        gateway = fake_client._vdc_gateway
        self.set_gateway_busy(gateway)
        self.prepare_retry(fake_ctx)
        self.set_services_conf_result(fake_client._vdc_gateway, None)
        with mock.patch('network_plugin.security_group.ctx', fake_ctx):
            with mock.patch('vcloud_plugin_common.ctx', fake_ctx):
                security_group._rule_operation(rule_type, fake_client)

        self.check_retry_realy_called(fake_ctx)
    def check_rule_operation_fail(self, rule_type, rules):
        fake_client = self.generate_client()
        fake_ctx = self.generate_context_for_security_group()
        fake_ctx._target.node.properties = {"rules": rules}
        # check busy
        gateway = fake_client._vdc_gateway
        self.set_gateway_busy(gateway)
        self.prepare_retry(fake_ctx)
        self.set_services_conf_result(fake_client._vdc_gateway, None)
        with mock.patch("network_plugin.security_group.ctx", fake_ctx):
            with mock.patch("vcloud_plugin_common.ctx", fake_ctx):
                security_group._rule_operation(rule_type, fake_client)

        self.check_retry_realy_called(fake_ctx)
 def check_rule_operation(self, rule_type, rules, vms_networks=None):
     if not vms_networks:
         vms_networks = []
     fake_client = self.generate_client(vms_networks=vms_networks)
     fake_ctx = self.generate_context_for_security_group()
     fake_ctx._target.node.properties = {"rules": rules}
     # any calls for save configuration will be success
     gateway = fake_client._vdc_gateway
     self.set_services_conf_result(gateway, vcloud_plugin_common.TASK_STATUS_SUCCESS)
     # for check calls for add/delete rule
     gateway.add_fw_rule = mock.MagicMock(return_value=None)
     gateway.delete_fw_rule = mock.MagicMock(return_value=None)
     # any networks will be routed
     self.set_network_routed_in_client(fake_client)
     with mock.patch("network_plugin.security_group.ctx", fake_ctx):
         with mock.patch("vcloud_plugin_common.ctx", fake_ctx):
             security_group._rule_operation(rule_type, fake_client)
     return gateway
 def check_rule_operation(self, rule_type, rules, vms_networks=None):
     if not vms_networks:
         vms_networks = []
     fake_client = self.generate_client(vms_networks=vms_networks)
     fake_ctx = self.generate_context_for_security_group()
     fake_ctx._target.node.properties = {'rules': rules}
     # any calls for save configuration will be success
     gateway = fake_client._vdc_gateway
     self.set_services_conf_result(gateway,
                                   vcloud_plugin_common.TASK_STATUS_SUCCESS)
     # for check calls for add/delete rule
     gateway.add_fw_rule = mock.MagicMock(return_value=None)
     gateway.delete_fw_rule = mock.MagicMock(return_value=None)
     # any networks will be routed
     self.set_network_routed_in_client(fake_client)
     with mock.patch('network_plugin.security_group.ctx', fake_ctx):
         with mock.patch('vcloud_plugin_common.ctx', fake_ctx):
             security_group._rule_operation(rule_type, fake_client)
     return gateway
 def check_rule_operation_fail(self, rule_type, rules):
     fake_client = self.generate_client()
     fake_ctx = self.generate_context_for_security_group()
     fake_ctx._target.node.properties = {
         'rules': rules
     }
     # check busy
     gateway = fake_client._vdc_gateway
     self.set_gateway_busy(gateway)
     self.set_services_conf_result(
         fake_client._vdc_gateway, None
     )
     with mock.patch('network_plugin.security_group.ctx', fake_ctx):
         with mock.patch('vcloud_plugin_common.ctx', fake_ctx):
             self.assertFalse(security_group._rule_operation(
                 rule_type, fake_client
             ))