예제 #1
0
파일: igor.py 프로젝트: jscruz/igor
def stop_auto_stop_candidates():
    autoStopCandidates = ec2.get_auto_stop_candidates()
    instanceIdsToStop = []
    
    for instance in autoStopCandidates:
        instanceIdsToStop.append(instance['id'])
        
    ec2.stop(instanceIdsToStop)
예제 #2
0
파일: test_ec2.py 프로젝트: jscruz/igor
    def test_stop_not_called_when_reqeusted_ids_is_empty(self, mock_landlord, mock_ec2):
        instances = []
        mock_landlord.Tenant = StubLandlord
        mock_connection = Mock()
        mock_ec2.connect_to_region.return_value = mock_connection

        ec2.stop(instances)
        
        self.assertEquals(mock_ec2.connect_to_region.call_count, 0);
        self.assertEquals(mock_connection.stop_instances.call_count, 0);
예제 #3
0
파일: test_ec2.py 프로젝트: jscruz/igor
    def test_tag_added_when_instance_auto_stopped(self, mock_landlord, mock_ec2):
        instances = ['i-278219', 'i-82715']
        mock_landlord.Tenant = StubLandlord
        mock_connection = Mock()
        mock_ec2.connect_to_region.return_value = mock_connection

        mockInstance1 = Mock()
        mockInstance2 = Mock()
        mock_connection.stop_instances.return_value = [mockInstance1, mockInstance2]
        
        ec2.stop(instances)
        
        mockInstance1.add_tags.assert_called_with({'AutoStopped': 'True'})
        mockInstance2.add_tags.assert_called_with({'AutoStopped': 'True'})
예제 #4
0
파일: test_ec2.py 프로젝트: jscruz/igor
    def test_stop_reqeusted_for_ids(self, mock_landlord, mock_ec2):
        instances = ['i-278219', 'i-82715']
        mock_landlord.Tenant = StubLandlord
        mock_connection = Mock()
        mock_ec2.connect_to_region.return_value = mock_connection

        mockInstance1 = Mock()
        mockInstance2 = Mock()
        mock_connection.stop_instances.return_value = [mockInstance1, mockInstance2]

        ec2.stop(instances)
        mock_ec2.connect_to_region.assert_called_with('deploy.region', aws_access_key_id='aws.id',
                                                      aws_secret_access_key='aws.secret')
        mock_connection.stop_instances.assert_called_with(instances)