示例#1
0
 def vm_update_os_metadata(dom, params):
     distro = params.get("os_distro")
     version = params.get("os_version")
     if distro is None:
         return
     os_elem = E.os({"distro": distro, "version": version})
     set_metadata_node(dom, os_elem)
示例#2
0
    def _vm_update_access_metadata(self, dom, params):
        users = groups = None
        if "users" in params:
            users = params["users"]
            invalid_users = set(users) - set(self.users.get_list())
            if len(invalid_users) != 0:
                raise InvalidParameter("KCHVM0027E",
                                       {'users': ", ".join(invalid_users)})
        if "groups" in params:
            groups = params["groups"]
            invalid_groups = set(groups) - set(self.groups.get_list())
            if len(invalid_groups) != 0:
                raise InvalidParameter("KCHVM0028E",
                                       {'groups': ", ".join(invalid_groups)})

        if users is None and groups is None:
            return

        access_xml = (get_metadata_node(dom, "access")
                      or """<access></access>""")
        old_users = xpath_get_text(access_xml, "/access/user")
        old_groups = xpath_get_text(access_xml, "/access/group")
        users = old_users if users is None else users
        groups = old_groups if groups is None else groups

        node = self._build_access_elem(users, groups)
        set_metadata_node(dom, node)
示例#3
0
文件: vms.py 项目: gouzongmei/kimchi
 def vm_update_os_metadata(dom, params, metadata_support):
     distro = params.get("os_distro")
     version = params.get("os_version")
     if distro is None:
         return
     os_elem = E.os({"distro": distro, "version": version})
     set_metadata_node(dom, os_elem, metadata_support)
示例#4
0
文件: vms.py 项目: cbosdo/kimchi
    def _vm_update_access_metadata(self, dom, params):
        users = groups = None
        if "users" in params:
            users = params["users"]
            invalid_users = set(users) - set(self.users.get_list())
            if len(invalid_users) != 0:
                raise InvalidParameter("KCHVM0027E",
                                       {'users': ", ".join(invalid_users)})
        if "groups" in params:
            groups = params["groups"]
            invalid_groups = set(groups) - set(self.groups.get_list())
            if len(invalid_groups) != 0:
                raise InvalidParameter("KCHVM0028E",
                                       {'groups': ", ".join(invalid_groups)})

        if users is None and groups is None:
            return

        access_xml = (get_metadata_node(dom, "access") or
                      """<access></access>""")
        old_users = xpath_get_text(access_xml, "/access/user")
        old_groups = xpath_get_text(access_xml, "/access/group")
        users = old_users if users is None else users
        groups = old_groups if groups is None else groups

        node = self._build_access_elem(users, groups)
        set_metadata_node(dom, node)
示例#5
0
    def _vm_update_access_metadata(self, dom, params):
        users = groups = None
        if "users" in params:
            users = params["users"]
            for user in users:
                if not self.users.validate(user):
                    raise InvalidParameter("KCHVM0027E", {'users': user})
        if "groups" in params:
            groups = params["groups"]
            for group in groups:
                if not self.groups.validate(group):
                    raise InvalidParameter("KCHVM0028E", {'groups': group})

        if users is None and groups is None:
            return

        node = self._build_access_elem(dom, users, groups)
        set_metadata_node(dom, node, self.caps.metadata_support)
示例#6
0
文件: vms.py 项目: clnperez/kimchi
    def _vm_update_access_metadata(self, dom, params):
        users = groups = None
        if "users" in params:
            users = params["users"]
            for user in users:
                if not self.users.validate(user):
                    raise InvalidParameter("KCHVM0027E",
                                           {'users': user})
        if "groups" in params:
            groups = params["groups"]
            for group in groups:
                if not self.groups.validate(group):
                    raise InvalidParameter("KCHVM0028E",
                                           {'groups': group})

        if users is None and groups is None:
            return

        node = self._build_access_elem(dom, users, groups)
        set_metadata_node(dom, node, self.caps.metadata_support)