Commit 7bc6e462 by Sulyok Gabor

Machine handling fixes

parent f7a8b0d6
Pipeline #257 failed with stage
in 0 seconds
......@@ -114,19 +114,27 @@ class SettyController:
@staticmethod
def getMachineAvailableList(serviceId, used_hostnames, current_user):
all_minions = []# SettyController.salthelper.getAllMinionsUngrouped()
usedMachines = Machine.objects.filter(service=serviceId)
user_instances = Instance.objects.filter(owner=current_user)
userMachines = []
def getMachineAvailableList(serviceId, usedHostnames, current_user):
saltMinions = []#SettyController.salthelper.getAllMinionsUngrouped()
savedMachines = Machine.objects.filter(service=serviceId)
savedHostNames = []
for machine in savedMachines:
savedHostNames.append( machine.hostname )
userInstances = Instance.objects.filter(owner=current_user)
userMachines = []
for instance in user_instances:
for instance in userInstances:
if instance.vm_name:
print instance.vm_name
userMachines.append(instance.vm_name)
return {'machinedata': userMachines}
usedHostnamesByUser = set( savedHostNames + usedHostnames )
if not usedHostnamesByUser:
return {'machinedata':userMachines}#{'machinedata': [machineName for machineName in userMachines if machineName in saltMinions] }
availableInstanceNames = list( set(userMachines) - usedHostnamesByUser )
return {'machinedata': availableInstanceNames}#[ machineName for machineName in availableInstanceNames if machineName in saltMinions ]}
@staticmethod
def addMachine(hostname):
......@@ -135,12 +143,12 @@ class SettyController:
return {'error': 'already added or doesnt exists'}
except:
pass
if SettyController.salthelper.checkMinionExists(hostname):
machine = Machine.clone()
machine.hostname = hostname
return machine.getDataDictionary()
else:
return {'error': 'already added or doesnt exists'}
#if SettyController.salthelper.checkMinionExists(hostname):
machine = Machine.clone()
machine.hostname = hostname
return machine.getDataDictionary()
# else:
# return {'error': 'already added or doesnt exists'}
@staticmethod
def addServiceNode(elementTemplateId):
......
......@@ -152,9 +152,9 @@ class Machine(Element): # As a real machine
@staticmethod
def getInformation():
return {'hostname': hostname.get_internal_type(),
'alias': alias.get_internal_type(),
'description': description.get_internal_type()}
return {'hostname': Machine._meta.get_field('hostname').get_internal_type(),
'alias': Machine._meta.get_field('alias').get_internal_type(),
'description': Machine._meta.get_field('description').get_internal_type()}
def getDataDictionary(self):
element_data = self.getDisplayData()
......
......@@ -97,6 +97,33 @@ textarea {
z-index: 2000;
}
.machine{
position: absolute;
left: 10px;
display: inline;
width: 75px;
height: 75px;
background: red;
border-radius: 8px;
border-color: black;
-webkit-border-radius: 8px;
border-style: solid;
border-width: 5px;
z-index: 40;
cursor: grab;
}
.machine:hover{
border: 5px solid #123456;
box-shadow: 2px 2px 19px #444;
-o-box-shadow: 2px 2px 19px #444;
-webkit-box-shadow: 2px 2px 19px #444;
-moz-box-shadow: 2px 2px 19px #fff;
opacity: 0.9;
filter: alpha(opacity=90);
z-index: 2000;
}
._jsPlumb_connector{
z-index: 10;
}
......
......@@ -192,8 +192,11 @@
<h4 class="modal-title"><i class="fa fa-outdent"></i>&nbsp;{% trans 'Machines' %}</h4>
</div>
<div class="modal-body" id="addMachineDialogBody">
<div class="list-group" id="availableMachineListContainer">
</div>
</div>
<div class="modal-footer">
<div class="btn btn-primary" data-dismiss="modal"/>Mégsem</div>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment