コード例 #1
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    
    execute_csv2_request(
        gvar, 2, None, 'server "unit-test", HTTP response code 401, unauthorized.',
        '/cloud/status/',
        server_user='******', server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV33', 'user "{}" is not a member of any group.'.format(ut_id(gvar, 'ctu1')),
        '/cloud/status/',
        server_user=ut_id(gvar, 'ctu1'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV33', 'user "{}" is not a member of any group.'.format(ut_id(gvar, 'ctu2')),
        '/cloud/status/',
        server_user=ut_id(gvar, 'ctu2'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV33', 'cannot switch to invalid group "invalid-unit-test".',
        '/cloud/status/', form_data={'group': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV33', 'cannot switch to invalid group "{}".'.format(ut_id(gvar, 'ctg2')),
        '/cloud/status/', form_data={'group': ut_id(gvar, 'ctg2')},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/status/',
        list='cloud_status_list', filter={'cloud_name': ut_id(gvar, 'ctc2')},
        values={
            'group_name': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'ctc2'),
            'ram_ctl': -1,
            'default_flavor': None,
            'keep_alive': 0,
            'default_image': None,
            'enabled': 1,
            'cores_ctl': -1,
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )
コード例 #2
0
def main(gvar):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    
    execute_csv2_request(
        gvar, None, None, None,
        '/group/delete/', form_data={'group_name': 'vm-test-group'}
    )
コード例 #3
0
def main(gvar):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         None,
                         None,
                         None,
                         '/user/delete/',
                         form_data={'username': ut_id(gvar, 'jtu1')})

    execute_csv2_request(gvar,
                         None,
                         None,
                         None,
                         '/user/delete/',
                         form_data={'username': ut_id(gvar, 'jtu2')})

    execute_csv2_request(gvar,
                         None,
                         None,
                         None,
                         '/user/delete/',
                         form_data={'username': ut_id(gvar, 'jtu3')})

    execute_csv2_request(gvar,
                         None,
                         None,
                         None,
                         '/user/delete/',
                         form_data={'username': ut_id(gvar, 'jtu4')})

    execute_csv2_request(gvar,
                         None,
                         None,
                         None,
                         '/group/delete/',
                         form_data={'group_name': ut_id(gvar, 'jtg1')})

    execute_csv2_request(gvar,
                         None,
                         None,
                         None,
                         '/group/delete/',
                         form_data={'group_name': ut_id(gvar, 'jtg2')})
コード例 #4
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/group/list/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/group/list/',
                         server_user=ut_id(gvar, 'gtu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'gtu2')),
                         '/group/list/',
                         server_user=ut_id(gvar, 'gtu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/group/list/',
                         form_data={'group': 'invalid-unit-test'})

    execute_csv2_request(
        gvar,
        1,
        'GV23',
        'request contained a bad parameter "invalid-unit-test".',
        '/group/list/',
        form_data={'invalid-unit-test': 'invalid-unit-test'})

    execute_csv2_request(gvar, 0, None, None, '/group/list/')
コード例 #5
0
ファイル: test_db_job.py プロジェクト: hep-gc/cloudscheduler
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/job/list/',
                         form_data={'group': 'vm-test-group'},
                         list='job_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'global_job_id': 'csv2-dev2.heprc.uvic.ca#1.0#1'
                         },
                         values={
                             'hold_job_reason': None,
                             'request_ram': 2000,
                             'js_idle': 0,
                             'held_reason': 'vm-testing',
                             'instance_type': 'vm-test-instance',
                             'request_disk': '14.3051',
                             'js_held': 1,
                             'request_cpus': 1,
                             'keep_alive': '0',
                             'js_completed': 0,
                             'js_running': 0,
                             'js_other': 0,
                             'job_status': 5,
                             'user': '******',
                             'requirements': 'group_name is "vm-test-group"',
                             'cloud_name': None,
                             'proc_id': 0,
                             'target_clouds': None,
                             'job_priority': 10,
                             'cluster_id': 1
                         })

    execute_csv2_command(gvar, 0, None, 'Rows: 1', [
        'cloudscheduler', 'job', 'list', '-g', 'vm-test-group', '-s',
        'unit-test'
    ])
コード例 #6
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "vm-test-group" successfully added.',
                         '/group/add/',
                         form_data={
                             'group_name': 'vm-test-group',
                             'condor_central_manager': 'vm-test-group-one.ca',
                             'username': ut_id(gvar, '')[:-1]
                         })

    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud "vm-test-group::vm-test-cloud" successfully added.',
        '/cloud/add/',
        form_data={
            'group': 'vm-test-group',
            'cloud_name': 'vm-test-cloud',
            'authurl': 'vm-test-cloud.ca',
            'project': 'vm-test-cloud',
            'username': '******',
            'password': '******',
            'region': 'vm-test-cloud',
            'cloud_type': 'local'
        })
コード例 #7
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(
        gvar, 2, None, 'HTTP response code 401, unauthorized.',
        '/vm/update/',
        server_user='******', server_pw='invalid-unit-test'
    )

    execute_csv2_request(
        gvar, 1, None, 'user "{}" is not a member of any group.'.format(ut_id(gvar, 'vtu1')),
        '/vm/update/',
        server_user=ut_id(gvar, 'vtu1'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, None, 'user "{}" is not a member of any group.'.format(ut_id(gvar, 'vtu2')),
        '/vm/update/',
        server_user=ut_id(gvar, 'vtu2'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'VV05', 'invalid method "GET" specified.',
        '/vm/update/',
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'VV02', 'vm update request contained a bad parameter "invalid-unit-test".',
        '/vm/update/', form_data={'invalid-unit-test': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".',
        '/vm/update/', form_data={'group': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'VV02', 'vm update request did not contain mandatory parameter "vm_option".',
        '/vm/update/', form_data={'group': ut_id(gvar, 'vtg1')},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, None, 'cannot switch to invalid group "{}".'.format(ut_id(gvar, 'vtg2')),
        '/vm/update/', form_data={'group': ut_id(gvar, 'vtg2')},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'VV02', "vm update value specified for \"vm_option\" must be one of the following options: ['kill', 'manctl', 'retire', 'sysctl'].",
        '/vm/update/', form_data={'group': ut_id(gvar, 'vtg1'), 'vm_option': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, "vm update, VMs set to system control: 0.",
        '/vm/update/', form_data={'vm_option': 'sysctl'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, "vm update, VMs killed: 0.",
        '/vm/update/', form_data={'vm_option': 'kill'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, "vm update, VMs set to manual control: 0.",
        '/vm/update/', form_data={'vm_option': 'manctl'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, "vm update, VMs retired: 0.",
        '/vm/update/', form_data={'vm_option': 'retire'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'VV02', "vm update value specified for \"poller_status\" must be one of the following options: ['error', 'manual', 'native', 'other', 'retiring', 'running', 'unregistered'].",
        '/vm/update/', form_data={'vm_option': 'sysctl', 'poller_status': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, "vm update, VMs set to system control: 0.",
        '/vm/update/', form_data={'vm_option': 'sysctl', 'poller_status': 'error'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, "vm update, VMs set to system control: 0.",
        '/vm/update/', form_data={'vm_option': 'sysctl', 'cloud_name': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, "vm update, VMs set to system control: 0.",
        '/vm/update/', form_data={'vm_option': 'sysctl', 'hostname': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'vtu3'), server_pw=user_secret
    )
コード例 #8
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        [
            'cloudscheduler', 'cloud', 'metadata-collation', '-xx', 'yy', '-s',
            'unit-test-un'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: metadata-mime-type',
        [
            'cloudscheduler', 'cloud', 'metadata-collation', '-mmt',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        [
            'cloudscheduler', 'cloud', 'metadata-collation', '-s',
            'invalid-unit-test'
        ])

    execute_csv2_command(gvar, 0, None, None, [
        'cloudscheduler', 'cloud', 'metadata-collation', '-s', 'unit-test-un'
    ])

    execute_csv2_command(
        gvar, 0, None,
        'Help requested for "cloudscheduler cloud metadata-collation".',
        ['cloudscheduler', 'cloud', 'metadata-collation', '-h'])

    execute_csv2_command(
        gvar, 0, None, 'General Commands Manual',
        ['cloudscheduler', 'cloud', 'metadata-collation', '-H'])

    execute_csv2_command(
        gvar, 0, None, 'Expose API requested',
        ['cloudscheduler', 'cloud', 'metadata-collation', '-xA'])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".', [
            'cloudscheduler', 'cloud', 'metadata-collation', '-g',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test-un, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, 'test'), ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'cloud', 'metadata-collation', '-g',
                ut_id(gvar, 'clg1')
            ])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, '')[:-1], ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'cloud', 'metadata-collation', '-s',
                'unit-test', '-g',
                ut_id(gvar, 'clg1')
            ])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test-un, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, 'test'), ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'cloud', 'metadata-collation', '-s',
                'unit-test-un'
            ])

    execute_csv2_command(gvar, 0, None, 'Rows: 0', [
        'cloudscheduler', 'cloud', 'metadata-collation', '-cn',
        'invalid-unit-test'
    ])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'cloud', 'metadata-collation', '-ok'],
        list='Clouds/Metadata Collation',
        columns=['Group', 'Cloud', 'Metadata Filename'])

    execute_csv2_command(
        gvar, 0, None,
        'cloud metadata-collation, table #1 columns: keys=group_name,cloud_name,metadata_name, columns=priority,type',
        ['cloudscheduler', 'cloud', 'metadata-collation', '-VC'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'cloud', 'metadata-collation', '-NV'],
        list='Clouds/Metadata Collation',
        columns=['Group', 'Cloud', 'Metadata Filename', 'Priority', 'Type'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'cloud', 'metadata-collation', '-V', 'type'],
        list='Clouds/Metadata Collation',
        columns=['Group', 'Cloud', 'Metadata Filename', 'Type'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'cloud', 'metadata-collation'],
        list='Clouds/Metadata Collation',
        columns=['Group', 'Cloud', 'Metadata Filename', 'Type'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'cloud', 'metadata-collation', '-V', ''],
        list='Clouds/Metadata Collation',
        columns=['Group', 'Cloud', 'Metadata Filename', 'Priority', 'Type'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'cloud', 'metadata-collation', '-r'],
        list='Clouds/Metadata Collation',
        columns=['Key', 'Value'])
コード例 #9
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/cloud/metadata-add/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu1')),
                         '/cloud/metadata-add/',
                         server_user=ut_id(gvar, 'ctu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu2')),
                         '/cloud/metadata-add/',
                         server_user=ut_id(gvar, 'ctu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV16',
                         'cloud metadata_add, invalid method "GET" specified.',
                         '/cloud/metadata-add/',
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/cloud/metadata-add/',
                         form_data={'group': 'invalid-unit-test'},
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'ctg2')),
                         '/cloud/metadata-add/',
                         form_data={'group': ut_id(gvar, 'ctg2')},
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'cloud metadata-add request did not contain mandatory parameter "cloud_name".',
        '/cloud/metadata-add/',
        form_data={'group': ut_id(gvar, 'ctg1')},
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'cloud metadata-add request did not contain mandatory parameter "cloud_name".',
        '/cloud/metadata-add/',
        form_data={'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test')},
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'cloud metadata-add request did not contain mandatory parameter "metadata_name".',
        '/cloud/metadata-add/',
        form_data={'cloud_name': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'cloud metadata-add request contained a bad parameter "invalid-unit-test".',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test',
            'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test'),
            'invalid-unit-test': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'Invalid-unit-test',
            'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test-',
            'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test!',
            'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'value specified for "metadata_name" must be all lower case.',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test',
            'metadata_name': 'Invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'boolean value specified for "enabled" must be one of the following: true, false, yes, no, 1, or 0.',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test',
            'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test'),
            'enabled': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'value specified for "mime_type" must be one of the following options: [\'cloud-config\', \'ucernvm-config\'].',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test',
            'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test'),
            'mime_type': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'yaml value specified for "metadata (metadata_name)" is invalid - scanner error',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test',
            'metadata_name': 'invalid-unit-test.yaml',
            'metadata':
            'foo: somebody said I should put a colon here: so I did'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV14',
                         'cloud name  "invalid-unit-test" does not exist.',
                         '/cloud/metadata-add/',
                         form_data={
                             'cloud_name':
                             'invalid-unit-test',
                             'metadata_name':
                             ut_id(gvar, 'cloud-md-invalid-unit-test')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV15',
                         'Field \'metadata\' doesn\'t have a default value',
                         '/cloud/metadata-add/',
                         form_data={
                             'cloud_name':
                             ut_id(gvar, 'ctc3'),
                             'metadata_name':
                             ut_id(gvar, 'cloud-md-invalid-unit-test')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV13',
        'value specified for "priority" must be an integer value.',
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': 'invalid-unit-test',
            'metadata_name': ut_id(gvar, 'cloud-md-invalid-unit-test'),
            'metadata': 'invalid-unit-test',
            'priority': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV14',
                         'cloud name  "invalid-unit-test" does not exist.',
                         '/cloud/metadata-add/',
                         form_data={
                             'cloud_name':
                             'invalid-unit-test',
                             'metadata_name':
                             ut_id(gvar, 'cloud-md-invalid-unit-test'),
                             'metadata':
                             'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV##',
                         'invalid metadata name',
                         '/cloud/metadata-add/',
                         form_data={
                             'cloud_name': ut_id(gvar, 'ctc3'),
                             'metadata_name': '',
                             'metadata': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar, 'cty1')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty1'),
            'metadata':
            'foo: somebody said I should put a colon here: so I did'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV15',
        'Duplicate entry \'{}-{}-{}\' for key \'PRIMARY\''.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar, 'cty1')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty1'),
            'metadata':
            'foo: somebody said I should put a colon here: so I did'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar,
                                                            'cty1.yaml')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty1.yaml'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)
コード例 #10
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/cloud/metadata-collation/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu1')),
                         '/cloud/metadata-collation/',
                         server_user=ut_id(gvar, 'ctu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu2')),
                         '/cloud/metadata-collation/',
                         server_user=ut_id(gvar, 'ctu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/cloud/metadata-collation/',
                         form_data={'group': 'invalid-unit-test'},
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'ctg2')),
                         '/cloud/metadata-collation/',
                         form_data={'group': ut_id(gvar, 'ctg2')},
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV19',
        'request contained a bad parameter "invalid-unit-test".',
        '/cloud/metadata-collation/',
        form_data={'invalid-unit-test': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/cloud/metadata-collation/',
                         list='cloud_metadata_list',
                         filter={
                             'metadata_name': ut_id(gvar, 'cty1'),
                             'cloud_name': ut_id(gvar, 'ctc2'),
                             'group_name': ut_id(gvar, 'ctg1')
                         },
                         values={'type': 'group'},
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/cloud/metadata-collation/',
                         list='cloud_metadata_list',
                         filter={
                             'metadata_name': ut_id(gvar, 'cty1'),
                             'cloud_name': ut_id(gvar, 'ctc3'),
                             'group_name': ut_id(gvar, 'ctg1')
                         },
                         values={'type': 'group'},
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/cloud/metadata-collation/',
                         list='cloud_metadata_list',
                         filter={
                             'metadata_name': ut_id(gvar, 'cty1'),
                             'cloud_name': ut_id(gvar, 'ctc2'),
                             'group_name': ut_id(gvar, 'ctg1')
                         },
                         values={'type': 'cloud'},
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)
コード例 #11
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'metadata', 'load'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'metadata', 'load', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: job-cores',
        ['cloudscheduler', 'metadata', 'load', '-jc', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        [
            'cloudscheduler', 'metadata', 'load', '-mn', 'invalid-unit-test',
            '-f', 'ut.yaml', '-s', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None, None,
        ['cloudscheduler', 'metadata', 'load', '-s', 'unit-test-un'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler metadata load".',
                         ['cloudscheduler', 'metadata', 'load', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'metadata', 'load', '-H'])

    execute_csv2_command(gvar, 0, None, 'Expose API requested', [
        'cloudscheduler', 'metadata', 'load', '-xA', '-mn',
        ut_id(gvar, 'clm11'), '-f', 'ut.yaml'
    ])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".', [
            'cloudscheduler', 'metadata', 'load', '-g', 'invalid-unit-test',
            '-mn', 'invalid-unit-test', '-f', 'ut.yaml'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'metadata', 'load', '-g',
         ut_id(gvar, 'clg1')])

    execute_csv2_command(
        gvar, 1, None,
        'The specified metadata file "invalid-unit-test" does not exist.', [
            'cloudscheduler', 'metadata', 'load', '-f', 'invalid-unit-test',
            '-mn',
            ut_id(gvar, 'cli-invalid-unit-test')
        ])

    execute_csv2_command(
        gvar, 1, 'GV25',
        'boolean value specified for "enabled" must be one of the following: true, false, yes, no, 1, or 0.',
        [
            'cloudscheduler', 'metadata', 'load', '-f', 'ut.yaml', '-mn',
            ut_id(gvar, 'cli-invalid-unit-test'), '-me', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'GV25',
        r'value specified for "mime_type" must be one of the following options: [\'cloud-config\', \'ucernvm-config\'].',
        [
            'cloudscheduler', 'metadata', 'load', '-f', 'ut.yaml', '-mn',
            ut_id(gvar, 'cli-invalid-unit-test'), '-mmt', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'GV25',
        'value specified for "priority" must be an integer value.', [
            'cloudscheduler', 'metadata', 'load', '-f', 'ut.yaml', '-mn',
            ut_id(gvar, 'cli-invalid-unit-test'), '-mp', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'GV25',
        'value specified for "metadata (metadata_name)" is invalid - scanner error',
        [
            'cloudscheduler', 'metadata', 'load', '-f', 'notyamlfile.txt',
            '-mn', 'invalid-unit-test.yaml'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'file "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'),
                                                   ut_id(gvar, 'clm10')),
        [
            'cloudscheduler', 'metadata', 'load', '-f', 'notyamlfile.txt',
            '-mn',
            ut_id(gvar, 'clm10')
        ])

    execute_csv2_command(
        gvar, 0, None,
        'file "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'),
                                                   ut_id(gvar, 'clm10.yaml')),
        [
            'cloudscheduler', 'metadata', 'load', '-f', 'ut.yaml', '-mn',
            ut_id(gvar, 'clm10.yaml')
        ])
