コード例 #1
0
ファイル: igor.py プロジェクト: jscruz/igor
def start_auto_start_candidates():
    autoStartCandidates = ec2.get_auto_start_candidates()
    instanceIdsToStart = []
    
    for instance in autoStartCandidates:
        instanceIdsToStart.append(instance['id'])
        
    ec2.start(instanceIdsToStart)
コード例 #2
0
ファイル: test_ec2.py プロジェクト: jscruz/igor
    def test_when_we_get_auto_start_candidates_the_correct_instances_are_returned(self, mock_landlord, mock_ec2):
        now = datetime.datetime.now()
        fiveHoursAgo = (datetime.datetime.now() - datetime.timedelta(hours=5))

        ec2.get_all_instances = Mock(return_value=self.getStubStartCandidateInstances())
        unitInstances = ec2.get_auto_start_candidates()

        self.assertEquals(len(unitInstances), 2)
        self.assertEquals(unitInstances[0]['id'], '2')
        self.assertEquals(unitInstances[0]['name'], 'Instance1StoppedAndStartTimePassed')
        
        self.assertEquals(unitInstances[1]['id'], '4')
        self.assertEquals(unitInstances[1]['name'], 'Instance3StoppedAndStartTimeTimeJustPassed')