Example #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(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'})
Example #2
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'})
Example #3
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"})
Example #4
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"})
Example #5
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'})
Example #6
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'})
Example #7
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"})
Example #8
0
    def check(self, deployment=None):
        """Check keystone authentication and list all available services.

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

        headers = ["services", "type", "status"]
        table_rows = []
        try:
            admin = db.deployment_get(deployment)["admin"]
            # TODO(boris-42): make this work for users in future
            for endpoint_dict in [admin]:
                clients = osclients.Clients(objects.Endpoint(**endpoint_dict))
                client = clients.verified_keystone()
                print("keystone endpoints are valid and following "
                      "services are available:")
                for service in client.services.list():
                    data = [service.name, service.type, "Available"]
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))
        except exceptions.InvalidArgumentsException:
            data = ["keystone", "identity", "Error"]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
            print(_("Authentication Issues: %s.")
                  % sys.exc_info()[1])
            return(1)
        cliutils.print_list(table_rows, headers)
Example #9
0
    def check(self, deployment=None):
        """Check keystone authentication and list all available services.

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

        headers = ["services", "type", "status"]
        table_rows = []
        try:
            admin = db.deployment_get(deployment)["admin"]
            # TODO(boris-42): make this work for users in future
            for endpoint_dict in [admin]:
                clients = osclients.Clients(objects.Endpoint(**endpoint_dict))
                client = clients.verified_keystone()
                print("keystone endpoints are valid and following "
                      "services are available:")
                for service in client.services.list():
                    data = [service.name, service.type, "Available"]
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))
        except exceptions.InvalidArgumentsException:
            data = ["keystone", "identity", "Error"]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
            print(_("Authentication Issues: %s.") % sys.exc_info()[1])
            return (1)
        cliutils.print_list(table_rows, headers)
Example #10
0
    def check(self, deploy_id=None):
        """Check the deployment.

        Check keystone authentication and list all available services.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['services', 'type', 'status']
        table = prettytable.PrettyTable(headers)
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                client = clients.verified_keystone()
                print("keystone endpoints are valid and following "
                      "services are available:")
                for service in client.service_catalog.get_data():
                    table.add_row([service['name'], service['type'],
                                   'Available'])
        except exceptions.InvalidArgumentsException:
            table.add_row(['keystone', 'identity', 'Error'])
            print(_("Authentication Issues: %s.")
                  % sys.exc_info()[1])
            return(1)
        print(table)
Example #11
0
    def config(self, deploy_id=None):
        """Print on stdout a config of the deployment in JSON format.

        :param deploy_id: a UUID of the deployment
        """
        deploy = db.deployment_get(deploy_id)
        print(json.dumps(deploy['config']))
Example #12
0
    def flavors(self, deploy_id=None):
        """Show the flavors that are available in a deployment.

        :param deploy_id: the UUID of a deployment
        """
        headers = ['ID', 'Name', 'vCPUs', 'RAM (MB)', 'Swap (MB)', 'Disk (GB)']
        mixed_case_fields = ['ID', 'Name', 'vCPUs']
        float_cols = ['RAM (MB)', 'Swap (MB)', 'Disk (GB)']
        formatters = dict(zip(float_cols,
                              [cliutils.pretty_float_formatter(col)
                               for col in float_cols]))
        table_rows = []
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                nova_client = clients.nova()
                for flavor in nova_client.flavors.list():
                    data = [flavor.id, flavor.name, flavor.vcpus,
                            flavor.ram, flavor.swap, flavor.disk]
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))

        except exceptions.InvalidArgumentsException:
            print(_("Authentication Issues: %s") % sys.exc_info()[1])
            return(1)
        common_cliutils.print_list(table_rows,
                                   fields=headers,
                                   formatters=formatters,
                                   mixed_case_fields=mixed_case_fields)
Example #13
0
    def images(self, deploy_id=None):
        """Show the images that are available in a deployment.

        :param deploy_id: the UUID of a deployment
        """
        headers = ['UUID', 'Name', 'Size (B)']
        mixed_case_fields = ['UUID', 'Name']
        float_cols = ["Size (B)"]
        table_rows = []
        formatters = dict(zip(float_cols,
                              [cliutils.pretty_float_formatter(col)
                               for col in float_cols]))
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                glance_client = clients.glance()
                for image in glance_client.images.list():
                    data = [image.id, image.name, image.size]
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))

        except exceptions.InvalidArgumentsException:
            print(_("Authentication Issues: %s") % sys.exc_info()[1])
            return(1)
        common_cliutils.print_list(table_rows,
                                   fields=headers,
                                   formatters=formatters,
                                   mixed_case_fields=mixed_case_fields)
Example #14
0
    def images(self, deploy_id=None):
        """Show the images that are available in a deployment.

        :param deploy_id: the UUID of a deployment
        """
        headers = ['UUID', 'Name', 'Size (B)']
        mixed_case_fields = ['UUID', 'Name']
        float_cols = ["Size (B)"]
        table_rows = []
        formatters = dict(
            zip(float_cols,
                [cliutils.pretty_float_formatter(col) for col in float_cols]))
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                glance_client = clients.glance()
                for image in glance_client.images.list():
                    data = [image.id, image.name, image.size]
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))

        except exceptions.InvalidArgumentsException:
            print(_("Authentication Issues: %s") % sys.exc_info()[1])
            return (1)
        common_cliutils.print_list(table_rows,
                                   fields=headers,
                                   formatters=formatters,
                                   mixed_case_fields=mixed_case_fields)
Example #15
0
    def check(self, deploy_id=None):
        """Check the deployment.

        Check keystone authentication and list all available services.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['services', 'type', 'status']
        table_rows = []
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                client = clients.verified_keystone()
                print("keystone endpoints are valid and following "
                      "services are available:")
                for service in client.services.list():
                    data = [service.name, service.type, 'Available']
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))
        except exceptions.InvalidArgumentsException:
            data = ['keystone', 'identity', 'Error']
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
            print(_("Authentication Issues: %s.")
                  % sys.exc_info()[1])
            return(1)
        common_cliutils.print_list(table_rows, headers)