コード例 #12
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'cloud', 'metadata-edit'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'cloud', 'metadata-edit', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: metadata-mime-type',
        [
            'cloudscheduler', 'cloud', 'metadata-edit', '-mmt',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        [
            'cloudscheduler', 'cloud', 'metadata-edit', '-s',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'cloud', 'metadata-edit', '-s', 'unit-test-un'])

    execute_csv2_command(
        gvar, 0, None,
        'Help requested for "cloudscheduler cloud metadata-edit".',
        ['cloudscheduler', 'cloud', 'metadata-edit', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'cloud', 'metadata-edit', '-H'])

    execute_csv2_command(gvar, 1, None, 'Expose API requested',
                         ['cloudscheduler', 'cloud', 'metadata-edit', '-xA'])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".', [
            'cloudscheduler', 'cloud', 'metadata-edit', '-g',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        [
            'cloudscheduler', 'cloud', 'metadata-edit', '-g',
            ut_id(gvar, 'clg1')
        ])

    execute_csv2_command(
        gvar, 1, None,
        'no value, neither default nor command line, for the following required parameters',
        [
            'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
            'invalid-unit-test', '-mn', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'received an invalid metadata file id "{}::invalid-unit-test::invalid-unit-test".'
        .format(ut_id(gvar, 'clg1')), [
            'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
            'invalid-unit-test', '-mn', 'invalid-unit-test', '-te',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'received an invalid metadata file id "{}::{}::invalid-unit-test".'.
        format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc2')), [
            'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
            ut_id(gvar, 'clc2'), '-mn', 'invalid-unit-test', '-te',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'received an invalid metadata file id "{}::invalid-unit-test::{}".'.
        format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clm2')), [
            'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
            'invalid-unit-test', '-mn',
            ut_id(gvar, 'clm2'), '-te', 'invalid-unit-test'
        ])

    execute_csv2_command(gvar, 1, None, None, [
        'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2'), '-te', 'invalid-unit-test'
    ])

    environ['EDITOR'] = './editscript5'

    execute_csv2_command(gvar, 0, None, 'completed, no changes.', [
        'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2')
    ])

    environ.pop('EDITOR')

    execute_csv2_command(
        gvar, 1, None,
        'Error: "cloudscheduler cloud metadata-edit" - no value, neither default nor command line, for the following required parameters:',
        [
            'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
            ut_id(gvar, 'clc2'), '-mn',
            ut_id(gvar, 'clm2')
        ])

    # The edit scripts in the next 8 tests will break easily as they rely on some system variables
    execute_csv2_command(gvar, 0, None, 'completed, no changes.', [
        'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2'), '-te', './editscript5'
    ])

    execute_csv2_command(gvar, 0, None, 'successfully  updated.', [
        'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2'), '-te', './editscript6-un'
    ])

    execute_csv2_command(gvar, 0, None, 'successfully  updated.', [
        'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2.yaml'), '-te', './editscript7-un'
    ])

    execute_csv2_command(
        gvar, 1, None,
        'Invalid yaml file "scanner error": mapping values are not allowed here',
        [
            'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
            ut_id(gvar, 'clc2'), '-mn',
            ut_id(gvar, 'clm2.yaml'), '-te', './editscript8-un'
        ])

    execute_csv2_command(gvar, 0, None, 'completed, no changes.', [
        'cloudscheduler', 'cloud', 'metadata-edit', '-g',
        ut_id(gvar, 'clg1'), '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2'), '-te', './editscript5', '-s', 'unit-test'
    ])

    execute_csv2_command(gvar, 0, None, 'successfully  updated.', [
        'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2'), '-te', './editscript6'
    ])

    execute_csv2_command(gvar, 0, None, 'successfully  updated.', [
        'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
        ut_id(gvar, 'clc2'), '-mn',
        ut_id(gvar, 'clm2.yaml'), '-te', './editscript7'
    ])

    execute_csv2_command(
        gvar, 1, None,
        'Invalid yaml file "scanner error": mapping values are not allowed here',
        [
            'cloudscheduler', 'cloud', 'metadata-edit', '-cn',
            ut_id(gvar, 'clc2'), '-mn',
            ut_id(gvar, 'clm2.yaml'), '-te', './editscript8'
        ])
コード例 #13
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(gvar, 1, None,
                         'No action specified for object "defaults"',
                         ['cloudscheduler', 'defaults', '-s', 'unit-test-un'])

    execute_csv2_command(
        gvar, 1, None,
        'Invalid action "invalid-unit-test" for object "defaults"',
        ['cloudscheduler', 'defaults', 'invalid-unit-test'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler defaults".',
                         ['cloudscheduler', 'defaults', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'defaults', '-H'])

    #### SET ####

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'defaults', 'set'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'defaults', 'set', '-xx', 'yy'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler defaults set".',
                         ['cloudscheduler', 'defaults', 'set', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'defaults', 'set', '-H'])

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'defaults', 'set', '-s',
         ut_id(gvar, 'cld1')])

    #### LIST ####

    execute_csv2_command(gvar, 0, None, None,
                         ['cloudscheduler', 'defaults', 'list'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'defaults', 'list', '-xx', 'yy'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler defaults list".',
                         ['cloudscheduler', 'defaults', 'list', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'defaults', 'list', '-H'])

    execute_csv2_command(
        gvar, 0, None, 'Rows: 0',
        ['cloudscheduler', 'defaults', 'list', '-s', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 0, None, 'Rows: 1',
        ['cloudscheduler', 'defaults', 'list', '-s',
         ut_id(gvar, 'cld1')])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'defaults', 'list', '-ok'],
                         list='',
                         columns=[])

    execute_csv2_command(
        gvar, 0, None,
        'defaults list, table #1 columns: keys=server, columns=',
        ['cloudscheduler', 'defaults', 'list', '-VC'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'defaults', 'list', '-NV'],
        list='Defaults',
        columns=[
            'server', 'cloud-address', 'cloud-enabled', 'cloud-name',
            'cloud-password', 'cloud-project', 'cloud-project-domain',
            'cloud-region', 'cloud-spot-price', 'cloud-type', 'cloud-user',
            'cloud-user-domain', 'expose-API', 'file-path', 'group',
            'group-manager', 'group-name', 'group-option', 'help', 'job-cores',
            'job-disk', 'job-ram', 'job-swap', 'long-help', 'metadata-enabled',
            'metadata-mime-type', 'metadata-name', 'metadata-priority',
            'no-view', 'only-keys', 'rotate', 'server-address',
            'server-grid-cert', 'server-grid-key', 'server-password',
            'server-user', 'super-user', 'text-editor', 'user-common-name',
            'user-password', 'user_option', 'username', 'view', 'view-columns',
            'vm-cores', 'vm-disk', 'vm-flavor', 'vm-foreign', 'vm-hostname',
            'vm-image', 'vm-keep-alive', 'vm-keypair', 'vm-option', 'vm-ram',
            'vm-status', 'vm-swap', 'yes'
        ])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, [
                             'cloudscheduler', 'defaults', 'list', '-V',
                             'server-address,server-user'
                         ],
                         list='Defaults',
                         columns=['server', 'server-address', 'server-user'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'defaults', 'list'],
                         list='Defaults',
                         columns=['server', 'server-address', 'server-user'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'defaults', 'list', '-V', ''],
        list='Defaults',
        columns=[
            'server', 'cloud-address', 'cloud-enabled', 'cloud-name',
            'cloud-password', 'cloud-project', 'cloud-project-domain',
            'cloud-region', 'cloud-spot-price', 'cloud-type', 'cloud-user',
            'cloud-user-domain', 'expose-API', 'file-path', 'group',
            'group-manager', 'group-name', 'group-option', 'help', 'job-cores',
            'job-disk', 'job-ram', 'job-swap', 'long-help', 'metadata-enabled',
            'metadata-mime-type', 'metadata-name', 'metadata-priority',
            'no-view', 'only-keys', 'rotate', 'server-address',
            'server-grid-cert', 'server-grid-key', 'server-password',
            'server-user', 'super-user', 'text-editor', 'user-common-name',
            'user-password', 'user_option', 'username', 'view', 'view-columns',
            'vm-cores', 'vm-disk', 'vm-flavor', 'vm-foreign', 'vm-hostname',
            'vm-image', 'vm-keep-alive', 'vm-keypair', 'vm-option', 'vm-ram',
            'vm-status', 'vm-swap', 'yes'
        ])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'defaults', 'list', '-r'],
                         list='Defaults',
                         columns=['Key', 'Value'])

    #### DELETE ####

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'defaults', 'delete'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'defaults', 'delete', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 0, None, 'Help requested for "cloudscheduler defaults delete".',
        ['cloudscheduler', 'defaults', 'delete', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'defaults', 'delete', '-H'])

    execute_csv2_command(
        gvar, 1, None, 'Settings for server "invalid-unit-test" do not exist.',
        ['cloudscheduler', 'defaults', 'delete', '-s', 'invalid-unit-test'])

    execute_csv2_command(gvar, 0, None, None, [
        'cloudscheduler', 'defaults', 'delete', '-s',
        ut_id(gvar, 'cld1'), '-Y'
    ])

    execute_csv2_command(gvar, None, None, None,
                         ['cloudscheduler', 'defaults', '-s', 'unit-test'])
