示例#1
0
    def test_deployment_update_several(self):
        # Create a deployment and update it
        deploy_one = db.deployment_create({})
        self.assertEqual({}, deploy_one["config"])
        update_deploy_one = db.deployment_update(deploy_one["uuid"],
                                                 {"config": {
                                                     "opt1": "val1"
                                                 }})
        self.assertEqual(deploy_one["uuid"], update_deploy_one["uuid"])
        self.assertEqual({"opt1": "val1"}, update_deploy_one["config"])
        get_deploy_one = db.deployment_get(deploy_one["uuid"])
        self.assertEqual(deploy_one["uuid"], get_deploy_one["uuid"])
        self.assertEqual({"opt1": "val1"}, get_deploy_one["config"])

        # Create another deployment
        deploy_two = db.deployment_create({})
        update_deploy_two = db.deployment_update(deploy_two["uuid"],
                                                 {"config": {
                                                     "opt2": "val2"
                                                 }})
        self.assertEqual(deploy_two["uuid"], update_deploy_two["uuid"])
        self.assertEqual({"opt2": "val2"}, update_deploy_two["config"])
        get_deploy_one_again = db.deployment_get(deploy_one["uuid"])
        self.assertEqual(deploy_one["uuid"], get_deploy_one_again["uuid"])
        self.assertEqual({"opt1": "val1"}, get_deploy_one_again["config"])
示例#2
0
 def test_deployment_get(self):
     deploy_one = db.deployment_create({"config": {"opt1": "val1"}})
     deploy_two = db.deployment_create({"config": {"opt2": "val2"}})
     get_deploy_one = db.deployment_get(deploy_one["uuid"])
     get_deploy_two = db.deployment_get(deploy_two["uuid"])
     self.assertNotEqual(get_deploy_one["uuid"], get_deploy_two["uuid"])
     self.assertEqual({"opt1": "val1"}, get_deploy_one["config"])
     self.assertEqual({"opt2": "val2"}, get_deploy_two["config"])
示例#3
0
 def test_deployment_get(self):
     deploy_one = db.deployment_create({"config": {"opt1": "val1"}})
     deploy_two = db.deployment_create({"config": {"opt2": "val2"}})
     get_deploy_one = db.deployment_get(deploy_one["uuid"])
     get_deploy_two = db.deployment_get(deploy_two["uuid"])
     self.assertNotEqual(get_deploy_one["uuid"], get_deploy_two["uuid"])
     self.assertEqual(get_deploy_one["config"], {"opt1": "val1"})
     self.assertEqual(get_deploy_two["config"], {"opt2": "val2"})
示例#4
0
    def create_controller(self, controller_create_args):
        """Create ovn centralized controller on ovn controller node.

        Contains ovn-northd, northbound ovsdb-server, sourthbound ovsdb-server.
        If not exist, create a new one; otherwise, cleanup old ones then create
        a new one.

        :param controller_create_args: dict, contains below values:

            ===========         ========
            key                 desc
            ===========         ========
            controller_cidr     str, the CIDR on which ovsdb-server listening
            net_dev             str, the dev name used to add CIDR to, e.g. eth0
            ===========         ========

        """
        multihost_dep = db.deployment_get(self.task["deployment_uuid"])

        config = multihost_dep["config"]
        controller_cidr = config["controller"].get("controller_cidr", None)
        net_dev = config["controller"].get("net_dev", None)
        deployment_name = config["controller"].get("deployment_name")

        controller_cidr = controller_create_args.get("controller_cidr",
                                                            controller_cidr)
        net_dev = controller_create_args.get("net_dev", net_dev)

        if controller_cidr == None:
            raise NoSuchConfigField(name="controller_cidr")

        if net_dev == None:
            raise NoSuchConfigField(name="net_dev")

        self._create_controller(deployment_name, controller_cidr, net_dev)
