Example #1
0
 def get_all_host_templates(self):
     """
 Retrieves all host templates in the cluster.
 @return ApiList of ApiHostTemplate objects.
 """
     return host_templates.get_all_host_templates(self._get_resource_root(),
                                                  self.name)
Example #2
0
 def get_all_host_templates(self):
   """
   Retrieves all host templates in the cluster.
   @return ApiList of ApiHostTemplate objects.
   """
   return host_templates.get_all_host_templates(self._get_resource_root(), self.name)
Example #3
0
        def _build_host_inventory(hostRef,inv,meta_hostvars):
            host = hosts.get_host(self.cm, hostRef.hostId)
            #print host.hostname

            self._add_host(inv, 'all', host.hostname)
            if meta_hostvars:
                inv['_meta']['hostvars'][host.hostname] = host.to_json_dict(preserve_ro=True)
            self._put_cache(host.hostname, host.to_json_dict(preserve_ro=True))

            # Group by cluster
            if host.clusterRef:
                cluster = clusters.get_cluster(self.cm, host.clusterRef.clusterName)
                self._add_child(inv, 'all', cluster.displayName)
                self._add_host(inv, cluster.displayName, host.hostname)

                if host.roleRefs:
                    for roleRef in host.roleRefs:
                        role = roles.get_role(self.cm, roleRef.serviceName, roleRef.roleName, roleRef.clusterName)

                        # Group by service
                        service = services.get_service(self.cm, roleRef.serviceName, roleRef.clusterName)

                        # There is no way to ensure that service display name is unique across clusters
                        # The only simple and unique representation of the service that can be used
                        # is the concatination of the service name and the cluster's name
                        service_group = cluster.displayName + '-' + service.displayName
                        self._add_child(inv, 'all', service.type)
                        self._add_child(inv, service.type, service_group)
                        self._add_child(inv, cluster.displayName, service_group)
                        self._add_host(inv, service_group, host.hostname)

                        # Group by role, roles depend on services and clusters, so the only unique and
                        # simple representation of a Group is the concatination of the role type, service
                        # name and the cluster name
                        role_group = cluster.displayName + '-' + service.displayName + '-' + role.type
                        self._add_child(inv, 'all', role.type)
                        #self._add_child(inv, role.type, service_group)
                        #self._add_child(inv, service_group, role_group)
                        self._add_child(inv, role.type, role_group)
                        self._add_host(inv, role_group, host.hostname)

                        # Group by role Group
                        role_group = role.roleConfigGroupRef.roleConfigGroupName
                        self._add_child(inv, role.type, role_group)
                        self._add_host(inv, role_group, host.hostname)

                        # Group by role template
                        for template in host_templates.get_all_host_templates(self.cm, host.clusterRef.clusterName):
                            self._add_child(inv, 'all', template.name)
                            for group in template.roleConfigGroupRefs:
                                if role_group == group.roleConfigGroupName:
                                    self._add_child(inv, template.name, role_group)
                    else:
                        self._add_child(inv, 'all', 'no_role')
                        self._add_host(inv, 'no_role', host.hostname)

                # Group by Rack
                self._add_child(inv, 'all', host.rackId)
                self._add_host(inv, host.rackId, host.clusterRef.clusterName)
            else:
                cluster_group = "no_cluster"
                self._add_child(inv, 'all', cluster_group)
                self._add_host(inv, cluster_group, host.hostname)