コード例 #14
0
ファイル: test_db_vm.py プロジェクト: hep-gc/cloudscheduler
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid1'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '5',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid1',
                             'vmid': 'vmid1',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid2'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid2',
                             'vmid': 'vmid2',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid3'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid3',
                             'vmid': 'vmid3',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid4'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid4',
                             'vmid': 'vmid4',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid5'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid5',
                             'vmid': 'vmid5',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid6'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid6',
                             'vmid': 'vmid6',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    # Setting Manual Control
    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs set to manual control: 0.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'manctl',
                             'hostname': 'foreign-cloud--vmid4'
                         })

    execute_csv2_command(gvar, 0, None,
                         'vm update, VMs set to manual control: 0.', [
                             'cloudscheduler', 'vm', 'update', '-vo', 'manctl',
                             '-vh', 'foreign-cloud--vmid4'
                         ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs set to manual control: 1.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'manctl',
                             'hostname': 'vm-test-group--vm-test-cloud--vmid1'
                         })

    execute_csv2_command(gvar, 0, None,
                         'vm update, VMs set to manual control: 1.', [
                             'cloudscheduler', 'vm', 'update', '-vo', 'manctl',
                             '-vh', 'vm-test-group--vm-test-cloud--vmid2'
                         ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs set to manual control: 3.",
                         '/vm/update/',
                         form_data={'vm_option': 'manctl'})

    execute_csv2_command(gvar, 0, None,
                         'vm update, VMs set to manual control: 3.',
                         ['cloudscheduler', 'vm', 'update', '-vo', 'manctl'])

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid1'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 1,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '5',
                             'poller_status': 'manual',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid1',
                             'vmid': 'vmid1',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid2'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 1,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'manual',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid2',
                             'vmid': 'vmid2',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid3'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 1,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'manual',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid3',
                             'vmid': 'vmid3',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid4'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid4',
                             'vmid': 'vmid4',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid5'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid5',
                             'vmid': 'vmid5',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid6'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid6',
                             'vmid': 'vmid6',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    # Setting System Control
    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs set to system control: 0.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'sysctl',
                             'hostname': 'foreign-cloud--vmid4'
                         })

    execute_csv2_command(gvar, 0, None,
                         'vm update, VMs set to system control: 0.', [
                             'cloudscheduler', 'vm', 'update', '-vo', 'sysctl',
                             '-vh', 'foreign-cloud--vmid4'
                         ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs set to system control: 1.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'sysctl',
                             'hostname': 'vm-test-group--vm-test-cloud--vmid2'
                         })

    execute_csv2_command(gvar, 0, None,
                         'vm update, VMs set to system control: 1.', [
                             'cloudscheduler', 'vm', 'update', '-vo', 'sysctl',
                             '-vh', 'vm-test-group--vm-test-cloud--vmid3'
                         ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs set to system control: 3.",
                         '/vm/update/',
                         form_data={'vm_option': 'sysctl'})

    execute_csv2_command(gvar, 0, None,
                         'vm update, VMs set to system control: 3.',
                         ['cloudscheduler', 'vm', 'update', '-vo', 'sysctl'])

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid1'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '5',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid1',
                             'vmid': 'vmid1',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid2'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid2',
                             'vmid': 'vmid2',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid3'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': 0,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid3',
                             'vmid': 'vmid3',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid4'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid4',
                             'vmid': 'vmid4',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid5'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid5',
                             'vmid': 'vmid5',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid6'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid6',
                             'vmid': 'vmid6',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    # Setting Retire
    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs retired: 0.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'retire',
                             'hostname': 'foreign-cloud--vmid4'
                         })

    execute_csv2_command(gvar, 0, None, 'vm update, VMs retired: 0.', [
        'cloudscheduler', 'vm', 'update', '-vo', 'retire', '-vh',
        'foreign-cloud--vmid4'
    ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs retired: 1.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'retire',
                             'hostname': 'vm-test-group--vm-test-cloud--vmid3'
                         })

    execute_csv2_command(gvar, 0, None, 'vm update, VMs retired: 1.', [
        'cloudscheduler', 'vm', 'update', '-vo', 'retire', '-vh',
        'vm-test-group--vm-test-cloud--vmid1'
    ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs retired: 3.",
                         '/vm/update/',
                         form_data={'vm_option': 'retire'})

    execute_csv2_command(gvar, 0, None, 'vm update, VMs retired: 3.',
                         ['cloudscheduler', 'vm', 'update', '-vo', 'retire'])

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid4'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid4',
                             'vmid': 'vmid4',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid5'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid5',
                             'vmid': 'vmid5',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid6'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid6',
                             'vmid': 'vmid6',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    # Setting Kill
    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs killed: 0.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'kill',
                             'hostname': 'foreign-cloud--vmid4'
                         })

    execute_csv2_command(gvar, 0, None, 'vm update, VMs killed: 0.', [
        'cloudscheduler', 'vm', 'update', '-vo', 'kill', '-vh',
        'foreign-cloud--vmid4'
    ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs killed: 1.",
                         '/vm/update/',
                         form_data={
                             'vm_option': 'kill',
                             'hostname': 'vm-test-group--vm-test-cloud--vmid1'
                         })

    execute_csv2_command(gvar, 0, None, 'vm update, VMs killed: 1.', [
        'cloudscheduler', 'vm', 'update', '-vo', 'kill', '-vh',
        'vm-test-group--vm-test-cloud--vmid2'
    ])

    execute_csv2_request(gvar,
                         0,
                         None,
                         "vm update, VMs killed: 3.",
                         '/vm/update/',
                         form_data={'vm_option': 'kill'})

    execute_csv2_command(gvar, 0, None, 'vm update, VMs killed: 3.',
                         ['cloudscheduler', 'vm', 'update', '-vo', 'kill'])

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid1'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'group_name': 'vm-test-group',
                             'terminate': 1,
                             'flavor_id': '5',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid1',
                             'vmid': 'vmid1',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid2'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'group_name': 'vm-test-group',
                             'terminate': 1,
                             'flavor_id': '4',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid2',
                             'vmid': 'vmid2',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid3'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'group_name': 'vm-test-group',
                             'terminate': 1,
                             'flavor_id': '4',
                             'poller_status': 'unregistered',
                             'foreign_vm': 0,
                             'hostname': 'vm-test-group--vm-test-cloud--vmid3',
                             'vmid': 'vmid3',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid4'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid4',
                             'vmid': 'vmid4',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid5'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid5',
                             'vmid': 'vmid5',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/vm/list/',
                         form_data={'group': 'vm-test-group'},
                         list='vm_list',
                         filter={
                             'group_name': 'vm-test-group',
                             'cloud_name': 'vm-test-cloud',
                             'vmid': 'vmid6'
                         },
                         values={
                             'power_status': 1,
                             'auth_url': 'vm-test-authurl',
                             'manual_control': 0,
                             'project': 'vm-test-project',
                             'status': 'ACTIVE',
                             'retire_request_time': None,
                             'group_name': 'vm-test-group',
                             'terminate': 0,
                             'flavor_id': '4',
                             'poller_status': 'foreign',
                             'foreign_vm': 1,
                             'hostname': 'foreign-cloud--vmid6',
                             'vmid': 'vmid6',
                             'keep_alive': 0,
                             'cloud_name': 'vm-test-cloud'
                         })
コード例 #15
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/cloud/delete/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu1')),
                         '/cloud/delete/',
                         server_user=ut_id(gvar, 'ctu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu2')),
                         '/cloud/delete/',
                         server_user=ut_id(gvar, 'ctu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV09',
                         'invalid method "GET" specified.',
                         '/cloud/delete/',
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV06',
        'cloud delete request did not contain mandatory parameter "cloud_name".',
        '/cloud/delete/',
        form_data={'group': ut_id(gvar, 'ctg1')},
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV06',
        'cloud delete request contained a bad parameter "invalid-unit-test".',
        '/cloud/delete/',
        form_data={
            'cloud_name': 'invalid-unit-test',
            'invalid-unit-test': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV05',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/cloud/delete/',
                         form_data={
                             'cloud_name': 'invalid-unit-test',
                             'group': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV05',
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'ctg2')),
                         '/cloud/delete/',
                         form_data={
                             'cloud_name': 'invalid-unit-test',
                             'group': ut_id(gvar, 'ctg2')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV06',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/delete/',
        form_data={
            'cloud_name': 'Invalid-Unit-Test',
            'group': ut_id(gvar, 'ctg1')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV06',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/delete/',
        form_data={
            'cloud_name': 'invalid-unit-test-',
            'group': ut_id(gvar, 'ctg1')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV06',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/delete/',
        form_data={
            'cloud_name': 'invalid-unit-test!',
            'group': ut_id(gvar, 'ctg1')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV08',
                         'the request did not match any rows.',
                         '/cloud/delete/',
                         form_data={
                             'cloud_name': 'invalid-unit-test',
                             'group': ut_id(gvar, 'ctg1')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully deleted.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc1')),
                         '/cloud/delete/',
                         form_data={
                             'cloud_name': ut_id(gvar, 'ctc1'),
                             'group': ut_id(gvar, 'ctg1')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)
コード例 #16
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        [
            'cloudscheduler', 'cloud', 'status', '-xx', 'yy', '-s',
            'unit-test-un'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: metadata-mime-type',
        ['cloudscheduler', 'cloud', 'status', '-mmt', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'cloud', 'status', '-s', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'cloud', 'status', '-s', 'unit-test-un'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler cloud status".',
                         ['cloudscheduler', 'cloud', 'status', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'cloud', 'status', '-H'])

    execute_csv2_command(gvar, 0, None, 'Expose API requested',
                         ['cloudscheduler', 'cloud', 'status', '-xA'])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".',
        ['cloudscheduler', 'cloud', 'status', '-g', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test-un, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, 'test'), ut_id(gvar, 'clg1')),
        ['cloudscheduler', 'cloud', 'status', '-g',
         ut_id(gvar, 'clg1')])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, '')[:-1], ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'cloud', 'status', '-g',
                ut_id(gvar, 'clg1'), '-s', 'unit-test'
            ])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test-un, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, 'test'), ut_id(gvar, 'clg1')),
        ['cloudscheduler', 'cloud', 'status', '-s', 'unit-test-un'])

    execute_csv2_command(
        gvar, 0, None, 'Rows: 0',
        ['cloudscheduler', 'cloud', 'status', '-cn', 'invalid-unit-test'])

    execute_csv2_command(gvar, 0, None, ut_id(gvar, 'clc2'),
                         ['cloudscheduler', 'cloud', 'status'])

    execute_csv2_command(
        gvar, 0, None, 'Rows: 1',
        ['cloudscheduler', 'cloud', 'status', '-cn',
         ut_id(gvar, 'clc2')])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'cloud', 'status', '-ok'],
                         list='Cloud status',
                         columns=['Group', 'Cloud'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'cloud', 'status', '-ok'],
                         list='Job status',
                         columns=['Group'])

    execute_csv2_command(
        gvar, 0, None,
        'cloud status, table #1 columns: keys=group_name, columns=Jobs,Idle,Running,Completed,Other\\ncloud status, table #2 columns: keys=group_name,cloud_name, columns=enabled,default_flavor,default_image,keep_alive,VMs,VMs_unregistered,VMs_running,VMs_retiring,VMs_manual,VMs_in_error,VMs_other,cores_max,cores_ctl,cores_idle,cores_native,ram_max,ram_ctl,ram_idle,ram_native,slots_max,slots_used,Foreign_VMs,cores_foreign,ram_foreign',
        ['cloudscheduler', 'cloud', 'status', '-VC'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'cloud', 'status', '-NV'],
                         list='Cloud status',
                         columns=[
                             'Defaults', 'VMs', 'Cores', 'Group', 'Cloud',
                             'Enabled', 'Flavor', 'Image', 'Keep Alive',
                             'Total', 'Unregistered', 'Running', 'Retiring',
                             'Manual', 'Error', 'Other', 'Setting', 'RAM',
                             'Slots', 'Foreign', 'Idle', 'Used'
                         ])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'cloud', 'status', '-NV'],
        list='Job status',
        columns=['Group', 'Jobs', 'Idle', 'Running', 'Completed', 'Other'])

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'cloud', 'status', '-V', 'Jobs/enabled'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'cloud', 'status'],
                         list='Cloud status',
                         columns=['Defaults', 'Group', 'Cloud', 'Enabled'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'cloud', 'status'],
                         list='Job status',
                         columns=['Group', 'Jobs'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'cloud', 'status', '-r'],
                         list='Cloud status',
                         columns=['Key', 'Value'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'cloud', 'status', '-r'],
                         list='Job status',
                         columns=['Key', 'Value'])

    execute_csv2_command(gvar, 0, None, None,
                         ['cloudscheduler', 'cloud', 'status', '-V', ''])
