Beispiel #1
0
 def test_create_server(self):
     """
     Create a server with particular args and succeeds on 202.
     """
     treq = get_fake_treq(self, 'post', 'novaurl/servers',
                          (('{"server": {}}',), self.expected_kwargs),
                          (Response(202), '{"server": {"id": "12345"}}'))
     d = nova.create_server(self.rcs, self.pool, {'server': {}}, _treq=treq)
     self.assertEqual("12345", self.successResultOf(d))
Beispiel #2
0
    def create_servers(self, rcs, num, wait_for=None):
        """
        Create some number of servers using just Nova, and wait until they
        are active.  This uses the same default server arguments as
        `create_group`.

        :param TestResources rcs: An instance of
            :class:`otter.integration.lib.resources.TestResources`
        :param int num: The number of servers to create.
        :param wait_for: What state to wait for for those servers - by default,
            it waits just for them to be active

        :return: an iterable of server details JSON of the created servers.
        """
        image_id = yield fetch_ubuntu_image_id(rcs, self.pool)
        as_args = create_scaling_group_dict(
            image_ref=image_id,
            flavor_ref=flavor_ref)
        server_args = as_args['launchConfiguration']['args']
        server_args['server']['name'] = "autogenerated-non-as-test-server"

        if wait_for is None:
            wait_for = ContainsDict({'status': Equals("ACTIVE")})

        server_ids = yield gatherResults([
            create_server(rcs, self.pool, server_args) for _ in range(num)])

        self.test_case.addCleanup(delete_servers, server_ids, rcs, self.pool)

        servers = yield wait_for_servers(
            rcs,
            self.pool,
            # The list of active servers' ids has the created server ids
            AfterPreprocessing(
                lambda servers: [s for s in servers if s['id'] in server_ids],
                AllMatch(wait_for)
            )
        )

        returnValue(
            [server for server in servers if server['id'] in server_ids])
Beispiel #3
0
    def create_servers(self, rcs, num, wait_for=None):
        """
        Create some number of servers using just Nova, and wait until they
        are active.  This uses the same default server arguments as
        `create_group`.

        :param TestResources rcs: An instance of
            :class:`otter.integration.lib.resources.TestResources`
        :param int num: The number of servers to create.
        :param wait_for: What state to wait for for those servers - by default,
            it waits just for them to be active

        :return: an iterable of server details JSON of the created servers.
        """
        image_id = yield fetch_ubuntu_image_id(rcs, self.pool)
        as_args = create_scaling_group_dict(
            image_ref=image_id,
            flavor_ref=flavor_ref)
        server_args = as_args['launchConfiguration']['args']
        server_args['server']['name'] = "autogenerated-non-as-test-server"

        if wait_for is None:
            wait_for = ContainsDict({'status': Equals("ACTIVE")})

        server_ids = yield gatherResults([
            create_server(rcs, self.pool, server_args) for _ in range(num)])

        self.test_case.addCleanup(delete_servers, server_ids, rcs, self.pool)

        servers = yield wait_for_servers(
            rcs,
            self.pool,
            # The list of active servers' ids has the created server ids
            AfterPreprocessing(
                lambda servers: [s for s in servers if s['id'] in server_ids],
                AllMatch(wait_for)
            )
        )

        returnValue(
            [server for server in servers if server['id'] in server_ids])