Example #1
0
    def test_create_and_start_server(self):
        create_server_parameters = {
            'm1.small': 'https://my.rightscale.com/api/acct/123/ec2_server_templates/52271',
        }
        righteous.init('user', 'pass', 'account', **create_server_parameters)
        new_server_href = '/server/new'
        self.response.status_code = 201
        self.response.headers['location'] = new_server_href 
        success, location = righteous.create_and_start_server('arduous', 'm1.small', server_template_parameters={'envname':'arduous'})
        assert success

        assert_equal(self.request.call_count, 3)

        # create server
        create_data = {
            'server[nickname]': 'arduous',
            'server[server_template_href]': create_server_parameters['m1.small']
        }
        create_expected = urlencode(create_data)
        self.request.assert_any_call('/servers', method='POST', body=create_expected)

        # set server parameters
        self.request.assert_any_call(new_server_href, method='PUT', body='server[parameters][ENVNAME]=text:arduous', headers={'Content-Type': 'application/x-www-form-urlencoded'}, prepend_api_base=False)

        # start server
        self.request.assert_any_call(new_server_href+'/start', method='POST', prepend_api_base=False)
Example #2
0
 def _create_server(self, instance_type='m1.small'):
     parameters = dict(envname=self.env, email=self.username, mode='unattended', branches='none')
     successful, location = righteous.create_and_start_server(self.env, instance_type, server_template_parameters=parameters)
     assert successful
     assert location is not None
     if self.delete_server:
         self.envs.append(self.env)
Example #3
0
 def test_create_and_start_server_fails(self):
     create_server_parameters = {
         'm1.small': 'https://my.rightscale.com/api/acct/123/ec2_server_templates/52271',
     }
     righteous.init('user', 'pass', 'account', **create_server_parameters)
     
     success, location = righteous.create_and_start_server('titanic', 'm1.small')
     assert not success
     assert not location
Example #4
0
def create(arguments):
    initialise(arguments)

    server_template_parameters = {}
    for argument in arguments['<template-key>=<template-value>']:
        param, value = argument.split('=')
        server_template_parameters[param] = value

    success, location = righteous.create_and_start_server(
        arguments['<environment>'][0],
        arguments['<instance-type>'] or 'm1.small',
        server_template_parameters=server_template_parameters)
    if success:
        puts(colored.green('Created and started environment %s @ %s' %
            (arguments['<environment>'][0], location)))
    else:
        error('Error creating environment %s' % arguments['<environment>'][0])