コード例 #17
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/group/metadata-add/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'GV27',
                         'invalid method "GET" specified.',
                         '/group/metadata-add/',
                         server_user=ut_id(gvar, 'gtu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/group/metadata-add/',
                         form_data={'invalid-unit-test': 'invalid-unit-test'},
                         server_user=ut_id(gvar, 'gtu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/group/metadata-add/',
                         form_data={'invalid-unit-test': 'invalid-unit-test'},
                         server_user=ut_id(gvar, 'gtu2'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'GV25',
        'group metadata-add request did not contain mandatory parameter "metadata_name".',
        '/group/metadata-add/',
        form_data={'enabled': 1},
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'GV25',
        'group metadata-add request contained a bad parameter "invalid-unit-test".',
        '/group/metadata-add/',
        form_data={
            'metadata_name': ut_id(gvar, 'group-md-invalid-unit-test'),
            'invalid-unit-test': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'GV24',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/group/metadata-add/',
                         form_data={
                             'metadata_name':
                             ut_id(gvar, 'group-md-invalid-unit-test'),
                             'group':
                             'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'GV24',
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'gtg7')),
                         '/group/metadata-add/',
                         form_data={
                             'metadata_name':
                             ut_id(gvar, 'group-md-invalid-unit-test'),
                             'group':
                             ut_id(gvar, 'gtg7')
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'GV25',
        'value specified for "metadata_name" must be all lower case.',
        '/group/metadata-add/',
        form_data={
            'group': ut_id(gvar, 'gtg4'),
            'metadata_name': 'Invalid-Unit-Test'
        },
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'GV25',
        'boolean value specified for "enabled" must be one of the following: true, false, yes, no, 1, or 0.',
        '/group/metadata-add/',
        form_data={
            'group': ut_id(gvar, 'gtg4'),
            'metadata_name': ut_id(gvar, 'group-md-invalid-unit-test'),
            'enabled': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'GV25',
        'value specified for "mime_type" must be one of the following options: [\'cloud-config\', \'ucernvm-config\'].',
        '/group/metadata-add/',
        form_data={
            'group': ut_id(gvar, 'gtg4'),
            'metadata_name': ut_id(gvar, 'group-md-invalid-unit-test'),
            'enabled': 0,
            'mime_type': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'GV26',
                         'Field \'metadata\' doesn\'t have a default value',
                         '/group/metadata-add/',
                         form_data={
                             'group':
                             ut_id(gvar, 'gtg4'),
                             'metadata_name':
                             ut_id(gvar, 'group-md-invalid-unit-test'),
                             'enabled':
                             0,
                             'mime_type':
                             'cloud-config'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'GV25',
        'value specified for "priority" must be an integer value.',
        '/group/metadata-add/',
        form_data={
            'group': ut_id(gvar, 'gtg4'),
            'metadata_name': ut_id(gvar, 'group-md-invalid-unit-test'),
            'enabled': 0,
            'mime_type': 'cloud-config',
            'metadata': 'invalid-unit-test',
            'priority': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'GV25',
        'yaml value specified for "metadata (metadata_name)" is invalid - scanner error',
        '/group/metadata-add/',
        form_data={
            'group': ut_id(gvar, 'gtg4'),
            'metadata_name': 'invalid-unit-test.yaml',
            'enabled': 0,
            'mime_type': 'cloud-config',
            'metadata':
            'foo: somebody said I should put a colon here: so I did',
            'priority': 1
        },
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'GV##',
                         'invalid metadata name',
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': '',
                             'metadata': 'invalid-unit-test',
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty1')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty1'),
                             'enabled': 0,
                             'mime_type': 'cloud-config',
                             'metadata': '{"not-yaml":"yes"}',
                             'priority': 1
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg4'), ut_id(gvar, 'gty1.yaml')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg4'),
                             'metadata_name': ut_id(gvar, 'gty1.yaml'),
                             'enabled': 0,
                             'mime_type': 'cloud-config',
                             'metadata': '- example: metadata',
                             'priority': 1
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/group/list/',
                         list='group_list',
                         filter={'group_name': ut_id(gvar, 'gtg4')},
                         values={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'metadata_names': ut_id(gvar, 'gty1.yaml')
                         })

    execute_csv2_request(
        gvar,
        1,
        'GV26',
        'Duplicate entry \'{}-{}\' for key \'PRIMARY\''.format(
            ut_id(gvar, 'gtg4'), ut_id(gvar, 'gty1.yaml')),
        '/group/metadata-add/',
        form_data={
            'group': ut_id(gvar, 'gtg4'),
            'metadata_name': ut_id(gvar, 'gty1.yaml'),
            'enabled': 1,
            'mime_type': 'ucernvm-config',
            'metadata': '{"example": "not yaml"}',
            'priority': 0
        },
        server_user=ut_id(gvar, 'gtu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty1.yaml')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty1.yaml'),
                             'enabled': 0,
                             'mime_type': 'cloud-config',
                             'metadata': '- example: yaml',
                             'priority': 1
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/group/metadata-list/',
                         form_data={'group': ut_id(gvar, 'gtg5')},
                         list='group_metadata_list',
                         filter={'metadata_name': ut_id(gvar, 'gty1.yaml')},
                         values={
                             'metadata_name': ut_id(gvar, 'gty1.yaml'),
                             'enabled': 0,
                             'metadata': '- example: yaml',
                             'group_name': ut_id(gvar, 'gtg5'),
                             'priority': 1,
                             'mime_type': 'cloud-config'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)
コード例 #18
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    new_secret = generate_secret()

    # 1
    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/user/settings/',
                         server_user='******',
                         server_pw=user_secret)

    # 2
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'utu1')),
                         '/user/settings/',
                         server_user=ut_id(gvar, 'utu1'),
                         server_pw=user_secret)

    # 3
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'utu2')),
                         '/user/settings/',
                         server_user=ut_id(gvar, 'utu2'),
                         server_pw=user_secret)

    # 4
    execute_csv2_request(gvar,
                         1,
                         'UV16',
                         'invalid method "GET" specified.',
                         '/user/settings/',
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 5
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/user/settings/',
                         form_data={'group': 'invalid-unit-test'},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 6
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'utg2')),
                         '/user/settings/',
                         form_data={'group': ut_id(gvar, 'utg2')},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 7
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'request contained a unnamed/bad parameter "invalid-unit-test".',
        '/user/settings/',
        form_data={'invalid-unit-test': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 8
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less than 6 characters.',
        '/user/settings/',
        form_data={'password': '******'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 9
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        '/user/settings/',
        form_data={'password': '******'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 10
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={'password': new_secret},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 11
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={'password': user_secret},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=new_secret)

    # 12
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'password update received a password but no verify password; both are required.',
        '/user/settings/',
        form_data={'password1': 'test'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 13
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'password update received a verify password but no password; both are required.',
        '/user/settings/',
        form_data={'password2': 'test'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 14
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less than 6 characters.',
        '/user/settings/',
        form_data={
            'password1': 'test',
            'password2': 'test'
        },
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 15
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        '/user/settings/',
        form_data={
            'password1': 'invalid',
            'password2': 'invalid'
        },
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 16
    execute_csv2_request(gvar,
                         1,
                         'UV15',
                         'values specified for passwords do not match.',
                         '/user/settings/',
                         form_data={
                             'password1': 'Abc123',
                             'password2': '321cbA'
                         },
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 17
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={
                             'password1': new_secret,
                             'password2': new_secret
                         },
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 18
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={
                             'password1': user_secret,
                             'password2': user_secret
                         },
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=new_secret)
コード例 #19
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/group/update/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/group/update/',
                         server_user=ut_id(gvar, 'gtu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/group/update/',
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'gtu2')),
                         '/group/update/',
                         server_user=ut_id(gvar, 'gtu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar, 1, 'GV47', 'invalid method "GET" specified.',
                         '/group/update/')

    execute_csv2_request(gvar,
                         1,
                         'GV41',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/group/update/',
                         form_data={'group': 'invalid-unit-test'})

    execute_csv2_request(
        gvar,
        1,
        'GV42',
        'request contained a bad parameter "invalid-unit-test".',
        '/group/update/',
        form_data={'invalid-unit-test': 'invalid-unit-test'})

    execute_csv2_request(
        gvar,
        1,
        'GV42',
        'value specified for "group_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/group/update/',
        form_data={'group_name': ut_id(gvar, 'Gtg1')})

    execute_csv2_request(
        gvar,
        1,
        'GV42',
        'value specified for "group_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/group/update/',
        form_data={'group_name': ut_id(gvar, 'gtg!1')})

    execute_csv2_request(
        gvar,
        1,
        'GV42',
        'value specified for "group_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/group/update/',
        form_data={'group_name': ut_id(gvar, 'gtg1-')})

    execute_csv2_request(
        gvar,
        1,
        'GV45',
        'group update must specify at least one field to update.',
        '/group/update/',
        form_data={'group_name': 'invalid-unit-test'})

    execute_csv2_request(
        gvar,
        1,
        'GV42',
        'value specified for "user_option" must be one of the following options: [\'add\', \'delete\'].',
        '/group/update/',
        form_data={'user_option': 'invalid-unit-test'})

    execute_csv2_request(
        gvar,
        1,
        'GV42',
        'group update request did not contain mandatory parameter "group_name".',
        '/group/update/',
        form_data={'username': '******'})

    execute_csv2_request(gvar,
                         1,
                         'GV44',
                         'the request did not match any rows.',
                         '/group/update/',
                         form_data={
                             'group_name': 'invalid-unit-test',
                             'condor_central_manager': 'invalid-unit-test'
                         })

    execute_csv2_request(
        gvar,
        1,
        'GV42',
        'group update parameter "condor_central_manager" contains an empty string which is specifically disallowed.',
        '/group/update/',
        form_data={
            'group_name': ut_id(gvar, 'gtg4'),
            'condor_central_manager': ''
        })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully updated.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/update/',
                         form_data={
                             'group_name':
                             ut_id(gvar, 'gtg4'),
                             'condor_central_manager':
                             'unit-test-group-four-update.ca'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/group/list/',
                         list='group_list',
                         filter={'group_name': ut_id(gvar, 'gtg4')},
                         values={
                             'group_name':
                             ut_id(gvar, 'gtg4'),
                             'condor_central_manager':
                             'unit-test-group-four-update.ca'
                         })

    execute_csv2_request(gvar,
                         1,
                         'GV43',
                         'specified user "invalid-unit-test" does not exist.',
                         '/group/update/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'username.1': 'invalid-unit-test'
                         })

    execute_csv2_request(
        gvar,
        1,
        'GV43',
        'group add, "{}" failed - user "{}" was specified twice.'.format(
            ut_id(gvar, 'gtg4'), ut_id(gvar, 'gtu4')),
        '/group/update/',
        form_data={
            'group_name': ut_id(gvar, 'gtg4'),
            'username.1': ut_id(gvar, 'gtu4'),
            'username.2': ut_id(gvar, 'gtu4')
        })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/group/list/',
                         list='group_list',
                         filter={'group_name': ut_id(gvar, 'gtg4')},
                         values={
                             'group_name':
                             ut_id(gvar, 'gtg4'),
                             'condor_central_manager':
                             'unit-test-group-four-update.ca'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully updated.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/update/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'username.1': ut_id(gvar, 'gtu4')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/group/list/',
                         list='group_list',
                         filter={'group_name': ut_id(gvar, 'gtg4')},
                         values={
                             'group_name':
                             ut_id(gvar, 'gtg4'),
                             'condor_central_manager':
                             'unit-test-group-four-update.ca'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'gtu4')},
                         values={'user_groups': ut_id(gvar, 'gtg4')})

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully updated.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/update/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'username': ''
                         },
                         html=True)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'gtu4')},
                         values={'user_groups': None})

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully updated.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/update/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'username.1': ut_id(gvar, 'gtu4')
                         },
                         html=True)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'gtu4')},
                         values={'user_groups': ut_id(gvar, 'gtg4')})

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully updated.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/update/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'username.1': ut_id(gvar, 'gtu5')
                         },
                         html=True)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'gtu4')},
                         values={'user_groups': None})

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'gtu5')},
                         values={'user_groups': ut_id(gvar, 'gtg4,gtg5')})

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully updated.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/update/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'username.1': ut_id(gvar, 'gtu4'),
                             'username.2': ut_id(gvar, 'gtu5')
                         },
                         html=True)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'gtu4')},
                         values={'user_groups': ut_id(gvar, 'gtg4')})

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'gtu5')},
                         values={'user_groups': ut_id(gvar, 'gtg4,gtg5')})
コード例 #20
0
ファイル: test_cli_job.py プロジェクト: hep-gc/cloudscheduler
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(gvar, 1, None, 'No action specified for object "job"',
                         ['cloudscheduler', 'job', '-s', 'unit-test-un'])

    execute_csv2_command(
        gvar, 1, None, 'Invalid action "invalid-unit-test" for object "job"',
        ['cloudscheduler', 'job', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'job', '-s', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'No action specified for object "job"; use -h or -H for help.',
        ['cloudscheduler', 'job', '-s', 'unit-test-un'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler job".',
                         ['cloudscheduler', 'job', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'job', '-H'])

    #### LIST ####
    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'job', 'list', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: job-cores',
        ['cloudscheduler', 'job', 'list', '-jc', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'job', 'list', '-s', 'invalid-unit-test'])

    execute_csv2_command(gvar, 0, None, None,
                         ['cloudscheduler', 'job', 'list', '-s', 'unit-test'])

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'job', 'list', '-s', 'unit-test-un'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler job list".',
                         ['cloudscheduler', 'job', 'list', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'job', 'list', '-H'])

    execute_csv2_command(gvar, 0, None, 'Expose API requested',
                         ['cloudscheduler', 'job', 'list', '-xA'])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".',
        ['cloudscheduler', 'job', 'list', '-g', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, '')[:-1], ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'job', 'list', '-g',
                ut_id(gvar, 'clg1'), '-s', 'unit-test'
            ])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test-un, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, 'test'), ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'job', 'list', '-g',
                ut_id(gvar, 'clg1'), '-s', 'unit-test-un'
            ])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'job', 'list', '-ok'],
                         list='Jobs',
                         columns=['Group', 'Job ID'])

    execute_csv2_command(
        gvar, 0, None,
        'job list, table #1 columns: keys=group_name,global_job_id, columns=cluster_id,proc_id,user,user_data,requirements,target_clouds,cloud_name,instance_type,request_cpus,request_ram,request_disk,request_swap,job_per_core,image,network,job_priority,job_status,js_idle,js_running,js_completed,js_held,js_other,keep_alive,max_price,entered_current_status,q_date,held_reason',
        ['cloudscheduler', 'job', 'list', '-VC'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'job', 'list', '-NV'],
                         list='Jobs',
                         columns=[
                             'Requested', 'Group', 'Job ID', 'Cluster ID',
                             'Process ID', 'User', 'User Data', 'Requirements',
                             'Target Clouds', 'Cloud', 'Instance Type', 'CPUs',
                             'RAM {MBs}', 'Disk {GBs}', 'Scratch (GBs)',
                             'Swap (GBs)', 'Jobs per Core', 'Image', 'Network',
                             'Idle', 'Running', 'Completed', 'Held', 'Other',
                             'Keep Alive (seconds)', 'Max Spot Price',
                             'State Change Date', 'Queued Date', 'Hold Job'
                         ])

    execute_csv2_command(
        gvar,
        0,
        None,
        None,
        ['cloudscheduler', 'job', 'list', '-V', 'cluster_id,proc_id,user'],
        list='Jobs',
        columns=['Group', 'Job ID', 'Cluster ID', 'Process ID', 'User'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'job', 'list'],
        list='Jobs',
        columns=['Group', 'Job ID', 'Cluster ID', 'Process ID', 'User'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'job', 'list', '-V', ''],
                         list='Jobs',
                         columns=[
                             'Requested', 'Group', 'Job ID', 'Cluster ID',
                             'Process ID', 'User', 'User Data', 'Requirements',
                             'Target Clouds', 'Cloud', 'Instance Type', 'CPUs',
                             'RAM {MBs}', 'Disk {GBs}', 'Scratch (GBs)',
                             'Swap (GBs)', 'Jobs per Core', 'Image', 'Network',
                             'Idle', 'Running', 'Completed', 'Held', 'Other',
                             'Keep Alive (seconds)', 'Max Spot Price',
                             'State Change Date', 'Queued Date', 'Hold Job'
                         ])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'job', 'list', '-r'],
                         list='Jobs',
                         columns=['Key', 'Value'])
