# Path: sshkm/models.py
# class Host(models.Model):
#     name = models.CharField(max_length=191, unique=True)
#     superuser = models.CharField(max_length=191, null=True, blank=True)
#     description = models.CharField(max_length=191, null=True, blank=True)
#     status = models.CharField(max_length=10, null=True, blank=True)
#     last_status = models.DateTimeField(null=True, blank=True)
# 
# class Osuser(models.Model):
#     name = models.CharField(max_length=191, unique=True)
#     home = models.CharField(max_length=191, null=True, blank=True)
#     description = models.CharField(max_length=191, null=True, blank=True)
# 
# class Key(models.Model):
#     name = models.CharField(max_length=191, unique=True)
#     description = models.CharField(max_length=191, null=True, blank=True)
#     firstname = models.CharField(max_length=191, null=True, blank=True)
#     lastname = models.CharField(max_length=191, null=True, blank=True)
#     email = models.EmailField(max_length=191, null=True, blank=True)
#     publickey = models.TextField(null=True, blank=True)
#     member_of = models.ManyToManyField('Group', through='KeyGroup', blank=True)
# 
# class KeyGroup(models.Model):
#     key = models.ForeignKey('Key', on_delete=models.CASCADE)
#     group = models.ForeignKey('Group', on_delete=models.CASCADE)
# 
# class Permission(models.Model):
#     group = models.ForeignKey(Group, on_delete=models.CASCADE)
#     host = models.ForeignKey(Host, on_delete=models.CASCADE)
#     osuser = models.ForeignKey(Osuser, on_delete=models.CASCADE)
# 
#     class Meta:
#         unique_together = ("group", "host", "osuser")
# 
# class Setting(models.Model):
#     name = models.CharField(max_length=100, unique=True)
#     value = models.TextField(null=True, blank=True)


from django.utils import timezone
    from StringIO import StringIO
    from io import StringIO
from sshkm.models import Host, Osuser, Key, KeyGroup, Permission, Setting
import paramiko

try:
except ImportError:



def CopyKeyfile(host, keyfile, osuser, home, superuser):
    hostupdate = Host.objects.get(name=host)
    hostupdate.status = 'PENDING'
    hostupdate.last_status = timezone.now()
    hostupdate.save()

    key = Setting.objects.get(name='MasterKeyPrivate')

    try:

# Path: sshkm/models.py
# class Host(models.Model):
#     name = models.CharField(max_length=191, unique=True)
#     superuser = models.CharField(max_length=191, null=True, blank=True)
#     description = models.CharField(max_length=191, null=True, blank=True)
#     status = models.CharField(max_length=10, null=True, blank=True)
#     last_status = models.DateTimeField(null=True, blank=True)
# 
# class Osuser(models.Model):
#     name = models.CharField(max_length=191, unique=True)
#     home = models.CharField(max_length=191, null=True, blank=True)
#     description = models.CharField(max_length=191, null=True, blank=True)
# 
# class Key(models.Model):
#     name = models.CharField(max_length=191, unique=True)
#     description = models.CharField(max_length=191, null=True, blank=True)
#     firstname = models.CharField(max_length=191, null=True, blank=True)
#     lastname = models.CharField(max_length=191, null=True, blank=True)
#     email = models.EmailField(max_length=191, null=True, blank=True)
#     publickey = models.TextField(null=True, blank=True)
#     member_of = models.ManyToManyField('Group', through='KeyGroup', blank=True)
# 
# class KeyGroup(models.Model):
#     key = models.ForeignKey('Key', on_delete=models.CASCADE)
#     group = models.ForeignKey('Group', on_delete=models.CASCADE)
# 
# class Permission(models.Model):
#     group = models.ForeignKey(Group, on_delete=models.CASCADE)
#     host = models.ForeignKey(Host, on_delete=models.CASCADE)
#     osuser = models.ForeignKey(Osuser, on_delete=models.CASCADE)
# 
#     class Meta:
#         unique_together = ("group", "host", "osuser")
# 
# class Setting(models.Model):
#     name = models.CharField(max_length=100, unique=True)
#     value = models.TextField(null=True, blank=True)


# Path: sshkm/views/deploy.py
from django.utils import timezone
    from StringIO import StringIO
    from io import StringIO
from sshkm.models import Host, Osuser, Key, KeyGroup, Permission, Setting
import paramiko


try:
except ImportError:



def CopyKeyfile(host, keyfile, osuser, home, superuser):
    hostupdate = Host.objects.get(name=host)
    hostupdate.status = 'PENDING'
    hostupdate.last_status = timezone.now()
    hostupdate.save()

    key = Setting.objects.get(name='MasterKeyPrivate')

    try:

        passphrase = Setting.objects.get(name='MasterKeyPrivatePassphrase').value