Exemple #1
0
def createHost(address, hostdata):
    # print("~~~~~ CREATING HOST ~~~~~")
    host = Host(name=address, alias=hostdata['ALIAS'])
    host.save()
    # print("~~~~~ HOST CREATED %s with ID: %s ~~~~~") % (host.alias, host.id)
    # Now add host to stage groups
    locations = Project.objects.filter(name__in=hostdata['LOCATIONS_AND_STAGES'].keys())
    # print("~~ Found locations")
    if locations:
        for location in locations:
            # print("Updating location %s with ID: %s") % (location.name, location.id)
            # Loop through locations and determine if host should be added to groups within location
            if location.name in hostdata['LOCATIONS_AND_STAGES']:
                groups = Stage.objects.filter(project_id=location.id, name__in=hostdata['LOCATIONS_AND_STAGES'][location.name])
                # print("~~ Adding to groups")
                if groups:
                    for group in groups:
                        # print("Updating group %s with ID: %s") % (group.name, group.id)
                        group.hosts.add(host)
    else:
        print("Client requesting unknown locations")
def createHost(address, hostdata):
    # print("~~~~~ CREATING HOST ~~~~~")
    host = Host(name=address, alias=hostdata["ALIAS"])
    host.save()
    # print("~~~~~ HOST CREATED %s with ID: %s ~~~~~") % (host.alias, host.id)
    # Now add host to stage groups
    locations = Project.objects.filter(name__in=hostdata["LOCATIONS_AND_STAGES"].keys())
    # print("~~ Found locations")
    if locations:
        for location in locations:
            # print("Updating location %s with ID: %s") % (location.name, location.id)
            # Loop through locations and determine if host should be added to groups within location
            if location.name in hostdata["LOCATIONS_AND_STAGES"]:
                groups = Stage.objects.filter(
                    project_id=location.id, name__in=hostdata["LOCATIONS_AND_STAGES"][location.name]
                )
                # print("~~ Adding to groups")
                if groups:
                    for group in groups:
                        # print("Updating group %s with ID: %s") % (group.name, group.id)
                        group.hosts.add(host)
    else:
        print ("Client requesting unknown locations")
Exemple #3
0
    def test_hook_unicode(self):
        host = Host()
        host.name = '127.0.0.1'
        host.alias = u'code'

        self.assertEqual(unicode(host), u'code')
Exemple #4
0
    def test_hook_unicode(self):
        host = Host()
        host.name = '127.0.0.1'
        host.alias = u'code'

        self.assertEqual(unicode(host), u'code')