示例#5
0
 def test_deployment_update(self):
     credentials = {
         "openstack": [{
             "admin": {
                 "foo": "bar"
             },
             "users": ["foo_user"]
         }]
     }
     deploy = db.deployment_create({})
     self.assertEqual({}, deploy["config"])
     self.assertEqual({}, deploy["credentials"])
     update_deploy = db.deployment_update(
         deploy["uuid"], {
             "config": {
                 "opt": "val"
             },
             "credentials": copy.deepcopy(credentials)
         })
     self.assertEqual(deploy["uuid"], update_deploy["uuid"])
     self.assertEqual({"opt": "val"}, update_deploy["config"])
     self.assertEqual(credentials, update_deploy["credentials"])
     get_deploy = db.deployment_get(deploy["uuid"])
     self.assertEqual(deploy["uuid"], get_deploy["uuid"])
     self.assertEqual({"opt": "val"}, get_deploy["config"])
     self.assertEqual(credentials, update_deploy["credentials"])
示例#6
0
    def create_controller(self, controller_create_args):
        """Create ovn centralized controller on ovn controller node.

        Contains ovn-northd, northbound ovsdb-server, sourthbound ovsdb-server.
        If not exist, create a new one; otherwise, cleanup old ones then create
        a new one.

        :param controller_create_args: dict, contains below values:

            ===========         ========
            key                 desc
            ===========         ========
            controller_cidr     str, the CIDR on which ovsdb-server listening
            net_dev             str, the dev name used to add CIDR to, e.g. eth0
            ===========         ========

        """
        multihost_dep = db.deployment_get(self.task["deployment_uuid"])

        config = multihost_dep["config"]
        controller_cidr = config["controller"].get("controller_cidr", None)
        net_dev = config["controller"].get("net_dev", None)
        deployment_name = config["controller"].get("deployment_name")

        controller_cidr = controller_create_args.get("controller_cidr",
                                                     controller_cidr)
        net_dev = controller_create_args.get("net_dev", net_dev)

        if controller_cidr == None:
            raise NoSuchConfigField(name="controller_cidr")

        if net_dev == None:
            raise NoSuchConfigField(name="net_dev")

        self._create_controller(deployment_name, controller_cidr, net_dev)
示例#7
0
文件: config.py 项目: aforalee/rally
    def __init__(self, deployment, conf_path):
        endpoint = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Endpoint(**endpoint))
        self.keystone = self.clients.verified_keystone()

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)
示例#8
0
    def __init__(self, deployment, conf_path):
        endpoint = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Endpoint(**endpoint))
        self.keystone = self.clients.verified_keystone()

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)
示例#9
0
 def test_deployment_update(self):
     deploy = db.deployment_create({})
     self.assertEqual(deploy["config"], {})
     update_deploy = db.deployment_update(deploy["uuid"],
                                          {"config": {"opt": "val"}})
     self.assertEqual(update_deploy["uuid"], deploy["uuid"])
     self.assertEqual(update_deploy["config"], {"opt": "val"})
     get_deploy = db.deployment_get(deploy["uuid"])
     self.assertEqual(get_deploy["uuid"], deploy["uuid"])
     self.assertEqual(get_deploy["config"], {"opt": "val"})
示例#10
0
 def test_deployment_update(self):
     deploy = db.deployment_create({})
     self.assertEqual(deploy["config"], {})
     update_deploy = db.deployment_update(deploy["uuid"],
                                          {"config": {"opt": "val"}})
     self.assertEqual(update_deploy["uuid"], deploy["uuid"])
     self.assertEqual(update_deploy["config"], {"opt": "val"})
     get_deploy = db.deployment_get(deploy["uuid"])
     self.assertEqual(get_deploy["uuid"], deploy["uuid"])
     self.assertEqual(get_deploy["config"], {"opt": "val"})
示例#11
0
    def config(self, deployment=None):
        """Display configuration of the deployment.

        Output is the configuration of the deployment in a
        pretty-printed JSON format.

        :param deployment: a UUID or name of the deployment
        """
        deploy = db.deployment_get(deployment)
        result = deploy["config"]
        print(json.dumps(result, sort_keys=True, indent=4))
示例#12
0
文件: task.py 项目: sen0120/rally-1
 def to_dict(self):
     db_task = self.task
     deployment_name = db.deployment_get(
         self.task["deployment_uuid"])["name"]
     db_task["deployment_name"] = deployment_name
     self._serialize_dt(db_task)
     for subtask in db_task.get("subtasks", []):
         self._serialize_dt(subtask)
         for workload in subtask["workloads"]:
             self._serialize_dt(workload)
     return db_task
