Esempio n. 1
0
 def test_triggers_list(self):
     trigger_items = self.karbor_client.triggers.list()
     before_num = len(trigger_items)
     trigger1 = self.store(objects.Trigger())
     trigger1.create('time', {'pattern': '0 20 * * 2', 'format': 'crontab'})
     trigger2 = self.store(objects.Trigger())
     trigger2.create('time', {'pattern': '0 10 * * *', 'format': 'crontab'})
     trigger_items = self.karbor_client.triggers.list()
     after_num = len(trigger_items)
     self.assertEqual(2, after_num - before_num)
Esempio n. 2
0
    def test_triggers_list(self):
        trigger1 = self.store(objects.Trigger())
        trigger1.create('time', {'pattern': '0 20 * * 2', 'format': 'crontab'})
        trigger2 = self.store(objects.Trigger())
        trigger2.create('time', {'pattern': '0 10 * * *', 'format': 'crontab'})

        items = self.karbor_client.triggers.list()
        ids = [item.id for item in items]
        self.assertTrue(trigger1.id in ids)
        self.assertTrue(trigger2.id in ids)
Esempio n. 3
0
    def test_triggers_list(self):
        pattern1 = "BEGIN:VEVENT\nRRULE:FREQ=HOURLY;INTERVAL=1;\nEND:VEVENT"
        trigger1 = self.store(objects.Trigger())
        trigger1.create('time', {'pattern': pattern1, 'format': 'calendar'})
        pattern2 = "BEGIN:VEVENT\nRRULE:FREQ=WEEKLY;INTERVAL=1;\nEND:VEVENT"
        trigger2 = self.store(objects.Trigger())
        trigger2.create('time', {'pattern': pattern2, 'format': 'calendar'})

        items = self.karbor_client.triggers.list()
        ids = [item.id for item in items]
        self.assertTrue(trigger1.id in ids)
        self.assertTrue(trigger2.id in ids)
Esempio n. 4
0
    def test_triggers_update(self):
        trigger_name = "FullStack Trigger Test Update"
        pattern1 = "BEGIN:VEVENT\nRRULE:FREQ=WEEKLY;INTERVAL=1;\nEND:VEVENT"
        pattern2 = "BEGIN:VEVENT\nRRULE:FREQ=DAILY;INTERVAL=1;\nEND:VEVENT"
        trigger = self.store(objects.Trigger())
        trigger.create('time', {
            'pattern': pattern1,
            'format': 'calendar'
        },
                       name=trigger_name)
        properties = {
            'properties': {
                'pattern': pattern2,
                'format': 'calendar',
                'start_time': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'),
            }
        }

        self.karbor_client.triggers.update(
            trigger.id,
            properties,
        )

        trigger = self.karbor_client.triggers.get(trigger.id)
        self.assertEqual(trigger.properties['pattern'], pattern2)
Esempio n. 5
0
 def test_triggers_get(self):
     trigger_name = "FullStack Trigger Test Get"
     trigger = self.store(objects.Trigger())
     trigger.create('time', {'pattern': '0 15 * * 2', 'format': 'crontab'},
                    name=trigger_name)
     trigger = self.karbor_client.triggers.get(trigger.id)
     self.assertEqual(trigger_name, trigger.name)
Esempio n. 6
0
 def test_triggers_delete(self):
     trigger = objects.Trigger()
     trigger.create('time', {'pattern': '0 12 * * 2', 'format': 'crontab'})
     self.karbor_client.triggers.delete(trigger.id)
     items = self.karbor_client.triggers.list()
     ids = [item.id for item in items]
     self.assertTrue(trigger.id not in ids)
Esempio n. 7
0
 def test_triggers_delete(self):
     pattern = "BEGIN:VEVENT\nRRULE:FREQ=WEEKLY;INTERVAL=1;\nEND:VEVENT"
     trigger = objects.Trigger()
     trigger.create('time', {'pattern': pattern, 'format': 'calendar'})
     self.karbor_client.triggers.delete(trigger.id)
     items = self.karbor_client.triggers.list()
     ids = [item.id for item in items]
     self.assertTrue(trigger.id not in ids)
Esempio n. 8
0
 def test_triggers_delete(self):
     trigger = objects.Trigger()
     trigger_items = self.karbor_client.triggers.list()
     before_num = len(trigger_items)
     trigger.create('time', {'pattern': '0 12 * * 2', 'format': 'crontab'})
     self.karbor_client.triggers.delete(trigger.id)
     trigger_items = self.karbor_client.triggers.list()
     after_num = len(trigger_items)
     self.assertEqual(0, after_num - before_num)
Esempio n. 9
0
 def test_triggers_get(self):
     trigger_name = "FullStack Trigger Test Get"
     pattern = "BEGIN:VEVENT\nRRULE:FREQ=WEEKLY;INTERVAL=1;\nEND:VEVENT"
     trigger = self.store(objects.Trigger())
     trigger.create('time', {
         'pattern': pattern,
         'format': 'calendar'
     },
                    name=trigger_name)
     trigger = self.karbor_client.triggers.get(trigger.id)
     self.assertEqual(trigger_name, trigger.name)
    def _create_scheduled_operation(self,
                                    trigger_properties,
                                    operation_definition,
                                    operation_name=None):
        trigger = self.store(objects.Trigger())
        trigger.create('time', trigger_properties)

        operation = objects.ScheduledOperation()
        operation.create('protect', trigger.id, operation_definition,
                         operation_name)
        return operation
    def _create_scheduled_operation(self,
                                    resources,
                                    trigger_properties=DEFAULT_PROPERTY,
                                    operation_name=None):
        plan = self.store(objects.Plan())
        plan.create(self.provider_id, resources)
        operation_definition = {
            'plan_id': plan.id,
            'provider_id': self.provider_id
        }
        trigger = self.store(objects.Trigger())
        trigger.create('time', trigger_properties)

        operation = objects.ScheduledOperation()
        operation.create('protect', trigger.id, operation_definition,
                         operation_name)
        return operation