コード例 #21
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    server_requests_cleanup.main(gvar)

    # unprivileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu1')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu1'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user one'.format(ut_id(gvar, 'server'))
                         })

    # privileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu2')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu2'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user two'.format(ut_id(gvar, 'server')),
                             'is_superuser':
                             1
                         })

    # group without users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'stg1')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'stg1'),
                             'condor_central_manager': 'unit-test-group-one.ca'
                         })

    # group with users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'stg2')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'stg2'),
                             'condor_central_manager': 'unit-test-group-two.ca'
                         })

    # unprivileged user in group
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu3')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu3'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user three'.format(ut_id(gvar,
                                                               'server')),
                             'group_name':
                             ut_id(gvar, 'stg2'),
                         })

    # privileged user in group
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu4')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu4'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'is_superuser':
                             1,
                             'cert_cn':
                             '{} test user four'.format(ut_id(gvar, 'server')),
                             'group_name':
                             ut_id(gvar, 'stg2'),
                         })
コード例 #22
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/user/update/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/user/update/',
                         server_user=ut_id(gvar, 'utu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'UV12',
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'utu2')),
                         '/user/update/',
                         server_user=ut_id(gvar, 'utu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar, 1, 'UV25', 'invalid method "GET" specified.',
                         '/user/update/')

    execute_csv2_request(gvar,
                         1,
                         'UV18',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/user/update/',
                         form_data={'group': 'invalid-unit-test'})

    execute_csv2_request(gvar,
                         1,
                         'UV18',
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'utg2')),
                         '/user/update/',
                         form_data={'group': ut_id(gvar, 'utg2')})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'request contained a bad parameter "invalid-unit-test".',
        '/user/update/',
        form_data={'invalid-unit-test': 'invalid-unit-test'})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'value specified for "username" must be all lower case.',
        '/user/update/',
        form_data={'username': '******'})

    execute_csv2_request(gvar,
                         1,
                         'UV23',
                         'must specify at least one field to update.',
                         '/user/update/',
                         form_data={'username': '******'})

    execute_csv2_request(gvar,
                         1,
                         'UV22',
                         'the request did not match any rows.',
                         '/user/update/',
                         form_data={
                             'username': '******',
                             'password': '******'
                         })

    execute_csv2_request(gvar,
                         1,
                         'UV23',
                         'must specify at least one field to update.',
                         '/user/update/',
                         form_data={'username': ut_id(gvar, 'utu6')})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'boolean value specified for "is_superuser" must be one of the following: true, false, yes, no, 1, or 0.',
        '/user/update/',
        form_data={'is_superuser': '******'})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'value specified for a password is less than 6 characters.',
        '/user/update/',
        form_data={'password': '******'})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        '/user/update/',
        form_data={'password': '******'})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'password update received a password but no verify password; both are required.',
        '/user/update/',
        form_data={'password1': 'test'})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'password update received a verify password but no password; both are required.',
        '/user/update/',
        form_data={'password2': 'test'})

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'value specified for a password is less than 6 characters.',
        '/user/update/',
        form_data={
            'password1': 'test',
            'password2': 'test'
        })

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        '/user/update/',
        form_data={
            'password1': 'invalid',
            'password2': 'invalid'
        })

    execute_csv2_request(gvar,
                         1,
                         'UV19',
                         'values specified for passwords do not match.',
                         '/user/update/',
                         form_data={
                             'password1': 'Abc123',
                             'password2': '321cbA'
                         })

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'request contained a rejected/bad parameter "join_date".',
        '/user/update/',
        form_data={
            'username': ut_id(gvar, 'utu6'),
            'join_date': 'invalid-unit-test'
        })

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'request contained a rejected/bad parameter "active_group".',
        '/user/update/',
        form_data={
            'username': ut_id(gvar, 'utu6'),
            'active_group': 'invalid-unit-test'
        })

    execute_csv2_request(gvar,
                         1,
                         'UV21',
                         'specified group "invalid-unit-test" does not exist.',
                         '/user/update/',
                         form_data={
                             'username': '******',
                             'group_name': 'invalid-unit-test'
                         })

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'request contained a bad parameter "condor_central_manager".',
        '/user/update/',
        form_data={
            'username': '******',
            'condor_central_manager': 'invalid-unit-test'
        })

    execute_csv2_request(
        gvar,
        1,
        'UV21',
        'user update, "{}" failed - group "{}" was specified twice.'.format(
            ut_id(gvar, 'utu6'), ut_id(gvar, 'utg1')),
        '/user/update/',
        form_data={
            'username': ut_id(gvar, 'utu6'),
            'group_name.1': ut_id(gvar, 'utg1'),
            'group_name.2': ut_id(gvar, 'utg1')
        })

    execute_csv2_request(
        gvar,
        1,
        'UV20',
        'common name "{0}" conflicts with registered user "{0}".'.format(
            ut_id(gvar, 'utu3')),
        '/user/update/',
        form_data={
            'username': ut_id(gvar, 'utu6'),
            'cert_cn': ut_id(gvar, 'utu3')
        })

    execute_csv2_request(
        gvar,
        1,
        'UV20',
        'common name "{}" conflicts with registered user "{}".'.format(
            ut_id(gvar, 'user test user three'), ut_id(gvar, 'utu3')),
        '/user/update/',
        form_data={
            'username': ut_id(gvar, 'utu6'),
            'cert_cn': ut_id(gvar, 'user test user three')
        })

    execute_csv2_request(
        gvar,
        1,
        'UV19',
        'value specified for "group_option" must be one of the following options: [\'add\', \'delete\'].',
        '/user/update/',
        form_data={
            'username': ut_id(gvar, 'utu6'),
            'group_option': 'invalid-unit-test'
        })

    execute_csv2_request(gvar,
                         1,
                         'UV23',
                         'must specify at least one field to update.',
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_option': 'add'
                         })

    execute_csv2_request(gvar,
                         1,
                         'UV23',
                         'must specify at least one field to update.',
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_option': 'delete'
                         })

    execute_csv2_request(gvar,
                         1,
                         'UV21',
                         'specified group "invalid-unit-test" does not exist.',
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_option': 'add',
                             'group_name': 'invalid-unit-test'
                         })

    execute_csv2_request(gvar,
                         1,
                         'UV21',
                         'specified group "invalid-unit-test" does not exist.',
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_option': 'delete',
                             'group_name': 'invalid-unit-test'
                         })

    execute_csv2_request(gvar,
                         1,
                         'UV21',
                         'specified group "invalid-unit-test" does not exist.',
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_name.2': 'invalid-unit-test'
                         })

    execute_csv2_request(gvar,
                         1,
                         'UV21',
                         'specified group "invalid-unit-test" does not exist.',
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_name.2': 'invalid-unit-test',
                             'group_option': 'add'
                         })

    execute_csv2_request(gvar,
                         1,
                         'UV21',
                         'specified group "invalid-unit-test" does not exist.',
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_name.2': 'invalid-unit-test',
                             'group_option': 'delete'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'cert_cn': ut_id(gvar, 'user-test-user-six')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'cert_cn': ut_id(gvar, 'user-test-user-six')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': None,
                             'cert_cn': ut_id(gvar, 'user-test-user-six')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name': ut_id(gvar, 'utg1')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': ut_id(gvar, 'utg1')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_name.2': ut_id(gvar, 'utg2')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': ut_id(gvar, 'utg1,utg2')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_option': 'delete'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': ut_id(gvar, 'utg2')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_option': 'add'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': ut_id(gvar, 'utg1,utg2')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_name.2': ut_id(gvar, 'utg2'),
                             'group_option': 'delete'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': None
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_name.2': ut_id(gvar, 'utg2'),
                             'group_option': 'add'
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': ut_id(gvar, 'utg1,utg2')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1')
                         },
                         html=True)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': ut_id(gvar, 'utg1')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name.1': ut_id(gvar, 'utg1'),
                             'group_name.2': ut_id(gvar, 'utg2')
                         },
                         html=True)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': ut_id(gvar, 'utg1,utg2')
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu6')),
                         '/user/update/',
                         form_data={
                             'username': ut_id(gvar, 'utu6'),
                             'group_name': ''
                         },
                         html=True)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/user/list/',
                         list='user_list',
                         filter={'username': ut_id(gvar, 'utu6')},
                         values={
                             'username': ut_id(gvar, 'utu6'),
                             'user_groups': None
                         })
コード例 #23
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/user/delete/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/user/delete/',
                         server_user=ut_id(gvar, 'utu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'UV12',
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'utu2')),
                         '/user/delete/',
                         server_user=ut_id(gvar, 'utu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 403, forbidden.',
                         '/user/delete/',
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar, 1, 'UV11', 'invalid method "GET" specified.',
                         '/user/delete/')

    execute_csv2_request(gvar,
                         1,
                         'UV07',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/user/delete/',
                         form_data={'group': 'invalid-unit-test'})

    execute_csv2_request(gvar,
                         1,
                         'UV07',
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'utg2')),
                         '/user/delete/',
                         form_data={'group': ut_id(gvar, 'utg2')})

    execute_csv2_request(
        gvar,
        1,
        'UV08',
        'request contained superfluous parameter "invalid-unit-test".',
        '/user/delete/',
        form_data={'invalid-unit-test': 'invalid-unit-test'})

    execute_csv2_request(
        gvar,
        1,
        'UV08',
        'value specified for "username" must be all lower case.',
        '/user/delete/',
        form_data={'username': '******'})

    execute_csv2_request(gvar,
                         1,
                         'UV08',
                         'request contained superfluous parameter "password".',
                         '/user/delete/',
                         form_data={'password': '******'})

    execute_csv2_request(
        gvar,
        1,
        'UV08',
        'request did not contain mandatory parameter "username".',
        '/user/delete/',
        form_data={'group': ut_id(gvar, 'utg1')},
        server_user=ut_id(gvar, 'utu4'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'UV10',
                         'the request did not match any rows.',
                         '/user/delete/',
                         form_data={'username': '******'})

    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully deleted.'.format(
                             ut_id(gvar, 'utu5')),
                         '/user/delete/',
                         form_data={'username': ut_id(gvar, 'utu5')})