示例#13
0
    def test_deployment_update_several(self):
        # Create a deployment and update it
        deploy_one = db.deployment_create({})
        self.assertEqual(deploy_one["config"], {})
        update_deploy_one = db.deployment_update(
            deploy_one["uuid"], {"config": {"opt1": "val1"}})
        self.assertEqual(update_deploy_one["uuid"], deploy_one["uuid"])
        self.assertEqual(update_deploy_one["config"], {"opt1": "val1"})
        get_deploy_one = db.deployment_get(deploy_one["uuid"])
        self.assertEqual(get_deploy_one["uuid"], deploy_one["uuid"])
        self.assertEqual(get_deploy_one["config"], {"opt1": "val1"})

        # Create another deployment
        deploy_two = db.deployment_create({})
        update_deploy_two = db.deployment_update(
            deploy_two["uuid"], {"config": {"opt2": "val2"}})
        self.assertEqual(update_deploy_two["uuid"], deploy_two["uuid"])
        self.assertEqual(update_deploy_two["config"], {"opt2": "val2"})
        get_deploy_one_again = db.deployment_get(deploy_one["uuid"])
        self.assertEqual(get_deploy_one_again["uuid"], deploy_one["uuid"])
        self.assertEqual(get_deploy_one_again["config"], {"opt1": "val1"})
示例#14
0
    def __init__(self, deployment):
        self.deployment = deployment

        self.credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**self.credential))
        self.keystone = self.clients.verified_keystone()
        self.available_services = self.clients.services().values()

        self.data_dir = _create_or_get_data_dir()

        self.conf = configparser.ConfigParser()
        self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))
示例#15
0
文件: config.py 项目: zioc/rally
    def __init__(self, deployment):
        self.deployment = deployment

        self.credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**self.credential))
        self.keystone = self.clients.verified_keystone()
        self.available_services = self.clients.services().values()

        self.data_dir = _create_or_get_data_dir()

        self.conf = configparser.ConfigParser()
        self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))
示例#16
0
    def __init__(self, deployment, conf_path):
        endpoint = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**endpoint))
        self.available_services = self.clients.services().values()

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)

        self._created_roles = []
        self._created_images = []
        self._created_flavors = []
        self._created_networks = []
示例#17
0
    def __init__(self, deployment, conf_path):
        endpoint = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**endpoint))
        self.available_services = self.clients.services().values()

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)

        self._created_roles = []
        self._created_images = []
        self._created_flavors = []
        self._created_networks = []
示例#18
0
文件: config.py 项目: davrobin/rally
    def __init__(self, deployment):
        self.deployment = deployment

        self.credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**self.credential))
        self.keystone = self.clients.verified_keystone()
        self.available_services = self.clients.services().values()

        self.data_dir = _create_or_get_data_dir()

        self.conf = configparser.ConfigParser()
        self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))
        self.image_name = parse.urlparse(CONF.image.cirros_img_url).path.split("/")[-1]

        self._download_cirros_image()
示例#19
0
 def test_deployment_update(self):
     credentials = {
         "openstack": [{"admin": {"foo": "bar"}, "users": ["foo_user"]}]}
     deploy = db.deployment_create({})
     self.assertEqual({}, deploy["config"])
     self.assertEqual({}, deploy["credentials"])
     update_deploy = db.deployment_update(
         deploy["uuid"], {"config": {"opt": "val"},
                          "credentials": copy.deepcopy(credentials)})
     self.assertEqual(deploy["uuid"], update_deploy["uuid"])
     self.assertEqual({"opt": "val"}, update_deploy["config"])
     self.assertEqual(credentials, update_deploy["credentials"])
     get_deploy = db.deployment_get(deploy["uuid"])
     self.assertEqual(deploy["uuid"], get_deploy["uuid"])
     self.assertEqual({"opt": "val"}, get_deploy["config"])
     self.assertEqual(credentials, update_deploy["credentials"])
示例#20
0
文件: config.py 项目: aswadr/rally
    def __init__(self, deployment):
        self.deployment = deployment

        self.credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**self.credential))
        self.keystone = self.clients.verified_keystone()
        self.available_services = self.clients.services().values()

        self.data_dir = _create_or_get_data_dir()

        self.conf = configparser.ConfigParser()
        self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))

        self.image_name = parse.urlparse(
            CONF.tempest.img_url).path.split("/")[-1]
        self._download_image()
