def rules_list(ctx, name): try: gateway_resource = get_gateway(ctx, name) firewall_rules = gateway_resource.get_firewall_rules_list() stdout(firewall_rules, ctx) except Exception as e: stderr(e, ctx)
def list(ctx, gateway_name): try: gateway_resource = get_gateway(ctx, gateway_name) nat_list = gateway_resource.list_nat_rules() stdout(nat_list, ctx) except Exception as e: stderr(e, ctx)
def list_objects(ctx, name, type, object_type): try: gateway_resource = get_gateway(ctx, name) objects = gateway_resource.list_firewall_objects(type, object_type) stdout(objects, ctx) except Exception as e: stderr(e, ctx)
def list_static_routes(ctx, gateway_name): try: gateway_resource = get_gateway(ctx, gateway_name) static_route_list = gateway_resource.list_static_routes() stdout(static_route_list, ctx) except Exception as e: stderr(e, ctx)
def list_service_certificate(ctx, gateway_name): try: gateway_resource = get_gateway(ctx, gateway_name) result = gateway_resource.list_service_certificates() stdout(result, ctx) except Exception as e: stderr(e, ctx)
def change_shared_key(ctx, gateway_name, new_shared_key): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.change_shared_key_ipsec_vpn(new_shared_key) stdout('IPsec VPN shared key changed.', ctx) except Exception as e: stderr(e, ctx)
def list_dhcp_pool(ctx, gateway_name): try: gateway_resource = get_gateway(ctx, gateway_name) result = gateway_resource.list_dhcp_pools() stdout(result, ctx) except Exception as e: stderr(e, ctx)
def set_log_level(ctx, gateway_name, log_level): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.set_log_level_ipsec_vpn(log_level) stdout('IPsec VPN log level changed.', ctx) except Exception as e: stderr(e, ctx)
def list_ipsec_vpn(ctx, gateway_name): try: gateway_resource = get_gateway(ctx, gateway_name) result = gateway_resource.list_ipsec_vpn() stdout(result, ctx) except Exception as e: stderr(e, ctx)
def info_logging_settings(ctx, gateway_name): try: gateway_resource = get_gateway(ctx, gateway_name) result = gateway_resource.info_logging_settings_ipsec_vpn() stdout(result, ctx) except Exception as e: stderr(e, ctx)
def enable_logging(ctx, gateway_name, enabled): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.enable_logging_ipsec_vpn(enabled) stdout('IPsec VPN logging enable status changed.', ctx) except Exception as e: stderr(e, ctx)
def info_activation_status(ctx, gateway_name): try: gateway_resource = get_gateway(ctx, gateway_name) result = gateway_resource.info_activation_status_ipsec_vpn() stdout(result, ctx) except Exception as e: stderr(e, ctx)
def reorder_nat_rule(ctx, gateway_name, rule_id, index): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.reorder_nat_rule(rule_id, position=index) stdout('NAT rule reordered successfully.', ctx) except Exception as e: stderr(e, ctx)
def enable_activation_status(ctx, gateway_name, enabled): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.enable_activation_status_ipsec_vpn(enabled) stdout('IPsec VPN activation status changed.', ctx) except Exception as e: stderr(e, ctx)
def create_static_route(ctx, gateway_name, type, network, next_hop, mtu, description, vnic): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_static_route(network, next_hop, mtu, description, type, vnic) stdout('Static route created successfully.', ctx) except Exception as e: stderr(e, ctx)
def create_firewall_rule(ctx, gateway_name, name, action, type, enabled, logging_enabled): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_firewall_rule(name, action, type, enabled, logging_enabled) stdout('Firewall rule created successfully.', ctx) except Exception as e: stderr(e, ctx)
def add_crl_certificate(ctx, gateway_name, certificate_file_path, desc): try: restore_session(ctx, vdc_required=True) gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_crl_certificate( crl_certificate_file_path=certificate_file_path, description=desc) stdout('CRL certificate added successfully', ctx) except Exception as e: stderr(e, ctx)
def create_dhcp_pool(ctx, gateway_name, ip_range, is_auto_dns, gateway_ip, domain, lease_expire, primary_server, secondary_server, lease, subnet): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_dhcp_pool(ip_range, is_auto_dns, gateway_ip, domain, lease_expire, lease, subnet, primary_server, secondary_server) stdout('DHCP Pool created successfully.', ctx) except Exception as e: stderr(e, ctx)
def add_ca_certificate(ctx, gateway_name, certificate_file_path, desc): try: restore_session(ctx, vdc_required=True) gateway_resource = get_gateway(ctx, gateway_name) gateway_resource. \ add_ca_certificate(ca_certificate_file_path= certificate_file_path, description=desc) stdout('CA certificate added successfully', ctx) except Exception as e: stderr(e, ctx)
def create_dhcp_pool(ctx, gateway_name, ip_range, is_auto_dns, gateway_ip, domain, lease_expire, primary_server, secondary_server, lease, subnet): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_dhcp_pool(ip_range, is_auto_dns, gateway_ip , domain, lease_expire, lease, subnet, primary_server, secondary_server) stdout('DHCP Pool created successfully.', ctx) except Exception as e: stderr(e, ctx)
def add_service_certificate(ctx, gateway_name, certificate_file_path, private_key_file_path, pass_phrase, desc): try: restore_session(ctx, vdc_required=True) gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_service_certificate( service_certificate_file_path=certificate_file_path, private_key_file_path=private_key_file_path, private_key_passphrase=pass_phrase, description=desc) stdout('Service certificate added successfully', ctx) except Exception as e: stderr(e, ctx)
def add_service_certificate(ctx, gateway_name, certificate_file_path, private_key_file_path, pass_phrase, desc): try: restore_session(ctx, vdc_required=True) gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.\ add_service_certificate(service_certificate_file_path= certificate_file_path, private_key_file_path=private_key_file_path, private_key_passphrase=pass_phrase, description=desc) stdout('Service certificate added successfully', ctx) except Exception as e: stderr(e, ctx)
def create_snat_rule(ctx, gateway_name, action, type, original_address, translated_address, enabled, logging_enabled, description, vnic): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_nat_rule(action=action, original_address=original_address, translated_address=translated_address, description=description, type=type, logging_enabled=logging_enabled, enabled=enabled, vnic=vnic) stdout('SNAT rule created successfully.', ctx) except Exception as e: stderr(e, ctx)
def create_snat_rule(ctx, gateway_name, action, type, original_address, translated_address, enabled, logging_enabled, description, vnic): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_nat_rule( action=action, original_address=original_address, translated_address=translated_address, description=description, type=type, logging_enabled=logging_enabled, enabled=enabled, vnic=vnic) stdout('SNAT rule created successfully.', ctx) except Exception as e: stderr(e, ctx)
def create_ipsec_vpn(ctx, gateway_name, name, local_id, peer_id, local_ip, peer_ip, local_subnet, peer_subnet, pre_shared_key, description, encryption_protocol, authentication_mode, dh_group, mtu, enabled, enable_pfs): try: gateway_resource = get_gateway(ctx, gateway_name) gateway_resource.add_ipsec_vpn(name=name, peer_id=peer_id, peer_ip_address=peer_ip, local_id=local_id, local_ip_address=local_ip, local_subnet=local_subnet, peer_subnet=peer_subnet, shared_secret_encrypted=pre_shared_key, encryption_protocol=encryption_protocol, authentication_mode=authentication_mode, dh_group=dh_group, mtu=mtu, description=description, is_enabled=enabled, enable_pfs=enable_pfs) stdout('IPsec VPN created successfully.', ctx) except Exception as e: stderr(e, ctx)