Example #16
0
    def config(self, deploy_id=None):
        """Print on stdout a config of the deployment in JSON format.

        :param deploy_id: a UUID of the deployment
        """
        deploy = db.deployment_get(deploy_id)
        print(json.dumps(deploy['config']))
Example #17
0
    def flavors(self, deploy_id=None):
        """Show the flavors that are available in a deployment.

        :param deploy_id: the UUID of a deployment
        """
        headers = ['ID', 'Name', 'vCPUs', 'RAM (MB)', 'Swap (MB)', 'Disk (GB)']
        mixed_case_fields = ['ID', 'Name', 'vCPUs']
        float_cols = ['RAM (MB)', 'Swap (MB)', 'Disk (GB)']
        formatters = dict(
            zip(float_cols,
                [cliutils.pretty_float_formatter(col) for col in float_cols]))
        table_rows = []
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                nova_client = clients.nova()
                for flavor in nova_client.flavors.list():
                    data = [
                        flavor.id, flavor.name, flavor.vcpus, flavor.ram,
                        flavor.swap, flavor.disk
                    ]
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))

        except exceptions.InvalidArgumentsException:
            print(_("Authentication Issues: %s") % sys.exc_info()[1])
            return (1)
        common_cliutils.print_list(table_rows,
                                   fields=headers,
                                   formatters=formatters,
                                   mixed_case_fields=mixed_case_fields)
