Rally source code changes

Asked by Rajeev

Hi,

I'm using Rally to benchmark openstack cloud.

Nova scenarios configure instances with randomly generated name, which i need to avoid.

In order to achieve this, i have modified the source code to include custom name. I'm including an example here to explain the changes.

Scenario name: boot-and-rebuild.json

This scenario boots a server and rebuilds it with different image. It calls the sub-routine _boot_server in utils.py.
I have made changes to servers.py where the plugin implementation is present and to the utils.py where the core sub-routine is present.

servers.py changes: (line 799 onwards)

def boot_and_rebuild_server(self, from_image, to_image, flavor, **kwargs):
        """Rebuild a server.

        This scenario launches a VM, then rebuilds that VM with a
        different image.

        :param from_image: image to be used to boot an instance
        :param to_image: image to be used to rebuild the instance
        :param flavor: flavor to be used to boot an instance
        :param kwargs: Optional additional arguments for server creation
        """

        #edited by Rajeev - 1/27/2017
        kwargs["custom_server_name"] = "test_nova_instance"
        server = self._boot_server(from_image, flavor, **kwargs)
        self._rebuild_server(server, to_image)
        self._delete_server(server)

utils.py changes:

    @atomic.action_timer("nova.boot_server")
    def _boot_server(self, image_id, flavor_id,
                     auto_assign_nic=False, **kwargs):
        """Boot a server.

        Returns when the server is actually booted and in "ACTIVE" state.

        If multiple networks created by Network context are present, the first
        network found that isn't associated with a floating IP pool is used.

        :param image_id: int, image ID for server creation
        :param flavor_id: int, flavor ID for server creation
        :param auto_assign_nic: bool, whether or not to auto assign NICs
        :param kwargs: other optional parameters to initialize the server
        :returns: nova Server instance
        """
        #server_name = self.generate_random_name() -- original
        #edited by Rajeev - 1/27/2017
        #server_name = kwargs["name"]
        if "custom_server_name" in kwargs:
            server_name = kwargs["custom_server_name"]
        else:
            server_name = self.generate_random_name()

        secgroup = self.context.get("user", {}).get("secgroup")
        if secgroup:
            if "security_groups" not in kwargs:
                kwargs["security_groups"] = [secgroup["name"]]
            elif secgroup["name"] not in kwargs["security_groups"]:
                kwargs["security_groups"].append(secgroup["name"])
      if auto_assign_nic and not kwargs.get("nics", False):
            nic = self._pick_random_nic()
            if nic:
                kwargs["nics"] = nic

        server = self.clients("nova").servers.create(
            server_name, image_id, flavor_id, **kwargs)

        time.sleep(CONF.benchmark.nova_server_boot_prepoll_delay)
        server = utils.wait_for(
            server,
            ready_statuses=["ACTIVE"],
            update_resource=utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_boot_timeout,
            check_interval=CONF.benchmark.nova_server_boot_poll_interval
        )
        return server

-------------

However, when i execute the benchmark scenario, it is creating an instance with the randomly generated name (which is commented in the code).

How can i make sure that rally picks up the changes which i have made in few of the files?
Do i have to overwrite/update some ENV variables to accept the changes?

Please let me know if i need to provide additional information.

Thanks,
Rajeev

Question information

Language:
English Edit question
Status:
Solved
For:
Rally Edit question
Assignee:
No assignee Edit question
Solved by:
Andriy Kurilin
Solved:
Last query:
Last reply:
Revision history for this message
Rajeev (rsomayaj) said :
#1

How does Rally know the location of the plugins and other source files?
What are the environment variables that get set on rally installation?

Revision history for this message
Rajeev (rsomayaj) said :
#2

Are there any videos or tutorials explaining the best practices for code changes in rally? I'm trying to change the existing code, but with no luck. Any help is appreciated.

Thanks,
Rajeev

Revision history for this message
Best Andriy Kurilin (andreykurilin) said :
#3

Actually, it looks like not a rally-specific question, but I'll try to help you.

I do not know how Rally was installed, but I can assume that Rally was cloned from the git repository and installed from there.
In this case, like for all others python packages, actual rally code(which is used for all other executions) is moved to python directories. Cloned repository is not used after Rally had been successfully installed and you can remove it.

The best way to identify the place where any python package is located - execute a simple command:

   python -c "import rally; print(rally.__file__)"

For you case, I can propose to not modify rally code at all. The better way is to create a separate scenario(it can be equal to original one, but with your own modifications). If you put it to proper place (http://rally.readthedocs.io/en/0.8.1/plugins/index.html#placement) rally will discover it.

Revision history for this message
Rajeev (rsomayaj) said :
#4

Thanks Andrey Kurilin, that solved my question.