コード例 #24
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test, Active User: {}'.format(ut_id(gvar, '')[:-1]),
        ['cloudscheduler', 'metadata', 'group-defaults'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'metadata', 'group-defaults', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: group-name', [
            'cloudscheduler', 'metadata', 'group-defaults', '-gn',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        [
            'cloudscheduler', 'metadata', 'group-defaults', '-s',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'metadata', 'group-defaults', '-s', 'unit-test-un'])

    execute_csv2_command(
        gvar, 0, None,
        'Help requested for "cloudscheduler metadata group-defaults".',
        ['cloudscheduler', 'metadata', 'group-defaults', '-h'])

    execute_csv2_command(
        gvar, 0, None, 'General Commands Manual',
        ['cloudscheduler', 'metadata', 'group-defaults', '-H'])

    execute_csv2_command(
        gvar, 0, None, 'Expose API requested',
        ['cloudscheduler', 'metadata', 'group-defaults', '-xA'])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".', [
            'cloudscheduler', 'metadata', 'group-defaults', '-g',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'Server: unit-test, Active User: {}, Active Group: {}'.format(
            ut_id(gvar, '')[:-1], ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'metadata', 'group-defaults', '-g',
                ut_id(gvar, 'clg1')
            ])

    execute_csv2_command(
        gvar, 1, 'GV07',
        'value specified for "job_cpus" must be an integer value.', [
            'cloudscheduler', 'metadata', 'group-defaults', '-jc',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'GV07',
        'value specified for "job_disk" must be an integer value.', [
            'cloudscheduler', 'metadata', 'group-defaults', '-jd',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-jed\', \'invalid-unit-test\']',
        [
            'cloudscheduler', 'metadata', 'group-defaults', '-jed',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'GV07',
        'value specified for "job_ram" must be an integer value.', [
            'cloudscheduler', 'metadata', 'group-defaults', '-jr',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'GV07',
        'value specified for "job_swap" must be an integer value.', [
            'cloudscheduler', 'metadata', 'group-defaults', '-js',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'GV07',
        'value specified for "vm_keep_alive" must be an integer value.', [
            'cloudscheduler', 'metadata', 'group-defaults', '-vka',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'group defaults "{}" successfully updated.'.format(ut_id(gvar,
                                                                 'clg1')),
        [
            'cloudscheduler', 'metadata', 'group-defaults', '-jc', '1', '-jd',
            '1', '-jr', '1', '-js', '1', '-vka', '1', '-vi', '', '-vk', '',
            '-vf', '', '-vn', ''
        ])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'metadata', 'group-defaults', '-ok'],
        list='Active Group Defaults',
        columns=['Group'])

    execute_csv2_command(
        gvar, 0, None,
        'group defaults, table #1 columns: keys=group_name, columns=',
        ['cloudscheduler', 'metadata', 'group-defaults', '-VC'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'metadata', 'group-defaults', '-NV'],
        list='Active Group Defaults',
        columns=[
            'VM', 'Job', 'Group', 'Flavor', 'Image', 'Keep Alive', 'Cores',
            'Disk (GBs)', 'RAM (MBs)', 'Swap (GBs)'
        ])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, [
            'cloudscheduler', 'metadata', 'group-defaults', '-V',
            'job_ram,vm_keep_alive'
        ],
        list='Active Group Defaults',
        columns=['VM', 'Job', 'Group', 'Keep Alive', 'RAM (MBs)'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'metadata', 'group-defaults'],
        list='Active Group Defaults',
        columns=['VM', 'Job', 'Group', 'Keep Alive', 'RAM (MBs)'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'metadata', 'group-defaults', '-r'],
        list='Active Group Defaults',
        columns=['Key', 'Value'])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'metadata', 'group-defaults', '-V', ''],
        list='Active Group Defaults',
        columns=[
            'VM', 'Job', 'Group', 'Flavor', 'Image', 'Keep Alive', 'Cores',
            'Disk (GBs)', 'RAM (MBs)', 'Swap (GBs)'
        ])
コード例 #25
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    group_requests_cleanup.main(gvar)

    # unprivileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu1')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu1'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user one'.format(ut_id(gvar, 'group'))
                         })

    # privileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu2')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu2'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user two'.format(ut_id(gvar, 'group')),
                             'is_superuser':
                             1
                         })

    # group to be changed in group_update
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'condor_central_manager':
                             'unit-test-group-four.ca'
                         })

    # group to be changed in group_yaml_*
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg5'),
                             'condor_central_manager':
                             'unit-test-group-five.ca',
                         })

    # group to be deleted in group_delete
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg6')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg6'),
                             'condor_central_manager':
                             'unit-test-group-six.ca',
                         })

    # group with no users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg7')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg7'),
                             'condor_central_manager':
                             'unit-test-group-seven.ca',
                         })

    # unprivileged user in groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu3')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu3'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user three'.format(ut_id(gvar, 'group')),
                             'group_name.1':
                             ut_id(gvar, 'gtg4'),
                             'group_name.2':
                             ut_id(gvar, 'gtg5')
                         })

    # privileged user in group gtg5,6
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu5')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu5'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'is_superuser':
                             1,
                             'cert_cn':
                             '{} test user five'.format(ut_id(gvar, 'group')),
                             'group_name.1':
                             ut_id(gvar, 'gtg4'),
                             'group_name.2':
                             ut_id(gvar, 'gtg5'),
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty4')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty4'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty5')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty5'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty5.yaml')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty5.yaml'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    # metadata to be deleted in a cloud exception
    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty6')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty6'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    # unprivileged user to be added to groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu4')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu4'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user four'.format(ut_id(gvar, 'group'))
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gtc1')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'cloud_name': ut_id(gvar, 'gtc1'),
                             'authurl': 'group-test-cloud-one.ca',
                             'project': 'group-test-cloud-one',
                             'username': ut_id(gvar, 'gtu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'gtc1-r'),
                             'cloud_type': 'local',
                             'metadata_name': ut_id(gvar, 'gty6')
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)
コード例 #26
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    
    execute_csv2_request(
        gvar, 2, None, 'HTTP response code 401, unauthorized.',
        '/cloud/update/',
        server_user='******', server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, None, 'user "{}" is not a member of any group.'.format(ut_id(gvar, 'ctu1')),
        '/cloud/update/',
        server_user=ut_id(gvar, 'ctu1'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, None, 'user "{}" is not a member of any group.'.format(ut_id(gvar, 'ctu2')),
        '/cloud/update/',
        server_user=ut_id(gvar, 'ctu2'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV37', 'invalid method "GET" specified.',
        '/cloud/update/',
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'cloud update request did not contain mandatory parameter "cloud_name".',
        '/cloud/update/', form_data={'cloud_type': 'local'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'cloud update request contained a bad parameter "invalid-unit-test".',
        '/cloud/update/', form_data={'cloud_name': 'invalid-unit-test', 'invalid-unit-test': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV34', 'cannot switch to invalid group "invalid-unit-test".',
        '/cloud/update/', form_data={'cloud_name': 'invalid-unit-test', 'group': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV34', 'cannot switch to invalid group "{}".'.format(ut_id(gvar, 'ctg2')),
        '/cloud/update/', form_data={'cloud_name': 'invalid-unit-test', 'group': ut_id(gvar, 'ctg2')},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/update/', form_data={'cloud_name': 'Invalid-Unit-Test', 'group': ut_id(gvar, 'ctg1')},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/update/', form_data={'cloud_name': 'invalid-unit-test-', 'group': ut_id(gvar, 'ctg1')},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/update/', form_data={'cloud_name': 'invalid-unit-test!', 'group': ut_id(gvar, 'ctg1')},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/update/', form_data={'cloud_name': 'invalid-unit-test!', 'group': ut_id(gvar, 'ctg1')},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "cloud_type" must be one of the following options: [\'amazon\', \'azure\', \'google\', \'local\', \'opennebula\', \'openstack\'].',
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'cloud_type': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'boolean value specified for "enabled" must be one of the following: true, false, yes, no, 1, or 0.',
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'enabled': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "vm_keep_alive" must be an integer value.',
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'vm_keep_alive': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "spot_price" must be an integer value.',
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'spot_price': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV03', 'cloud update, "{}" failed - specified metadata_name "invalid-unit-test" does not exist.'.format(ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'metadata_name': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'value specified for "metadata_option" must be one of the following options: [\'add\', \'delete\'].',
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'metadata_option': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV23', 'cloud update must specify at least one field to update',
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'metadata_option': 'add'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV23', 'cloud update must specify at least one field to update',
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'metadata_option': 'delete'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV03', 'cloud update, "{}" failed - specified metadata_name "invalid-unit-test" does not exist.'.format(ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'metadata_name': 'invalid-unit-test', 'metadata_option': 'add'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV03', 'cloud update, "{}" failed - specified metadata_name "invalid-unit-test" does not exist.'.format(ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={'cloud_name': ut_id(gvar, 'ctc3'), 'group': ut_id(gvar, 'ctg1'), 'metadata_name': 'invalid-unit-test', 'metadata_option': 'delete'},
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'parameter "authurl" contains an empty string which is specifically disallowed.',
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'authurl': '',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'parameter "project" contains an empty string which is specifically disallowed.',
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'project': '',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'parameter "username" contains an empty string which is specifically disallowed.',
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'username': '',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'parameter "password" contains an empty string which is specifically disallowed.',
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'password': '',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV35', 'parameter "region" contains an empty string which is specifically disallowed.',
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'region': '',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/list/', form_data={'group': ut_id(gvar, 'ctg1')},
        list='cloud_list', filter={'cloud_name': ut_id(gvar, 'ctc3')},
        values={
            'user_domain_name': 'Default',
            'project': 'unit-test-cloud-three',
            'vm_image': '',
            'username': ut_id(gvar, 'ctu3'),
            'cores_ctl': -1,
            'vm_flavor': '',
            'vm_keep_alive': 0,
            'vm_keyname': None,
            'vm_network': '',
            'group_exclusions': None,
            'cloud_type': 'local',
            'spot_price': None,
            'authurl': 'unit-test-cloud-three.ca',
            'cloud_name': ut_id(gvar, 'ctc3'),
            'project_domain_name': 'Default',
            'cacertificate': None,
            'ram_ctl': -1,
            'group_name': ut_id(gvar, 'ctg1'),
            'enabled': 1,
            'region': ut_id(gvar, 'ctc3-r')
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully updated.'.format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'authurl': 'updated-value',
            'project': 'updated-value',
            'username': '******',
            'password': '******',
            'cacertificate': 'updated-value',
            'region': 'updated-value',
            'user_domain_name': 'updated-value',
            'project_domain_name': 'updated-value',
            'cloud_type': 'local',
            'ram_ctl': 5,
            'cores_ctl': 5,
            'enabled': 0,
            'vm_flavor': '',
            'vm_image': '',
            'vm_keep_alive': 10,
            'vm_keyname': '',
            'vm_network': '',
            'spot_price': 1,
            'metadata_name': ut_id(gvar, 'cty1')
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/list/', form_data={'group': ut_id(gvar, 'ctg1')},
        list='cloud_list', filter={'cloud_name': ut_id(gvar, 'ctc3')},
        values={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group_name': ut_id(gvar, 'ctg1'),
            'authurl': 'updated-value',
            'project': 'updated-value',
            'username': '******',
            'cacertificate': 'updated-value',
            'region': 'updated-value',
            'user_domain_name': 'updated-value',
            'project_domain_name': 'updated-value',
            'cloud_type': 'local',
            'enabled': 0,
            'vm_keep_alive': 10,
            'vm_flavor': '',
            'vm_image': '',
            'vm_keyname': '',
            'vm_network': '',
            'spot_price': 1,
            'group_exclusions': ut_id(gvar, 'cty1')
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully updated.'.format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'metadata_name': ut_id(gvar, 'cty1'),
            'metadata_option': 'delete'
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/list/', form_data={'group': ut_id(gvar, 'ctg1')},
        list='cloud_list', filter={'cloud_name': ut_id(gvar, 'ctc3')},
        values={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group_name': ut_id(gvar, 'ctg1'),
            'group_exclusions': None
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )
    
    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully updated.'.format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'metadata_name.1': ut_id(gvar, 'cty1'),
            'metadata_name.2': ut_id(gvar, 'cty2'),
            'metadata_name.3': ut_id(gvar, 'cty3')
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/list/', form_data={'group': ut_id(gvar, 'ctg1')},
        list='cloud_list', filter={'cloud_name': ut_id(gvar, 'ctc3')},
        values={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group_name': ut_id(gvar, 'ctg1'),
            'group_exclusions': ut_id(gvar, 'cty1,cty2,cty3')
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully updated.'.format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'metadata_name.1': ut_id(gvar, 'cty1'),
            'metadata_name.2': ut_id(gvar, 'cty2'),
            'metadata_name.3': ut_id(gvar, 'cty3'),
            'metadata_option': 'delete'
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/list/', form_data={'group': ut_id(gvar, 'ctg1')},
        list='cloud_list', filter={'cloud_name': ut_id(gvar, 'ctc3')},
        values={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group_name': ut_id(gvar, 'ctg1'),
            'group_exclusions': None
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully updated.'.format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'metadata_name': ut_id(gvar, 'cty3'),
            'metadata_option': 'add'
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/list/', form_data={'group': ut_id(gvar, 'ctg1')},
        list='cloud_list', filter={'cloud_name': ut_id(gvar, 'ctc3')},
        values={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group_name': ut_id(gvar, 'ctg1'),
            'group_exclusions': ut_id(gvar, 'cty3')
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully updated.'.format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'metadata_name.1': ut_id(gvar, 'cty2'),
            'metadata_name.2': ut_id(gvar, 'cty1'),
            'metadata_option': 'add'
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 0, None, None,
        '/cloud/list/', form_data={'group': ut_id(gvar, 'ctg1')},
        list='cloud_list', filter={'cloud_name': ut_id(gvar, 'ctc3')},
        values={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group_name': ut_id(gvar, 'ctg1'),
            'group_exclusions': ut_id(gvar, 'cty1,cty2,cty3')
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV99', 'cloud update, "{0}" failed - specified item does not exist: vm_image=invalid-unit-test, group_name={1}, cloud_name={0}.'.format(ut_id(gvar, 'ctc3'), ut_id(gvar, 'ctg1')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'vm_image': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV98', 'cloud update, "{0}" failed - specified item does not exist: vm_flavor=invalid-unit-test, group_name={1}, cloud_name={0}.'.format(ut_id(gvar, 'ctc3'), ut_id(gvar, 'ctg1')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'vm_flavor': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV94', 'cloud update, "{0}" failed - specified item does not exist: vm_network=invalid-unit-test, group_name={1}, cloud_name={0}.'.format(ut_id(gvar, 'ctc3'), ut_id(gvar, 'ctg1')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'vm_network': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )

    execute_csv2_request(
        gvar, 1, 'CV94', 'cloud update, "{0}" failed - specified item does not exist: vm_keyname=invalid-unit-test, group_name={1}, cloud_name={0}.'.format(ut_id(gvar, 'ctc3'), ut_id(gvar, 'ctg1')),
        '/cloud/update/', form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'group': ut_id(gvar, 'ctg1'),
            'vm_keyname': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'), server_pw=user_secret
    )
コード例 #27
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    # set profile
    execute_csv2_command(
        gvar, 1, None, 'You are not authorized to access object "user";',
        ['cloudscheduler', 'user', 'list', '-s', 'unit-test-un'])

    # set profile
    execute_csv2_command(gvar, 0, None, None,
                         ['cloudscheduler', 'user', 'list', '-s', 'unit-test'])

    execute_csv2_command(gvar, 1, None,
                         'No action specified for object "user"',
                         ['cloudscheduler', 'user'])

    execute_csv2_command(
        gvar, 1, None, 'Invalid action "invalid-unit-test" for object "user"',
        ['cloudscheduler', 'user', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'user', '-s', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'No action specified for object "user"; use -h or -H for help.',
        ['cloudscheduler', 'user', '-s', 'unit-test'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler user".',
                         ['cloudscheduler', 'user', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'user', '-H'])

    #### ADD ####
    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'add'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized',
        ['cloudscheduler', 'user', 'add', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: group-option',
        ['cloudscheduler', 'user', 'add', '-go', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'user', 'add', '-s', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'add', '-s', 'unit-test'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler user add".',
                         ['cloudscheduler', 'user', 'add', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'user', 'add', '-H'])

    execute_csv2_command(gvar, 1, None, 'Expose API requested',
                         ['cloudscheduler', 'user', 'add', '-xA'])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'cli-invalid-unit-test')
        ])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'add', '-ucn', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'add', '-upw', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, 'UV01',
        'value specified for a password is less than 6 characters.', [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'cli-invalid-unit-test'), '-upw', 'test', '-ucn',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV01',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'cli-invalid-unit-test'), '-upw', 'invalid', '-ucn',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV01',
        'value specified for "username" must be all lower case.', [
            'cloudscheduler', 'user', 'add', '-un', 'Invalid-Unit-Test',
            '-upw', 'invalid-unit-test', '-ucn', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV03', 'specified group "invalid-unit-test" does not exist.',
        [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'cli-invalid-unit-test'), '-upw', 'invalid-unit-test',
            '-ucn', 'invalid-unit-test', '-gn', 'invalid-unit-test'
        ])

    execute_csv2_command(gvar, 1, 'UV04',
                         r'Data too long for column \'username\' at row 1', [
                             'cloudscheduler', 'user', 'add', '-un',
                             'thisisausernametoolongtoinsertint', '-upw',
                             'invalid-unit-test', '-ucn', 'invalid-unit-test'
                         ])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".', [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'cli-invalid-unit-test'), '-upw', 'invalid-unit-test',
            '-ucn', 'invalid-unit-test', '-g', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV02',
        'username "{}" unavailable.'.format(ut_id(gvar, 'clu1')), [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'clu1'), '-upw', 'invalid-unit-test', '-ucn',
            'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV02', 'username "{}" unavailable.'.format(
            ut_id(gvar, 'command line user one')), [
                'cloudscheduler', 'user', 'add', '-un',
                ut_id(gvar, 'command line user one'), '-upw',
                'invalid-unit-test', '-ucn', 'invalid-unit-test'
            ])

    execute_csv2_command(
        gvar, 1, 'UV02',
        'common name "{0}" conflicts with registered user "{0}".'.format(
            ut_id(gvar, 'clu1')), [
                'cloudscheduler', 'user', 'add', '-un',
                ut_id(gvar, 'cli-invalid-unit-test'), '-upw',
                'invalid-unit-test', '-ucn',
                ut_id(gvar, 'clu1')
            ])

    execute_csv2_command(
        gvar, 1, 'UV02',
        'common name "{}" conflicts with registered user "{}".'.format(
            ut_id(gvar, 'command line user one'), ut_id(gvar, 'clu1')), [
                'cloudscheduler', 'user', 'add', '-un',
                ut_id(gvar, 'cli-invalid-unit-test'), '-upw',
                'invalid-unit-test', '-ucn',
                ut_id(gvar, 'command line user one')
            ])

    execute_csv2_command(
        gvar, 1, 'UV03',
        'user add, "{}" failed - group "{}" was specified twice.'.format(
            ut_id(gvar, 'cli-invalid-unit-test'), ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'user', 'add', '-un',
                ut_id(gvar, 'cli-invalid-unit-test'), '-upw',
                'invalid-unit-test', '-ucn', 'invalid-unit-test', '-gn',
                ut_id(gvar, 'clg1,clg1')
            ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully added.'.format(ut_id(gvar, 'clu10')), [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'clu10'), '-upw', user_secret, '-ucn',
            ut_id(gvar, 'command line user 10')
        ])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-SU\']', [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'clu11'), '-upw', user_secret, '-ucn',
            ut_id(gvar, 'command line user 11'), '-SU'
        ])

    execute_csv2_command(
        gvar, 1, 'UV01',
        'boolean value specified for "is_superuser" must be one of the following: true, false, yes, no, 1, or 0.',
        [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'clu11'), '-upw', user_secret, '-ucn',
            ut_id(gvar, 'command line user 11'), '-SU', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully added.'.format(ut_id(gvar, 'clu11')), [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'clu11'), '-upw', user_secret, '-ucn',
            ut_id(gvar, 'command line user 11'), '-SU', 'true'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully added.'.format(ut_id(gvar, 'clu12')), [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'clu12'), '-upw', user_secret, '-ucn',
            ut_id(gvar, 'command line user 12'), '-gn',
            ut_id(gvar, 'clg1')
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully added.'.format(ut_id(gvar, 'clu13')), [
            'cloudscheduler', 'user', 'add', '-un',
            ut_id(gvar, 'clu13'), '-upw', user_secret, '-ucn',
            ut_id(gvar, 'command line user 13'), '-gn',
            ut_id(gvar, 'clg1,clg2')
        ])

    #### DELETE ####
    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'delete'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'user', 'delete', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: group-option',
        ['cloudscheduler', 'user', 'delete', '-go', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'user', 'delete', '-s', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'delete', '-s', 'unit-test'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler user delete".',
                         ['cloudscheduler', 'user', 'delete', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'user', 'delete', '-H'])

    execute_csv2_command(gvar, 1, None, 'Expose API requested',
                         ['cloudscheduler', 'user', 'delete', '-xA'])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".',
        ['cloudscheduler', 'user', 'delete', '-g', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-un\']',
        ['cloudscheduler', 'user', 'delete', '-un'])

    execute_csv2_command(
        gvar, 1, None,
        r'cannot delete "invalid-unit-test", user doesn\'t exist.',
        ['cloudscheduler', 'user', 'delete', '-un', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully deleted.'.format(ut_id(gvar, 'clu5')),
        ['cloudscheduler', 'user', 'delete', '-un',
         ut_id(gvar, 'clu5'), '-Y'])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully deleted.'.format(ut_id(gvar, 'clu6')),
        ['cloudscheduler', 'user', 'delete', '-un',
         ut_id(gvar, 'clu6'), '-Y'])

    #### LIST ####
    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".',
        ['cloudscheduler', 'user', 'list', '-g', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'user', 'list', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: group-option',
        ['cloudscheduler', 'user', 'list', '-go', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'user', 'list', '-s', 'invalid-unit-test'])

    execute_csv2_command(gvar, 0, None, None,
                         ['cloudscheduler', 'user', 'list', '-s', 'unit-test'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler user list".',
                         ['cloudscheduler', 'user', 'list', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'user', 'list', '-H'])

    execute_csv2_command(gvar, 0, None, 'Expose API requested',
                         ['cloudscheduler', 'user', 'list', '-xA'])

    execute_csv2_command(gvar, 0, None, 'Rows: 0', [
        'cloudscheduler', 'user', 'list', '-un',
        ut_id(gvar, 'cli-invalid-unit-test')
    ])

    execute_csv2_command(
        gvar, 0, None, 'Rows: 1',
        ['cloudscheduler', 'user', 'list', '-un',
         ut_id(gvar, 'clu1')])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'user', 'list', '-ok'],
                         list='Users',
                         columns=['Username'])

    execute_csv2_command(
        gvar, 0, None,
        'user list, table #1 columns: keys=username, columns=cert_cn,active_group,user_groups,available_groups,is_superuser,join_date',
        ['cloudscheduler', 'user', 'list', '-VC'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'user', 'list', '-NV'],
                         list='Users',
                         columns=[
                             'Username', 'Common Name', 'Active Group',
                             'User Groups', 'Not In Groups', 'Super User',
                             'Joined'
                         ])

    execute_csv2_command(
        gvar,
        0,
        None,
        None, ['cloudscheduler', 'user', 'list', '-V', 'is_superuser'],
        list='Users',
        columns=['Username', 'Super User'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'user', 'list'],
                         list='Users',
                         columns=['Username', 'Super User'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'user', 'list', '-r'],
                         list='Users',
                         columns=['Key', 'Value'])

    execute_csv2_command(gvar,
                         0,
                         None,
                         None, ['cloudscheduler', 'user', 'list', '-V', ''],
                         list='Users',
                         columns=[
                             'Username', 'Common Name', 'Active Group',
                             'User Groups', 'Not In Groups', 'Super User',
                             'Joined'
                         ])

    #### UPDATE ####
    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'update'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-xx\', \'yy\']',
        ['cloudscheduler', 'user', 'update', '-xx', 'yy'])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were invalid: only-keys',
        ['cloudscheduler', 'user', 'update', '-ok'])

    execute_csv2_command(
        gvar, 1, None,
        'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'user', 'update', '-s', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        'the following mandatory parameters must be specfied on the command line',
        ['cloudscheduler', 'user', 'update', '-s', 'unit-test'])

    execute_csv2_command(gvar, 0, None,
                         'Help requested for "cloudscheduler user update".',
                         ['cloudscheduler', 'user', 'update', '-h'])

    execute_csv2_command(gvar, 0, None, 'General Commands Manual',
                         ['cloudscheduler', 'user', 'update', '-H'])

    execute_csv2_command(gvar, 1, None, 'Expose API requested',
                         ['cloudscheduler', 'user', 'update', '-xA'])

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".',
        ['cloudscheduler', 'user', 'update', '-g', 'invalid-unit-test'])

    execute_csv2_command(
        gvar, 1, None,
        '"cloudscheduler user update" requires at least one option to update.',
        ['cloudscheduler', 'user', 'update', '-un', 'invalid-unit-test'])

    execute_csv2_command(gvar, 1, 'UV22',
                         'the request did not match any rows.', [
                             'cloudscheduler', 'user', 'update', '-un',
                             'invalid-unit-test', '-SU', 'yes'
                         ])

    execute_csv2_command(
        gvar, 1, None,
        '"cloudscheduler user update" requires at least one option to update.',
        ['cloudscheduler', 'user', 'update', '-un',
         ut_id(gvar, 'clu7')])

    execute_csv2_command(
        gvar, 1, 'UV19',
        'value specified for a password is less than 6 characters.', [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-upw', 'test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV19',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-upw', 'invalid'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-ucn', ''
        ])

    execute_csv2_command(
        gvar, 1, 'UV20',
        'common name "{0}" conflicts with registered user "{0}".'.format(
            ut_id(gvar, 'clu1')), [
                'cloudscheduler', 'user', 'update', '-un',
                ut_id(gvar, 'clu7'), '-ucn',
                ut_id(gvar, 'clu1')
            ])

    execute_csv2_command(
        gvar, 1, 'UV20',
        'common name "{}" conflicts with registered user "{}".'.format(
            ut_id(gvar, 'command line user one'), ut_id(gvar, 'clu1')), [
                'cloudscheduler', 'user', 'update', '-un',
                ut_id(gvar, 'clu7'), '-ucn',
                ut_id(gvar, 'command line user one')
            ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-ucn',
            ut_id(gvar, 'command line user update')
        ])

    execute_csv2_command(
        gvar, 1, None,
        'The following command line arguments were unrecognized: [\'-SU\']', [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-SU'
        ])

    execute_csv2_command(
        gvar, 1, 'UV19',
        'boolean value specified for "is_superuser" must be one of the following: true, false, yes, no, 1, or 0.',
        [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-SU', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-SU', 'yes'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-SU', 'false'
        ])

    execute_csv2_command(
        gvar, 1, 'UV19',
        r'value specified for "group_option" must be one of the following options: [\'add\', \'delete\'].',
        [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-go', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV23',
        'user update must specify at least one field to update.', [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-go', 'add'
        ])

    execute_csv2_command(
        gvar, 1, 'UV23',
        'user update must specify at least one field to update.', [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-go', 'delete'
        ])

    # TODO: is this expected?
    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn', ''
        ])

    execute_csv2_command(
        gvar, 1, 'UV21', 'specified group "invalid-unit-test" does not exist.',
        [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn', 'invalid-unit-test'
        ])

    execute_csv2_command(
        gvar, 1, 'UV21',
        'user update, "{}" failed - group "{}" was specified twice.'.format(
            ut_id(gvar, 'clu7'), ut_id(gvar, 'clg1')), [
                'cloudscheduler', 'user', 'update', '-un',
                ut_id(gvar, 'clu7'), '-gn',
                ut_id(gvar, 'clg1,clg1')
            ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg1')
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg1'), '-go', 'delete'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg1'), '-go', 'add'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg2'), '-go', 'add'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg1,clg2'), '-go', 'delete'
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg1,clg2')
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg1')
        ])

    execute_csv2_command(
        gvar, 0, None,
        'user "{}" successfully updated.'.format(ut_id(gvar, 'clu7')), [
            'cloudscheduler', 'user', 'update', '-un',
            ut_id(gvar, 'clu7'), '-gn',
            ut_id(gvar, 'clg1'), '-go', 'add'
        ])
コード例 #28
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    cloud_requests_cleanup.main(gvar)

    # unprivileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu1')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu1'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user one'.format(ut_id(gvar, 'cloud'))
                         })

    # privileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu2')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu2'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user two'.format(ut_id(gvar, 'cloud')),
                             'is_superuser':
                             1
                         })

    # group with users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'ctg1'),
                             'condor_central_manager': 'unit-test-group-one.ca'
                         })

    # group without users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'ctg2')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'ctg2'),
                             'condor_central_manager': 'unit-test-group-two.ca'
                         })

    # unprivileged user in ctg1
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu3')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu3'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user three'.format(ut_id(gvar, 'cloud')),
                             'group_name.1':
                             ut_id(gvar, 'ctg1')
                         })

    # privileged user in ctg1
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu4')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu4'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user four'.format(ut_id(gvar, 'cloud')),
                             'is_superuser':
                             1,
                             'group_name.1':
                             ut_id(gvar, 'ctg1')
                         })

    # cloud to be deleted in test_cloud_delete
    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc1')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc1'),
                             'authurl': 'unit-test-cloud-one.ca',
                             'project': 'unit-test-cloud-one',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc1-r'),
                             'cloud_type': 'local'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # cloud to be listed in test_cloud_list
    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc2')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc2'),
                             'authurl': 'unit-test-cloud-two.ca',
                             'project': 'unit-test-cloud-two',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc2-r'),
                             'cloud_type': 'local'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # cloud to be changed in test_cloud_update, test_cloud_metadata_add, test_cloud_metadata_delete
    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc3'),
                             'authurl': 'unit-test-cloud-three.ca',
                             'project': 'unit-test-cloud-three',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc3-r'),
                             'cloud_type': 'local'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # metadata to be deleted in test_cloud_metadata_delete
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar, 'cty2')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty2'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    # metadata to be updated in test_cloud_metadata_update
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar, 'cty3')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty3'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    # metadata to be updated in test_cloud_metadata_update
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar,
                                                            'cty3.yaml')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty3.yaml'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    # metadata to be fetched in test_cloud_metadata_fetch and test_cloud_metadata_list
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc2'), ut_id(gvar, 'cty1')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc2'),
            'metadata_name': ut_id(gvar, 'cty1'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'cty1')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'metadata_name': ut_id(gvar, 'cty1'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # group metadata for metadata exceptions in test_cloud_add and test_cloud_update
    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'cty2')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'metadata_name': ut_id(gvar, 'cty2'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'cty3')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'metadata_name': ut_id(gvar, 'cty3'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)
