def get_or_create_node(node_fqdn): try: node = Node.get_by_name(node_fqdn) except: node = Node.create(node_fqdn) # Generate and assign a Host GUID host_guid = _generate_host_guid() param = ConfigClassParameter.get_by_name( ConfigClassParameter.HOST_GUID) Override.update_or_create_override(node, param, host_guid) # Assign default roles on node creation default_roles = Role.get_default_roles() NodeRoleAssignment.add_roles_to_node(node, default_roles) # determine if we can add celeryd on each worker. This is # possible only if the DB backend is != sqlite3 if DATABASES['default']['ENGINE'] == 'django.db.backends.mysql': celery_role = Role.get_by_name(Role.CELERY_WORKER) NodeRoleAssignment.add_roles_to_node(node, [celery_role], True) return node
def _add_dummy_node(self, fqdn='test_fqdn', is_enabled=True): self.dummy_node_fqdn = fqdn node = Node.create(fqdn) node.enabled = is_enabled import pickle node.facts = pickle.dumps({ "geppetto_status_running_services": "openstack-nova-api,openstack-nova-compute", "geppetto_status_stopped_services": "openstack-nova-network", "host_fqdn": "test_host", "ipaddress_eth0": "169.254.0.2", "ipaddress_eth1": "127.0.0.1", "interfaces": "'eth0,eth1,eth2,lo'", }) node.save() node.joined_date = datetime.datetime(2001, 1, 1, 0, 0, 0, 0) # make the host guid predictable param = ConfigClassParameter.get_by_name( ConfigClassParameter.HOST_GUID) Override.update_or_create_override(node, param, "00:00:00:00:00:00") return node