fix: org_type was not the correct variable

pull/69/head
Adrien RAFFIN 2017-04-07 17:10:47 +02:00
parent dfd194fa2b
commit 6ab8eee9e8
1 changed files with 15 additions and 10 deletions

View File

@ -1300,16 +1300,21 @@ class PyMISP(object):
# ############## Servers ################## # ############## Servers ##################
def _set_server_organisation(self, server, organisation): def _set_server_organisation(self, server, organisation):
if organisation is not None and 'type' in organisation: if organisation is None:
organisation_type = organisation['type'] raise PyMISPError('Need a valid organisation as argument, create it before if needed')
if organisation_type < 2: if 'Organisation' in organisation:
if 'id' in organisation: organisation=organisation.get('Organisation')
server['organisation_type'] = organisation_type if 'local' not in organisation:
server['json'] = json.dump({'id': organisation['id']}) raise PyMISPError('Need a valid organisation as argument. "local" value have not been set in this organisation')
else: if 'id' not in organisation:
if 'name' in organisation and 'uuid' in organisation: raise PyMISPError('Need a valid organisation as argument. "id" value doesn\'t exist in provided organisation')
server['organisation_type'] = organisation_type # Local organisation is '0' and remote organisation is '1'. These values are extracted from web interface of MISP
server['json'] = json.dumps({'name': organisation['name'], 'uuid': organisation['uuid']}) if organisation.get('local') == True:
organisation_type = 0
else:
organisation_type = 1
server['organisation_type'] = organisation_type
server['json'] = json.dumps({'id': organisation['id']})
return server return server
def _set_server_parameters(self, url, name, authkey, organisation, internal, def _set_server_parameters(self, url, name, authkey, organisation, internal,