Example #18
0
    def check(self, deploy_id=None):
        """Check the deployment.

        Check keystone authentication and list all available services.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['services', 'type', 'status']
        table = prettytable.PrettyTable(headers)
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                client = clients.verified_keystone()
                print("keystone endpoints are valid and following "
                      "services are available:")
                for service in client.service_catalog.get_data():
                    table.add_row([service['name'], service['type'],
                                   'Available'])
        except exceptions.InvalidArgumentsException:
            table.add_row(['keystone', 'identity', 'Error'])
            print(_("Authentication Issues: %s.")
                  % sys.exc_info()[1])
            return(1)
        print(table)
Example #19
0
def verify(deploy_id, image_id, alt_image_id, flavor_id, alt_flavor_id,
           set_name, regex):
    """Start verifying.

    :param deploy_id: a UUID of a deployment.
    :param image_id: Valid primary image reference to be used in tests.
    :param alt_image_id: Valid secondary image reference to be used in tests.
    :param flavor_id: Valid primary flavor to use in tests.
    :param alt_flavor_id: Valid secondary flavor to be used in tests.
    :param set_name: Valid name of tempest test set.
    """
    verifier = tempest.Tempest()
    if not verifier.is_installed():
        print("Tempest is not installed. "
              "Please use 'rally-manage tempest install'")
        return
    print("Starting verification of deployment: %s" % deploy_id)

    endpoints = db.deployment_get(deploy_id)['endpoints']
    endpoint = endpoints[0]
    verifier.verify(image_ref=image_id,
                    image_ref_alt=alt_image_id,
                    flavor_ref=flavor_id,
                    flavor_ref_alt=alt_flavor_id,
                    username=endpoint['username'],
                    password=endpoint['password'],
                    tenant_name=endpoint['tenant_name'],
                    uri=endpoint['auth_url'],
                    uri_v3=re.sub('/v2.0', '/v3', endpoint['auth_url']),
                    set_name=set_name,
                    regex=regex)
Example #20
0
    def check(self, deploy_id=None):
        """Check the deployment.

        Check keystone authentication and list all available services.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['services', 'type', 'status']
        table_rows = []
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                client = clients.verified_keystone()
                print("keystone endpoints are valid and following "
                      "services are available:")
                for service in client.service_catalog.get_data():
                    data = [service['name'], service['type'], 'Available']
                    table_rows.append(utils.Struct(**dict(zip(headers, data))))
        except exceptions.InvalidArgumentsException:
            data = ['keystone', 'identity', 'Error']
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
            print(_("Authentication Issues: %s.")
                  % sys.exc_info()[1])
            return(1)
        common_cliutils.print_list(table_rows, headers)
Example #21
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'})
Example #22
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"})
Example #23
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'})
Example #24
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))
Example #25
0
    def endpoint(self, deploy_id=None):
        """Print endpoint of the deployment.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['auth_url', 'username', 'password', 'tenant_name']
        table = prettytable.PrettyTable(headers)
        endpoints = db.deployment_get(deploy_id)['endpoints']
        for ep in endpoints:
            table.add_row([ep.get(m, '') for m in headers])
        print(table)
Example #26
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))
Example #27
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"})
Example #28
0
    def endpoint(self, deploy_id=None):
        """Print endpoint of the deployment.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['auth_url', 'username', 'password', 'tenant_name',
                   'region_name']
        table = prettytable.PrettyTable(headers)
        endpoints = db.deployment_get(deploy_id)['endpoints']
        for ep in endpoints:
            table.add_row([ep.get(m, '') for m in headers])
        print(table)
Example #29
0
 def endpoint(self, deploy_id=None):
     """Print endpoint of the deployment.
     :param deploy_id: a UUID of the deployment
     """
     headers = ['auth_url', 'username', 'password', 'tenant_name',
                'region_name', 'use_public_urls', 'admin_port']
     table_rows = []
     endpoints = db.deployment_get(deploy_id)['endpoints']
     for ep in endpoints:
         data = [ep.get(m, '') for m in headers]
         table_rows.append(utils.Struct(**dict(zip(headers, data))))
     common_cliutils.print_list(table_rows, headers)
Example #30
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"})
Example #31
0
    def start(self, deploy_id=None, set_name='smoke', regex=None):
        """Start running tempest tests against a live cloud cluster.

        :param deploy_id: a UUID of a deployment
        :param set_name: Name of tempest test set
        :param regex: Regular expression of test
        """
        if regex:
            set_name = 'full'
        if set_name not in TEMPEST_TEST_SETS:
            print('Sorry, but there are no desired tempest test set. '
                  'Please choose from: %s' % ', '.join(TEMPEST_TEST_SETS))
            return(1)

        endpoints = db.deployment_get(deploy_id)['endpoints']
        endpoint_dict = endpoints[0]
        clients = osclients.Clients(objects.Endpoint(**endpoint_dict))
        glance = clients.glance()

        image_list = []
        for image in glance.images.list():
            if 'cirros' in image.name:
                image_list.append(image)

        #TODO(miarmak): Add ability to upload new images if there are no
        #necessary images in the cloud (cirros)

        try:
            image_id = image_list[0].id
            alt_image_id = image_list[1].id
        except IndexError:
            print('Sorry, but there are no desired images or only one')
            return(1)

        nova = clients.nova()
        flavor_list = []
        for fl in sorted(nova.flavors.list(), key=lambda flavor: flavor.ram):
            flavor_list.append(fl)

        #TODO(miarmak): Add ability to create new flavors if they are missing

        try:
            flavor_id = flavor_list[0].id
            alt_flavor_id = flavor_list[1].id
        except IndexError:
            print('Sorry, but there are no desired flavors or only one')
            return(1)

        #TODO(miarmak): Add getting network and router id's from neutronclient

        api.verify(deploy_id, image_id, alt_image_id, flavor_id, alt_flavor_id,
                   set_name, regex)