示例#21
0
文件: config.py 项目: davrobin/rally
    def __init__(self, deployment, verification, conf_path):
        credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**credential))
        self.available_services = self.clients.services().values()

        self.verification = verification

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)
        self.image_name = parse.urlparse(CONF.image.cirros_img_url).path.split("/")[-1]

        self._created_roles = []
        self._created_images = []
        self._created_flavors = []
        self._created_networks = []
示例#22
0
    def __init__(self, deployment, verification, conf_path):
        credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**credential))
        self.available_services = self.clients.services().values()

        self.verification = verification

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)
        self.image_name = parse.urlparse(
            CONF.image.cirros_img_url).path.split("/")[-1]

        self._created_roles = []
        self._created_images = []
        self._created_flavors = []
        self._created_networks = []
示例#23
0
    def __init__(self, deployment, verification, conf_path):
        credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**credential))
        self.available_services = self.clients.services().values()

        self.verification = verification

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)

        self.data_dir = _create_or_get_data_dir()
        self.image_name = "tempest-image"

        self._created_roles = []
        self._created_images = []
        self._created_flavors = []
        self._created_networks = []
示例#24
0
文件: config.py 项目: zioc/rally
    def __init__(self, deployment, verification, conf_path):
        credential = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Credential(**credential))
        self.available_services = self.clients.services().values()

        self.verification = verification

        self.conf_path = conf_path
        self.conf = configparser.ConfigParser()
        self.conf.read(conf_path)

        self.data_dir = _create_or_get_data_dir()
        self.image_name = "tempest-image"

        self._created_roles = []
        self._created_images = []
        self._created_flavors = []
        self._created_networks = []
示例#25
0
    def show(self, deployment=None):
        """Show the endpoints of the deployment.

        :param deployment: a UUID or name of the deployment
        """

        headers = ["auth_url", "username", "password", "tenant_name",
                   "region_name", "endpoint_type"]
        table_rows = []

        deployment = db.deployment_get(deployment)
        users = deployment.get("users", [])
        admin = deployment.get("admin")
        endpoints = users + [admin] if admin else users

        for ep in endpoints:
            data = ["***" if m == "password" else ep.get(m, "")
                    for m in headers]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
        cliutils.print_list(table_rows, headers)
示例#26
0
    def setup(self):

        multihost_uuid = self.task["deployment_uuid"]
        controller_name = self.config["controller"]

        multihost_info = get_ovn_multihost_info(multihost_uuid,
                                                controller_name)
        self.context["ovn_multihost"] = multihost_info

        try:
            controller_dep = db.deployment_get(controller_name)
        except exceptions.DeploymentNotFound:
            raise

        try:
            res = db.resource_get_all(controller_dep["uuid"],
                                      type=ResourceType.CONTROLLER)[0]
        except:
            raise exceptions.GetResourceNotFound(resource="controller")

        self.context["controller"] = res["info"]
示例#27
0
 def to_dict(self):
     db_task = self.task
     deployment_name = db.deployment_get(
         self.task["deployment_uuid"])["name"]
     db_task["deployment_name"] = deployment_name
     db_task["duration"] = db_task.get("updated_at") - db_task.get(
         "created_at")
     db_task["created_at"] = db_task.get("created_at",
                                         "").strftime(self.TIME_FORMAT)
     db_task["updated_at"] = db_task.get("updated_at",
                                         "").strftime(self.TIME_FORMAT)
     db_results = self.get_results()
     results = []
     for result in db_results:
         result["created_at"] = result.get("created_at",
                                           "").strftime(self.TIME_FORMAT)
         result["updated_at"] = result.get("updated_at",
                                           "").strftime(self.TIME_FORMAT)
         results.append(result)
     db_task["results"] = results
     return db_task
示例#28
0
    def setup(self):

        multihost_uuid = self.task["deployment_uuid"]
        controller_name = self.config["controller"]

        multihost_info = get_ovn_multihost_info(multihost_uuid, controller_name)
        self.context["ovn_multihost"] = multihost_info

        try:
            controller_dep = db.deployment_get(controller_name)
        except exceptions.DeploymentNotFound:
            raise

        try:
            res = db.resource_get_all(controller_dep["uuid"],
                                        type=ResourceType.CONTROLLER)[0]
        except:
            raise exceptions.GetResourceNotFound(resource="controller")


        self.context["controller"] = res["info"]