コード例 #29
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/cloud/add/',
                         server_user='******',
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu1')),
                         '/cloud/add/',
                         server_user=ut_id(gvar, 'ctu1'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         None,
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'ctu2')),
                         '/cloud/add/',
                         server_user=ut_id(gvar, 'ctu2'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV03',
                         'invalid method "GET" specified.',
                         '/cloud/add/',
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'cloud add request did not contain mandatory parameter "cloud_name".',
        '/cloud/add/',
        form_data={'group': ut_id(gvar, 'ctg1')},
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'cloud add request contained a bad parameter "invalid-unit-test".',
        '/cloud/add/',
        form_data={
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'invalid-unit-test': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV00',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/cloud/add/',
                         form_data={
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'group': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV00',
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'ctg2')),
                         '/cloud/add/',
                         form_data={
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'group': ut_id(gvar, 'ctg2')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/add/',
        form_data={
            'cloud_name': 'Invalid-Unit-Test',
            'group': ut_id(gvar, 'ctg1')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/add/',
        form_data={
            'cloud_name': 'invalid-unit-test-',
            'group': ut_id(gvar, 'ctg1')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/add/',
        form_data={
            'cloud_name': 'invalid-unit-test!',
            'group': ut_id(gvar, 'ctg1')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV02',
        '"{}::{}" failed - (1364, "Field \'authurl\' doesn\'t have a default value").'
        .format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test')
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV02',
        '"{}::{}" failed - (1364, "Field \'project\' doesn\'t have a default value").'
        .format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV02',
        '"{}::{}" failed - (1364, "Field \'username\' doesn\'t have a default value").'
        .format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV02',
        '"{}::{}" failed - (1364, "Field \'password\' doesn\'t have a default value").'
        .format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV02',
        '"{}::{}" failed - (1364, "Field \'region\' doesn\'t have a default value").'
        .format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV02',
        '"{}::{}" failed - (1364, "Field \'cloud_type\' doesn\'t have a default value").'
        .format(ut_id(gvar, 'ctg1'), ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "cloud_type" must be one of the following options: [\'amazon\', \'azure\', \'google\', \'local\', \'opennebula\', \'openstack\'].',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "cloud_name" must be all lower case, numeric digits, and dashes but cannot start or end with dashes.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': '',
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'cloud add parameter "authurl" contains an empty string which is specifically disallowed.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': '',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'cloud add parameter "project" contains an empty string which is specifically disallowed.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': '',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'cloud add parameter "username" contains an empty string which is specifically disallowed.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'cloud add parameter "password" contains an empty string which is specifically disallowed.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'cloud add parameter "region" contains an empty string which is specifically disallowed.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': '',
            'cloud_type': 'local',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "server_meta_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'server_meta_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "instances_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'instances_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "personality_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'personality_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "image_meta_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'image_meta_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "personality_size_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'personality_size_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "ram_ctl" must be an integer value.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'ram_ctl': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "server_groups_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'server_groups_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "security_group_rules_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'security_group_rules_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "keypairs_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'keypairs_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "security_groups_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'security_groups_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "server_group_members_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'server_group_members_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV01',
                         'bad parameter "floating_ips_ctl"',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar,
                                                 'cloud-invalid-unit-test'),
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local',
                             'floating_ips_ctl': 'invalid-unit-test'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "cores_ctl" must be an integer value.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'cores_ctl': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "vm_keep_alive" must be an integer value.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'vm_keep_alive': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'boolean value specified for "enabled" must be one of the following: true, false, yes, no, 1, or 0.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'enabled': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         1,
                         'CV02',
                         'Data too long for column \'cloud_name\' at row 1',
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name':
                             'cloudnametoolongtobeinsertedintodb',
                             'authurl': 'invalid-unit-test',
                             'project': 'invalid-unit-test',
                             'username': '******',
                             'password': '******',
                             'region': 'invalid-unit-test',
                             'cloud_type': 'local'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV01',
        'value specified for "spot_price" must be an integer value.',
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'spot_price': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV03',
        'cloud add, "{}" failed - specified metadata_name "invalid-unit-test" does not exist.'
        .format(ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'metadata_name': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV03',
        'cloud add, "{}" failed - specified metadata_name "invalid-unit-test" does not exist.'
        .format(ut_id(gvar, 'cloud-invalid-unit-test')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'metadata_name.1': ut_id(gvar, 'cty1'),
            'metadata_name.2': 'invalid-unit-test'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV03',
        'cloud add, "{}" failed - metadata name "{}" was specified twice.'.
        format(ut_id(gvar, 'cloud-invalid-unit-test'), ut_id(gvar, 'cty1')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'cloud-invalid-unit-test'),
            'authurl': 'invalid-unit-test',
            'project': 'invalid-unit-test',
            'username': '******',
            'password': '******',
            'region': 'invalid-unit-test',
            'cloud_type': 'local',
            'metadata_name.1': ut_id(gvar, 'cty1'),
            'metadata_name.2': ut_id(gvar, 'cty1'),
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc5')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc5'),
                             'authurl': 'unit-test-cloud-five.ca',
                             'project': 'unit-test-cloud-five',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc5-r'),
                             'cloud_type': 'local',
                             'vm_flavor': '',
                             'vm_image': '',
                             'vm_keyname': '',
                             'vm_network': '',
                             'enabled': 0,
                             'vm_keep_alive': 10,
                             'metadata_name': ut_id(gvar, 'cty1'),
                             'spot_price': 10
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/cloud/list/',
                         list='cloud_list',
                         filter={'cloud_name': ut_id(gvar, 'ctc5')},
                         values={
                             'group_name': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc5'),
                             'authurl': 'unit-test-cloud-five.ca',
                             'project': 'unit-test-cloud-five',
                             'username': ut_id(gvar, 'ctu3'),
                             'region': ut_id(gvar, 'ctc5-r'),
                             'cloud_type': 'local',
                             'vm_flavor': '',
                             'vm_image': '',
                             'vm_keyname': '',
                             'vm_network': '',
                             'enabled': 0,
                             'vm_keep_alive': 10,
                             'group_exclusions': ut_id(gvar, 'cty1'),
                             'spot_price': 10
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc6')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc6'),
                             'authurl': 'unit-test-cloud-six.ca',
                             'project': 'unit-test-cloud-six',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc6-r'),
                             'cloud_type': 'local',
                             'vm_flavor': '',
                             'vm_image': '',
                             'vm_keyname': '',
                             'vm_network': '',
                             'metadata_name.1': ut_id(gvar, 'cty1'),
                             'metadata_name.2': ut_id(gvar, 'cty2'),
                             'metadata_name.3': ut_id(gvar, 'cty3')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         None,
                         '/cloud/list/',
                         list='cloud_list',
                         filter={'cloud_name': ut_id(gvar, 'ctc6')},
                         values={
                             'group_name': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc6'),
                             'group_exclusions': ut_id(gvar, 'cty1,cty2,cty3')
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV02',
        'Duplicate entry \'{}-{}\' for key \'PRIMARY\''.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc5')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'ctc5'),
            'authurl': 'unit-test-cloud-five.ca',
            'project': 'unit-test-cloud-five',
            'username': ut_id(gvar, 'ctu3'),
            'password': user_secret,
            'region': ut_id(gvar, 'ctc5-r'),
            'cloud_type': 'local'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV97',
        'cloud add, "{0}" failed - specified item does not exist: vm_image=invalid-unit-test, group_name={1}, cloud_name={0}.'
        .format(ut_id(gvar, 'invalid-unit-test'), ut_id(gvar, 'ctg1')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'invalid-unit-test'),
            'authurl': 'unit-test-cloud-seven.ca',
            'project': 'unit-test-cloud-seven',
            'username': ut_id(gvar, 'ctu3'),
            'password': user_secret,
            'region': ut_id(gvar, 'ctc7-r'),
            'cloud_type': 'local',
            'vm_image': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV96',
        'cloud add, "{0}" failed - specified item does not exist: vm_flavor=invalid-unit-test, group_name={1}, cloud_name={0}.'
        .format(ut_id(gvar, 'invalid-unit-test'), ut_id(gvar, 'ctg1')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'invalid-unit-test'),
            'authurl': 'unit-test-cloud-seven.ca',
            'project': 'unit-test-cloud-seven',
            'username': ut_id(gvar, 'ctu3'),
            'password': user_secret,
            'region': ut_id(gvar, 'ctc7-r'),
            'cloud_type': 'local',
            'vm_flavor': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV95',
        'cloud add, "{0}" failed - specified item does not exist: vm_network=invalid-unit-test, group_name={1}, cloud_name={0}.'
        .format(ut_id(gvar, 'invalid-unit-test'), ut_id(gvar, 'ctg1')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'invalid-unit-test'),
            'authurl': 'unit-test-cloud-seven.ca',
            'project': 'unit-test-cloud-seven',
            'username': ut_id(gvar, 'ctu3'),
            'password': user_secret,
            'region': ut_id(gvar, 'ctc7-r'),
            'cloud_type': 'local',
            'vm_network': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(
        gvar,
        1,
        'CV95',
        'cloud add, "{0}" failed - specified item does not exist: vm_keyname=invalid-unit-test, group_name={1}, cloud_name={0}.'
        .format(ut_id(gvar, 'invalid-unit-test'), ut_id(gvar, 'ctg1')),
        '/cloud/add/',
        form_data={
            'group': ut_id(gvar, 'ctg1'),
            'cloud_name': ut_id(gvar, 'invalid-unit-test'),
            'authurl': 'unit-test-cloud-seven.ca',
            'project': 'unit-test-cloud-seven',
            'username': ut_id(gvar, 'ctu3'),
            'password': user_secret,
            'region': ut_id(gvar, 'ctc7-r'),
            'cloud_type': 'local',
            'vm_keyname': 'invalid-unit-test',
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)
コード例 #30
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    execute_csv2_command(
        gvar, 1, None, 'The following command line arguments were unrecognized',
        ['cloudscheduler', 'group', 'list', '-xx', 'yy']
    )

    execute_csv2_command(
        gvar, 1, None, 'The following command line arguments were invalid: job-cores',
        ['cloudscheduler', 'group', 'list', '-jc', 'invalid-unit-test']
    )

    execute_csv2_command(
        gvar, 1, None, 'Error: the specified server "invalid-unit-test" does not exist in your defaults.',
        ['cloudscheduler', 'group', 'list', '-s', 'invalid-unit-test']
    )

    execute_csv2_command(
        gvar, 1, None, 'You are not authorized to access object "group";',
        ['cloudscheduler', 'group', 'list', '-s', 'unit-test-un']
    )

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'group', 'list', '-s', 'unit-test']
    )

    execute_csv2_command(
        gvar, 0, None, 'Help requested for "cloudscheduler group list".',
        ['cloudscheduler', 'group', 'list', '-h']
    )

    execute_csv2_command(
        gvar, 0, None, 'General Commands Manual',
        ['cloudscheduler', 'group', 'list', '-H']
    )

    execute_csv2_command(
        gvar, 0, None, 'Expose API requested',
        ['cloudscheduler', 'group', 'list', '-xA']
    )

    execute_csv2_command(
        gvar, 1, None, 'cannot switch to invalid group "invalid-unit-test".',
        ['cloudscheduler', 'group', 'list', '-g', 'invalid-unit-test']
    )

    execute_csv2_command(
        gvar, 0, None, 'Server: unit-test, Active User: {}, Active Group: {}'.format(ut_id(gvar, '')[:-1], ut_id(gvar, 'clg1')),
        ['cloudscheduler', 'group', 'list', '-g', ut_id(gvar, 'clg1')]
    )

    execute_csv2_command(
        gvar, 0, None, 'Server: unit-test, Active User: {}, Active Group: {}'.format(ut_id(gvar, '')[:-1], ut_id(gvar, 'clg1')),
        ['cloudscheduler', 'group', 'list']
    )

    execute_csv2_command(
        gvar, 0, None, 'Rows: 0',
        ['cloudscheduler', 'group', 'list', '-gn', 'invalid-unit-test']
    )

    execute_csv2_command(
        gvar, 0, None, 'Rows: 1',
        ['cloudscheduler', 'group', 'list', '-gn', ut_id(gvar, 'clg1')]
    )

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'group', 'list', '-ok'],
        list='Groups', columns=['Group']
    )

    execute_csv2_command(
        gvar, 0, None, 'group list, table #1 columns: keys=group_name, columns=condor_central_manager,metadata_names',
        ['cloudscheduler', 'group', 'list', '-VC']
    )

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'group', 'list', '-NV'],
        list='Groups', columns=['Group', 'Central Manager', 'Metadata Filenames']
    )

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'group', 'list', '-V', 'metadata_names'],
        list='Groups', columns=['Group', 'Metadata Filenames']
    )

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'group', 'list'],
        list='Groups', columns=['Group', 'Metadata Filenames']
    )

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'group', 'list', '-r'],
        list='Groups', columns=['Key', 'Value']
    )

    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'group', 'list', '-V', ''],
        list='Groups', columns=['Group', 'Central Manager', 'Metadata Filenames']
    )