Example #32
0
File: show.py Project: Ch00k/rally
 def keypairs(self, deploy_id=None):
     headers = ['Name', 'Fingerprint']
     table = prettytable.PrettyTable(headers)
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
             nova_client = clients.nova()
             for keypair in nova_client.keypairs.list():
                 table.add_row([keypair.name, keypair.fingerprint])
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
     print(table)
Example #33
0
    def endpoint(self, deploy_id=None):
        """Print endpoint of the deployment.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['auth_url', 'username', 'password', 'tenant_name',
                   'region_name', 'use_public_urls', 'admin_port']
        table_rows = []
        endpoints = db.deployment_get(deploy_id)['endpoints']
        for ep in endpoints:
            data = [ep.get(m, '') for m in headers]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
        common_cliutils.print_list(table_rows, headers)
Example #34
0
File: show.py Project: Ch00k/rally
 def networks(self, deploy_id=None):
     headers = ['ID', 'Label', 'CIDR']
     table = prettytable.PrettyTable(headers)
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
         nova_client = clients.nova()
         for network in nova_client.networks.list():
             table.add_row([network.id, network.label, network.cidr])
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
     print(table)
Example #35
0
 def secgroups(self, deploy_id=None):
     headers = ["ID", "Name", "Description"]
     table = prettytable.PrettyTable(headers)
     try:
         endpoints = db.deployment_get(deploy_id)["endpoints"]
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
             nova_client = clients.nova()
             for secgroup in nova_client.security_groups.list():
                 table.add_row([secgroup.id, secgroup.name, secgroup.description])
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
         return 1
     print(table)
Example #36
0
 def endpoint(self, deploy_id):
     """Print endpoint of the deployment."""
     attribute_map = [
         ('auth_url', 'uri'),
         ('user_name', 'admin_username'),
         ('password', 'admin_password'),
         ('tenant_name', 'admin_tenant_name'),
     ]
     headers = [m[0] for m in attribute_map]
     table = prettytable.PrettyTable(headers)
     endpoint = db.deployment_get(deploy_id)['endpoint']
     identity = endpoint.get('identity', {})
     table.add_row([identity.get(m[1], '') for m in attribute_map])
     print(table)
Example #37
0
File: show.py Project: Ch00k/rally
    def images(self, deploy_id=None):
        """Show the images that are available in a deployment.

        :param deploy_id: the UUID of a deployment
        """
        headers = ['UUID', 'Name', 'Size (B)']
        table = prettytable.PrettyTable(headers)
        try:
            endpoints = db.deployment_get(deploy_id)['endpoints']
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                glance_client = clients.glance()
                for image in glance_client.images.list():
                    table.add_row([image.id, image.name, image.size])
        except exceptions.InvalidArgumentsException:
            print(_("Authentication Issues: %s") % sys.exc_info()[1])
        print(table)
Example #38
0
 def keypairs(self, deploy_id=None):
     headers = ['Name', 'Fingerprint']
     mixed_case_fields = ['Name', 'Fingerprint']
     table_rows = []
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
             nova_client = clients.nova()
             for keypair in nova_client.keypairs.list():
                 data = [keypair.name, keypair.fingerprint]
                 table_rows.append(utils.Struct(**dict(zip(headers, data))))
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
         return(1)
     common_cliutils.print_list(table_rows,
                                fields=headers,
                                mixed_case_fields=mixed_case_fields)
Example #39
0
 def networks(self, deploy_id=None):
     headers = ['ID', 'Label', 'CIDR']
     mixed_case_fields = ['ID', 'Label', 'CIDR']
     table_rows = []
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
         nova_client = clients.nova()
         for network in nova_client.networks.list():
             data = [network.id, network.label, network.cidr]
             table_rows.append(utils.Struct(**dict(zip(headers, data))))
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
         return (1)
     common_cliutils.print_list(table_rows,
                                fields=headers,
                                mixed_case_fields=mixed_case_fields)
Example #40
0
 def secgroups(self, deploy_id=None):
     headers = ['ID', 'Name', 'Description']
     mixed_case_fields = ['ID', 'Name', 'Description']
     table_rows = []
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
             nova_client = clients.nova()
             for secgroup in nova_client.security_groups.list():
                 data = [secgroup.id, secgroup.name, secgroup.description]
                 table_rows.append(utils.Struct(**dict(zip(headers, data))))
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
         return (1)
     common_cliutils.print_list(table_rows,
                                fields=headers,
                                mixed_case_fields=mixed_case_fields)
Example #41
0
 def keypairs(self, deploy_id=None):
     headers = ['Name', 'Fingerprint']
     mixed_case_fields = ['Name', 'Fingerprint']
     table_rows = []
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
             nova_client = clients.nova()
             for keypair in nova_client.keypairs.list():
                 data = [keypair.name, keypair.fingerprint]
                 table_rows.append(utils.Struct(**dict(zip(headers, data))))
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
         return (1)
     common_cliutils.print_list(table_rows,
                                fields=headers,
                                mixed_case_fields=mixed_case_fields)
Example #42
0
    def endpoint(self, deploy_id=None):
        """Print all endpoints of the deployment.

        :param deploy_id: a UUID of the deployment
        """
        headers = ['auth_url', 'username', 'password', 'tenant_name',
                   'region_name', 'endpoint_type', 'admin_port']
        table_rows = []

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

        for ep in endpoints:
            data = [ep.get(m, '') for m in headers]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
        common_cliutils.print_list(table_rows, headers)
Example #43
0
 def networks(self, deploy_id=None):
     headers = ['ID', 'Label', 'CIDR']
     mixed_case_fields = ['ID', 'Label', 'CIDR']
     table_rows = []
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
         nova_client = clients.nova()
         for network in nova_client.networks.list():
             data = [network.id, network.label, network.cidr]
             table_rows.append(utils.Struct(**dict(zip(headers, data))))
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
         return(1)
     common_cliutils.print_list(table_rows,
                                fields=headers,
                                mixed_case_fields=mixed_case_fields)
Example #44
0
    def flavors(self, deploy_id=None):
        """Show the flavors that are available in a deployment.

        :param deploy_id: the UUID of a deployment
        """
        headers = ["ID", "Name", "vCPUs", "RAM (MB)", "Swap (MB)", "Disk (GB)"]
        table = prettytable.PrettyTable(headers)
        try:
            endpoints = db.deployment_get(deploy_id)["endpoints"]
            for endpoint_dict in endpoints:
                clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
                nova_client = clients.nova()
                for flavor in nova_client.flavors.list():
                    table.add_row([flavor.id, flavor.name, flavor.vcpus, flavor.ram, flavor.swap, flavor.disk])
        except exceptions.InvalidArgumentsException:
            print(_("Authentication Issues: %s") % sys.exc_info()[1])
            return 1
        print(table)
Example #45
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 = [ep.get(m, "") for m in headers]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
        cliutils.print_list(table_rows, headers)
Example #46
0
    def deployment(self, deploy_id=None, name=None):
        """Set active deployment.

        :param deploy_id: a UUID of a deployment
        """

        if not (name or deploy_id):
            print('You should specify --name or --uuid of deployment')
            return 1

        deploy = None

        if name:
            deployments = db.deployment_list(name=name)
            if len(deployments) > 1:
                print("Multiple deployments found by name: `%s`" % name)
                return 1
            elif not deployments:
                print("There is no `%s` deployment" % name)
                return 1
            else:
                deploy = deployments[0]
                deploy_id = deploy["uuid"]

        try:
            deploy = deploy or db.deployment_get(deploy_id)
            print('Using deployment: %s' % deploy_id)
            self._ensure_rally_configuration_dir_exists()
            self._update_attribute_in_global_file('RALLY_DEPLOYMENT',
                                                  deploy_id)
            self._update_openrc_deployment_file(
                deploy_id,
                deploy.get('admin') or deploy.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.' % deploy_id)
            return 1
Example #47
0
    def deployment(self, deploy_id=None, name=None):
        """Set active deployment.

        :param deploy_id: a UUID of a deployment
        """

        if not (name or deploy_id):
            print('You should specify --name or --uuid of deployment')
            return 1

        deploy = None

        if name:
            deployments = db.deployment_list(name=name)
            if len(deployments) > 1:
                print("Multiple deployments found by name: `%s`" % name)
                return 1
            elif not deployments:
                print("There is no `%s` deployment" % name)
                return 1
            else:
                deploy = deployments[0]
                deploy_id = deploy["uuid"]

        try:
            deploy = deploy or db.deployment_get(deploy_id)
            print('Using deployment: %s' % deploy_id)
            self._ensure_rally_configuration_dir_exists()
            self._update_attribute_in_global_file('RALLY_DEPLOYMENT',
                                                  deploy_id)
            self._update_openrc_deployment_file(
                deploy_id, deploy.get('admin') or deploy.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.' % deploy_id)
            return 1
Example #48
0
 def secgroups(self, deploy_id=None):
     headers = ['ID', 'Name', 'Description']
     mixed_case_fields = ['ID', 'Name', 'Description']
     table_rows = []
     try:
         endpoints = db.deployment_get(deploy_id)['endpoints']
         for endpoint_dict in endpoints:
             clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
             nova_client = clients.nova()
             for secgroup in nova_client.security_groups.list():
                 data = [secgroup.id, secgroup.name,
                         secgroup.description]
                 table_rows.append(utils.Struct(**dict(zip(headers,
                                                           data))))
     except exceptions.InvalidArgumentsException:
         print(_("Authentication Issues: %s") % sys.exc_info()[1])
         return(1)
     common_cliutils.print_list(table_rows,
                                fields=headers,
                                mixed_case_fields=mixed_case_fields)
Example #49
0
    def config(self, deploy_id=None, output_json=None, output_pprint=None):
        """Print on stdout a config of the deployment.

            Output can JSON or Pretty print format.

        :param deploy_id: a UUID of the deployment
        :param output_json: Output in json format (Default)
        :param output_pprint: Output in pretty print format
        """
        deploy = db.deployment_get(deploy_id)
        result = deploy['config']
        if all([output_json, output_pprint]):
            print(_('Please select only one output format'))
            return 1
        elif output_pprint:
            print()
            pprint.pprint(result)
            print()
        else:
            print(json.dumps(result))
Example #50
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 = [ep.get(m, "") for m in headers]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
        cliutils.print_list(table_rows, headers)
Example #51
0
    def show(self, deploy_id=None):
        """Show the endpoints of the deployment.

        :param deploy_id: a UUID of the deployment
        """

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

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

        for ep in endpoints:
            data = [ep.get(m, '') for m in headers]
            table_rows.append(utils.Struct(**dict(zip(headers, data))))
        common_cliutils.print_list(table_rows, headers)
Example #52
0
    def use(self, deployment):
        """Set active deployment. Alias for "rally use 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