示例#29
0
    def use(self, deployment):
        """Set active deployment.

        :param deployment: UUID or name of a deployment
        """
        try:
            deployment = db.deployment_get(deployment)
            print("Using deployment: %s" % deployment["uuid"])
            fileutils.update_globals_file("RALLY_DEPLOYMENT",
                                          deployment["uuid"])
            self._update_openrc_deployment_file(
                deployment["uuid"], deployment.get("admin") or
                deployment.get("users")[0])
            print ("~/.rally/openrc was updated\n\nHINTS:\n"
                   "* To get your cloud resources, run:\n\t"
                   "rally show [flavors|images|keypairs|networks|secgroups]\n"
                   "\n* To use standard OpenStack clients, set up your env by "
                   "running:\n\tsource ~/.rally/openrc\n"
                   "  OpenStack clients are now configured, e.g run:\n\t"
                   "glance image-list")
        except exceptions.DeploymentNotFound:
            print("Deployment %s is not found." % deployment)
            return 1
示例#30
0
    def __init__(self, deployment):
        self.endpoint = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Endpoint(**self.endpoint))
        try:
            self.keystoneclient = self.clients.verified_keystone()
        except exceptions.InvalidAdminException:
            msg = (_("Admin permission is required to generate tempest "
                     "configuration file. User %s doesn't have admin role.") %
                   self.endpoint["username"])
            raise TempestConfigCreationFailure(msg)

        self.available_services = self.clients.services().values()

        self.conf = configparser.ConfigParser()
        self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))
        self.deployment = deployment
        self.data_path = os.path.join(os.path.expanduser("~"), ".rally",
                                      "tempest", "data")
        if not os.path.exists(self.data_path):
            os.makedirs(self.data_path)
        self.img_path = os.path.join(self.data_path,
                                     CONF.image.cirros_image)
        if not os.path.isfile(self.img_path):
            self._load_img()
示例#31
0
文件: config.py 项目: afaheem88/rally
    def __init__(self, deployment):
        self.endpoint = db.deployment_get(deployment)["admin"]
        self.clients = osclients.Clients(objects.Endpoint(**self.endpoint))
        try:
            self.keystoneclient = self.clients.verified_keystone()
        except exceptions.InvalidAdminException:
            msg = (_("Admin permission is required to generate tempest "
                     "configuration file. User %s doesn't have admin role.") %
                   self.endpoint["username"])
            raise TempestConfigCreationFailure(msg)

        self.available_services = self.clients.services().values()

        self.conf = configparser.ConfigParser()
        self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))
        self.deployment = deployment
        self.data_path = os.path.join(os.path.expanduser("~"), ".rally",
                                      "tempest", "data")
        if not os.path.exists(self.data_path):
            os.makedirs(self.data_path)
        self.img_path = os.path.join(self.data_path,
                                     CONF.image.cirros_image)
        if not os.path.isfile(self.img_path):
            self._load_img()
示例#32
0
文件: show.py 项目: Pigueiras/rally
    def _get_endpoints(self, deployment):
        deployment = db.deployment_get(deployment)
        admin = deployment.get("admin")
        endpoints = [admin] if admin else []

        return endpoints + deployment.get("users", [])
示例#33
0
文件: show.py 项目: rvbaz/rally
    def _get_credentials(self, deployment):
        deployment = db.deployment_get(deployment)
        admin = deployment.get("admin")
        credentials = [admin] if admin else []

        return credentials + deployment.get("users", [])
示例#34
0
 def to_dict(self):
     db_task = self.task
     deployment_name = db.deployment_get(
         self.task["deployment_uuid"])["name"]
     db_task["deployment_name"] = deployment_name
     return db_task
示例#35
0
 def get(deploy):
     return Deployment(db.deployment_get(deploy))
示例#36
0
文件: task.py 项目: lihaijing/rally
 def to_dict(self):
     db_task = self.task
     deployment_name = db.deployment_get(self.task.deployment_uuid)["name"]
     db_task["deployment_name"] = deployment_name
     return db_task
示例#37
0
文件: show.py 项目: ePlusPS/gbp-rally
    def _get_endpoints(self, deployment):
        deployment = db.deployment_get(deployment)
        admin = deployment.get("admin")
        endpoints = [admin] if admin else []

        return endpoints + deployment.get("users", [])
示例#38
0
 def get(deploy):
     return Deployment(db.deployment_get(deploy))