Ejemplo n.º 1
0
def forwards_func(apps, schema_editor):
    Worker = apps.get_model("lava_scheduler_app", "Worker")
    db_alias = schema_editor.connection.alias
    # Identify master node and populate the required fields.
    # Since migrations run only on master node, we assume the current node
    # should be designated as master.
    is_master = True
    localhost = utils.get_fqdn()
    ipaddr = utils.get_ip_address()

    # NOTE: RPC2_URL formed below is a guess. The administrator should
    #       revisit the correctness of this URL from the administration
    #       UI, fixing it for the node which is designated as the master.
    rpc2_url = "http://{0}/RPC2".format(localhost)

    if localhost == 'example.com' or localhost == 'www.example.com':
        rpc2_url = "http://{0}/RPC2".format(ipaddr)

    try:
        with transaction.atomic():
            worker, created = Worker.objects.using(db_alias).get_or_create(
                hostname=localhost)
            worker.is_master = is_master
            worker.ip_address = ipaddr
            worker.rpc2_url = rpc2_url
            worker.save()
    except:
        print "Identifying master node failed ..."
Ejemplo n.º 2
0
    def forwards(self, orm):
        # Deleting field 'Worker.heartbeat'
        db.delete_column('lava_scheduler_app_worker', 'heartbeat')

        # Adding field 'Worker.rpc2_url'
        db.add_column('lava_scheduler_app_worker',
                      'rpc2_url',
                      self.gf('django.db.models.fields.CharField')(
                          default=None, max_length=200, null=True, blank=True),
                      keep_default=False)

        # Adding field 'Worker.ip_address'
        db.add_column('lava_scheduler_app_worker',
                      'ip_address',
                      self.gf('django.db.models.fields.CharField')(
                          default=None, max_length=20, null=True, blank=True),
                      keep_default=False)

        # Adding field 'Worker.is_master'
        db.add_column(
            'lava_scheduler_app_worker',
            'is_master',
            self.gf('django.db.models.fields.BooleanField')(default=False),
            keep_default=False)

        # Deleting field 'Device.heartbeat'
        db.delete_column('lava_scheduler_app_device', 'heartbeat')

        # Deleting field 'Device.last_heartbeat'
        db.delete_column('lava_scheduler_app_device', 'last_heartbeat')

        # Identify master node and populate the required fields.
        # Since migrations run only on master node, we assume the current node
        # should be designated as master.
        is_master = True
        localhost = utils.get_fqdn()
        ipaddr = utils.get_ip_address()

        # NOTE: RPC2_URL formed below is a guess. The administrator should
        #       revisit the correctness of this URL from the administration
        #       UI, fixing it for the node which is designated as the master.
        rpc2_url = "http://{0}/RPC2".format(localhost)

        if localhost == 'example.com' or localhost == 'www.example.com':
            rpc2_url = "http://{0}/RPC2".format(ipaddr)

        try:
            worker = orm['lava_scheduler_app.Worker'].objects.get(
                hostname=localhost)
            worker.is_master = is_master
            worker.ip_address = ipaddr
            worker.rpc2_url = rpc2_url
        except:
            worker = orm['lava_scheduler_app.Worker'](hostname=localhost,
                                                      ip_address=ipaddr,
                                                      is_master=is_master,
                                                      rpc2_url=rpc2_url)
        worker.save()
Ejemplo n.º 3
0
 def populate_complete_worker_data(self):
     """This method populates the complete information about the worker
     node, which is a lengthy operation.
     """
     self.populate_minimal_worker_data()
     self.worker['info_size'] = 'complete'
     self.worker['arch'] = platform.machine()
     self.worker['platform'] = platform.platform()
     self.worker['ipaddr'] = utils.get_ip_address()
     self.worker['hardware_info'] = utils.get_lshw_out()
     self.worker['software_info'] = utils.get_software_info()
     self.logger.debug("Complete worker data populated ...")
Ejemplo n.º 4
0
 def populate_complete_worker_data(self):
     """This method populates the complete information about the worker
     node, which is a lengthy operation.
     """
     self.populate_minimal_worker_data()
     self.worker["info_size"] = "complete"
     self.worker["arch"] = platform.machine()
     self.worker["platform"] = platform.platform()
     self.worker["ipaddr"] = utils.get_ip_address()
     self.worker["hardware_info"] = utils.get_lshw_out()
     self.worker["software_info"] = utils.get_software_info()
     self.logger.debug("Complete worker data populated ...")
    def forwards(self, orm):
        # Deleting field 'Worker.heartbeat'
        db.delete_column('lava_scheduler_app_worker', 'heartbeat')

        # Adding field 'Worker.rpc2_url'
        db.add_column('lava_scheduler_app_worker', 'rpc2_url',
                      self.gf('django.db.models.fields.CharField')(default=None, max_length=200, null=True, blank=True),
                      keep_default=False)

        # Adding field 'Worker.ip_address'
        db.add_column('lava_scheduler_app_worker', 'ip_address',
                      self.gf('django.db.models.fields.CharField')(default=None, max_length=20, null=True, blank=True),
                      keep_default=False)

        # Adding field 'Worker.is_master'
        db.add_column('lava_scheduler_app_worker', 'is_master',
                      self.gf('django.db.models.fields.BooleanField')(default=False),
                      keep_default=False)

        # Deleting field 'Device.heartbeat'
        db.delete_column('lava_scheduler_app_device', 'heartbeat')

        # Deleting field 'Device.last_heartbeat'
        db.delete_column('lava_scheduler_app_device', 'last_heartbeat')

        # Identify master node and populate the required fields.
        # Since migrations run only on master node, we assume the current node
        # should be designated as master.
        is_master = True
        localhost = utils.get_fqdn()
        ipaddr = utils.get_ip_address()

        # NOTE: RPC2_URL formed below is a guess. The administrator should
        #       revisit the correctness of this URL from the administration
        #       UI, fixing it for the node which is designated as the master.
        rpc2_url = "http://{0}/RPC2".format(localhost)

        if localhost == 'example.com' or localhost == 'www.example.com':
            rpc2_url = "http://{0}/RPC2".format(ipaddr)

        try:
            worker = orm['lava_scheduler_app.Worker'].objects.get(
                hostname=localhost)
            worker.is_master = is_master
            worker.ip_address = ipaddr
            worker.rpc2_url = rpc2_url
        except:
            worker = orm['lava_scheduler_app.Worker'](hostname=localhost,
                                                      ip_address=ipaddr,
                                                      is_master=is_master,
                                                      rpc2_url=rpc2_url)
        worker.save()