Commit 7bc6e462 by Sulyok Gabor

Machine handling fixes

parent f7a8b0d6
Pipeline #257 failed with stage
in 0 seconds
...@@ -114,19 +114,27 @@ class SettyController: ...@@ -114,19 +114,27 @@ class SettyController:
@staticmethod @staticmethod
def getMachineAvailableList(serviceId, used_hostnames, current_user): def getMachineAvailableList(serviceId, usedHostnames, current_user):
all_minions = []# SettyController.salthelper.getAllMinionsUngrouped() saltMinions = []#SettyController.salthelper.getAllMinionsUngrouped()
usedMachines = Machine.objects.filter(service=serviceId) savedMachines = Machine.objects.filter(service=serviceId)
user_instances = Instance.objects.filter(owner=current_user)
userMachines = [] savedHostNames = []
for machine in savedMachines:
savedHostNames.append( machine.hostname )
userInstances = Instance.objects.filter(owner=current_user)
userMachines = [] userMachines = []
for instance in user_instances: for instance in userInstances:
if instance.vm_name: if instance.vm_name:
print instance.vm_name
userMachines.append(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 @staticmethod
def addMachine(hostname): def addMachine(hostname):
...@@ -135,12 +143,12 @@ class SettyController: ...@@ -135,12 +143,12 @@ class SettyController:
return {'error': 'already added or doesnt exists'} return {'error': 'already added or doesnt exists'}
except: except:
pass pass
if SettyController.salthelper.checkMinionExists(hostname): #if SettyController.salthelper.checkMinionExists(hostname):
machine = Machine.clone() machine = Machine.clone()
machine.hostname = hostname machine.hostname = hostname
return machine.getDataDictionary() return machine.getDataDictionary()
else: # else:
return {'error': 'already added or doesnt exists'} # return {'error': 'already added or doesnt exists'}
@staticmethod @staticmethod
def addServiceNode(elementTemplateId): def addServiceNode(elementTemplateId):
......
...@@ -152,9 +152,9 @@ class Machine(Element): # As a real machine ...@@ -152,9 +152,9 @@ class Machine(Element): # As a real machine
@staticmethod @staticmethod
def getInformation(): def getInformation():
return {'hostname': hostname.get_internal_type(), return {'hostname': Machine._meta.get_field('hostname').get_internal_type(),
'alias': alias.get_internal_type(), 'alias': Machine._meta.get_field('alias').get_internal_type(),
'description': description.get_internal_type()} 'description': Machine._meta.get_field('description').get_internal_type()}
def getDataDictionary(self): def getDataDictionary(self):
element_data = self.getDisplayData() element_data = self.getDisplayData()
......
...@@ -97,6 +97,33 @@ textarea { ...@@ -97,6 +97,33 @@ textarea {
z-index: 2000; 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{ ._jsPlumb_connector{
z-index: 10; z-index: 10;
} }
......
...@@ -192,8 +192,11 @@ ...@@ -192,8 +192,11 @@
<h4 class="modal-title"><i class="fa fa-outdent"></i>&nbsp;{% trans 'Machines' %}</h4> <h4 class="modal-title"><i class="fa fa-outdent"></i>&nbsp;{% trans 'Machines' %}</h4>
</div> </div>
<div class="modal-body" id="addMachineDialogBody"> <div class="modal-body" id="addMachineDialogBody">
<div class="list-group" id="availableMachineListContainer">
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="btn btn-primary" data-dismiss="modal"/>Mégsem</div>
</div> </div>
</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