Skip to content

Commit

Permalink
Remove system birthday (#12955)
Browse files Browse the repository at this point in the history
(cherry picked from commit daf94ce)

Co-authored-by: themylogin <themylogin@gmail.com>
  • Loading branch information
bugclerk and themylogin committed Jan 23, 2024
1 parent fc1f42a commit eea0f3f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 40 deletions.
@@ -0,0 +1,32 @@
"""Remove system birthday
Revision ID: 7c456c2a4926
Revises: 809e46a452e0
Create Date: 2024-01-23 10:38:31.580418+00:00
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '7c456c2a4926'
down_revision = '809e46a452e0'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.drop_column('stg_birthday')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.add_column(sa.Column('stg_birthday', sa.DATETIME(), nullable=True))

# ### end Alembic commands ###
17 changes: 0 additions & 17 deletions src/middlewared/middlewared/plugins/system/info.py
Expand Up @@ -30,25 +30,11 @@ class SystemService(Service):
'physmem_size': None,
}

BIRTHDAY_DATE = {
'date': None,
}

HOST_ID = None

class Config:
cli_namespace = 'system'

@private
async def birthday(self):

if self.BIRTHDAY_DATE['date'] is None:
birth = (await self.middleware.call('datastore.config', 'system.settings'))['stg_birthday']
if birth != datetime(1970, 1, 1):
self.BIRTHDAY_DATE['date'] = birth

return self.BIRTHDAY_DATE

@private
async def mem_info(self):

Expand Down Expand Up @@ -148,7 +134,6 @@ async def build_time(self, app):
Dict('license', additional_attrs=True, null=True), # TODO: Fill this in please
Datetime('boottime', required=True),
Datetime('datetime', required=True),
Datetime('birthday', required=True, null=True),
Str('timezone', required=True),
Str('system_manufacturer', required=True, null=True),
Bool('ecc_memory', required=True),
Expand All @@ -161,7 +146,6 @@ async def info(self):
dmidecode = await self.middleware.call('system.dmidecode_info')
cpu_info = await self.middleware.call('system.cpu_info')
mem_info = await self.middleware.call('system.mem_info')
birthday = await self.middleware.call('system.birthday')
timezone_setting = (await self.middleware.call('datastore.config', 'system.settings'))['stg_timezone']

return {
Expand All @@ -181,7 +165,6 @@ async def info(self):
'license': await self.middleware.call('system.license'),
'boottime': time_info['boot_time'],
'datetime': time_info['datetime'],
'birthday': birthday['date'],
'timezone': timezone_setting,
'system_manufacturer': dmidecode['system-manufacturer'] if dmidecode['system-manufacturer'] else None,
'ecc_memory': dmidecode['ecc-memory'],
Expand Down
21 changes: 0 additions & 21 deletions src/middlewared/middlewared/plugins/system/lifecycle.py
Expand Up @@ -85,30 +85,9 @@ async def shutdown(self, job, options):
await Popen(['/sbin/poweroff'])


async def _update_birthday(middleware):
while True:
birthday = await middleware.call('system.get_synced_clock_time')
if birthday:
middleware.logger.debug('Updating birthday data')
# update db with new birthday
settings = await middleware.call('datastore.config', 'system.settings')
await middleware.call(
'datastore.update', 'system.settings', settings['id'], {'stg_birthday': birthday}, {'ha_sync': False}
)
break
else:
await asyncio.sleep(300)


async def _event_system_ready(middleware, event_type, args):
lifecycle_conf.SYSTEM_READY = True

# Check if birthday is already set
birthday = await middleware.call('system.birthday')
if birthday is None:
# try to set birthday in background
middleware.create_task(_update_birthday(middleware))

if (await middleware.call('system.advanced.config'))['kdump_enabled']:
cp = await run(['kdump-config', 'status'], check=False)
if cp.returncode:
Expand Down
2 changes: 0 additions & 2 deletions src/middlewared/middlewared/plugins/system_general/update.py
Expand Up @@ -27,7 +27,6 @@ class SystemGeneralModel(sa.Model):
stg_guiconsolemsg = sa.Column(sa.Boolean(), default=True)
stg_language = sa.Column(sa.String(120), default='en')
stg_kbdmap = sa.Column(sa.String(120), default='us')
stg_birthday = sa.Column(sa.DateTime(), nullable=True)
stg_timezone = sa.Column(sa.String(120), default='America/Los_Angeles')
stg_wizardshown = sa.Column(sa.Boolean(), default=False)
stg_pwenc_check = sa.Column(sa.String(100))
Expand Down Expand Up @@ -67,7 +66,6 @@ class Config:
Str('language', empty=False, required=True),
Str('timezone', empty=False, required=True),
Bool('usage_collection', null=True, required=True),
Datetime('birthday', required=True),
Bool('wizardshown', required=True),
Bool('usage_collection_is_set', required=True),
Bool('ds_auth', required=True),
Expand Down

0 comments on commit eea0f3f

Please sign in to comment.