def setUp(self): (flexmock(EC2Connection) .should_receive('get_key_pair') .and_return(None)) (flexmock(EC2Connection) .should_receive('create_key_pair') .with_args('bookeyname') .and_return(KeyPair())) (flexmock(EC2Connection) .should_receive('get_all_security_groups') .and_return([])) (flexmock(EC2Connection) .should_receive('create_security_group') .with_args('boogroup', 'AppScale security group') .and_return(SecurityGroup())) (flexmock(EC2Connection) .should_receive('authorize_security_group') .and_return()) reservation = Reservation() # the old implementation had a regression where public and private IPs # were getting sorted, and thus public ip1 would point to private ip 2. # to prevent this regression from resurfacing, set up the dns names so # that a sort would mess them up again. instance1 = Instance() instance1.public_dns_name = 'ABC-public-ip1' instance1.private_dns_name = 'DEF-private-ip1' instance1.id = 'i-id1' instance1._state.name = 'running' instance1.key_name = 'bookeyname' instance2 = Instance() instance2.public_dns_name = 'DEF-public-ip2' instance2.private_dns_name = 'ABC-private-ip2' instance2.id = 'i-id2' instance2._state.name = 'running' instance2.key_name = 'bookeyname' reservation.instances = [instance1, instance2] (flexmock(EC2Connection) .should_receive('get_all_instances') .and_return([]) .and_return([reservation])) (flexmock(EC2Connection) .should_receive('run_instances') .and_return()) (flexmock(utils) .should_receive('get_secret') .and_return('secret')) (flexmock(utils) .should_receive('sleep') .and_return()) (flexmock(utils) .should_receive('get_random_alphanumeric') .and_return('0000000000')) (flexmock(utils) .should_receive('write_key_file') .and_return())
def setUp(self): (flexmock(EC2Connection).should_receive('get_key_pair').and_return( None)) (flexmock(EC2Connection).should_receive('create_key_pair').with_args( 'bookeyname').and_return(KeyPair())) (flexmock(EC2Connection).should_receive( 'get_all_security_groups').and_return([])) (flexmock( EC2Connection).should_receive('create_security_group').with_args( 'boogroup', 'AppScale security group').and_return(SecurityGroup())) (flexmock(EC2Connection).should_receive( 'authorize_security_group').and_return()) reservation = Reservation() instance = Instance() instance.private_dns_name = 'private-ip' instance.public_dns_name = 'public-ip' instance.id = 'i-id' instance._state.name = 'running' instance.key_name = 'bookeyname' reservation.instances = [instance] (flexmock(EC2Connection).should_receive( 'get_all_instances').and_return([]).and_return([reservation])) (flexmock(EC2Connection).should_receive( 'terminate_instances').and_return([instance])) (flexmock(EC2Connection).should_receive('run_instances').and_return()) (flexmock(utils).should_receive('get_secret').and_return('secret')) (flexmock(utils).should_receive('sleep').and_return()) (flexmock(utils).should_receive('get_random_alphanumeric').and_return( '0000000000')) (flexmock(utils).should_receive('write_key_file').and_return())
def setUp(self): (flexmock(EC2Connection) .should_receive('get_key_pair') .and_return(None)) (flexmock(EC2Connection) .should_receive('create_key_pair') .with_args('bookeyname') .and_return(KeyPair())) (flexmock(EC2Connection) .should_receive('get_all_security_groups') .and_return([])) (flexmock(EC2Connection) .should_receive('create_security_group') .with_args('boogroup', 'AppScale security group') .and_return(SecurityGroup())) (flexmock(EC2Connection) .should_receive('authorize_security_group') .and_return()) reservation = Reservation() instance = Instance() instance.private_dns_name = 'private-ip' instance.public_dns_name = 'public-ip' instance.id = 'i-id' instance._state.name = 'running' instance.key_name = 'bookeyname' reservation.instances = [instance] (flexmock(EC2Connection) .should_receive('get_all_instances') .and_return([]) .and_return([reservation])) (flexmock(EC2Connection) .should_receive('terminate_instances') .and_return([instance])) (flexmock(EC2Connection) .should_receive('run_instances') .and_return()) (flexmock(utils) .should_receive('get_secret') .and_return('secret')) (flexmock(utils) .should_receive('sleep') .and_return()) (flexmock(utils) .should_receive('get_random_alphanumeric') .and_return('0000000000')) (flexmock(utils) .should_receive('write_key_file') .and_return())
def setUp(self): fake_ec2 = flexmock(name='fake_ec2') fake_ec2.should_receive('get_key_pair') fake_ec2.should_receive('create_key_pair').with_args('bookeyname') \ .and_return(KeyPair()) fake_ec2.should_receive('get_all_security_groups').and_return([]) fake_ec2.should_receive('create_security_group') \ .with_args('boogroup', 'AppScale security group') \ .and_return(SecurityGroup()) fake_ec2.should_receive('authorize_security_group') reservation = Reservation() instance = Instance() instance.private_dns_name = 'private-ip' instance.public_dns_name = 'public-ip' instance.id = 'i-id' instance._state.name = 'running' instance.key_name = 'bookeyname' reservation.instances = [instance] fake_ec2.should_receive('get_all_instances').and_return([]) \ .and_return([reservation]) fake_ec2.should_receive('terminate_instances').and_return([instance]) fake_ec2.should_receive('request_spot_instances') flexmock(boto.ec2) boto.ec2.should_receive('connect_to_region').and_return(fake_ec2) (flexmock(utils) .should_receive('get_secret') .and_return('secret')) (flexmock(utils) .should_receive('sleep') .and_return()) (flexmock(utils) .should_receive('get_random_alphanumeric') .and_return('0000000000')) (flexmock(utils) .should_receive('write_key_file') .and_return())