Esempio n. 1
0
 def test_print_dict_list_dictionary(self):
     dict = {'k': [{'foo': 'bar'}]}
     utils.print_dict(dict)
     self.assertEqual('+----------+------------------+\n'
                      '| Property | Value            |\n'
                      '+----------+------------------+\n'
                      '| k        | [{"foo": "bar"}] |\n'
                      '+----------+------------------+\n',
                      sys.stdout.getvalue())
Esempio n. 2
0
 def test_print_dict_list(self):
     dict = {'k': ['foo', 'bar']}
     utils.print_dict(dict)
     self.assertEqual('+----------+----------------+\n'
                      '| Property | Value          |\n'
                      '+----------+----------------+\n'
                      '| k        | ["foo", "bar"] |\n'
                      '+----------+----------------+\n',
                      sys.stdout.getvalue())
Esempio n. 3
0
 def test_print_dict(self):
     dict = {'key': 'value'}
     utils.print_dict(dict)
     self.assertEqual('+----------+-------+\n'
                      '| Property | Value |\n'
                      '+----------+-------+\n'
                      '| key      | value |\n'
                      '+----------+-------+\n',
                      sys.stdout.getvalue())
Esempio n. 4
0
def do_image_mapper_create(cs, args):
    """create a new image mapper."""

    raw_properties = args.property
    properties = _property_parsing(raw_properties)

    image_mapper = cs.image_mapper.create(args.image_id, args.dest_image_id,
                                          args.project_id, **properties)
    utils.print_dict(image_mapper._info)
Esempio n. 5
0
def do_flavor_mapper_create(cs, args):
    """create a new flavor mapper."""

    raw_properties = args.property
    properties = _property_parsing(raw_properties)
    print(args)
    flavor_mapper = cs.flavor_mapper.create(args.flavor_id, args.dest_flavor_id,
                                            args.project_id,
                                            **properties)
    utils.print_dict(flavor_mapper._info)
Esempio n. 6
0
 def test_print_large_dict_list(self):
     dict = {'k': ['foo1', 'bar1', 'foo2', 'bar2',
                   'foo3', 'bar3', 'foo4', 'bar4']}
     utils.print_dict(dict, wrap=40)
     self.assertEqual(
         '+----------+------------------------------------------+\n'
         '| Property | Value                                    |\n'
         '+----------+------------------------------------------+\n'
         '| k        | ["foo1", "bar1", "foo2", "bar2", "foo3", |\n'
         '|          | "bar3", "foo4", "bar4"]                  |\n'
         '+----------+------------------------------------------+\n',
         sys.stdout.getvalue())
Esempio n. 7
0
 def test_print_dict_wrap(self):
     dict = {'key1': 'not wrapped',
             'key2': 'this will be wrapped'}
     utils.print_dict(dict, wrap=16)
     self.assertEqual('+----------+--------------+\n'
                      '| Property | Value        |\n'
                      '+----------+--------------+\n'
                      '| key1     | not wrapped  |\n'
                      '| key2     | this will be |\n'
                      '|          | wrapped      |\n'
                      '+----------+--------------+\n',
                      sys.stdout.getvalue())
Esempio n. 8
0
 def test_print_unicode_dict(self):
     dict = {'k': u'\u2026'}
     utils.print_dict(dict)
     if six.PY3:
         s = u'\u2026'
     else:
         s = encodeutils.safe_encode(u'\u2026')
     self.assertEqual('+----------+-------+\n'
                      '| Property | Value |\n'
                      '+----------+-------+\n'
                      '| k        | %s     |\n'
                      '+----------+-------+\n' % s,
                      sys.stdout.getvalue())
Esempio n. 9
0
def do_project_mapper_update(cs, args):
    """create a new project mapper."""

    set_properties = args.set
    set_properties = _property_parsing(set_properties)

    unset_properties = args.unset
    unset_properties = _extract_keys(unset_properties)

    project_mapper = cs.project_mapper.update(args.project_id,
                                              args.dest_project_id,
                                              set_properties=set_properties,
                                              unset_properties=unset_properties)
    utils.print_dict(project_mapper._info)
Esempio n. 10
0
def do_instance_mapper_show(cs, args):
    """show instance mapper"""

    instance_mapper = cs.instance_mapper.get(args.instance_id)

    utils.print_dict(instance_mapper._info)
Esempio n. 11
0
def do_project_mapper_show(cs, args):
    """show project mapper"""

    project_mapper = cs.project_mapper.get(args.project_id)

    utils.print_dict(project_mapper._info)
Esempio n. 12
0
def do_flavor_mapper_show(cs, args):
    """show flavor mapper"""

    flavor_mapper = cs.flavor_mapper.get(args.flavor_id)

    utils.print_dict(flavor_mapper._info)
Esempio n. 13
0
def do_image_mapper_show(cs, args):
    """show image mapper"""

    image_mapper = cs.image_mapper.get(args.image_id)

    utils.print_dict(image_mapper._info)