Skip to content

Commit

Permalink
fix default REST ports for http and https in openswitch (ansible#15580)
Browse files Browse the repository at this point in the history
properly uses the right default ports for http (80) and https (443)
  • Loading branch information
privateip authored and Qalthos committed Apr 25, 2016
1 parent 1a49267 commit 2f411c9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/ansible/module_utils/openswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
password=dict(no_log=True, fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD'])),
ssh_keyfile=dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']), type='path'),
use_ssl=dict(default=True, type='bool'),
validate_certs=dict(default=True, type='bool'),
transport=dict(default='ssh', choices=['ssh', 'cli', 'rest']),
provider=dict()
provider=dict(type='dict')
)

def to_list(val):
Expand Down Expand Up @@ -100,14 +101,17 @@ def connect(self):
host = self.module.params['host']
port = self.module.params['port']

self.module.params['url_username'] = self.module.params['username']
self.module.params['url_password'] = self.module.params['password']

if self.module.params['use_ssl']:
proto = 'https'
if not port:
port = 18091
port = 443
else:
proto = 'http'
if not port:
port = 8091
port = 80

self.baseurl = '%s://%s:%s/rest/v1' % (proto, host, port)

Expand Down Expand Up @@ -156,9 +160,10 @@ def connect(self, **kwargs):
key_filename = self.module.params['ssh_keyfile']

self.shell = Shell()
self.shell.open(host, port=port, username=username, password=password, key_filename=key_filename)
self.shell.open(host, port=port, username=username, password=password,
key_filename=key_filename)

def send(self, commands, encoding='text'):
def send(self, commands):
return self.shell.send(commands)

class NetworkModule(AnsibleModule):
Expand Down

0 comments on commit 2f411c9

Please sign in to comment.