Example #53
0
 def __init__(self, deploy_id):
     self.endpoint = db.deployment_get(deploy_id)['endpoints'][0]
     self.clients = osclients.Clients(endpoint.Endpoint(**self.endpoint))
     try:
         self.keystoneclient = self.clients.verified_keystone()
     except exceptions.InvalidAdminException:
         msg = _('Admin permission is required to run tempest. User %s '
                 'doesn\'t have admin role') % self.endpoint['username']
         raise exceptions.TempestConfigCreationFailure(message=msg)
     self.available_services = [
         service['name']
         for service in self.keystoneclient.service_catalog.get_data()
     ]
     self.conf = configparser.ConfigParser()
     self.conf.read(os.path.join(os.path.dirname(__file__), 'config.ini'))
     self.deploy_id = deploy_id
     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()
Example #54
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()
Example #55
0
 def get(deploy):
     return Deployment(db.deployment_get(deploy))
Example #56
0
 def get(uuid):
     return Deployment(db.deployment_get(uuid))
Example #57
0
    def _get_endpoints(self, deployment):
        deployment = db.deployment_get(deployment)
        admin = deployment.get("admin")
        endpoints = [admin] if admin else []

        return endpoints + deployment.get("users", [])
Example #58
0
    def _get_endpoints(self, deploy_id):
        deployment = db.deployment_get(deploy_id)
        admin = deployment.get("admin")
        admin = [admin] if admin else []

        return admin + deployment.get("users", [])
Example #59
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