コード例 #1
0
 def build_entity(self):
     return otypes.User(
         domain=otypes.Domain(name=self._module.params['authz_name']),
         user_name=username(self._module),
         principal=self._module.params['name'],
         namespace=self._module.params['namespace'],
     )
コード例 #2
0
 def build_entity(self):
     return otypes.Event(
         description=self._module.params['description'],
         severity=otypes.LogSeverity(self._module.params['severity']),
         origin=self._module.params['origin'],
         custom_id=self._module.params['custom_id'],
         id=self._module.params['id'],
         cluster=otypes.Cluster(
             id=self._module.params['cluster']
         ) if self._module.params['cluster'] is not None else None,
         data_center=otypes.DataCenter(
             id=self._module.params['data_center']
         ) if self._module.params['data_center'] is not None else None,
         host=otypes.Host(
             id=self._module.params['host']
         ) if self._module.params['host'] is not None else None,
         storage_domain=otypes.StorageDomain(
             id=self._module.params['storage_domain']
         ) if self._module.params['storage_domain'] is not None else None,
         template=otypes.Template(
             id=self._module.params['template']
         ) if self._module.params['template'] is not None else None,
         user=otypes.User(
             id=self._module.params['user']
         ) if self._module.params['user'] is not None else None,
         vm=otypes.Vm(
             id=self._module.params['vm']
         ) if self._module.params['vm'] is not None else None,
     )
コード例 #3
0
def test_add_ldap_user(engine_api):
    engine = engine_api.system_service()
    users_service = engine.users_service()
    with engine_utils.wait_for_event(engine, 149):  # USER_ADD(149)
        users_service.add(
            types.User(
                user_name=AAA_LDAP_USER,
                domain=types.Domain(name=AAA_LDAP_AUTHZ_PROVIDER),
            ), )
コード例 #4
0
ファイル: ovirt_permission.py プロジェクト: nasirhm/general
    def build_entity(self):
        entity = self._group(
        ) if self._module.params['group_name'] else self._user()

        return otypes.Permission(
            user=otypes.User(
                id=entity.id) if self._module.params['user_name'] else None,
            group=otypes.Group(
                id=entity.id) if self._module.params['group_name'] else None,
            role=otypes.Role(name=self._module.params['role']),
        )
コード例 #5
0
def test_add_ldap_user(api_v4):
    engine = api_v4.system_service()
    users_service = engine.users_service()
    with test_utils.TestEvent(engine, 149): # USER_ADD(149)
        users_service.add(
            types.User(
                user_name=AAA_LDAP_USER,
                domain=types.Domain(
                    name=AAA_LDAP_AUTHZ_PROVIDER
                ),
            ),
        )
コード例 #6
0
ファイル: __init__.py プロジェクト: openpabz/kcli
    def serialconsole(self, name):
        """

        :param name:
        :return:
        """
        # localport1 = common.get_free_port()
        #    command = "ssh -o LogLevel=QUIET -f -p %s -L %s:127.0.0.1:2222  ovirt-vmconsole@%s sleep 10"\
        #        % (self.port, localport, self.host)
        #    os.popen(command)
        system_service = self.conn.system_service()
        users_service = system_service.users_service()
        user = users_service.list(search='usrname=%s-authz' % self.user)[0]
        user_service = users_service.user_service(user.id)
        vmsearch = self.vms_service.list(search='name=%s' % name)
        if not vmsearch:
            common.pprint("VM %s not found" % name, color='red')
            return {'result': 'failure', 'reason': "VM %s not found" % name}
        vm = vmsearch[0]
        # if not vm.console.enabled:
        #    vm_service = self.vms_service.vm_service(vm.id)
        #    vm_service.update(types.Vm(console=types.Console(enabled=True)))
        #    common.pprint("Enabling Serial Console. You will need to reboot VM" % name, color='green')
        #    return
        permissions_service = self.vms_service.vm_service(
            vm.id).permissions_service()
        permissions_service.add(
            types.Permission(user=types.User(id=user.id),
                             role=types.Role(name='UserVmManager')))
        keys_service = user_service.ssh_public_keys_service()
        key = get_home_ssh_key()
        if key is None:
            common.print(
                "neither id_rsa.pub or id_dsa public keys found in your .ssh directory. This is required"
            )
            return
        try:
            keys_service.add(key=types.SshPublicKey(content=key))
        except:
            pass
        command = "ssh -t -p 2222 ovirt-vmconsole@%s connect --vm-name %s" % (
            self.host, name)
        call(command, shell=True)
        return
コード例 #7
0
connection = sdk.Connection(
    url='https://engine40.example.com/ovirt-engine/api',
    username='******',
    password='******',
    ca_file='ca.pem',
    debug=True,
    log=logging.getLogger(),
)

# Locate the networks service and use it to find the network:
networks_service = connection.system_service().networks_service()
network = networks_service.list(search='name=mynetwork')[0]

# Locate the users service and use it to find the user:
users_service = connection.system_service().users_service()
user = users_service.list(search='usrname=myuser@mydomain-authz')[0]

# Locate the service that manages the permissions of the network:
permissions_service = networks_service.network_service(
    network.id).permissions_service()

# Use the "add" method to assign GlusterAdmin role to user on network:
permissions_service.add(
    types.Permission(
        user=types.User(id=user.id, ),
        role=types.Role(name='GlusterAdmin'),
    ), )

# Close the connection to the server:
connection.close()