Example #1
0
 def test_create_role(self):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org)
     role_name = self.config['vcd']['role_name']
     org.create_role(role_name, 'test description', ('Disk: View Properties',))
     role_record = org.get_role(role_name)
     assert self.config['vcd']['role_name'] == role_record.get('name')
Example #2
0
def create(ctx, user_name, password, role_name, full_name, description, email,
           telephone, im, enabled, alert_enabled, alert_email,
           alert_email_prefix, external, default_cached, group_role,
           stored_vm_quota, deployed_vm_quota):
    try:
        client = ctx.obj['client']
        in_use_org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, in_use_org_href)
        role = org.get_role(role_name)
        role_href = role.get('href')
        result = org.create_user(user_name=user_name,
                                 password=password,
                                 role_href=role_href,
                                 full_name=full_name,
                                 description=description,
                                 email=email,
                                 telephone=telephone,
                                 im=im,
                                 alert_email=alert_email,
                                 alert_email_prefix=alert_email_prefix,
                                 stored_vm_quota=stored_vm_quota,
                                 deployed_vm_quota=deployed_vm_quota,
                                 is_group_role=group_role,
                                 is_default_cached=default_cached,
                                 is_external=external,
                                 is_alert_enabled=alert_enabled,
                                 is_enabled=enabled)
        stdout('User \'%s\' is successfully created.' % result.get('name'),
               ctx)
    except Exception as e:
        stderr(e, ctx)
Example #3
0
 def test_get_rights(self):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org)
     role_name = self.config['vcd']['role_name']
     role_record = org.get_role(role_name)
     role = Role(self.client, href=role_record.get('href'))
     rights = role.list_rights()
     assert len(rights) > 0
Example #4
0
def list_rights(ctx, role_name, org_name):
    try:
        client = ctx.obj['client']
        if org_name is not None:
            org_href = client.get_org_by_name(org_name).get('href')
        else:
            org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, org_href)
        role_record = org.get_role(role_name)
        role = Role(client, href=role_record.get('href'))
        rights = role.list_rights()
        stdout(rights, ctx)
    except Exception as e:
        stderr(e, ctx)
Example #5
0
 def create_user(self, user_name, enabled=False):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org)
     role = org.get_role(self.config['vcd']['role_name'])
     role_href = role.get('href')
     return org.create_user(user_name,
                            "password",
                            role_href,
                            "Full Name",
                            "Description",
                            "*****@*****.**",
                            "408-487-9087",
                            "test_user_im",
                            "*****@*****.**",
                            "Alert Vcd:",
                            is_enabled=enabled)
Example #6
0
def link(ctx, role_name, org_name):
    try:
        client = ctx.obj['client']
        if org_name is not None:
            org_href = client.get_org_by_name(org_name).get('href')
        else:
            org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, org_href)
        role_record = org.get_role(role_name)
        role = Role(client, href=role_record.get('href'))
        role.link()
        stdout(
            'Role \'%s\' has been successfully linked to it\'s template.' %
            role_name, ctx)
    except Exception as e:
        stderr(e, ctx)
Example #7
0
 def test_create_user(self):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org, is_admin=True)
     role = org.get_role(self.config['vcd']['role_name'])
     role_href = role.get('href')
     user_name = self.config['vcd']['user_name'].join(
         random.sample(string.ascii_lowercase, 8))
     user = org.create_user(user_name,
                            "password",
                            role_href,
                            "Full Name",
                            "Description",
                            "*****@*****.**",
                            "408-487-9087",
                            "test_user_im",
                            "*****@*****.**",
                            "Alert Vcd:",
                            is_enabled=True)
     assert user_name == user.get('name')
Example #8
0
 def test_get_role(self):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org)
     role = org.get_role(self.config['vcd']['role_name'])
     assert self.config['vcd']['role_name'] == role.get('name')