'Return a network dictionary or the value of given key of.'

def get_network(self, key=None):

    if self.network:
        return self._get_by_key(key, self.network)
    network = self.module.params.get('network')
    if (not network):
        vpc_name = self.get_vpc(key='name')
        if vpc_name:
            self.fail_json(msg=("Could    not    find    network    for    VPC    '%s'    due    missing    argument:    network" % vpc_name))
        return None
    args = {'account': self.get_account(key='name'), 'domainid': self.get_domain(key='id'), 'projectid': self.get_project(key='id'), 'zoneid': self.get_zone(key='id'), 'vpcid': self.get_vpc(key='id')}
    networks = self.query_api('listNetworks', **args)
    if (not networks):
        self.fail_json(msg='No    networks    available.')
    for n in networks['network']:
        if (('vpcid' in n) and (not self.get_vpc(key='id'))):
            continue
        if (network in [n['displaytext'], n['name'], n['id']]):
            self.result['network'] = n['name']
            self.network = n
            return self._get_by_key(key, self.network)
    self.fail_json(msg=("Network    '%s'    not    found" % network))
