def migrate_from_pre_snaps():
    remove_state('kubernetes.components.installed')
    remove_state('kubernetes.dashboard.available')
    remove_state('kube-dns.available')
    remove_state('kubernetes-master.app_version.set')
    services = ['kube-apiserver', 'kube-controller-manager', 'kube-scheduler']
    for service in services:
        hookenv.log('Stopping {0} service.'.format(service))
        host.service_stop(service)
    os.makedirs('/root/cdk', exist_ok=True)
    rename_file_idempotent('/etc/kubernetes/serviceaccount.key', '/root/cdk/serviceaccount.key')
    rename_file_idempotent('/srv/kubernetes/basic_auth.csv', '/root/cdk/basic_auth.csv')
    rename_file_idempotent('/srv/kubernetes/known_tokens.csv', '/root/cdk/known_tokens.csv')
    files = ['/lib/systemd/system/kube-apiserver.service', '/lib/systemd/system/kube-controller-manager.service', '/lib/systemd/system/kube-scheduler.service', '/etc/default/kube-defaults', '/etc/default/kube-apiserver.defaults', '/etc/default/kube-controller-manager.defaults', '/etc/default/kube-scheduler.defaults', '/srv/kubernetes', '/home/ubuntu/kubectl', '/usr/local/bin/kubectl', '/usr/local/bin/kube-apiserver', '/usr/local/bin/kube-controller-manager', '/usr/local/bin/kube-scheduler', '/etc/kubernetes']
    for file in files:
        if os.path.isdir(file):
            hookenv.log(('Removing directory: ' + file))
            shutil.rmtree(file)
        elif os.path.isfile(file):
            hookenv.log(('Removing file: ' + file))
            os.remove(file)
    FlagManager('kube-apiserver').destroy_all()
    FlagManager('kube-controller-manager').destroy_all()
    FlagManager('kube-scheduler').destroy_all()
def migrate_from_pre_snaps():
    remove_state('kubernetes.components.installed')
    remove_state('kubernetes.dashboard.available')
    remove_state('kube-dns.available')
    remove_state('kubernetes-master.app_version.set')
    services = ['kube-apiserver', 'kube-controller-manager', 'kube-scheduler']
    for service in services:
        hookenv.log('Stopping {0} service.'.format(service))
        host.service_stop(service)
    os.makedirs('/root/cdk', exist_ok=True)
    rename_file_idempotent('/etc/kubernetes/serviceaccount.key', '/root/cdk/serviceaccount.key')
    rename_file_idempotent('/srv/kubernetes/basic_auth.csv', '/root/cdk/basic_auth.csv')
    rename_file_idempotent('/srv/kubernetes/known_tokens.csv', '/root/cdk/known_tokens.csv')
    files = ['/lib/systemd/system/kube-apiserver.service', '/lib/systemd/system/kube-controller-manager.service', '/lib/systemd/system/kube-scheduler.service', '/etc/default/kube-defaults', '/etc/default/kube-apiserver.defaults', '/etc/default/kube-controller-manager.defaults', '/etc/default/kube-scheduler.defaults', '/srv/kubernetes', '/home/ubuntu/kubectl', '/usr/local/bin/kubectl', '/usr/local/bin/kube-apiserver', '/usr/local/bin/kube-controller-manager', '/usr/local/bin/kube-scheduler', '/etc/kubernetes']
    for file in files:
        if os.path.isdir(file):
            hookenv.log(('Removing directory: ' + file))
            shutil.rmtree(file)
        elif os.path.isfile(file):
            hookenv.log(('Removing file: ' + file))
            os.remove(file)
    FlagManager('kube-apiserver').destroy_all()
    FlagManager('kube-controller-manager').destroy_all()
    FlagManager('kube-scheduler').destroy_all()