diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..7ba0f884 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @SoftLayer/SLDN diff --git a/.metadata b/.metadata new file mode 100644 index 00000000..55ef9150 --- /dev/null +++ b/.metadata @@ -0,0 +1,12 @@ +{ + "service": "iaas-all", + "production_code": "yes", + "production_branches": ["master"], + "security_sensitive": "no", + "ip_sensitive": "no", + "allow_cloud_readers": "yes", + "public_override": + { + "other": "Open Source SDK Library for building the sl ibmcloud plugin" + } +} diff --git a/.pipeline-config.yaml b/.pipeline-config.yaml new file mode 100644 index 00000000..5fcc0813 --- /dev/null +++ b/.pipeline-config.yaml @@ -0,0 +1,44 @@ +version: '1' +# 'ibmcloud cr images --restrict continuous-delivery' for image options +setup: + skip: true + +test: + abort_on_failure: true + image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi9:latest + script: | + #!/usr/bin/env bash + + if [[ "$PIPELINE_DEBUG" == 1 ]]; then + trap env EXIT + env + set -x + fi + + cd "$WORKSPACE/$(load_repo app-repo path)" + + dnf update + wget -q https://go.dev/dl/go1.23.6.linux-amd64.tar.gz + tar -C /usr/local -xzf go1.23.6.linux-amd64.tar.gz + export PATH=$PATH:/usr/local/go/bin + export GOPATH=$HOME/go + export PATH=$PATH:$GOPATH/bin + curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -d -b $GOPATH/bin + go version + # Actual Tests + "./bin/gotest.sh" + +# See .cra/cveignore file for skipped checks. +compliance-checks: + image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi9:latest + dind: true + abort_on_failure: false + image_pull_policy: IfNotPresent + skip: false + runAfter: null + script: | + #!/bin/sh + yum update -yq && yum install -yq python3-pip + python3 --version + + "/opt/commons/compliance-checks/run.sh" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5bb24b0f..00000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -group: bluezone -jobs: - include: - - language: python - python: 3.12 - install: - - echo -e "machine github.ibm.com\n login $CI_USER_TOKEN" > ~/.netrc - - python3 -m pip install -U pip - - pip3 install importlib_metadata - - pip3 install pyOpenSSL --upgrade - - pip3 install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets" - script: - - detect-secrets scan --update .secrets.baseline - - detect-secrets audit .secrets.baseline --report --fail-on-unaudited --omit-instructions - - language: go - go: 1.21.3 - install: - # Required to install detect-secrets - - echo -e "machine github.ibm.com\n login $CI_USER_TOKEN" > ~/.netrc - - curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -d -b $GOPATH/bin - before_script: - - go vet $(go list ./... | grep -v "fixtures" | grep -v "vendor") - - go test $(go list ./... | grep -v "fixtures" | grep -v "vendor") - - gosec -exclude-dir=fixture -exclude-dir=plugin/resources -quiet ./... - script: - - go build - -notifications: - slack: - rooms: ibm-cloudplatform:RZfnTv0P664KhVAtEAjcEBPJ - on_failure: always - on_success: change diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..7ab40af4 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @SoftLayer/sldn diff --git a/bin/gotest.sh b/bin/gotest.sh new file mode 100755 index 00000000..fd9c69dc --- /dev/null +++ b/bin/gotest.sh @@ -0,0 +1,7 @@ +#!/usr/bin/bash +set -e + +go vet $(go list ./... | grep -v "fixtures" | grep -v "vendor") +go test $(go list ./... | grep -v "fixtures" | grep -v "vendor") +gosec -exclude-dir=fixture -exclude-dir=plugin/resources -quiet ./... +go build \ No newline at end of file diff --git a/go.mod b/go.mod index a564dd7d..721b83ca 100644 --- a/go.mod +++ b/go.mod @@ -1,48 +1,51 @@ module github.ibm.com/SoftLayer/softlayer-cli -go 1.22.3 +go 1.23.0 + +toolchain go1.23.4 require ( - github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.4.0 - github.com/Xuanwo/go-locale v1.1.0 + github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.7.2 + github.com/Xuanwo/go-locale v1.1.3 github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 - github.com/miekg/dns v1.1.61 - github.com/nicksnyder/go-i18n/v2 v2.4.0 + github.com/miekg/dns v1.1.65 + github.com/nicksnyder/go-i18n/v2 v2.6.0 github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.36.1 github.com/sethvargo/go-password v0.3.1 - github.com/softlayer/softlayer-go v1.1.6 - github.com/spf13/cobra v1.8.1 - github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.9.0 - golang.org/x/text v0.21.0 + github.com/softlayer/softlayer-go v1.1.7 + github.com/spf13/cobra v1.9.1 + github.com/spf13/pflag v1.0.6 + github.com/stretchr/testify v1.10.0 + golang.org/x/text v0.25.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.17.0 // indirect + github.com/fatih/color v1.18.0 // indirect github.com/fatih/structs v1.1.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/gofrs/flock v0.12.0 // indirect + github.com/gofrs/flock v0.12.1 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jedib0t/go-pretty/v6 v6.6.7 // indirect github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/mod v0.20.0 // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/term v0.27.0 // indirect - golang.org/x/tools v0.24.0 // indirect + golang.org/x/crypto v0.38.0 // indirect + golang.org/x/mod v0.24.0 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sync v0.14.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/term v0.32.0 // indirect + golang.org/x/tools v0.33.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 //indirect ) diff --git a/go.sum b/go.sum index d00ae66d..25d42dc1 100644 --- a/go.sum +++ b/go.sum @@ -1,53 +1,49 @@ -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.4.0 h1:Q+zEWnb3z9vfWOkCRlNziO5Pd7i2xwXFRMWQ5RU+CKA= -github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.4.0/go.mod h1:XxWyb5MQDU4GnRBSDZpGgIFwfbcn+GAUbPKS8CR8Bxc= -github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= -github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.7.2 h1:eW5o8NpblAyqPjwOlZ+XISdhlYynjf7B7dsCmsvfC/s= +github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.7.2/go.mod h1:HulyrJLLc9FSZlwKQ9vu5Jq83thNlUfg1afonOdhrRA= +github.com/Xuanwo/go-locale v1.1.3 h1:EWZZJJt5rqPHHbqPRH1zFCn5D7xHjjebODctA4aUO3A= +github.com/Xuanwo/go-locale v1.1.3/go.mod h1:REn+F/c+AtGSWYACBSYZgl23AP+0lfQC+SEFPN+hj30= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/gofrs/flock v0.12.0 h1:xHW8t8GPAiGtqz7KxiSqfOEXwpOaqhpYZrTE2MQBgXY= -github.com/gofrs/flock v0.12.0/go.mod h1:FirDy1Ing0mI2+kB6wk+vyyAH+e6xiE+EYA0jnzV9jc= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jarcoal/httpmock v1.0.5 h1:cHtVEcTxRSX4J0je7mWPfc9BpDpqzXSJ5HbymZmyHck= github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/jedib0t/go-pretty/v6 v6.6.7 h1:m+LbHpm0aIAPLzLbMfn8dc3Ht8MW7lsSO4MPItz/Uuo= +github.com/jedib0t/go-pretty/v6 v6.6.7/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 h1:NicmruxkeqHjDv03SfSxqmaLuisddudfP3h5wdXFbhM= github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1/go.mod h1:eyp4DdUJAKkr9tvxR3jWhw2mDK7CWABMG5r9uyaKC7I= -github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= -github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= -github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM= -github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4= +github.com/miekg/dns v1.1.65 h1:0+tIPHzUW0GCge7IiK3guGP57VAw7hoPDfApjkMD1Fc= +github.com/miekg/dns v1.1.65/go.mod h1:Dzw9769uoKVaLuODMDZz9M6ynFU6Em65csPuoi8G0ck= +github.com/nicksnyder/go-i18n/v2 v2.6.0 h1:C/m2NNWNiTB6SK4Ao8df5EWm3JETSTIGNXBpMJTxzxQ= +github.com/nicksnyder/go-i18n/v2 v2.6.0/go.mod h1:88sRqr0C6OPyJn0/KRNaEz1uWorjxIKP7rUUcvycecE= github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo= github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw= @@ -64,48 +60,33 @@ github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= github.com/sethvargo/go-password v0.3.1 h1:WqrLTjo7X6AcVYfC6R7GtSyuUQR9hGyAj/f1PYQZCJU= github.com/sethvargo/go-password v0.3.1/go.mod h1:rXofC1zT54N7R8K/h1WDUdkf9BOx5OptoxrMBcrXzvs= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= -github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/softlayer/softlayer-go v1.1.6 h1:VRNXiXZTpb7cfKjimU5E7W9zzKYzWMr/xtqlJ0pHwkQ= -github.com/softlayer/softlayer-go v1.1.6/go.mod h1:WeJrBLoTJcaT8nO1azeyHyNpo/fDLtbpbvh+pzts+Qw= +github.com/softlayer/softlayer-go v1.1.7 h1:SgTL+pQZt1h+5QkAhVmHORM/7N9c1X0sljJhuOIHxWE= +github.com/softlayer/softlayer-go v1.1.7/go.mod h1:WeJrBLoTJcaT8nO1azeyHyNpo/fDLtbpbvh+pzts+Qw= github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e h1:3OgWYFw7jxCZPcvAg+4R8A50GZ+CCkARF10lxu2qDsQ= github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e/go.mod h1:fKZCUVdirrxrBpwd9wb+lSoVixvpwAu8eHzbQB2tums= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= +github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= +golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= +golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -113,6 +94,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugin/commands/cdn/cdn.go b/plugin/commands/cdn/cdn.go index e4e2fad2..cca29607 100644 --- a/plugin/commands/cdn/cdn.go +++ b/plugin/commands/cdn/cdn.go @@ -1,7 +1,7 @@ package cdn import ( - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/plugin" + "github.com/spf13/cobra" . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" @@ -18,11 +18,3 @@ func SetupCobraCommands(sl *metadata.SoftlayerCommand) *cobra.Command { return cobraCmd } - -func CdnNamespace() plugin.Namespace { - return plugin.Namespace{ - ParentName: "sl", - Name: "cdn", - Description: T("Classic infrastructure CDN commands" + " " + T("Deprecated")), - } -} diff --git a/plugin/commands/ipsec/cancel.go b/plugin/commands/ipsec/cancel.go deleted file mode 100644 index b528ace6..00000000 --- a/plugin/commands/ipsec/cancel.go +++ /dev/null @@ -1,70 +0,0 @@ -package ipsec - -import ( - "strconv" - - "github.com/spf13/cobra" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" -) - -type CancelCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - Immediate bool - Reason string - ForceFlag bool -} - -func NewCancelCommand(sl *metadata.SoftlayerCommand) (cmd *CancelCommand) { - thisCmd := &CancelCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "cancel " + T("CONTEXT_ID"), - Short: T("Cancel a IPSec VPN tunnel context"), - Args: metadata.OneArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().BoolVar(&thisCmd.Immediate, "immediate", false, T("Cancel the IPSec immediately instead of on the billing anniversary")) - cobraCmd.Flags().StringVar(&thisCmd.Reason, "reason", "", T("An optional reason for cancellation")) - cobraCmd.Flags().BoolVarP(&thisCmd.ForceFlag, "force", "f", false, T("Force operation without confirmation")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *CancelCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - if !cmd.ForceFlag { - confirm, err := cmd.UI.Confirm(T("This will cancel the IPSec: {{.ContextID}} and cannot be undone. Continue?", map[string]interface{}{"ContextID": contextId})) - if err != nil { - return err - } - if !confirm { - cmd.UI.Print(T("Aborted.")) - return nil - } - } - err = cmd.IPSECManager.CancelTunnelContext(contextId, cmd.Immediate, cmd.Reason) - if err != nil { - return errors.NewAPIError(T("Failed to cancel IPSec {{.ContextID}}.\n", map[string]interface{}{"ContextID": contextId}), err.Error(), 2) - } - cmd.UI.Ok() - cmd.UI.Print(T("IPSec {{.ContextID}} is cancelled.", map[string]interface{}{"ContextID": contextId})) - return nil -} diff --git a/plugin/commands/ipsec/cancel_test.go b/plugin/commands/ipsec/cancel_test.go deleted file mode 100644 index 479e64c1..00000000 --- a/plugin/commands/ipsec/cancel_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/session" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec cancel", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.CancelCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewCancelCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - - Context("cancel without contextID", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires one argument")).To(BeTrue()) - }) - }) - Context("cancel with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("cancel without confirmation", func() { - It("return aborted", func() { - fakeUI.Inputs("No") - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"This will cancel the IPSec: 1234 and cannot be undone. Continue?"})) - }) - }) - Context("cancel with server fails", func() { - BeforeEach(func() { - fakeIPSecManager.CancelTunnelContextReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-f") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to cancel IPSec 1234.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("cancel with correct context id", func() { - BeforeEach(func() { - fakeIPSecManager.ApplyConfigurationReturns(nil) - }) - It("return no error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-f") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"OK"})) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"IPSec 1234 is cancelled."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/config.go b/plugin/commands/ipsec/config.go deleted file mode 100644 index b5684049..00000000 --- a/plugin/commands/ipsec/config.go +++ /dev/null @@ -1,60 +0,0 @@ -package ipsec - -import ( - "strconv" - - "github.com/spf13/cobra" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" -) - -type ConfigCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command -} - -func NewConfigCommand(sl *metadata.SoftlayerCommand) (cmd *ConfigCommand) { - thisCmd := &ConfigCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "config " + T("CONTEXT_ID"), - Short: T("Request configuration of a tunnel context"), - Long: T(`${COMMAND_NAME} sl ipsec config CONTEXT_ID [OPTIONS] - - Request configuration of a tunnel context. - - This action will update the advancedConfigurationFlag on the context - instance and further modifications against the context will be prevented - until all changes can be propagated to network devices.`), - Args: metadata.OneArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *ConfigCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - err = cmd.IPSECManager.ApplyConfiguration(contextId) - if err != nil { - return errors.NewAPIError(T("Failed to enqueue configuration request for IPSec {{.ContextID}}.\n", map[string]interface{}{"ContextID": contextId}), err.Error(), 2) - } - cmd.UI.Ok() - cmd.UI.Print(T("Configuration request received for IPSec {{.ContextID}}.", map[string]interface{}{"ContextID": contextId})) - return nil -} diff --git a/plugin/commands/ipsec/config_test.go b/plugin/commands/ipsec/config_test.go deleted file mode 100644 index 22a486a1..00000000 --- a/plugin/commands/ipsec/config_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/session" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec config", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.ConfigCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewConfigCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - - Context("config without contextID", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires one argument")).To(BeTrue()) - }) - }) - Context("config with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("config with server fails", func() { - BeforeEach(func() { - fakeIPSecManager.ApplyConfigurationReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to enqueue configuration request for IPSec 1234.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("config with correct context id", func() { - BeforeEach(func() { - fakeIPSecManager.ApplyConfigurationReturns(nil) - }) - It("return no error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"OK"})) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Configuration request received for IPSec 1234."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/detail.go b/plugin/commands/ipsec/detail.go deleted file mode 100644 index bb8cff53..00000000 --- a/plugin/commands/ipsec/detail.go +++ /dev/null @@ -1,223 +0,0 @@ -package ipsec - -import ( - "bytes" - "strconv" - - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/terminal" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/spf13/cobra" - - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" -) - -type DetailCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - Include []string -} - -func NewDetailCommand(sl *metadata.SoftlayerCommand) (cmd *DetailCommand) { - thisCmd := &DetailCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "detail " + T("CONTEXT_ID"), - Short: T("List IPSec VPN tunnel context details"), - Long: T(`${COMMAND_NAME} sl ipsec detail CONTEXT_ID [OPTIONS] - - List IPSEC VPN tunnel context details. - - Additional resources can be joined using multiple instances of the include - option, for which the following choices are available. - - at: address translations - is: internal subnets - rs: remote subnets - sr: statically routed subnets - ss: service subnets`), - Args: metadata.OneArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().StringSliceVarP(&thisCmd.Include, "include", "i", []string{}, T("Include extra resources. Options are: at,is,rs,sr,ss")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *DetailCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - - outputFormat := cmd.GetOutputFlag() - - at, is, rs, sr, ss := false, false, false, false, false - includes := cmd.Include - if i := utils.StringInSlice("at", includes); i >= 0 { - at = true - } - if i := utils.StringInSlice("is", includes); i >= 0 { - is = true - } - if i := utils.StringInSlice("rs", includes); i >= 0 { - rs = true - } - if i := utils.StringInSlice("sr", includes); i >= 0 { - sr = true - } - if i := utils.StringInSlice("ss", includes); i >= 0 { - ss = true - } - mask := GetTunnelContextMask(at, is, rs, sr, ss) - context, err := cmd.IPSECManager.GetTunnelContext(contextId, mask) - if err != nil { - return errors.NewAPIError(T("Failed to get IPSec with ID {{.ID}}.\n", map[string]interface{}{"ID": contextId}), err.Error(), 2) - } - - if outputFormat == "JSON" { - return utils.PrintPrettyJSON(cmd.UI, context) - } - - table := cmd.UI.Table([]string{T("Name"), T("Value")}) - table = printTunnelContext(table, &context) - if at { - table = printAddressTransaltion(table, T("Address Translations"), context.AddressTranslations) - } - if is { - table = printSubnetTable(table, T("Internal Subnets"), context.InternalSubnets) - } - if rs { - table = printCustomerSubnetTable(table, T("Remote Subnets"), context.CustomerSubnets) - } - if sr { - table = printSubnetTable(table, T("Static Subnets"), context.StaticRouteSubnets) - } - if ss { - table = printSubnetTable(table, T("Service Subnets"), context.ServiceSubnets) - } - table.Print() - return nil -} - -// Yields a mask for a tunnel context -// All exposed properties on the tunnel context service are included inthe constructed mask. Additional joins may be requested. -// addressTranslations: Whether to join the context's address translation entries. -// internalSubnets: Whether to join the context's internal subnet associations. -// remoteSubnets: Whether to join the context's remote subnet associations. -// staticSubnets: Whether to join the context's statically routed subnet associations. -// serviceSubnets: Whether to join the SoftLayer service network subnets. -func GetTunnelContextMask(addressTranslation, internalSubnets, remoteSubnets, statusSubnets, serviceSubnets bool) string { - mask := "id,accountId,advancedConfigurationFlag,createDate,customerPeerIpAddress,modifyDate,name,friendlyName,internalPeerIpAddress" + - ",phaseOneAuthentication,phaseOneDiffieHellmanGroup,phaseOneEncryption,phaseOneKeylife" + - ",phaseTwoAuthentication,phaseTwoDiffieHellmanGroup,phaseTwoEncryption,phaseTwoKeylife" + - ",phaseTwoPerfectForwardSecrecy,presharedKey" - if addressTranslation { - mask = mask + ",addressTranslations[internalIpAddressRecord[ipAddress],customerIpAddressRecord[ipAddress]]" - } - if internalSubnets { - mask = mask + ",internalSubnets" - } - if remoteSubnets { - mask = mask + ",customerSubnets" - } - if statusSubnets { - mask = mask + ",staticRouteSubnets" - } - if serviceSubnets { - mask = mask + ",serviceSubnets" - } - return mask -} - -func printTunnelContext(table terminal.Table, context *datatypes.Network_Tunnel_Module_Context) terminal.Table { - table.Add(T("ID"), utils.FormatIntPointer(context.Id)) - table.Add(T("Name"), utils.FormatStringPointer(context.Name)) - table.Add(T("Friendly name"), utils.FormatStringPointer(context.FriendlyName)) - table.Add(T("Internal peer IP address"), utils.FormatStringPointer(context.InternalPeerIpAddress)) - table.Add(T("Remote peer IP address"), utils.FormatStringPointer(context.CustomerPeerIpAddress)) - table.Add(T("Advanced configuration flag"), utils.FormatIntPointer(context.AdvancedConfigurationFlag)) - table.Add(T("Preshared key"), utils.FormatStringPointer(context.PresharedKey)) - table.Add(T("Phase 1 authentication"), utils.FormatStringPointer(context.PhaseOneAuthentication)) - table.Add(T("Phase 1 diffie hellman group"), utils.FormatIntPointer(context.PhaseOneDiffieHellmanGroup)) - table.Add(T("Phase 1 encryption"), utils.FormatStringPointer(context.PhaseOneEncryption)) - table.Add(T("Phase 1 key life"), utils.FormatIntPointer(context.PhaseOneKeylife)) - table.Add(T("Phase 2 authentication"), utils.FormatStringPointer(context.PhaseTwoAuthentication)) - table.Add(T("Phase 2 diffie hellman group"), utils.FormatIntPointer(context.PhaseTwoDiffieHellmanGroup)) - table.Add(T("Phase 2 encryption"), utils.FormatStringPointer(context.PhaseTwoEncryption)) - table.Add(T("Phase 2 key life"), utils.FormatIntPointer(context.PhaseTwoKeylife)) - table.Add(T("Phase 2 perfect forward secrecy"), utils.FormatIntPointer(context.PhaseTwoPerfectForwardSecrecy)) - table.Add(T("Created"), utils.FormatSLTimePointer(context.CreateDate)) - table.Add(T("Modified"), utils.FormatSLTimePointer(context.ModifyDate)) - return table -} - -func printSubnetTable(table terminal.Table, header string, subnets []datatypes.Network_Subnet) terminal.Table { - if len(subnets) == 0 { - table.Add(header, T("None")) - } else { - buf := new(bytes.Buffer) - snTable := terminal.NewTable(buf, []string{T("ID"), T("Network identifier"), T("CIDR"), T("Note")}) - for _, sn := range subnets { - snTable.Add(utils.FormatIntPointer(sn.Id), - utils.FormatStringPointer(sn.NetworkIdentifier), - utils.FormatIntPointer(sn.Cidr), - utils.FormatStringPointer(sn.Note)) - } - snTable.Print() - table.Add(header, buf.String()) - } - return table -} - -func printCustomerSubnetTable(table terminal.Table, header string, subnets []datatypes.Network_Customer_Subnet) terminal.Table { - if len(subnets) == 0 { - table.Add(header, T("None")) - } else { - buf := new(bytes.Buffer) - snTable := terminal.NewTable(buf, []string{T("ID"), T("Network identifier"), T("CIDR"), T("Note")}) - for _, sn := range subnets { - snTable.Add(utils.FormatIntPointer(sn.Id), - utils.FormatStringPointer(sn.NetworkIdentifier), - utils.FormatIntPointer(sn.Cidr), - "") - } - snTable.Print() - table.Add(header, buf.String()) - } - return table -} - -func printAddressTransaltion(table terminal.Table, header string, translations []datatypes.Network_Tunnel_Module_Context_Address_Translation) terminal.Table { - if len(translations) == 0 { - table.Add(header, T("None")) - } else { - buf := new(bytes.Buffer) - atTable := terminal.NewTable(buf, []string{T("ID"), T("Static IP address"), T("Static IP address ID"), T("Remote IP address"), T("Remote IP address ID"), T("Note")}) - for _, at := range translations { - atTable.Add(utils.FormatIntPointer(at.Id), - utils.FormatStringPointer(at.InternalIpAddressRecord.IpAddress), - utils.FormatIntPointer(at.InternalIpAddressId), - utils.FormatStringPointer(at.CustomerIpAddressRecord.IpAddress), - utils.FormatIntPointer(at.CustomerIpAddressId), - utils.FormatStringPointer(at.Notes)) - } - atTable.Print() - table.Add(header, buf.String()) - } - - return table -} diff --git a/plugin/commands/ipsec/detail_test.go b/plugin/commands/ipsec/detail_test.go deleted file mode 100644 index 4c2109cc..00000000 --- a/plugin/commands/ipsec/detail_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec detail", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.DetailCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewDetailCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("detail without contextID", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires one argument")).To(BeTrue()) - }) - }) - Context("detail with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("detail with server fails", func() { - BeforeEach(func() { - fakeIPSecManager.GetTunnelContextReturns(datatypes.Network_Tunnel_Module_Context{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to get IPSec with ID 1234.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) -}) diff --git a/plugin/commands/ipsec/ipsec.go b/plugin/commands/ipsec/ipsec.go deleted file mode 100644 index 8493692e..00000000 --- a/plugin/commands/ipsec/ipsec.go +++ /dev/null @@ -1,38 +0,0 @@ -package ipsec - -import ( - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/plugin" - "github.com/spf13/cobra" - - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" -) - -func SetupCobraCommands(sl *metadata.SoftlayerCommand) *cobra.Command { - cobraCmd := &cobra.Command{ - Use: "ipsec", - Short: T("Classic infrastructure IPSEC VPN"), - RunE: nil, - } - - cobraCmd.AddCommand(NewConfigCommand(sl).Command) - cobraCmd.AddCommand(NewCancelCommand(sl).Command) - cobraCmd.AddCommand(NewOrderCommand(sl).Command) - cobraCmd.AddCommand(NewDetailCommand(sl).Command) - cobraCmd.AddCommand(NewListCommand(sl).Command) - cobraCmd.AddCommand(NewAddSubnetCommand(sl).Command) - cobraCmd.AddCommand(NewRemoveSubnetCommand(sl).Command) - cobraCmd.AddCommand(NewAddTranslationCommand(sl).Command) - cobraCmd.AddCommand(NewRemoveTranslationCommand(sl).Command) - cobraCmd.AddCommand(NewUpdateTranslationCommand(sl).Command) - cobraCmd.AddCommand(NewUpdateCommand(sl).Command) - return cobraCmd -} - -func IpsecNamespace() plugin.Namespace { - return plugin.Namespace{ - ParentName: "sl", - Name: "ipsec", - Description: T("Classic infrastructure IPSEC VPN"), - } -} diff --git a/plugin/commands/ipsec/ipsec_test.go b/plugin/commands/ipsec/ipsec_test.go deleted file mode 100644 index db7085cc..00000000 --- a/plugin/commands/ipsec/ipsec_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package ipsec_test - -import ( - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" -) - -func TestManagers(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "IPSEC Suite") -} - -var availableCommands = []string{ - "cancel", - "config", - "detail", - "list", - "order", - "subnet-add", - "subnet-remove", - "translation-add", - "translation-remove", - "translation-update", - "update", -} - -// This test suite exists to make sure commands don't get accidently removed from the SetupCobraCommands -var _ = Describe("Test ipsec commands", func() { - fakeUI := terminal.NewFakeUI() - fakeSession := testhelpers.NewFakeSoftlayerSession(nil) - slMeta := metadata.NewSoftlayerCommand(fakeUI, fakeSession) - - Context("New commands testable", func() { - commands := ipsec.SetupCobraCommands(slMeta) - - var arrayCommands = []string{} - for _, command := range commands.Commands() { - commandName := command.Name() - arrayCommands = append(arrayCommands, commandName) - It("available commands "+commands.Name(), func() { - available := false - if utils.StringInSlice(commandName, availableCommands) != -1 { - available = true - } - Expect(available).To(BeTrue(), commandName+" not found in array available Commands") - }) - } - for _, command := range availableCommands { - commandName := command - It("ibmcloud sl "+commands.Name(), func() { - available := false - if utils.StringInSlice(commandName, arrayCommands) != -1 { - available = true - } - Expect(available).To(BeTrue(), commandName+" not found in ibmcloud sl "+commands.Name()) - }) - } - }) - - Context("ipsec Namespace", func() { - It("ipsec Name Space", func() { - Expect(ipsec.IpsecNamespace().ParentName).To(ContainSubstring("sl")) - Expect(ipsec.IpsecNamespace().Name).To(ContainSubstring("ipsec")) - Expect(ipsec.IpsecNamespace().Description).To(ContainSubstring("Classic infrastructure IPSEC VPN")) - }) - }) -}) diff --git a/plugin/commands/ipsec/list.go b/plugin/commands/ipsec/list.go deleted file mode 100644 index 77dce547..00000000 --- a/plugin/commands/ipsec/list.go +++ /dev/null @@ -1,67 +0,0 @@ -package ipsec - -import ( - "github.com/spf13/cobra" - - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" -) - -type ListCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - Order int -} - -func NewListCommand(sl *metadata.SoftlayerCommand) (cmd *ListCommand) { - thisCmd := &ListCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "list", - Short: T("List IPSec VPN tunnel contexts"), - Args: metadata.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().IntVar(&thisCmd.Order, "order", 0, T("Filter by ID of the order that purchased the IPSec")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *ListCommand) Run(args []string) error { - outputFormat := cmd.GetOutputFlag() - contexts, err := cmd.IPSECManager.GetTunnelContexts(cmd.Order, "") - if err != nil { - return errors.NewAPIError(T("Failed to get IPSec on your account."), err.Error(), 2) - } - - if outputFormat == "JSON" { - return utils.PrintPrettyJSON(cmd.UI, contexts) - } - - if len(contexts) == 0 { - cmd.UI.Print(T("No IPSec was found.")) - } else { - table := cmd.UI.Table([]string{T("ID"), T("Name"), T("FriendlyName"), T("Internal Peer IP Address"), T("Customer Peer IP Address"), T("Created")}) - for _, c := range contexts { - table.Add(utils.FormatIntPointer(c.Id), - utils.FormatStringPointer(c.Name), - utils.FormatStringPointer(c.FriendlyName), - utils.FormatStringPointer(c.InternalPeerIpAddress), - utils.FormatStringPointer(c.CustomerPeerIpAddress), - utils.FormatSLTimePointer(c.CreateDate)) - } - table.Print() - } - return nil -} diff --git a/plugin/commands/ipsec/list_test.go b/plugin/commands/ipsec/list_test.go deleted file mode 100644 index 4d4d0d2c..00000000 --- a/plugin/commands/ipsec/list_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - "time" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.com/softlayer/softlayer-go/sl" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec list", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.ListCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewListCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("list with server fails", func() { - BeforeEach(func() { - fakeIPSecManager.GetTunnelContextsReturns(nil, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to get IPSec on your account.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("list", func() { - BeforeEach(func() { - fakeIPSecManager.GetTunnelContextsReturns(nil, nil) - }) - It("return no ipsec", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"No IPSec was found."})) - }) - }) - Context("list", func() { - BeforeEach(func() { - created := time.Now() - fakeIPSecManager.GetTunnelContextsReturns([]datatypes.Network_Tunnel_Module_Context{ - datatypes.Network_Tunnel_Module_Context{ - Id: sl.Int(123), - Name: sl.String("abc"), - FriendlyName: sl.String("ABC"), - InternalPeerIpAddress: sl.String("1.1.1.2"), - CustomerPeerIpAddress: sl.String("2.2.2.3"), - CreateDate: sl.Time(created), - }, - }, nil) - }) - It("return ipseclist", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"123"})) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"abc"})) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"ABC"})) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"1.1.1.2"})) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"2.2.2.3"})) - }) - }) -}) diff --git a/plugin/commands/ipsec/order.go b/plugin/commands/ipsec/order.go deleted file mode 100644 index 9510dd4c..00000000 --- a/plugin/commands/ipsec/order.go +++ /dev/null @@ -1,63 +0,0 @@ -package ipsec - -import ( - "github.com/spf13/cobra" - - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" -) - -type OrderCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - Datacenter string -} - -func NewOrderCommand(sl *metadata.SoftlayerCommand) (cmd *OrderCommand) { - thisCmd := &OrderCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "order", - Short: T("Order a IPSec VPN tunnel"), - Args: metadata.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().StringVarP(&thisCmd.Datacenter, "datacenter", "d", "", T("Short name of the datacenter for the IPSec. For example, dal09[required]")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *OrderCommand) Run(args []string) error { - location := cmd.Datacenter - if location == "" { - return errors.NewMissingInputError("-d|--datacenter") - } - - outputFormat := cmd.GetOutputFlag() - - orderReceipt, err := cmd.IPSECManager.OrderTunnelContext(location) - if err != nil { - return errors.NewAPIError(T("Failed to order IPSec.Please try again later.\n"), err.Error(), 2) - } - - if outputFormat == "JSON" { - return utils.PrintPrettyJSON(cmd.UI, orderReceipt) - } - - cmd.UI.Ok() - cmd.UI.Print(T("Order {{.OrderID}} was placed.", map[string]interface{}{"OrderID": *orderReceipt.OrderId})) - cmd.UI.Print(T("You may run '{{.CommandName}} sl ipsec list --order {{.OrderID}}' to find this IPSec VPN after it is ready.", - map[string]interface{}{"OrderID": *orderReceipt.OrderId, "CommandName": "ibmcloud"})) - return nil -} diff --git a/plugin/commands/ipsec/order_test.go b/plugin/commands/ipsec/order_test.go deleted file mode 100644 index c68ddae9..00000000 --- a/plugin/commands/ipsec/order_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.com/softlayer/softlayer-go/sl" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec order", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.OrderCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewOrderCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("order without -d", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: '-d|--datacenter' is required")).To(BeTrue()) - }) - }) - Context("order with server fails", func() { - BeforeEach(func() { - fakeIPSecManager.OrderTunnelContextReturns(datatypes.Container_Product_Order_Receipt{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "-d", "dal09") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to order IPSec.Please try again later.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("order", func() { - BeforeEach(func() { - fakeIPSecManager.OrderTunnelContextReturns(datatypes.Container_Product_Order_Receipt{ - OrderId: sl.Int(12345), - }, nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "-d", "dal09") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Order 12345 was placed."})) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"You may run 'ibmcloud sl ipsec list --order 12345' to find this IPSec VPN after it is ready."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/subnet_add.go b/plugin/commands/ipsec/subnet_add.go deleted file mode 100644 index 78325d47..00000000 --- a/plugin/commands/ipsec/subnet_add.go +++ /dev/null @@ -1,124 +0,0 @@ -package ipsec - -import ( - "strconv" - "strings" - - "github.com/spf13/cobra" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" -) - -type AddSubnetCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - SubnetId int - SubnetType string - Network string -} - -func NewAddSubnetCommand(sl *metadata.SoftlayerCommand) (cmd *AddSubnetCommand) { - thisCmd := &AddSubnetCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "subnet-add " + T("CONTEXT_ID"), - Short: T("Add a subnet to an IPSec tunnel context"), - Long: T(`${COMMAND_NAME} sl ipsec subnet-add CONTEXT_ID [OPTIONS] - - Add a subnet to an IPSEC tunnel context. - - A subnet id may be specified to link to the existing tunnel context. - - Otherwise, a network identifier in CIDR notation should be specified, - indicating that a subnet resource should first be created before - associating it with the tunnel context. Note that this is only supported - for remote subnets, which are also deleted upon failure to attach to a - context. - - A separate configuration request should be made to realize changes on - network devices.`), - Args: metadata.OneArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().IntVarP(&thisCmd.SubnetId, "subnet-id", "s", 0, T("Subnet identifier to add, required")) - cobraCmd.Flags().StringVarP(&thisCmd.SubnetType, "subnet-type", "t", "", T("Subnet type to add. Options are: internal,remote,service[required]")) - cobraCmd.Flags().StringVarP(&thisCmd.Network, "network", "n", "", T("Subnet network identifier to create")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *AddSubnetCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - subnetId := cmd.SubnetId - subnetType := cmd.SubnetType - if subnetType != "internal" && subnetType != "remote" && subnetType != "service" { - return errors.NewInvalidUsageError(T("The subnet type has to be either internal, or remote or service.")) - } - networkIdentifier := cmd.Network - createRemote := false - if subnetId == 0 { - if networkIdentifier == "" { - return errors.NewInvalidUsageError(T("Either -s|--subnet-id or -n|--network must be provided.")) - } - if subnetType != "remote" { - return errors.NewInvalidUsageError(T("Unable to create {{.Type}} subnet.", map[string]interface{}{"Type": subnetType})) - } - createRemote = true - } - context, err := cmd.IPSECManager.GetTunnelContext(contextId, "id,accountId") - if err != nil { - return errors.NewAPIError(T("Failed to get IPSec with ID {{.ID}}.\n", map[string]interface{}{"ID": contextId}), err.Error(), 2) - } - if createRemote { - ids := strings.Split(networkIdentifier, "/") - id := ids[0] - cidr, _ := strconv.Atoi(ids[1]) - subnet, err := cmd.IPSECManager.CreateRemoteSubnet(*context.AccountId, id, cidr) - if err != nil { - return errors.NewAPIError(T("Failed to create subnet with {{.ID}}.\n", map[string]interface{}{"ID": networkIdentifier}), err.Error(), 2) - } - subnetId = *subnet.Id - cmd.UI.Print(T("Created subnet {{.ID}}/{{.CIDR}} #{{.Identifier}}.", - map[string]interface{}{"ID": id, "CIDR": cidr, "Identifier": *subnet.Id})) - } - succeeded := false - if subnetType == "internal" { - err = cmd.IPSECManager.AddInternalSubnet(contextId, subnetId) - if err == nil { - succeeded = true - } - } else if subnetType == "remote" { - err = cmd.IPSECManager.AddRemoteSubnet(contextId, subnetId) - if err == nil { - succeeded = true - } - } else if subnetType == "service" { - err = cmd.IPSECManager.AddServiceSubnet(contextId, subnetId) - if err == nil { - succeeded = true - } - } - if succeeded { - cmd.UI.Ok() - cmd.UI.Print(T("Added {{.Type}} subnet #{{.ID}} to IPSec {{.ContextID}}.", - map[string]interface{}{"Type": subnetType, "ID": subnetId, "ContextID": contextId})) - return nil - } - return errors.NewAPIError(T("Failed to add {{.Type}} subnet #{{.ID}} to IPSec {{.ContextID}}.\n", - map[string]interface{}{"Type": subnetType, "ID": subnetId, "ContextID": contextId}), err.Error(), 2) -} diff --git a/plugin/commands/ipsec/subnet_add_test.go b/plugin/commands/ipsec/subnet_add_test.go deleted file mode 100644 index 5d59ab63..00000000 --- a/plugin/commands/ipsec/subnet_add_test.go +++ /dev/null @@ -1,146 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec add subnet", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.AddSubnetCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewAddSubnetCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("Add subnet without context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires one argument")).To(BeTrue()) - }) - }) - Context("Add subnet with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("Add subnet with wrong subnet type", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: The subnet type has to be either internal, or remote or service.")).To(BeTrue()) - }) - }) - Context("Add subnet without subnetId or subnet identifier", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-t", "remote") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: Either -s|--subnet-id or -n|--network must be provided.")).To(BeTrue()) - }) - }) - Context("Add subnet with subnet identifier but wrong subnet type", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-n", "1.1.2.3", "-t", "internal") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: Unable to create internal subnet.")).To(BeTrue()) - }) - }) - //TODO create remote subnet cases - Context("Add internal subnet with get context fail", func() { - BeforeEach(func() { - fakeIPSecManager.GetTunnelContextReturns(datatypes.Network_Tunnel_Module_Context{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "internal") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to get IPSec with ID 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("Add internal subnet with add subnet fail", func() { - BeforeEach(func() { - fakeIPSecManager.AddInternalSubnetReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "internal") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to add internal subnet #456 to IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("Add remote subnet with add subnet fail", func() { - BeforeEach(func() { - fakeIPSecManager.AddRemoteSubnetReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "remote") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to add remote subnet #456 to IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("Add service subnet with add subnet fail", func() { - BeforeEach(func() { - fakeIPSecManager.AddServiceSubnetReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "service") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to add service subnet #456 to IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - - Context("Add internal subnet", func() { - BeforeEach(func() { - fakeIPSecManager.AddInternalSubnetReturns(nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "internal") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Added internal subnet #456 to IPSec 123."})) - }) - }) - Context("Add remote subnet", func() { - BeforeEach(func() { - fakeIPSecManager.AddRemoteSubnetReturns(nil) - }) - It("Add", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "remote") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Added remote subnet #456 to IPSec 123."})) - }) - }) - Context("Add service subnet", func() { - BeforeEach(func() { - fakeIPSecManager.AddServiceSubnetReturns(nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "456", "-t", "service") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Added service subnet #456 to IPSec 123."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/subnet_remove.go b/plugin/commands/ipsec/subnet_remove.go deleted file mode 100644 index 881e190a..00000000 --- a/plugin/commands/ipsec/subnet_remove.go +++ /dev/null @@ -1,93 +0,0 @@ -package ipsec - -import ( - "strconv" - - "github.com/spf13/cobra" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" -) - -type RemoveSubnetCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command -} - -func NewRemoveSubnetCommand(sl *metadata.SoftlayerCommand) (cmd *RemoveSubnetCommand) { - thisCmd := &RemoveSubnetCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "subnet-remove " + T("CONTEXT_ID") + " " + T("SUBNET_ID") + " " + T("SUBNET_TYPE"), - Short: T("Remove a subnet from an IPSEC tunnel context"), - Long: T(`${COMMAND_NAME} sl ipsec subnet-remove CONTEXT_ID SUBNET_ID SUBNET_TYPE - - Remove a subnet from an IPSEC tunnel context. - - The subnet id to remove must be specified. - - Remote subnets are deleted upon removal from a tunnel context. - - A separate configuration request should be made to realize changes on - network devices.`), - Args: metadata.ThreeArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *RemoveSubnetCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - args1 := args[1] - subnetId, err := strconv.Atoi(args1) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Subnet ID") - } - subnetType := args[2] - if subnetType != "internal" && subnetType != "remote" && subnetType != "service" { - return errors.NewInvalidUsageError(T("The subnet type has to be either internal, or remote or service.")) - } - _, err = cmd.IPSECManager.GetTunnelContext(contextId, "") - if err != nil { - return errors.NewAPIError(T("Failed to get IPSec with ID {{.ID}}.\n", map[string]interface{}{"ID": contextId}), err.Error(), 2) - } - succeeded := false - if subnetType == "internal" { - err = cmd.IPSECManager.RemoveInternalSubnet(contextId, subnetId) - if err == nil { - succeeded = true - } - } else if subnetType == "remote" { - err = cmd.IPSECManager.RemoveRemoteSubnet(contextId, subnetId) - if err == nil { - succeeded = true - } - } else if subnetType == "service" { - err = cmd.IPSECManager.RemoveServiceSubnet(contextId, subnetId) - if err == nil { - succeeded = true - } - } - if succeeded { - cmd.UI.Ok() - cmd.UI.Print(T("Removed {{.Type}} subnet #{{.ID}} from IPSec {{.ContextID}}.", - map[string]interface{}{"Type": subnetType, "ID": subnetId, "ContextID": contextId})) - return nil - } - return errors.NewAPIError(T("Failed to remove {{.Type}} subnet #{{.ID}} from IPSec {{.ContextID}}.\n", - map[string]interface{}{"Type": subnetType, "ID": subnetId, "ContextID": contextId}), err.Error(), 2) -} diff --git a/plugin/commands/ipsec/subnet_remove_test.go b/plugin/commands/ipsec/subnet_remove_test.go deleted file mode 100644 index 2ac93c56..00000000 --- a/plugin/commands/ipsec/subnet_remove_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/session" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec remove subnet", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.RemoveSubnetCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewRemoveSubnetCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("remove subnet without context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires three arguments.")).To(BeTrue()) - }) - }) - Context("remove subnet with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc", "bcd", "efg") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("remove subnet with wrong subnet id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "bcd", "efg") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Subnet ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("remove subnet with wrong subnet type", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "efg") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: The subnet type has to be either internal, or remote or service.")).To(BeTrue()) - }) - }) - Context("remove internal subnet with server fail", func() { - BeforeEach(func() { - fakeIPSecManager.RemoveInternalSubnetReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "internal") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to remove internal subnet #456 from IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("remove remote subnet with server fail", func() { - BeforeEach(func() { - fakeIPSecManager.RemoveRemoteSubnetReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "remote") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to remove remote subnet #456 from IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("remove service subnet with server fail", func() { - BeforeEach(func() { - fakeIPSecManager.RemoveServiceSubnetReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "service") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to remove service subnet #456 from IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("remove internal subnet", func() { - BeforeEach(func() { - fakeIPSecManager.RemoveInternalSubnetReturns(nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "internal") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Removed internal subnet #456 from IPSec 123."})) - }) - }) - Context("remove remote subnet", func() { - BeforeEach(func() { - fakeIPSecManager.RemoveRemoteSubnetReturns(nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "remote") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Removed remote subnet #456 from IPSec 123."})) - }) - }) - Context("remove service subnet", func() { - BeforeEach(func() { - fakeIPSecManager.RemoveServiceSubnetReturns(nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "service") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Removed service subnet #456 from IPSec 123."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/translation_add.go b/plugin/commands/ipsec/translation_add.go deleted file mode 100644 index 2e8f7a30..00000000 --- a/plugin/commands/ipsec/translation_add.go +++ /dev/null @@ -1,87 +0,0 @@ -package ipsec - -import ( - "strconv" - - "github.com/spf13/cobra" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" -) - -type AddTranslationCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - StaticIp string - RemoteIp string - Note string -} - -func NewAddTranslationCommand(sl *metadata.SoftlayerCommand) (cmd *AddTranslationCommand) { - thisCmd := &AddTranslationCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "translation-add " + T("CONTEXT_ID"), - Short: T("Add an address translation to an IPSec tunnel"), - Long: T(`${COMMAND_NAME} sl ipsec translation-add CONTEXT_ID [OPTIONS] - - Add an address translation to an IPSEC tunnel context. - - A separate configuration request should be made to realize changes on - network devices.`), - Args: metadata.OneArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().StringVarP(&thisCmd.StaticIp, "static-ip", "s", "", T("Static IP address[required]")) - cobraCmd.Flags().StringVarP(&thisCmd.RemoteIp, "remote-ip", "r", "", T("Remote IP address[required]")) - cobraCmd.Flags().StringVarP(&thisCmd.Note, "note", "n", "", T("Note value")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *AddTranslationCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - - outputFormat := cmd.GetOutputFlag() - - staticIp := cmd.StaticIp - if staticIp == "" { - return errors.NewMissingInputError("-s|--static-ip") - } - remoteIp := cmd.RemoteIp - if remoteIp == "" { - return errors.NewMissingInputError("-r|--remote-ip") - } - _, err = cmd.IPSECManager.GetTunnelContext(contextId, "") - if err != nil { - return errors.NewAPIError(T("Failed to get IPSec with ID {{.ID}}.\n", map[string]interface{}{"ID": contextId}), err.Error(), 2) - } - translation, err := cmd.IPSECManager.CreateTranslation(contextId, staticIp, remoteIp, cmd.Note) - if err != nil { - return errors.NewAPIError(T("Failed to create translation for IPSec with ID {{.ID}}.\n", map[string]interface{}{"ID": contextId}), err.Error(), 2) - } - - if outputFormat == "JSON" { - return utils.PrintPrettyJSON(cmd.UI, translation) - } - - cmd.UI.Ok() - cmd.UI.Print(T("Created translation from {{.StaticIP}} to {{.RemoteIP}} #{{.ID}}.", - map[string]interface{}{"StaticIP": staticIp, "RemoteIP": remoteIp, "ID": *translation.Id})) - return nil -} diff --git a/plugin/commands/ipsec/translation_add_test.go b/plugin/commands/ipsec/translation_add_test.go deleted file mode 100644 index 2d784e0b..00000000 --- a/plugin/commands/ipsec/translation_add_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.com/softlayer/softlayer-go/sl" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec add translation", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.AddTranslationCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewAddTranslationCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("add translation without context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires one argument")).To(BeTrue()) - }) - }) - Context("add translation with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("add translation without static IP", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: '-s|--static-ip' is required")).To(BeTrue()) - }) - }) - Context("add translation without remote IP", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "1.2.3.4") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: '-r|--remote-ip' is required")).To(BeTrue()) - }) - }) - Context("add translation with get context fails", func() { - BeforeEach(func() { - fakeIPSecManager.GetTunnelContextReturns(datatypes.Network_Tunnel_Module_Context{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "1.2.3.4", "-r", "5.6.7.8") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to get IPSec with ID 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("add translation with create translation fails", func() { - BeforeEach(func() { - fakeIPSecManager.GetTunnelContextReturns(datatypes.Network_Tunnel_Module_Context{Id: sl.Int(123)}, nil) - fakeIPSecManager.CreateTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "1.2.3.4", "-r", "5.6.7.8") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to create translation for IPSec with ID 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("add translation ", func() { - BeforeEach(func() { - fakeIPSecManager.GetTunnelContextReturns(datatypes.Network_Tunnel_Module_Context{Id: sl.Int(123)}, nil) - fakeIPSecManager.CreateTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{Id: sl.Int(567)}, nil) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "-s", "1.2.3.4", "-r", "5.6.7.8") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Created translation from 1.2.3.4 to 5.6.7.8 #567."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/translation_remove.go b/plugin/commands/ipsec/translation_remove.go deleted file mode 100644 index 9769264b..00000000 --- a/plugin/commands/ipsec/translation_remove.go +++ /dev/null @@ -1,70 +0,0 @@ -package ipsec - -import ( - "strconv" - - "github.com/spf13/cobra" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" -) - -type RemoveTranslationCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command -} - -func NewRemoveTranslationCommand(sl *metadata.SoftlayerCommand) (cmd *RemoveTranslationCommand) { - thisCmd := &RemoveTranslationCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "translation-remove " + T("CONTEXT_ID") + " " + T("TRANSLATION_ID"), - Short: T("Remove a translation entry from an IPSec"), - Long: T(`${COMMAND_NAME} sl ipsec translation-remove CONTEXT_ID TRANSLATION_ID - - Remove a translation entry from an IPSEC tunnel context. - - A separate configuration request should be made to realize changes on - network devices.`), - Args: metadata.TwoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *RemoveTranslationCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - args1 := args[1] - translationId, err := strconv.Atoi(args1) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Translation ID") - } - _, err = cmd.IPSECManager.GetTranslation(contextId, translationId) - if err != nil { - return errors.NewAPIError(T("Failed to get translation with ID {{.TransID}} from IPSec {{.ID}}.", - map[string]interface{}{"TransID": translationId, "ID": contextId}), err.Error(), 2) - } - err = cmd.IPSECManager.RemoveTranslation(contextId, translationId) - if err != nil { - return errors.NewAPIError(T("Failed to remove translation with ID {{.TransID}} from IPSec {{.ID}}.", - map[string]interface{}{"TransID": translationId, "ID": contextId}), err.Error(), 2) - } - cmd.UI.Ok() - cmd.UI.Print(T("Removed translation with ID {{.TransID}} from IPSec {{.ID}}.", - map[string]interface{}{"TransID": translationId, "ID": contextId})) - return nil -} diff --git a/plugin/commands/ipsec/translation_remove_test.go b/plugin/commands/ipsec/translation_remove_test.go deleted file mode 100644 index c4db5991..00000000 --- a/plugin/commands/ipsec/translation_remove_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.com/softlayer/softlayer-go/sl" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec remove translation", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.RemoveTranslationCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewRemoveTranslationCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("remove translation without context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires two arguments.")).To(BeTrue()) - }) - }) - Context("remove translation without translation id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires two arguments.")).To(BeTrue()) - }) - }) - Context("remove translation with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc", "456") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("remove translation with wrong translation id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Translation ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("remove translation with fail to get translation", func() { - BeforeEach(func() { - fakeIPSecManager.GetTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to get translation with ID 456 from IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("remove translation with fail to remove translation", func() { - BeforeEach(func() { - fakeIPSecManager.GetTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{Id: sl.Int(456)}, nil) - fakeIPSecManager.RemoveTranslationReturns(errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to remove translation with ID 456 from IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("remove translation ", func() { - BeforeEach(func() { - fakeIPSecManager.GetTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{Id: sl.Int(456)}, nil) - fakeIPSecManager.RemoveTranslationReturns(nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Removed translation with ID 456 from IPSec 123."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/translation_update.go b/plugin/commands/ipsec/translation_update.go deleted file mode 100644 index 6facfea8..00000000 --- a/plugin/commands/ipsec/translation_update.go +++ /dev/null @@ -1,81 +0,0 @@ -package ipsec - -import ( - "strconv" - - "github.com/spf13/cobra" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" -) - -type UpdateTranslationCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - StaticIp string - RemoteIp string - Note string -} - -func NewUpdateTranslationCommand(sl *metadata.SoftlayerCommand) (cmd *UpdateTranslationCommand) { - thisCmd := &UpdateTranslationCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "translation-update " + T("CONTEXT_ID") + " " + T("TRANSLATION_ID"), - Short: T("Update an address translation for an IPSec"), - Long: T(`${COMMAND_NAME} sl ipsec translation-update CONTEXT_ID TRANSLATION_ID [OPTIONS] - - Update an address translation for an IPSEC tunnel context. - - A separate configuration request should be made to realize changes on - network devices.`), - Args: metadata.TwoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().StringVarP(&thisCmd.StaticIp, "static-ip", "s", "", T("Static IP address[required]")) - cobraCmd.Flags().StringVarP(&thisCmd.RemoteIp, "remote-ip", "r", "", T("Remote IP address[required]")) - cobraCmd.Flags().StringVarP(&thisCmd.Note, "note", "n", "", T("Note")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *UpdateTranslationCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - args1 := args[1] - translationId, err := strconv.Atoi(args1) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Translation ID") - } - - outputFormat := cmd.GetOutputFlag() - - resp, err := cmd.IPSECManager.UpdateTranslation(contextId, translationId, cmd.StaticIp, cmd.RemoteIp, cmd.Note) - if err != nil { - return errors.NewAPIError(T("Failed to update translation with ID {{.TransID}} in IPSec {{.ID}}.", - map[string]interface{}{"TransID": translationId, "ID": contextId}), err.Error(), 2) - } - - if outputFormat == "JSON" { - return utils.PrintPrettyJSON(cmd.UI, resp) - } - - cmd.UI.Ok() - cmd.UI.Print(T("Updated translation with ID {{.TransID}} in IPSec {{.ID}}.", - map[string]interface{}{"TransID": translationId, "ID": contextId})) - return nil -} diff --git a/plugin/commands/ipsec/translation_update_test.go b/plugin/commands/ipsec/translation_update_test.go deleted file mode 100644 index 8d6cb8e5..00000000 --- a/plugin/commands/ipsec/translation_update_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.com/softlayer/softlayer-go/sl" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec update translation", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.UpdateTranslationCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewUpdateTranslationCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("update translation without context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires two arguments.")).To(BeTrue()) - }) - }) - Context("update translation without translation id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires two arguments.")).To(BeTrue()) - }) - }) - Context("update translation with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc", "456") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("update translation with wrong translation id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Translation ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("update translation with fail to update translation", func() { - BeforeEach(func() { - fakeIPSecManager.GetTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{Id: sl.Int(456)}, nil) - fakeIPSecManager.UpdateTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to update translation with ID 456 in IPSec 123.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("update translation ", func() { - BeforeEach(func() { - fakeIPSecManager.GetTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{Id: sl.Int(456)}, nil) - fakeIPSecManager.UpdateTranslationReturns(datatypes.Network_Tunnel_Module_Context_Address_Translation{Id: sl.Int(456)}, nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "-s", "1.2.3.4") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated translation with ID 456 in IPSec 123."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "-r", "1.2.3.4") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated translation with ID 456 in IPSec 123."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "-n", "test") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated translation with ID 456 in IPSec 123."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "-s", "1.2.3.4", "-n", "test") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated translation with ID 456 in IPSec 123."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "-r", "1.2.3.4", "-n", "test") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated translation with ID 456 in IPSec 123."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "456", "-s", "1.2.3.4", "-r", "5.6.7.8", "-n", "test") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated translation with ID 456 in IPSec 123."})) - }) - }) -}) diff --git a/plugin/commands/ipsec/update.go b/plugin/commands/ipsec/update.go deleted file mode 100644 index 37486e1b..00000000 --- a/plugin/commands/ipsec/update.go +++ /dev/null @@ -1,164 +0,0 @@ -package ipsec - -import ( - "strconv" - - "github.com/spf13/cobra" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - slErr "github.ibm.com/SoftLayer/softlayer-cli/plugin/errors" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" -) - -type UpdateCommand struct { - *metadata.SoftlayerCommand - IPSECManager managers.IPSECManager - Command *cobra.Command - Name string - RemotePeer string - PresharedKey string - Phase1Auth string - Phase1Crypto string - Phase1Dh int - Phase1KeyTtl int - Phase2Auth string - Phase2Crypto string - Phase2Dh int - Phase2ForwardSecrecy int - Phase2KeyTtl int -} - -func NewUpdateCommand(sl *metadata.SoftlayerCommand) (cmd *UpdateCommand) { - thisCmd := &UpdateCommand{ - SoftlayerCommand: sl, - IPSECManager: managers.NewIPSECManager(sl.Session), - } - - cobraCmd := &cobra.Command{ - Use: "update " + T("CONTEXT_ID"), - Short: T("Update tunnel context properties"), - Long: T(`${COMMAND_NAME} sl ipsec update CONTEXT_ID [OPTIONS] - - Update tunnel context properties. - - Updates are made atomically, so either all are accepted or none are. - - Key life values must be in the range 120-172800. - - Phase 2 perfect forward secrecy must be in the range 0-1. - - A separate configuration request should be made to realize changes on - network devices.`), - Args: metadata.OneArgs, - RunE: func(cmd *cobra.Command, args []string) error { - return thisCmd.Run(args) - }, - } - - cobraCmd.Flags().StringVarP(&thisCmd.Name, "name", "n", "", T("Friendly name")) - cobraCmd.Flags().StringVarP(&thisCmd.RemotePeer, "remote-peer", "r", "", T("Remote peer IP address")) - cobraCmd.Flags().StringVarP(&thisCmd.PresharedKey, "preshared-key", "k", "", T("Preshared key")) - cobraCmd.Flags().StringVarP(&thisCmd.Phase1Auth, "phase1-auth", "a", "", T("Phase 1 authentication. Options are: MD5,SHA1,SHA256")) - cobraCmd.Flags().StringVarP(&thisCmd.Phase1Crypto, "phase1-crypto", "c", "", T("Phase 1 encryption. Options are: DES,3DES,AES128,AES192,AES256")) - cobraCmd.Flags().IntVarP(&thisCmd.Phase1Dh, "phase1-dh", "d", 0, T("Phase 1 Diffie-Hellman group. Options are: 0,1,2,5")) - cobraCmd.Flags().IntVarP(&thisCmd.Phase1KeyTtl, "phase1-key-ttl", "t", 0, T("Phase 1 key life. Range is 120-172800")) - cobraCmd.Flags().StringVarP(&thisCmd.Phase2Auth, "phase2-auth", "u", "", T("Phase 2 authentication. Options are: MD5,SHA1,SHA256")) - cobraCmd.Flags().StringVarP(&thisCmd.Phase2Crypto, "phase2-crypto", "y", "", T("Phase 2 encryption. Options are: DES,3DES,AES128,AES192,AES256")) - cobraCmd.Flags().IntVarP(&thisCmd.Phase2Dh, "phase2-dh", "e", 0, T("Phase 2 Diffie-Hellman group. Options are: 0,1,2,5")) - cobraCmd.Flags().IntVarP(&thisCmd.Phase2ForwardSecrecy, "phase2-forward-secrecy", "f", 0, T("Phase 2 perfect forward secrecy. Range is 0-1")) - cobraCmd.Flags().IntVarP(&thisCmd.Phase2KeyTtl, "phase2-key-ttl", "l", 0, T("Phase 2 key life. Range is 120-172800")) - - thisCmd.Command = cobraCmd - return thisCmd -} - -func (cmd *UpdateCommand) Run(args []string) error { - args0 := args[0] - contextId, err := strconv.Atoi(args0) - if err != nil { - return slErr.NewInvalidSoftlayerIdInputError("Context ID") - } - if cmd.Phase1Auth != "" { - phase1Auth := cmd.Phase1Auth - if phase1Auth != "MD5" && phase1Auth != "SHA1" && phase1Auth != "SHA256" { - return errors.NewInvalidUsageError(T("-a|--phase1-auth must be either MD5 or SHA1 or SHA256.")) - } - } - if cmd.Phase1Crypto != "" { - phase1Crypto := cmd.Phase1Crypto - if phase1Crypto != "DES" && phase1Crypto != "3DES" && phase1Crypto != "AES128" && phase1Crypto != "AES192" && phase1Crypto != "AES256" { - return errors.NewInvalidUsageError(T("-c|--phase1-crypto must be either DES or 3DES or AES128 or AES192 or AES256.")) - } - } - if cmd.Phase1Dh != 0 { - phase1Dh := cmd.Phase1Dh - if phase1Dh != 0 && phase1Dh != 1 && phase1Dh != 2 && phase1Dh != 5 { - return errors.NewInvalidUsageError(T("-d|--phase1-dh must be either 0 or 1 or 2 or 5.")) - } - } - if cmd.Phase1KeyTtl != 0 { - phase1KeyLife := cmd.Phase1KeyTtl - if phase1KeyLife < 120 || phase1KeyLife > 172800 { - return errors.NewInvalidUsageError(T("-t|--phase1-key-ttl must be in range 120-172800.")) - } - } - if cmd.Phase2Auth != "" { - phase2Auth := cmd.Phase2Auth - if phase2Auth != "MD5" && phase2Auth != "SHA1" && phase2Auth != "SHA256" { - return errors.NewInvalidUsageError(T("-u|--phase2-auth must be either MD5 or SHA1 or SHA256.")) - } - } - if cmd.Phase2Crypto != "" { - phase2Crypto := cmd.Phase2Crypto - if phase2Crypto != "DES" && phase2Crypto != "3DES" && phase2Crypto != "AES128" && phase2Crypto != "AES192" && phase2Crypto != "AES256" { - return errors.NewInvalidUsageError(T("-y|--phase2-crypto must be either DES or 3DES or AES128 or AES192 or AES256.")) - } - } - if cmd.Phase2Dh != 0 { - phase2Dh := cmd.Phase2Dh - if phase2Dh != 0 && phase2Dh != 1 && phase2Dh != 2 && phase2Dh != 5 { - return errors.NewInvalidUsageError(T("-e|--phase2-dh must be either 0 or 1 or 2 or 5.")) - } - } - if cmd.Phase2ForwardSecrecy != 0 { - phase2ForwardSecrecy := cmd.Phase2ForwardSecrecy - if phase2ForwardSecrecy != 0 && phase2ForwardSecrecy != 1 { - return errors.NewInvalidUsageError(T("-f|--phase2-forward-secrecy must be either 0 or 1.")) - } - } - if cmd.Phase2KeyTtl != 0 { - phase2KeyLife := cmd.Phase2KeyTtl - if phase2KeyLife < 120 || phase2KeyLife > 172800 { - return errors.NewInvalidUsageError(T("-l|--phase2-key-ttl must be in range 120-172800.")) - } - } - - outputFormat := cmd.GetOutputFlag() - - resp, err := cmd.IPSECManager.UpdateTunnelContext(contextId, - cmd.Name, - cmd.RemotePeer, - cmd.PresharedKey, - cmd.Phase1Auth, - cmd.Phase1Crypto, - cmd.Phase1Dh, - cmd.Phase1KeyTtl, - cmd.Phase2Auth, - cmd.Phase2Crypto, - cmd.Phase2Dh, - cmd.Phase2ForwardSecrecy, - cmd.Phase2KeyTtl) - if err != nil { - return errors.NewAPIError(T("Failed to update IPSec {{.ContextID}}.\n", map[string]interface{}{"ContextID": contextId}), err.Error(), 2) - } - - if outputFormat == "JSON" { - return utils.PrintPrettyJSON(cmd.UI, resp) - } - - cmd.UI.Ok() - cmd.UI.Print(T("Updated IPSec {{.ContextID}}.", map[string]interface{}{"ContextID": contextId})) - return nil -} diff --git a/plugin/commands/ipsec/update_test.go b/plugin/commands/ipsec/update_test.go deleted file mode 100644 index 791196d3..00000000 --- a/plugin/commands/ipsec/update_test.go +++ /dev/null @@ -1,174 +0,0 @@ -package ipsec_test - -import ( - "errors" - "strings" - - . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers" - "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/session" - "github.com/softlayer/softlayer-go/sl" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" -) - -var _ = Describe("IPSec update", func() { - var ( - fakeUI *terminal.FakeUI - fakeIPSecManager *testhelpers.FakeIPSECManager - cliCommand *ipsec.UpdateCommand - fakeSession *session.Session - slCommand *metadata.SoftlayerCommand - ) - BeforeEach(func() { - fakeUI = terminal.NewFakeUI() - fakeIPSecManager = new(testhelpers.FakeIPSECManager) - fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) - slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) - cliCommand = ipsec.NewUpdateCommand(slCommand) - cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") - cliCommand.IPSECManager = fakeIPSecManager - }) - Context("update without contextID", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command) - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: This command requires one argument")).To(BeTrue()) - }) - }) - Context("update with wrong context id", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Invalid input for 'Context ID'. It must be a positive integer.")).To(BeTrue()) - }) - }) - Context("update with wrong phase1-auth", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-a", "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -a|--phase1-auth must be either MD5 or SHA1 or SHA256.")).To(BeTrue()) - }) - }) - Context("update with wrong phase1-crypto", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-c", "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "-c|--phase1-crypto must be either DES or 3DES or AES128 or AES192 or AES256.")).To(BeTrue()) - }) - }) - Context("update with wrong phase1-dh", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-d", "10") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -d|--phase1-dh must be either 0 or 1 or 2 or 5.")).To(BeTrue()) - }) - }) - Context("update with wrong phase1-key-ttl", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-t", "100") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -t|--phase1-key-ttl must be in range 120-172800.")).To(BeTrue()) - }) - }) - Context("update with wrong phase2-auth", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-u", "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -u|--phase2-auth must be either MD5 or SHA1 or SHA256.")).To(BeTrue()) - }) - }) - Context("update with wrong phase2-crypto", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-y", "abc") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -y|--phase2-crypto must be either DES or 3DES or AES128 or AES192 or AES256.")).To(BeTrue()) - }) - }) - Context("update with wrong phase2-dh", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-e", "3") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -e|--phase2-dh must be either 0 or 1 or 2 or 5.")).To(BeTrue()) - }) - }) - Context("update with wrong phase2-forward-secrecy", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-f", "2") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -f|--phase2-forward-secrecy must be either 0 or 1.")).To(BeTrue()) - }) - }) - Context("update with wrong phase2-key-ttl", func() { - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-l", "100") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Incorrect Usage: -l|--phase2-key-ttl must be in range 120-172800.")).To(BeTrue()) - }) - }) - Context("update with server fail", func() { - BeforeEach(func() { - fakeIPSecManager.UpdateTunnelContextReturns(datatypes.Network_Tunnel_Module_Context{}, errors.New("Internal server error")) - }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-l", "150") - Expect(err).To(HaveOccurred()) - Expect(strings.Contains(err.Error(), "Failed to update IPSec 1234.")).To(BeTrue()) - Expect(strings.Contains(err.Error(), "Internal server error")).To(BeTrue()) - }) - }) - Context("update", func() { - BeforeEach(func() { - fakeIPSecManager.UpdateTunnelContextReturns(datatypes.Network_Tunnel_Module_Context{Id: sl.Int(1234)}, nil) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-a", "SHA256") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-c", "AES256") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-d", "1") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-t", "1000") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-u", "SHA256") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-y", "AES256") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-e", "2") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-f", "1") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - It("succeed", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-l", "150") - Expect(err).NotTo(HaveOccurred()) - Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Updated IPSec 1234."})) - }) - }) -}) diff --git a/plugin/commands/security/key_print_test.go b/plugin/commands/security/key_print_test.go index 8bf27be9..92f12ff3 100644 --- a/plugin/commands/security/key_print_test.go +++ b/plugin/commands/security/key_print_test.go @@ -88,11 +88,6 @@ var _ = Describe("Key print", func() { Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"notes"})) Expect(fakeUI.Outputs()).NotTo(ContainSubstrings([]string{"ssh-rsa djghtbtmfhgentongwfrdnglkhsdye"})) }) - It("return error", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "-f", "/root/key") - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("Failed to write SSH key to file: /root/key.")) - }) }) }) }) diff --git a/plugin/commands/virtual/create_test.go b/plugin/commands/virtual/create_test.go index 631ac812..5947a65f 100644 --- a/plugin/commands/virtual/create_test.go +++ b/plugin/commands/virtual/create_test.go @@ -97,11 +97,6 @@ var _ = Describe("VS create", func() { }) }) Context("VS create with --export", func() { - It("Failed to write file", func() { - err := testhelpers.RunCobraCommand(cliCommand.Command, "-H", "vs-abc", "-D", "wilma.com", "-c", "2", "-m", "4096", "--datacenter", "dal10", "-o", "CENTOS", "--export", "/root/template") - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("Failed to write virtual server template file to: /root/template.")) - }) It("Success", func() { tmpFile, tmpErr := ioutil.TempFile(os.TempDir(), "create_tests-") if tmpErr != nil { diff --git a/plugin/i18n/v2Resources/active.en-US.json b/plugin/i18n/v2Resources/active.en-US.json index 9207a752..85fd3f17 100644 --- a/plugin/i18n/v2Resources/active.en-US.json +++ b/plugin/i18n/v2Resources/active.en-US.json @@ -95,30 +95,6 @@ "${COMMAND_NAME} sl image import NAME URI API_KEY [--note NOTE] [--os-code OS_CODE] [--root-key-crn ROOT_KEY_CRN] [--wrapper-dek WRAPPER_DEK] [--cloud-init] [--byol] [--is-encrypted]\n NAME: The image name\n URI: The URI for an object storage object (.vhd/.iso file) of the format: cos:////\n API_KEY: The IBM Cloud API Key with access to IBM Cloud Object Storage instance.": { "other": "${COMMAND_NAME} sl image import NAME URI API_KEY [--note NOTE] [--os-code OS_CODE] [--root-key-crn ROOT_KEY_CRN] [--wrapper-dek WRAPPER_DEK] [--cloud-init] [--byol] [--is-encrypted]\n NAME: The image name\n URI: The URI for an object storage object (.vhd/.iso file) of the format: cos:////\n API_KEY: The IBM Cloud API Key with access to IBM Cloud Object Storage instance." }, - "${COMMAND_NAME} sl ipsec config CONTEXT_ID [OPTIONS]\n\n Request configuration of a tunnel context.\n\n This action will update the advancedConfigurationFlag on the context\n instance and further modifications against the context will be prevented\n until all changes can be propagated to network devices.": { - "other": "${COMMAND_NAME} sl ipsec config CONTEXT_ID [OPTIONS]\n\n Request configuration of a tunnel context.\n\n This action will update the advancedConfigurationFlag on the context\n instance and further modifications against the context will be prevented\n until all changes can be propagated to network devices." - }, - "${COMMAND_NAME} sl ipsec detail CONTEXT_ID [OPTIONS]\n\n List IPSEC VPN tunnel context details.\n\n Additional resources can be joined using multiple instances of the include\n option, for which the following choices are available.\n\n at: address translations\n is: internal subnets\n rs: remote subnets\n sr: statically routed subnets\n ss: service subnets": { - "other": "${COMMAND_NAME} sl ipsec detail CONTEXT_ID [OPTIONS]\n\n List IPSEC VPN tunnel context details.\n\n Additional resources can be joined using multiple instances of the include\n option, for which the following choices are available.\n\n at: address translations\n is: internal subnets\n rs: remote subnets\n sr: statically routed subnets\n ss: service subnets" - }, - "${COMMAND_NAME} sl ipsec subnet-add CONTEXT_ID [OPTIONS] \n\n Add a subnet to an IPSEC tunnel context.\n\n A subnet id may be specified to link to the existing tunnel context.\n\n Otherwise, a network identifier in CIDR notation should be specified,\n indicating that a subnet resource should first be created before\n associating it with the tunnel context. Note that this is only supported\n for remote subnets, which are also deleted upon failure to attach to a\n context.\n\n A separate configuration request should be made to realize changes on\n network devices.": { - "other": "${COMMAND_NAME} sl ipsec subnet-add CONTEXT_ID [OPTIONS] \n\n Add a subnet to an IPSEC tunnel context.\n\n A subnet id may be specified to link to the existing tunnel context.\n\n Otherwise, a network identifier in CIDR notation should be specified,\n indicating that a subnet resource should first be created before\n associating it with the tunnel context. Note that this is only supported\n for remote subnets, which are also deleted upon failure to attach to a\n context.\n\n A separate configuration request should be made to realize changes on\n network devices." - }, - "${COMMAND_NAME} sl ipsec subnet-remove CONTEXT_ID SUBNET_ID SUBNET_TYPE \n\n Remove a subnet from an IPSEC tunnel context.\n\n The subnet id to remove must be specified.\n\n Remote subnets are deleted upon removal from a tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices.": { - "other": "${COMMAND_NAME} sl ipsec subnet-remove CONTEXT_ID SUBNET_ID SUBNET_TYPE \n\n Remove a subnet from an IPSEC tunnel context.\n\n The subnet id to remove must be specified.\n\n Remote subnets are deleted upon removal from a tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices." - }, - "${COMMAND_NAME} sl ipsec translation-add CONTEXT_ID [OPTIONS]\n\n Add an address translation to an IPSEC tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices.": { - "other": "${COMMAND_NAME} sl ipsec translation-add CONTEXT_ID [OPTIONS]\n\n Add an address translation to an IPSEC tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices." - }, - "${COMMAND_NAME} sl ipsec translation-remove CONTEXT_ID TRANSLATION_ID \n\n Remove a translation entry from an IPSEC tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices.": { - "other": "${COMMAND_NAME} sl ipsec translation-remove CONTEXT_ID TRANSLATION_ID \n\n Remove a translation entry from an IPSEC tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices." - }, - "${COMMAND_NAME} sl ipsec translation-update CONTEXT_ID TRANSLATION_ID [OPTIONS]\n\n Update an address translation for an IPSEC tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices.": { - "other": "${COMMAND_NAME} sl ipsec translation-update CONTEXT_ID TRANSLATION_ID [OPTIONS]\n\n Update an address translation for an IPSEC tunnel context.\n\n A separate configuration request should be made to realize changes on\n network devices." - }, - "${COMMAND_NAME} sl ipsec update CONTEXT_ID [OPTIONS]\n\n Update tunnel context properties.\n\n Updates are made atomically, so either all are accepted or none are.\n\n Key life values must be in the range 120-172800.\n\n Phase 2 perfect forward secrecy must be in the range 0-1.\n\n A separate configuration request should be made to realize changes on\n network devices.": { - "other": "${COMMAND_NAME} sl ipsec update CONTEXT_ID [OPTIONS]\n\n Update tunnel context properties.\n\n Updates are made atomically, so either all are accepted or none are.\n\n Key life values must be in the range 120-172800.\n\n Phase 2 perfect forward secrecy must be in the range 0-1.\n\n A separate configuration request should be made to realize changes on\n network devices." - }, "${COMMAND_NAME} sl loadbal l7member-del (--pool-uuid L7POOL_UUID) (--member-uuid L7MEMBER_UUID)": { "other": "${COMMAND_NAME} sl loadbal l7member-del (--pool-uuid L7POOL_UUID) (--member-uuid L7MEMBER_UUID)" }, @@ -410,18 +386,12 @@ "-a, --action should be REJECT | REDIRECT_POOL | REDIRECT_URL | REDIRECT_HTTPS": { "other": "-a, --action should be REJECT | REDIRECT_POOL | REDIRECT_URL | REDIRECT_HTTPS" }, - "-a|--phase1-auth must be either MD5 or SHA1 or SHA256.": { - "other": "-a|--phase1-auth must be either MD5 or SHA1 or SHA256." - }, "-b|--billing can only be either hourly or monthly.\nRun '{{.CommandName}} sl file volume-options' to check available options.": { "other": "-b|--billing can only be either hourly or monthly.\nRun '{{.CommandName}} sl file volume-options' to check available options." }, "-b|--billing has to be either hourly or monthly.": { "other": "-b|--billing has to be either hourly or monthly." }, - "-c|--phase1-crypto must be either DES or 3DES or AES128 or AES192 or AES256.": { - "other": "-c|--phase1-crypto must be either DES or 3DES or AES128 or AES192 or AES256." - }, "-d|--datacenter is required.\nRun '{{.CommandName}} sl block volume-options' to check available options.": { "other": "-d|--datacenter is required.\nRun '{{.CommandName}} sl block volume-options' to check available options." }, @@ -431,15 +401,9 @@ "-d|--direction has to be either egress or ingress.": { "other": "-d|--direction has to be either egress or ingress." }, - "-d|--phase1-dh must be either 0 or 1 or 2 or 5.": { - "other": "-d|--phase1-dh must be either 0 or 1 or 2 or 5." - }, "-e|--ether-type has to be either IPv4 or IPv6.": { "other": "-e|--ether-type has to be either IPv4 or IPv6." }, - "-e|--phase2-dh must be either 0 or 1 or 2 or 5.": { - "other": "-e|--phase2-dh must be either 0 or 1 or 2 or 5." - }, "-e|--tier can only be specified with endurance volume.": { "other": "-e|--tier can only be specified with endurance volume." }, @@ -449,9 +413,6 @@ "-e|--tier is required with endurance volume in IOPS/GB, options are: 0.25, 2, 4, 10.\nRun '{{.CommandName}} sl file volume-options' to check available options.": { "other": "-e|--tier is required with endurance volume in IOPS/GB, options are: 0.25, 2, 4, 10.\nRun '{{.CommandName}} sl file volume-options' to check available options." }, - "-f|--phase2-forward-secrecy must be either 0 or 1.": { - "other": "-f|--phase2-forward-secrecy must be either 0 or 1." - }, "-i|--interface must be either public or private": { "other": "-i|--interface must be either public or private" }, @@ -482,9 +443,6 @@ "-k, --key is only available in HEADER or COOKIE type.": { "other": "-k, --key is only available in HEADER or COOKIE type." }, - "-l|--phase2-key-ttl must be in range 120-172800.": { - "other": "-l|--phase2-key-ttl must be in range 120-172800." - }, "-o|--os-type is optional, options are: HYPER_V,LINUX,VMWARE,WINDOWS_2008,WINDOWS_GPT,WINDOWS,XEN.": { "other": "-o|--os-type is optional, options are: HYPER_V,LINUX,VMWARE,WINDOWS_2008,WINDOWS_GPT,WINDOWS,XEN." }, @@ -512,21 +470,12 @@ "-s|--size is required, must be a positive integer.\nRun '{{.CommandName}} sl file volume-options' to check available options.": { "other": "-s|--size is required, must be a positive integer.\nRun '{{.CommandName}} sl file volume-options' to check available options." }, - "-t|--phase1-key-ttl must be in range 120-172800.": { - "other": "-t|--phase1-key-ttl must be in range 120-172800." - }, "-t|--storage-type is required, must be either performance or endurance.\nRun '{{.CommandName}} sl block volume-options' to check available options.": { "other": "-t|--storage-type is required, must be either performance or endurance.\nRun '{{.CommandName}} sl block volume-options' to check available options." }, "-t|--storage-type is required, must be either performance or endurance.\nRun '{{.CommandName}} sl file volume-options' to check available options.": { "other": "-t|--storage-type is required, must be either performance or endurance.\nRun '{{.CommandName}} sl file volume-options' to check available options." }, - "-u|--phase2-auth must be either MD5 or SHA1 or SHA256.": { - "other": "-u|--phase2-auth must be either MD5 or SHA1 or SHA256." - }, - "-y|--phase2-crypto must be either DES or 3DES or AES128 or AES192 or AES256.": { - "other": "-y|--phase2-crypto must be either DES or 3DES or AES128 or AES192 or AES256." - }, "300, 600, 1800, 3600, 43200 or 86400 seconds.": { "other": "300, 600, 1800, 3600, 43200 or 86400 seconds." }, @@ -692,15 +641,9 @@ "Add a security group rule to a security group": { "other": "Add a security group rule to a security group" }, - "Add a subnet to an IPSec tunnel context": { - "other": "Add a subnet to an IPSec tunnel context" - }, "Add access to subnet.": { "other": "Add access to subnet." }, - "Add an address translation to an IPSec tunnel": { - "other": "Add an address translation to an IPSec tunnel" - }, "Add and upload SSL certificate details": { "other": "Add and upload SSL certificate details" }, @@ -716,27 +659,18 @@ "Add/Remove datacenter of an image.": { "other": "Add/Remove datacenter of an image." }, - "Added {{.Type}} subnet #{{.ID}} to IPSec {{.ContextID}}.": { - "other": "Added {{.Type}} subnet #{{.ID}} to IPSec {{.ContextID}}." - }, "Additional notes": { "other": "Additional notes" }, "Address": { "other": "Address" }, - "Address Translations": { - "other": "Address Translations" - }, "Adds an attachment to an existing ticket": { "other": "Adds an attachment to an existing ticket" }, "Adds an update to an existing ticket": { "other": "Adds an update to an existing ticket" }, - "Advanced configuration flag": { - "other": "Advanced configuration flag" - }, "All multi vlan rules must be managed through the FortiGate dashboard using the provided credentials.": { "other": "All multi vlan rules must be managed through the FortiGate dashboard using the provided credentials." }, @@ -932,9 +866,6 @@ "CIDR": { "other": "CIDR" }, - "CONTEXT_ID": { - "other": "CONTEXT_ID" - }, "CPU": { "other": "CPU" }, @@ -962,9 +893,6 @@ "Can't get router ID with hostname {{.HostName}}": { "other": "Can't get router ID with hostname {{.HostName}}" }, - "Cancel a IPSec VPN tunnel context": { - "other": "Cancel a IPSec VPN tunnel context" - }, "Cancel a VLAN": { "other": "Cancel a VLAN" }, @@ -1004,9 +932,6 @@ "Cancel immediately instead of on the billing anniversary": { "other": "Cancel immediately instead of on the billing anniversary" }, - "Cancel the IPSec immediately instead of on the billing anniversary": { - "other": "Cancel the IPSec immediately instead of on the billing anniversary" - }, "Cancel the block storage volume immediately instead of on the billing anniversary": { "other": "Cancel the block storage volume immediately instead of on the billing anniversary" }, @@ -1148,9 +1073,6 @@ "Classic infrastructure Global IP addresses": { "other": "Classic infrastructure Global IP addresses" }, - "Classic infrastructure IPSEC VPN": { - "other": "Classic infrastructure IPSEC VPN" - }, "Classic infrastructure Licenses": { "other": "Classic infrastructure Licenses" }, @@ -1292,9 +1214,6 @@ "Completed Percentage": { "other": "Completed Percentage" }, - "Configuration request received for IPSec {{.ContextID}}.": { - "other": "Configuration request received for IPSec {{.ContextID}}." - }, "Convert a dependent duplicate volume to an independent volume.": { "other": "Convert a dependent duplicate volume to an independent volume." }, @@ -1451,12 +1370,6 @@ "Created resource record under zone {{.Zone}}: ID={{.ID}}, type={{.RecordType}}, record={{.Host}}, data={{.Data}}, ttl={{.Ttl}}.": { "other": "Created resource record under zone {{.Zone}}: ID={{.ID}}, type={{.RecordType}}, record={{.Host}}, data={{.Data}}, ttl={{.Ttl}}." }, - "Created subnet {{.ID}}/{{.CIDR}} #{{.Identifier}}.": { - "other": "Created subnet {{.ID}}/{{.CIDR}} #{{.Identifier}}." - }, - "Created translation from {{.StaticIP}} to {{.RemoteIP}} #{{.ID}}.": { - "other": "Created translation from {{.StaticIP}} to {{.RemoteIP}} #{{.ID}}." - }, "Creates a new mapping between incoming traffic to the loadbalancer and the backend servers.\nUse '{COMMAND_NAME} sl security cert-list' to get IDs for the --ssl-id option.\nSee: https://cloud.ibm.com/docs/loadbalancer-service?topic=loadbalancer-service-about-ibm-cloud-load-balancer for more details\n\nExample:\n\t${COMMAND_NAME} sl loadbal protocol-add --id 1115129 --front-port 443 --front-protocol HTTPS --back-port 80 --back-protocol HTTP --ssl-id 335659 --client-timeout 60 --connections 100\n\tCreates a new protocol on Load Balancer 1115129 that terminates SSL on port 443, mapping to a backend port 80 HTTP. Using SSL cert 335659\n": { "other": "Creates a new mapping between incoming traffic to the loadbalancer and the backend servers.\nUse '{COMMAND_NAME} sl security cert-list' to get IDs for the --ssl-id option.\nSee: https://cloud.ibm.com/docs/loadbalancer-service?topic=loadbalancer-service-about-ibm-cloud-load-balancer for more details\n\nExample:\n\t${COMMAND_NAME} sl loadbal protocol-add --id 1115129 --front-port 443 --front-protocol HTTPS --back-port 80 --back-protocol HTTP --ssl-id 335659 --client-timeout 60 --connections 100\n\tCreates a new protocol on Load Balancer 1115129 that terminates SSL on port 443, mapping to a backend port 80 HTTP. Using SSL cert 335659\n" }, @@ -1481,9 +1394,6 @@ "Current Usage": { "other": "Current Usage" }, - "Customer Peer IP Address": { - "other": "Customer Peer IP Address" - }, "DATA": { "other": "DATA" }, @@ -1898,9 +1808,6 @@ "Either -n, --name or -d, --description is required to edit security group.": { "other": "Either -n, --name or -d, --description is required to edit security group." }, - "Either -s|--subnet-id or -n|--network must be provided.": { - "other": "Either -s|--subnet-id or -n|--network must be provided." - }, "Email": { "other": "Email" }, @@ -2114,9 +2021,6 @@ "Failed to add user.\n": { "other": "Failed to add user.\n" }, - "Failed to add {{.Type}} subnet #{{.ID}} to IPSec {{.ContextID}}.\n": { - "other": "Failed to add {{.Type}} subnet #{{.ID}} to IPSec {{.ContextID}}.\n" - }, "Failed to assign global IP {{.IpID}} to target {{.Target}}.\n": { "other": "Failed to assign global IP {{.IpID}} to target {{.Target}}.\n" }, @@ -2138,9 +2042,6 @@ "Failed to authorize storage to the virtual server instance: {{.Storage}}.\n{{.Error}}": { "other": "Failed to authorize storage to the virtual server instance: {{.Storage}}.\n{{.Error}}" }, - "Failed to cancel IPSec {{.ContextID}}.\n": { - "other": "Failed to cancel IPSec {{.ContextID}}.\n" - }, "Failed to cancel VLAN {{.ID}}.\n": { "other": "Failed to cancel VLAN {{.ID}}.\n" }, @@ -2225,15 +2126,9 @@ "Failed to create security group with name {{.Name}}.\n": { "other": "Failed to create security group with name {{.Name}}.\n" }, - "Failed to create subnet with {{.ID}}.\n": { - "other": "Failed to create subnet with {{.ID}}.\n" - }, "Failed to create the license.": { "other": "Failed to create the license." }, - "Failed to create translation for IPSec with ID {{.ID}}.\n": { - "other": "Failed to create translation for IPSec with ID {{.ID}}.\n" - }, "Failed to create user vpn override.": { "other": "Failed to create user vpn override." }, @@ -2348,9 +2243,6 @@ "Failed to enable {{.ScheduleType}} snapshot for volume {{.VolumeID}}.\n": { "other": "Failed to enable {{.ScheduleType}} snapshot for volume {{.VolumeID}}.\n" }, - "Failed to enqueue configuration request for IPSec {{.ContextID}}.\n": { - "other": "Failed to enqueue configuration request for IPSec {{.ContextID}}.\n" - }, "Failed to find ID for domain: {{.Domain}} on your account.": { "other": "Failed to find ID for domain: {{.Domain}} on your account." }, @@ -2366,9 +2258,6 @@ "Failed to find price for this type of vlan.": { "other": "Failed to find price for this type of vlan." }, - "Failed to find product package for this IPSEC.": { - "other": "Failed to find product package for this IPSEC." - }, "Failed to find product package for this firewall.": { "other": "Failed to find product package for this firewall." }, @@ -2390,12 +2279,6 @@ "Failed to get Event Logs.\n": { "other": "Failed to get Event Logs.\n" }, - "Failed to get IPSec on your account.": { - "other": "Failed to get IPSec on your account." - }, - "Failed to get IPSec with ID {{.ID}}.\n": { - "other": "Failed to get IPSec with ID {{.ID}}.\n" - }, "Failed to get Image.\n": { "other": "Failed to get Image.\n" }, @@ -2720,9 +2603,6 @@ "Failed to get the vlans available for datacener: {{.DATACENTER}} and flavor: {{.FLAVOR}}.": { "other": "Failed to get the vlans available for datacener: {{.DATACENTER}} and flavor: {{.FLAVOR}}." }, - "Failed to get translation with ID {{.TransID}} from IPSec {{.ID}}.": { - "other": "Failed to get translation with ID {{.TransID}} from IPSec {{.ID}}." - }, "Failed to get unplanned event ID.": { "other": "Failed to get unplanned event ID." }, @@ -2876,9 +2756,6 @@ "Failed to open editor for vlan rules: {{.FirewallID}}.\n": { "other": "Failed to open editor for vlan rules: {{.FirewallID}}.\n" }, - "Failed to order IPSec.Please try again later.\n": { - "other": "Failed to order IPSec.Please try again later.\n" - }, "Failed to order Quote.\n": { "other": "Failed to order Quote.\n" }, @@ -3002,15 +2879,9 @@ "Failed to remove subnets.": { "other": "Failed to remove subnets." }, - "Failed to remove translation with ID {{.TransID}} from IPSec {{.ID}}.": { - "other": "Failed to remove translation with ID {{.TransID}} from IPSec {{.ID}}." - }, "Failed to remove user's API authentication key": { "other": "Failed to remove user's API authentication key" }, - "Failed to remove {{.Type}} subnet #{{.ID}} from IPSec {{.ContextID}}.\n": { - "other": "Failed to remove {{.Type}} subnet #{{.ID}} from IPSec {{.ContextID}}.\n" - }, "Failed to rescue hardware server: {{.ID}}.\n": { "other": "Failed to rescue hardware server: {{.ID}}.\n" }, @@ -3092,9 +2963,6 @@ "Failed to unmarshal template file: {{.File}}.\n": { "other": "Failed to unmarshal template file: {{.File}}.\n" }, - "Failed to update IPSec {{.ContextID}}.\n": { - "other": "Failed to update IPSec {{.ContextID}}.\n" - }, "Failed to update VPN user.": { "other": "Failed to update VPN user." }, @@ -3155,9 +3023,6 @@ "Failed to update the user data of virtual server instance: {{.VsId}}.\n": { "other": "Failed to update the user data of virtual server instance: {{.VsId}}.\n" }, - "Failed to update translation with ID {{.TransID}} in IPSec {{.ID}}.": { - "other": "Failed to update translation with ID {{.TransID}} in IPSec {{.ID}}." - }, "Failed to update user vpn password.": { "other": "Failed to update user vpn password." }, @@ -3236,9 +3101,6 @@ "File volume {{.VolumeId}} has been marked for immediate cancellation.": { "other": "File volume {{.VolumeId}} has been marked for immediate cancellation." }, - "Filter by ID of the order that purchased the IPSec": { - "other": "Filter by ID of the order that purchased the IPSec" - }, "Filter by ID of the order that purchased the VLAN": { "other": "Filter by ID of the order that purchased the VLAN" }, @@ -3434,12 +3296,6 @@ "FortiGate username": { "other": "FortiGate username" }, - "Friendly name": { - "other": "Friendly name" - }, - "FriendlyName": { - "other": "FriendlyName" - }, "Frontend port": { "other": "Frontend port" }, @@ -3731,9 +3587,6 @@ "IPMI_username": { "other": "IPMI_username" }, - "IPSec {{.ContextID}} is cancelled.": { - "other": "IPSec {{.ContextID}} is cancelled." - }, "IPs": { "other": "IPs" }, @@ -3803,9 +3656,6 @@ "Inbound Usage": { "other": "Inbound Usage" }, - "Include extra resources. Options are: at,is,rs,sr,ss": { - "other": "Include extra resources. Options are: at,is,rs,sr,ss" - }, "Include invoices with a CLOSED status.": { "other": "Include invoices with a CLOSED status." }, @@ -3839,15 +3689,6 @@ "Intermediate Certificate file": { "other": "Intermediate Certificate file" }, - "Internal Peer IP Address": { - "other": "Internal Peer IP Address" - }, - "Internal Subnets": { - "other": "Internal Subnets" - }, - "Internal peer IP address": { - "other": "Internal peer IP address" - }, "Internet side port": { "other": "Internet side port" }, @@ -3944,6 +3785,9 @@ "Item {{.Item}} does not exist for package {{.Package}}": { "other": "Item {{.Item}} does not exist for package {{.Package}}" }, + "Item {{.Item}} does not exist for package {{.Package}} with category {{.Category}}": { + "other": "Item {{.Item}} does not exist for package {{.Package}} with category {{.Category}}" + }, "Item: {{.itemID}} was cancelled.": { "other": "Item: {{.itemID}} was cancelled." }, @@ -4043,12 +3887,6 @@ "List Dedicated Host Guests.": { "other": "List Dedicated Host Guests." }, - "List IPSec VPN tunnel context details": { - "other": "List IPSec VPN tunnel context details" - }, - "List IPSec VPN tunnel contexts": { - "other": "List IPSec VPN tunnel contexts" - }, "List L7 policies": { "other": "List L7 policies" }, @@ -4433,9 +4271,6 @@ "Network component {{.ComponentID}} is removed from security group {{.GroupID}}.": { "other": "Network component {{.ComponentID}} is removed from security group {{.GroupID}}." }, - "Network identifier": { - "other": "Network identifier" - }, "Network port speed in Mbps": { "other": "Network port speed in Mbps" }, @@ -4457,9 +4292,6 @@ "No IP V6 address associated with virtual server instance: {{.VsId}}.": { "other": "No IP V6 address associated with virtual server instance: {{.VsId}}." }, - "No IPSec was found.": { - "other": "No IPSec was found." - }, "No available router was found.": { "other": "No available router was found." }, @@ -4541,9 +4373,6 @@ "Note": { "other": "Note" }, - "Note value": { - "other": "Note value" - }, "Note: IOPS above 6,000 available only in: https://cloud.ibm.com/docs/BlockStorage?topic=BlockStorage-selectDC": { "other": "Note: IOPS above 6,000 available only in: https://cloud.ibm.com/docs/BlockStorage?topic=BlockStorage-selectDC" }, @@ -4703,9 +4532,6 @@ "Order Total Amount": { "other": "Order Total Amount" }, - "Order a IPSec VPN tunnel": { - "other": "Order a IPSec VPN tunnel" - }, "Order a block storage replica volume": { "other": "Order a block storage replica volume" }, @@ -4886,60 +4712,6 @@ "Permissions updated successfully": { "other": "Permissions updated successfully" }, - "Phase 1 Diffie-Hellman group. Options are: 0,1,2,5": { - "other": "Phase 1 Diffie-Hellman group. Options are: 0,1,2,5" - }, - "Phase 1 authentication": { - "other": "Phase 1 authentication" - }, - "Phase 1 authentication. Options are: MD5,SHA1,SHA256": { - "other": "Phase 1 authentication. Options are: MD5,SHA1,SHA256" - }, - "Phase 1 diffie hellman group": { - "other": "Phase 1 diffie hellman group" - }, - "Phase 1 encryption": { - "other": "Phase 1 encryption" - }, - "Phase 1 encryption. Options are: DES,3DES,AES128,AES192,AES256": { - "other": "Phase 1 encryption. Options are: DES,3DES,AES128,AES192,AES256" - }, - "Phase 1 key life": { - "other": "Phase 1 key life" - }, - "Phase 1 key life. Range is 120-172800": { - "other": "Phase 1 key life. Range is 120-172800" - }, - "Phase 2 Diffie-Hellman group. Options are: 0,1,2,5": { - "other": "Phase 2 Diffie-Hellman group. Options are: 0,1,2,5" - }, - "Phase 2 authentication": { - "other": "Phase 2 authentication" - }, - "Phase 2 authentication. Options are: MD5,SHA1,SHA256": { - "other": "Phase 2 authentication. Options are: MD5,SHA1,SHA256" - }, - "Phase 2 diffie hellman group": { - "other": "Phase 2 diffie hellman group" - }, - "Phase 2 encryption": { - "other": "Phase 2 encryption" - }, - "Phase 2 encryption. Options are: DES,3DES,AES128,AES192,AES256": { - "other": "Phase 2 encryption. Options are: DES,3DES,AES128,AES192,AES256" - }, - "Phase 2 key life": { - "other": "Phase 2 key life" - }, - "Phase 2 key life. Range is 120-172800": { - "other": "Phase 2 key life. Range is 120-172800" - }, - "Phase 2 perfect forward secrecy": { - "other": "Phase 2 perfect forward secrecy" - }, - "Phase 2 perfect forward secrecy. Range is 0-1": { - "other": "Phase 2 perfect forward secrecy. Range is 0-1" - }, "Phone Number": { "other": "Phone Number" }, @@ -5033,9 +4805,6 @@ "Preset {{.Preset}} does not exist in package {{.Package}}": { "other": "Preset {{.Preset}} does not exist in package {{.Package}}" }, - "Preshared key": { - "other": "Preshared key" - }, "Price ID not found": { "other": "Price ID not found" }, @@ -5297,21 +5066,6 @@ "Remote IP": { "other": "Remote IP" }, - "Remote IP address": { - "other": "Remote IP address" - }, - "Remote IP address ID": { - "other": "Remote IP address ID" - }, - "Remote IP address[required]": { - "other": "Remote IP address[required]" - }, - "Remote Subnets": { - "other": "Remote Subnets" - }, - "Remote peer IP address": { - "other": "Remote peer IP address" - }, "Remove SSL certificate": { "other": "Remove SSL certificate" }, @@ -5324,12 +5078,6 @@ "Remove a rule from a security group": { "other": "Remove a rule from a security group" }, - "Remove a subnet from an IPSEC tunnel context": { - "other": "Remove a subnet from an IPSEC tunnel context" - }, - "Remove a translation entry from an IPSec": { - "other": "Remove a translation entry from an IPSec" - }, "Remove a user VS notification entry.": { "other": "Remove a user VS notification entry." }, @@ -5351,12 +5099,6 @@ "Remove resource record from a zone": { "other": "Remove resource record from a zone" }, - "Removed translation with ID {{.TransID}} from IPSec {{.ID}}.": { - "other": "Removed translation with ID {{.TransID}} from IPSec {{.ID}}." - }, - "Removed {{.Type}} subnet #{{.ID}} from IPSec {{.ContextID}}.": { - "other": "Removed {{.Type}} subnet #{{.ID}} from IPSec {{.ContextID}}." - }, "Removes all empty tags.": { "other": "Removes all empty tags." }, @@ -5384,9 +5126,6 @@ "Reports which resources are still active in Datacenters that are scheduled to be closed.": { "other": "Reports which resources are still active in Datacenters that are scheduled to be closed." }, - "Request configuration of a tunnel context": { - "other": "Request configuration of a tunnel context" - }, "Requested by": { "other": "Requested by" }, @@ -5525,9 +5264,6 @@ "SUBNET_ID": { "other": "SUBNET_ID" }, - "SUBNET_TYPE": { - "other": "SUBNET_TYPE" - }, "Sales": { "other": "Sales" }, @@ -5600,9 +5336,6 @@ "Servers": { "other": "Servers" }, - "Service Subnets": { - "other": "Service Subnets" - }, "Session Stickiness": { "other": "Session Stickiness" }, @@ -5654,9 +5387,6 @@ "Short Name": { "other": "Short Name" }, - "Short name of the datacenter for the IPSec. For example, dal09[required]": { - "other": "Short name of the datacenter for the IPSec. For example, dal09[required]" - }, "Short name of the datacenter for the replica. For example, dal09 [required]": { "other": "Short name of the datacenter for the replica. For example, dal09 [required]" }, @@ -5789,12 +5519,6 @@ "Snapshots space usage threshold warning notification has been set to '{{.ENABLE}}' for volume '{{.ID}}'.": { "other": "Snapshots space usage threshold warning notification has been set to '{{.ENABLE}}' for volume '{{.ID}}'." }, - "SoftLayer_Exception_ObjectNotFound: Unable to find object with id {{.ContextID}}": { - "other": "SoftLayer_Exception_ObjectNotFound: Unable to find object with id {{.ContextID}}" - }, - "SoftLayer_Exception_ObjectNotFound: Unable to find object with id {{.TranslationID}}": { - "other": "SoftLayer_Exception_ObjectNotFound: Unable to find object with id {{.TranslationID}}" - }, "Software": { "other": "Software" }, @@ -5858,18 +5582,6 @@ "State": { "other": "State" }, - "Static IP address": { - "other": "Static IP address" - }, - "Static IP address ID": { - "other": "Static IP address ID" - }, - "Static IP address[required]": { - "other": "Static IP address[required]" - }, - "Static Subnets": { - "other": "Static Subnets" - }, "Status": { "other": "Status" }, @@ -5885,18 +5597,9 @@ "Subnet": { "other": "Subnet" }, - "Subnet identifier to add, required": { - "other": "Subnet identifier to add, required" - }, - "Subnet network identifier to create": { - "other": "Subnet network identifier to create" - }, "Subnet notes": { "other": "Subnet notes" }, - "Subnet type to add. Options are: internal,remote,service[required]": { - "other": "Subnet type to add. Options are: internal,remote,service[required]" - }, "Subnet {{.ID}} was cancelled.": { "other": "Subnet {{.ID}} was cancelled." }, @@ -5993,9 +5696,6 @@ "TICKETID": { "other": "TICKETID" }, - "TRANSLATION_ID": { - "other": "TRANSLATION_ID" - }, "TTL(Time-To-Live) in seconds, such as: 86400. The default is: 7200": { "other": "TTL(Time-To-Live) in seconds, such as: 86400. The default is: 7200" }, @@ -6323,9 +6023,6 @@ "The subject id to use for the ticket, issue '${COMMAND_NAME} sl ticket subjects' to get the list. [required]": { "other": "The subject id to use for the ticket, issue '${COMMAND_NAME} sl ticket subjects' to get the list. [required]" }, - "The subnet type has to be either internal, or remote or service.": { - "other": "The subnet type has to be either internal, or remote or service." - }, "The subnet {{.Subnet}} was authorized to access {{.VolumeId}}.": { "other": "The subnet {{.Subnet}} was authorized to access {{.VolumeId}}." }, @@ -6485,9 +6182,6 @@ "This will cancel the IP address: {{.ID}} and cannot be undone. Continue?": { "other": "This will cancel the IP address: {{.ID}} and cannot be undone. Continue?" }, - "This will cancel the IPSec: {{.ContextID}} and cannot be undone. Continue?": { - "other": "This will cancel the IPSec: {{.ContextID}} and cannot be undone. Continue?" - }, "This will cancel the VLAN: {{.ID}} and cannot be undone. Continue?": { "other": "This will cancel the VLAN: {{.ID}} and cannot be undone. Continue?" }, @@ -6686,9 +6380,6 @@ "UUID of the protocol you want to edit.": { "other": "UUID of the protocol you want to edit." }, - "Unable to create {{.Type}} subnet.": { - "other": "Unable to create {{.Type}} subnet." - }, "Unable to find VLAN with ID {{.ID}}.\n": { "other": "Unable to find VLAN with ID {{.ID}}.\n" }, @@ -6797,9 +6488,6 @@ "Update RAID firmware": { "other": "Update RAID firmware" }, - "Update an address translation for an IPSec": { - "other": "Update an address translation for an IPSec" - }, "Update could not be added: {{.Error}}\n": { "other": "Update could not be added: {{.Error}}\n" }, @@ -6815,18 +6503,9 @@ "Update server firmware. By default will update all available server components.": { "other": "Update server firmware. By default will update all available server components." }, - "Update tunnel context properties": { - "other": "Update tunnel context properties" - }, - "Updated IPSec {{.ContextID}}.": { - "other": "Updated IPSec {{.ContextID}}." - }, "Updated resource record under zone {{.Zone}}: ID={{.ID}}, type={{.RecordType}}, record={{.Host}}, data={{.Data}}, ttl={{.Ttl}}.": { "other": "Updated resource record under zone {{.Zone}}: ID={{.ID}}, type={{.RecordType}}, record={{.Host}}, data={{.Data}}, ttl={{.Ttl}}." }, - "Updated translation with ID {{.TransID}} in IPSec {{.ID}}.": { - "other": "Updated translation with ID {{.TransID}} in IPSec {{.ID}}." - }, "Updates": { "other": "Updates" }, @@ -7049,9 +6728,6 @@ "You may run '{{.CommandName}} sl file volume-list --order {{.OrderID}}' to find this file volume after it is ready.": { "other": "You may run '{{.CommandName}} sl file volume-list --order {{.OrderID}}' to find this file volume after it is ready." }, - "You may run '{{.CommandName}} sl ipsec list --order {{.OrderID}}' to find this IPSec VPN after it is ready.": { - "other": "You may run '{{.CommandName}} sl ipsec list --order {{.OrderID}}' to find this IPSec VPN after it is ready." - }, "You may run '{{.CommandName}} sl vs host-list --order {{.OrderID}}' to find this dedicated host after it is ready.": { "other": "You may run '{{.CommandName}} sl vs host-list --order {{.OrderID}}' to find this dedicated host after it is ready." }, diff --git a/plugin/managers/ipsec.go b/plugin/managers/ipsec.go deleted file mode 100644 index b5587250..00000000 --- a/plugin/managers/ipsec.go +++ /dev/null @@ -1,355 +0,0 @@ -package managers - -import ( - "errors" - "strconv" - - "github.com/softlayer/softlayer-go/datatypes" - "github.com/softlayer/softlayer-go/filter" - "github.com/softlayer/softlayer-go/services" - "github.com/softlayer/softlayer-go/session" - "github.com/softlayer/softlayer-go/sl" - . "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n" -) - -const ( - CONTEXT_DETAULT_MASK = "id,name,friendlyName,internalPeerIpAddress,customerPeerIpAddress,createDate" -) - -// This provides helpers to manage IPSEC contexts, private and remote subnets, and NAT translations. -//counterfeiter:generate -o ../testhelpers/ . IPSECManager -type IPSECManager interface { - AddInternalSubnet(contextId, subnetId int) error - AddRemoteSubnet(contextId, subnetId int) error - AddServiceSubnet(contextId, subnetId int) error - ApplyConfiguration(contextId int) error - CreateRemoteSubnet(accountId int, networkId string, cidr int) (datatypes.Network_Customer_Subnet, error) - CreateTranslation(contextId int, staticIp, remoteIp, note string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - DeleteRemoteSubnet(contextId, subnetId int) error - GetTunnelContexts(order int, mask string) ([]datatypes.Network_Tunnel_Module_Context, error) - GetTunnelContext(contextId int, mask string) (datatypes.Network_Tunnel_Module_Context, error) - GetTranslations(contextId int) ([]datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - GetTranslation(contextId, translationId int) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - RemoveInternalSubnet(contextId, subnetId int) error - RemoveRemoteSubnet(contextId, subnetId int) error - RemoveServiceSubnet(contextId, subnetId int) error - RemoveTranslation(contextId, translationId int) error - UpdateTranslation(contextId, translationId int, staticIp, remoteIp, notes string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - UpdateTunnelContext(contextId int, name, remotePeer, presharedKey, phase1Auth, phase1Crypto string, phase1Dh, phase1KeyTtl int, phase2Auth, phase2Crypto string, phase2Dh, phase2ForwareSecrecy, phase2KeyTtl int) (datatypes.Network_Tunnel_Module_Context, error) - OrderTunnelContext(location string) (datatypes.Container_Product_Order_Receipt, error) - CancelTunnelContext(contextId int, immediate bool, reason string) error -} - -type ipsecManager struct { - AccountService services.Account - ContextService services.Network_Tunnel_Module_Context - RemoteSubnetService services.Network_Customer_Subnet - PackageService services.Product_Package - LocationService services.Location_Datacenter - OrderService services.Product_Order - BillingService services.Billing_Item -} - -func NewIPSECManager(session *session.Session) *ipsecManager { - return &ipsecManager{ - services.GetAccountService(session), - services.GetNetworkTunnelModuleContextService(session), - services.GetNetworkCustomerSubnetService(session), - services.GetProductPackageService(session), - services.GetLocationDatacenterService(session), - services.GetProductOrderService(session), - services.GetBillingItemService(session), - } -} - -// Add an internal subnet to a tunnel context -// contextId: The id-value representing the context instance -// subnetId: The id-value representing the internal subnet -func (i ipsecManager) AddInternalSubnet(contextId, subnetId int) error { - _, err := i.ContextService.Id(contextId).AddPrivateSubnetToNetworkTunnel(&subnetId) - return err -} - -// Add a remote subnet to a tunnel context -// contextId: The id-value representing the context instance -// subnetId: The id-value representing the internal subnet -func (i ipsecManager) AddRemoteSubnet(contextId, subnetId int) error { - _, err := i.ContextService.Id(contextId).AddCustomerSubnetToNetworkTunnel(&subnetId) - return err -} - -// Add a service subnet to a tunnel context -// contextId: The id-value representing the context instance -// subnetId: The id-value representing the internal subnet -func (i ipsecManager) AddServiceSubnet(contextId, subnetId int) error { - _, err := i.ContextService.Id(contextId).AddServiceSubnetToNetworkTunnel(&subnetId) - return err -} - -// Requests network configuration for a tunnel context. -// contextId: The id-value representing the context instance -func (i ipsecManager) ApplyConfiguration(contextId int) error { - _, err := i.ContextService.Id(contextId).ApplyConfigurationsToDevice() - return err -} - -// Creates a remote subnet on the given account -// accountId: The account identifier -// networkId: The network identifier of the remote subnet -// cidr: The CIDR value of the remote subnet -func (i ipsecManager) CreateRemoteSubnet(accountId int, networkId string, cidr int) (datatypes.Network_Customer_Subnet, error) { - remoteSubnet := datatypes.Network_Customer_Subnet{ - AccountId: sl.Int(accountId), - NetworkIdentifier: sl.String(networkId), - Cidr: sl.Int(cidr), - } - return i.RemoteSubnetService.CreateObject(&remoteSubnet) -} - -// Creates an address translation on a tunnel context -// staticIp: The IP address value representing the internal side of the translation entry -// remoteIp: The IP address value representing the remote side of the translation entry -// notes: The notes to supply with the translation entry -func (i ipsecManager) CreateTranslation(contextId int, staticIp, remoteIp, note string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - translation := datatypes.Network_Tunnel_Module_Context_Address_Translation{ - CustomerIpAddress: sl.String(remoteIp), - InternalIpAddress: sl.String(staticIp), - Notes: sl.String(note), - } - return i.ContextService.Id(contextId).CreateAddressTranslation(&translation) -} - -// Deletes a remote subnet from the current account -// contextId: The id representing the tunnel context -// subnetId: The id-value representing the remote subnet -func (i ipsecManager) DeleteRemoteSubnet(contextId, subnetId int) error { - _, err := i.ContextService.Id(contextId).RemoveCustomerSubnetFromNetworkTunnel(&subnetId) - return err -} - -// Retrieves the network tunnel context instance -// contextId: The id-value representing the context instance -func (i ipsecManager) GetTunnelContext(contextId int, mask string) (datatypes.Network_Tunnel_Module_Context, error) { - filters := filter.New(filter.Path("networkTunnelContexts.id").Eq(contextId)) - if mask == "" { - mask = CONTEXT_DETAULT_MASK - } - contexts, err := i.AccountService.Mask(mask).Filter(filters.Build()).GetNetworkTunnelContexts() - if err != nil { - return datatypes.Network_Tunnel_Module_Context{}, err - } - if len(contexts) == 0 { - return datatypes.Network_Tunnel_Module_Context{}, errors.New(T("SoftLayer_Exception_ObjectNotFound: Unable to find object with id {{.ContextID}}", map[string]interface{}{"ContextID": contextId})) - } - return contexts[0], nil -} - -// Retrieves the network tunnel contexts -func (i ipsecManager) GetTunnelContexts(orderId int, mask string) ([]datatypes.Network_Tunnel_Module_Context, error) { - if mask == "" { - mask = CONTEXT_DETAULT_MASK - } - if orderId != 0 { - filters := filter.New() - filters = append(filters, filter.Path("networkTunnelContexts.billingItem.orderItem.order.id").Eq(orderId)) - return i.AccountService.Mask(mask).Filter(filters.Build()).GetNetworkTunnelContexts() - } - return i.AccountService.Mask(mask).GetNetworkTunnelContexts() -} - -// Retrieves all translation entries for a tunnel context -// contextId: The id-value representing the context instance -func (i ipsecManager) GetTranslations(contextId int) ([]datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - mask := "addressTranslations[customerIpAddressRecord,internalIpAddressRecord]" - context, err := i.GetTunnelContext(contextId, mask) - if err != nil { - return nil, err - } - for _, t := range context.AddressTranslations { - remoteIp := t.CustomerIpAddressRecord - internalIp := t.InternalIpAddressRecord - t.CustomerIpAddress = remoteIp.IpAddress - t.InternalIpAddress = internalIp.IpAddress - t.CustomerIpAddressRecord = nil - t.InternalIpAddressRecord = nil - } - return context.AddressTranslations, nil -} - -// Retrieves a translation entry for the given id values -// contextId: The id-value representing the context instance -// translationId: The id-value representing the translation instance -func (i ipsecManager) GetTranslation(contextId, translationId int) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - translations, err := i.GetTranslations(contextId) - if err != nil { - return datatypes.Network_Tunnel_Module_Context_Address_Translation{}, err - } - for _, t := range translations { - if t.Id != nil && *t.Id == translationId { - return t, nil - } - } - return datatypes.Network_Tunnel_Module_Context_Address_Translation{}, errors.New(T("SoftLayer_Exception_ObjectNotFound: Unable to find object with id {{.TranslationID}}", map[string]interface{}{"TranslationID": translationId})) -} - -// Remove an internal subnet from a tunnel context -// contextId: The id-value representing the context instance -// subnetId: The id-value representing the internal subnet -func (i ipsecManager) RemoveInternalSubnet(contextId, subnetId int) error { - _, err := i.ContextService.Id(contextId).RemovePrivateSubnetFromNetworkTunnel(&subnetId) - return err -} - -// Removes a remote subnet from a tunnel context -// contextId: The id-value representing the context instance -// subnetId: The id-value representing the remote subnet -func (i ipsecManager) RemoveRemoteSubnet(contextId, subnetId int) error { - _, err := i.ContextService.Id(contextId).RemoveCustomerSubnetFromNetworkTunnel(&subnetId) - return err -} - -// Removes a service subnet from a tunnel context -// contextId: The id-value representing the context instance -// subnetId: The id-value representing the service subnet -func (i ipsecManager) RemoveServiceSubnet(contextId, subnetId int) error { - _, err := i.ContextService.Id(contextId).RemoveServiceSubnetFromNetworkTunnel(&subnetId) - return err -} - -// Removes a translation entry from a tunnel context -// contextId: The id-value representing the context instance -// translationId: The id-value representing the translation -func (i ipsecManager) RemoveTranslation(contextId, translationId int) error { - _, err := i.ContextService.Id(contextId).DeleteAddressTranslation(&translationId) - return err -} - -// Updates an address translation entry using the given values -// contextId: The id-value representing the context instance. -// staticIp: The static IP address value to update. -// remoteIp: The remote IP address value to update. -// notes: The notes value to update. -func (i ipsecManager) UpdateTranslation(contextId, translationId int, staticIp, remoteIp, notes string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - translation, err := i.GetTranslation(contextId, translationId) - if err != nil { - return datatypes.Network_Tunnel_Module_Context_Address_Translation{}, err - } - if staticIp != "" { - translation.InternalIpAddress = &staticIp - translation.InternalIpAddressId = nil - } - if remoteIp != "" { - translation.CustomerIpAddress = &remoteIp - translation.CustomerIpAddressId = nil - } - if notes != "" { - translation.Notes = ¬es - } - return i.ContextService.Id(contextId).EditAddressTranslation(&translation) -} - -// Updates a tunnel context using the given values -// contextId: The id-value representing the context. -// name: The friendly name value to update. -// remotePeer: The remote peer IP address value to update. -// presharedKey: The preshared key value to update. -// phase1Auth: The phase 1 authentication value to update. -// phase1Crypto: The phase 1 encryption value to update. -// phase1Dh: The phase 1 diffie hellman group value to update. -// phase1KeyTtl: The phase 1 key life value to update. -// phase2Auth: The phase 2 authentication value to update. -// phase2Crypto: The phase 2 encryption value to update. -// phase2Dh: The phase 2 diffie hellman group value to update. -// phase2ForwardSecrecy: The phase 2 perfect forward secrecy value to update. -// phase2KeyTtl: The phase 2 key life value to update. -func (i ipsecManager) UpdateTunnelContext(contextId int, name, remotePeer, presharedKey, phase1Auth, phase1Crypto string, phase1Dh, phase1KeyTtl int, phase2Auth, phase2Crypto string, phase2Dh, phase2ForwareSecrecy, phase2KeyTtl int) (datatypes.Network_Tunnel_Module_Context, error) { - context, err := i.GetTunnelContext(contextId, "") - if err != nil { - return datatypes.Network_Tunnel_Module_Context{}, err - } - if name != "" { - context.FriendlyName = &name - } - if remotePeer != "" { - context.CustomerPeerIpAddress = &remotePeer - } - if presharedKey != "" { - context.PresharedKey = &presharedKey - } - if phase1Auth != "" { - context.PhaseOneAuthentication = &phase1Auth - } - if phase1Crypto != "" { - context.PhaseOneEncryption = &phase1Crypto - } - if phase1Dh != 0 { - context.PhaseOneDiffieHellmanGroup = &phase1Dh - } - if phase1KeyTtl != 0 { - context.PhaseOneKeylife = &phase1KeyTtl - } - if phase2Auth != "" { - context.PhaseTwoAuthentication = &phase2Auth - } - if phase2Crypto != "" { - context.PhaseTwoEncryption = &phase2Crypto - } - if phase2Dh != 0 { - context.PhaseTwoDiffieHellmanGroup = &phase2Dh - } - if phase2ForwareSecrecy != 0 { - context.PhaseTwoPerfectForwardSecrecy = &phase2ForwareSecrecy - } - if phase2KeyTtl != 0 { - context.PhaseTwoKeylife = &phase2KeyTtl - } - _, err = i.ContextService.Id(contextId).EditObject(&context) - if err != nil { - return datatypes.Network_Tunnel_Module_Context{}, err - } - return context, nil -} - -func (i ipsecManager) OrderTunnelContext(location string) (datatypes.Container_Product_Order_Receipt, error) { - categoryCode := "network_tunnel" - filters := filter.New() - filters = append(filters, filter.Path("items.itemCategory.categoryCode").Eq(categoryCode)) - packageItems, err := i.PackageService.Id(0).Filter(filters.Build()).GetItems() - if err != nil { - return datatypes.Container_Product_Order_Receipt{}, err - } - if len(packageItems) == 0 { - return datatypes.Container_Product_Order_Receipt{}, errors.New(T("Failed to find product package for this IPSEC.")) - } - locationId, err := GetLocationId(i.LocationService, location) - if err != nil { - return datatypes.Container_Product_Order_Receipt{}, err - } - order := datatypes.Container_Product_Order_Network_Tunnel_Ipsec{ - Container_Product_Order: datatypes.Container_Product_Order{ - ComplexType: sl.String("Container_Product_Order_Network_Tunnel_Ipsec"), - PackageId: sl.Int(0), - Location: sl.String(strconv.Itoa(locationId)), - Quantity: sl.Int(1), - Prices: []datatypes.Product_Item_Price{ - datatypes.Product_Item_Price{ - Id: packageItems[0].Prices[0].Id, - }, - }, - }, - } - return i.OrderService.PlaceOrder(&order, sl.Bool(false)) -} - -func (i ipsecManager) CancelTunnelContext(contextId int, immediate bool, reason string) error { - context, err := i.GetTunnelContext(contextId, "id,billingItem.id") - if err != nil { - return err - } - if context.BillingItem == nil || context.BillingItem.Id == nil { - return errors.New(T("No billing item is found to cancel.")) - } - billitemId := *context.BillingItem.Id - _, err = i.BillingService.Id(billitemId).CancelItem(sl.Bool(immediate), sl.Bool(true), sl.String(reason), sl.String("")) - return err -} diff --git a/plugin/managers/ipsec_test.go b/plugin/managers/ipsec_test.go deleted file mode 100644 index 9227b2b0..00000000 --- a/plugin/managers/ipsec_test.go +++ /dev/null @@ -1 +0,0 @@ -package managers_test diff --git a/plugin/managers/order.go b/plugin/managers/order.go index 91d05d3b..d48998ce 100644 --- a/plugin/managers/order.go +++ b/plugin/managers/order.go @@ -332,7 +332,8 @@ func (i orderManager) GetPriceIdList(packageKeyname string, itemKeynames []strin return nil, err } var prices []int - categoryDict := map[string]int{"gpu0": -1, "pcie_slot0": -1} + // start at -1 so we can increment before we use it. 0 is a valid value here + categoryDict := map[string]int{"gpu0": -1, "pcie_slot0": -1, "disk_controller": -1} for _, itemKeyname := range itemKeynames { var newItems []datatypes.Product_Item @@ -355,10 +356,10 @@ func (i orderManager) GetPriceIdList(packageKeyname string, itemKeynames []strin itemCategory = *matchingItem.ItemCategory.CategoryCode } + // Normal items if _, ok := categoryDict[itemCategory]; !ok { for _, p := range matchingItem.Prices { - if ((p.LocationGroupId != nil && *p.LocationGroupId == 0) || - p.LocationGroupId == nil) && p.Id != nil { + if isDefaultPrice(p) { capacityMin := -1 capacityMax := -1 @@ -386,19 +387,23 @@ func (i orderManager) GetPriceIdList(packageKeyname string, itemKeynames []strin } } } + // Items in categoryDict need special handling if there are more than 1 } else { - var PriceIdList []int + categoryDict[itemCategory] += 1 - categoryCode := itemCategory[:len(itemCategory)-1] + strconv.Itoa(categoryDict[itemCategory]) + categoryCode := getSpecialCategory(categoryDict[itemCategory], itemCategory) for _, p := range matchingItem.Prices { - if p.LocationGroupId != nil && *p.LocationGroupId == 0 && - len(p.Categories) > 0 && p.Categories[0].CategoryCode != nil && + if isDefaultPrice(p) && len(p.Categories) > 0 && p.Categories[0].CategoryCode != nil && *p.Categories[0].CategoryCode == categoryCode { - - PriceIdList = append(PriceIdList, *p.Id) + priceId = *p.Id } } - priceId = PriceIdList[0] + if priceId == 0 { + subs := map[string]interface{}{"Item": itemKeyname, "Package": packageKeyname, "Category": categoryCode} + return nil, errors.New( + T("Item {{.Item}} does not exist for package {{.Package}} with category {{.Category}}", subs)) + } + } prices = append(prices, priceId) } @@ -491,3 +496,28 @@ func (i orderManager) GetAllCancelation(mask string) ([]datatypes.Billing_Item_C func (i orderManager) DeleteQuote(quoteId int) (datatypes.Billing_Order_Quote, error) { return i.BillingOrderQuoteService.Id(quoteId).DeleteQuote() } + +func getSpecialCategory(index int, base string) string { + // Special case because its disk_controller and disk_controller1 + // unlike gpu0/pci0 -> gpu1/pci1 + if base == "disk_controller" { + if index == 0 { + return base + } else { + return fmt.Sprintf("%s1", base) + } + } + categoryCode := base[:len(base)-1] + strconv.Itoa(index) + return categoryCode +} + +func isDefaultPrice(price datatypes.Product_Item_Price) bool { + if price.LocationGroupId != nil && *price.LocationGroupId > 0 { + return false + } else { + if price.Id != nil { + return true + } + } + return false +} \ No newline at end of file diff --git a/plugin/managers/order_test.go b/plugin/managers/order_test.go index cc287344..40bacdb1 100644 --- a/plugin/managers/order_test.go +++ b/plugin/managers/order_test.go @@ -222,8 +222,7 @@ var _ = Describe("Order", func() { }) Describe("GetPriceIdList", func() { Items := []string{ - "PRIVATE_NETWORK_VLAN", - "DOMAIN_INFO_1_YEAR", + "PRIVATE_NETWORK_VLAN", "DOMAIN_INFO_1_YEAR", } BeforeEach(func() { fakeSLSession = testhelpers.NewFakeSoftlayerSession(nil) @@ -250,5 +249,36 @@ var _ = Describe("Order", func() { Expect(err).To(HaveOccurred()) }) }) + Context("NVMe Selection", func() { + BeforeEach(func() { + handler := testhelpers.GetSessionHandler(fakeSLSession) + handler.SetFileNames([]string{"getItems-3137"}) + }) + It("Select NVMe Prices", func() { + Items := []string{ + "DISK_CONTROLLER_RAID", "DISK_CONTROLLER_RAID_1_MIRRORED_NMVE_M_2", + } + prices, err := OrderManager.GetPriceIdList("Test", Items, 0) + Expect(err).ToNot(HaveOccurred()) + Expect(len(prices)).To(Equal(2)) + Expect(prices[0]).To(Equal(22484)) // DISK_CONTROLLER_RAID + Expect(prices[1]).To(Equal(306531)) // DISK_CONTROLLER_RAID_1_MIRRORED_NMVE_M_2 + }) + It("Select nonraid Prices", func() { + Items := []string{"DISK_CONTROLLER_NONRAID"} + prices, err := OrderManager.GetPriceIdList("Test", Items, 0) + Expect(err).ToNot(HaveOccurred()) + Expect(len(prices)).To(Equal(1)) + Expect(prices[0]).To(Equal(876)) // DISK_CONTROLLER_NONRAID + }) + It("Select NVMe Prices Failure", func() { + Items := []string{ + "DISK_CONTROLLER_RAID_1_MIRRORED_NMVE_M_2", "DISK_CONTROLLER_RAID", + } + _, err := OrderManager.GetPriceIdList("Test", Items, 0) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("Item DISK_CONTROLLER_RAID does not exist for package Test with category disk_controller1")) + }) + }) }) }) diff --git a/plugin/plugin.go b/plugin/plugin.go index 614ff980..1735888d 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -36,7 +36,6 @@ import ( "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/globalip" "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/hardware" "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/image" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/ipsec" "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/licenses" "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/loadbal" @@ -231,7 +230,6 @@ func Namespaces() []plugin.Namespace { metadata.SoftlayerNamespace(), block.BlockNamespace(), file.FileNamespace(), - cdn.CdnNamespace(), dns.DnsNamespace(), eventlog.EventLogNamespace(), firewall.FirewallNamespace(), @@ -239,7 +237,6 @@ func Namespaces() []plugin.Namespace { globalip.GlobalIpNamespace(), hardware.HardwareNamespace(), image.ImageNamespace(), - ipsec.IpsecNamespace(), licenses.LicensesNamespace(), loadbal.LoadbalNamespace(), nas.NasNetworkStorageNamespace(), @@ -382,7 +379,6 @@ func GetTopCobraCommand(ui terminal.UI, session *session.Session) *cobra.Command cobraCmd.AddCommand(email.SetupCobraCommands(slCommand)) cobraCmd.AddCommand(image.SetupCobraCommands(slCommand)) cobraCmd.AddCommand(hardware.SetupCobraCommands(slCommand)) - cobraCmd.AddCommand(ipsec.SetupCobraCommands(slCommand)) cobraCmd.AddCommand(reports.SetupCobraCommands(slCommand)) cobraCmd.AddCommand(eventlog.SetupCobraCommands(slCommand)) cobraCmd.AddCommand(user.SetupCobraCommands(slCommand)) diff --git a/plugin/testfixtures/.bluemix/config.json b/plugin/testfixtures/.bluemix/config.json index 873c5c6e..3f770f0b 100644 --- a/plugin/testfixtures/.bluemix/config.json +++ b/plugin/testfixtures/.bluemix/config.json @@ -48,14 +48,25 @@ "LastSessionUpdateTime": 0, "Trace": "", "ColorEnabled": "", + "AlphaCommandsEnabled": "", "HTTPTimeout": 0, "TypeOfSSO": "", + "FallbackAccount": { + "GUID": "", + "Name": "", + "Owner": "" + }, + "FallbackIAMTokens": { + "IAMToken": "", + "IAMRefreshToken": "" + }, + "AssumedTrustedProfileId": "", "CLIInfoEndpoint": "", "CheckCLIVersionDisabled": false, "UsageStatsDisabled": false, "UsageStatsEnabled": false, "UsageStatsEnabledLastUpdate": "0001-01-01T00:00:00Z", - "SDKVersion": "1.4.0", + "SDKVersion": "1.7.2", "UpdateCheckInterval": 0, "UpdateRetryCheckInterval": 0, "UpdateNotificationInterval": 0, diff --git a/plugin/testfixtures/SoftLayer_Product_Package/getItems-3137.json b/plugin/testfixtures/SoftLayer_Product_Package/getItems-3137.json new file mode 100644 index 00000000..f4a504b1 --- /dev/null +++ b/plugin/testfixtures/SoftLayer_Product_Package/getItems-3137.json @@ -0,0 +1,554 @@ +[ + { + "id": 27479, + "itemCategory": { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + }, + "keyName": "DISK_CONTROLLER_RAID_1_MIRRORED_NMVE_M_2", + "prices": [ + { + "categories": [ + { + "categoryCode": "disk_controller1", + "id": 1180, + "name": "Second Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 306531, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": null, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller1", + "id": 1180, + "name": "Second Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 306537, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 507, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 305131, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": null, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 305135, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 505, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 305139, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 509, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 305141, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 545, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller1", + "id": 1180, + "name": "Second Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 306533, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 503, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller1", + "id": 1180, + "name": "Second Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 306541, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 545, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 305133, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 503, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller1", + "id": 1180, + "name": "Second Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 306535, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 505, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller1", + "id": 1180, + "name": "Second Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 306539, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 509, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "id": 305137, + "itemId": 27479, + "laborFee": "0", + "locationGroupId": 507, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + } + ] + }, + { + "id": 487, + "itemCategory": { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + }, + "keyName": "DISK_CONTROLLER_NONRAID", + "prices": [ + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": "0", + "id": 876, + "itemId": 487, + "laborFee": "0", + "locationGroupId": null, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "0", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + } + ] + }, + { + "id": 4478, + "itemCategory": { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + }, + "keyName": "DISK_CONTROLLER_RAID", + "prices": [ + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".07983", + "id": 22484, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": null, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "52.25", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".08392", + "id": 75005, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": 503, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "55.41", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".08943", + "id": 75007, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": 505, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "59.07", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".0914", + "id": 75009, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": 507, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "60.57", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".0943", + "id": 75011, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": 509, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "62.67", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".09739", + "id": 328016, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": 5382, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "63.75", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".10345", + "id": 75013, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": 545, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "68.97", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + }, + { + "categories": [ + { + "categoryCode": "disk_controller", + "id": 11, + "name": "Disk Controller", + "quantityLimit": 0, + "sortOrder": 4 + } + ], + "currentPriceFlag": null, + "hourlyRecurringFee": ".10868", + "id": 151601, + "itemId": 4478, + "laborFee": "0", + "locationGroupId": 583, + "onSaleFlag": null, + "oneTimeFee": "0", + "quantity": null, + "recurringFee": "72.11", + "setupFee": "0", + "sort": 0, + "termLength": null, + "tierMinimumThreshold": null + } + ] + } +] diff --git a/plugin/testhelpers/fake_ipsecmanager.go b/plugin/testhelpers/fake_ipsecmanager.go deleted file mode 100644 index 384a64f3..00000000 --- a/plugin/testhelpers/fake_ipsecmanager.go +++ /dev/null @@ -1,1557 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package testhelpers - -import ( - "sync" - - "github.com/softlayer/softlayer-go/datatypes" - "github.ibm.com/SoftLayer/softlayer-cli/plugin/managers" -) - -type FakeIPSECManager struct { - AddInternalSubnetStub func(int, int) error - addInternalSubnetMutex sync.RWMutex - addInternalSubnetArgsForCall []struct { - arg1 int - arg2 int - } - addInternalSubnetReturns struct { - result1 error - } - addInternalSubnetReturnsOnCall map[int]struct { - result1 error - } - AddRemoteSubnetStub func(int, int) error - addRemoteSubnetMutex sync.RWMutex - addRemoteSubnetArgsForCall []struct { - arg1 int - arg2 int - } - addRemoteSubnetReturns struct { - result1 error - } - addRemoteSubnetReturnsOnCall map[int]struct { - result1 error - } - AddServiceSubnetStub func(int, int) error - addServiceSubnetMutex sync.RWMutex - addServiceSubnetArgsForCall []struct { - arg1 int - arg2 int - } - addServiceSubnetReturns struct { - result1 error - } - addServiceSubnetReturnsOnCall map[int]struct { - result1 error - } - ApplyConfigurationStub func(int) error - applyConfigurationMutex sync.RWMutex - applyConfigurationArgsForCall []struct { - arg1 int - } - applyConfigurationReturns struct { - result1 error - } - applyConfigurationReturnsOnCall map[int]struct { - result1 error - } - CancelTunnelContextStub func(int, bool, string) error - cancelTunnelContextMutex sync.RWMutex - cancelTunnelContextArgsForCall []struct { - arg1 int - arg2 bool - arg3 string - } - cancelTunnelContextReturns struct { - result1 error - } - cancelTunnelContextReturnsOnCall map[int]struct { - result1 error - } - CreateRemoteSubnetStub func(int, string, int) (datatypes.Network_Customer_Subnet, error) - createRemoteSubnetMutex sync.RWMutex - createRemoteSubnetArgsForCall []struct { - arg1 int - arg2 string - arg3 int - } - createRemoteSubnetReturns struct { - result1 datatypes.Network_Customer_Subnet - result2 error - } - createRemoteSubnetReturnsOnCall map[int]struct { - result1 datatypes.Network_Customer_Subnet - result2 error - } - CreateTranslationStub func(int, string, string, string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - createTranslationMutex sync.RWMutex - createTranslationArgsForCall []struct { - arg1 int - arg2 string - arg3 string - arg4 string - } - createTranslationReturns struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - createTranslationReturnsOnCall map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - DeleteRemoteSubnetStub func(int, int) error - deleteRemoteSubnetMutex sync.RWMutex - deleteRemoteSubnetArgsForCall []struct { - arg1 int - arg2 int - } - deleteRemoteSubnetReturns struct { - result1 error - } - deleteRemoteSubnetReturnsOnCall map[int]struct { - result1 error - } - GetTranslationStub func(int, int) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - getTranslationMutex sync.RWMutex - getTranslationArgsForCall []struct { - arg1 int - arg2 int - } - getTranslationReturns struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - getTranslationReturnsOnCall map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - GetTranslationsStub func(int) ([]datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - getTranslationsMutex sync.RWMutex - getTranslationsArgsForCall []struct { - arg1 int - } - getTranslationsReturns struct { - result1 []datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - getTranslationsReturnsOnCall map[int]struct { - result1 []datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - GetTunnelContextStub func(int, string) (datatypes.Network_Tunnel_Module_Context, error) - getTunnelContextMutex sync.RWMutex - getTunnelContextArgsForCall []struct { - arg1 int - arg2 string - } - getTunnelContextReturns struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - } - getTunnelContextReturnsOnCall map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - } - GetTunnelContextsStub func(int, string) ([]datatypes.Network_Tunnel_Module_Context, error) - getTunnelContextsMutex sync.RWMutex - getTunnelContextsArgsForCall []struct { - arg1 int - arg2 string - } - getTunnelContextsReturns struct { - result1 []datatypes.Network_Tunnel_Module_Context - result2 error - } - getTunnelContextsReturnsOnCall map[int]struct { - result1 []datatypes.Network_Tunnel_Module_Context - result2 error - } - OrderTunnelContextStub func(string) (datatypes.Container_Product_Order_Receipt, error) - orderTunnelContextMutex sync.RWMutex - orderTunnelContextArgsForCall []struct { - arg1 string - } - orderTunnelContextReturns struct { - result1 datatypes.Container_Product_Order_Receipt - result2 error - } - orderTunnelContextReturnsOnCall map[int]struct { - result1 datatypes.Container_Product_Order_Receipt - result2 error - } - RemoveInternalSubnetStub func(int, int) error - removeInternalSubnetMutex sync.RWMutex - removeInternalSubnetArgsForCall []struct { - arg1 int - arg2 int - } - removeInternalSubnetReturns struct { - result1 error - } - removeInternalSubnetReturnsOnCall map[int]struct { - result1 error - } - RemoveRemoteSubnetStub func(int, int) error - removeRemoteSubnetMutex sync.RWMutex - removeRemoteSubnetArgsForCall []struct { - arg1 int - arg2 int - } - removeRemoteSubnetReturns struct { - result1 error - } - removeRemoteSubnetReturnsOnCall map[int]struct { - result1 error - } - RemoveServiceSubnetStub func(int, int) error - removeServiceSubnetMutex sync.RWMutex - removeServiceSubnetArgsForCall []struct { - arg1 int - arg2 int - } - removeServiceSubnetReturns struct { - result1 error - } - removeServiceSubnetReturnsOnCall map[int]struct { - result1 error - } - RemoveTranslationStub func(int, int) error - removeTranslationMutex sync.RWMutex - removeTranslationArgsForCall []struct { - arg1 int - arg2 int - } - removeTranslationReturns struct { - result1 error - } - removeTranslationReturnsOnCall map[int]struct { - result1 error - } - UpdateTranslationStub func(int, int, string, string, string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) - updateTranslationMutex sync.RWMutex - updateTranslationArgsForCall []struct { - arg1 int - arg2 int - arg3 string - arg4 string - arg5 string - } - updateTranslationReturns struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - updateTranslationReturnsOnCall map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - } - UpdateTunnelContextStub func(int, string, string, string, string, string, int, int, string, string, int, int, int) (datatypes.Network_Tunnel_Module_Context, error) - updateTunnelContextMutex sync.RWMutex - updateTunnelContextArgsForCall []struct { - arg1 int - arg2 string - arg3 string - arg4 string - arg5 string - arg6 string - arg7 int - arg8 int - arg9 string - arg10 string - arg11 int - arg12 int - arg13 int - } - updateTunnelContextReturns struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - } - updateTunnelContextReturnsOnCall map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeIPSECManager) AddInternalSubnet(arg1 int, arg2 int) error { - fake.addInternalSubnetMutex.Lock() - ret, specificReturn := fake.addInternalSubnetReturnsOnCall[len(fake.addInternalSubnetArgsForCall)] - fake.addInternalSubnetArgsForCall = append(fake.addInternalSubnetArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.AddInternalSubnetStub - fakeReturns := fake.addInternalSubnetReturns - fake.recordInvocation("AddInternalSubnet", []interface{}{arg1, arg2}) - fake.addInternalSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) AddInternalSubnetCallCount() int { - fake.addInternalSubnetMutex.RLock() - defer fake.addInternalSubnetMutex.RUnlock() - return len(fake.addInternalSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) AddInternalSubnetCalls(stub func(int, int) error) { - fake.addInternalSubnetMutex.Lock() - defer fake.addInternalSubnetMutex.Unlock() - fake.AddInternalSubnetStub = stub -} - -func (fake *FakeIPSECManager) AddInternalSubnetArgsForCall(i int) (int, int) { - fake.addInternalSubnetMutex.RLock() - defer fake.addInternalSubnetMutex.RUnlock() - argsForCall := fake.addInternalSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) AddInternalSubnetReturns(result1 error) { - fake.addInternalSubnetMutex.Lock() - defer fake.addInternalSubnetMutex.Unlock() - fake.AddInternalSubnetStub = nil - fake.addInternalSubnetReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) AddInternalSubnetReturnsOnCall(i int, result1 error) { - fake.addInternalSubnetMutex.Lock() - defer fake.addInternalSubnetMutex.Unlock() - fake.AddInternalSubnetStub = nil - if fake.addInternalSubnetReturnsOnCall == nil { - fake.addInternalSubnetReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.addInternalSubnetReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) AddRemoteSubnet(arg1 int, arg2 int) error { - fake.addRemoteSubnetMutex.Lock() - ret, specificReturn := fake.addRemoteSubnetReturnsOnCall[len(fake.addRemoteSubnetArgsForCall)] - fake.addRemoteSubnetArgsForCall = append(fake.addRemoteSubnetArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.AddRemoteSubnetStub - fakeReturns := fake.addRemoteSubnetReturns - fake.recordInvocation("AddRemoteSubnet", []interface{}{arg1, arg2}) - fake.addRemoteSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) AddRemoteSubnetCallCount() int { - fake.addRemoteSubnetMutex.RLock() - defer fake.addRemoteSubnetMutex.RUnlock() - return len(fake.addRemoteSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) AddRemoteSubnetCalls(stub func(int, int) error) { - fake.addRemoteSubnetMutex.Lock() - defer fake.addRemoteSubnetMutex.Unlock() - fake.AddRemoteSubnetStub = stub -} - -func (fake *FakeIPSECManager) AddRemoteSubnetArgsForCall(i int) (int, int) { - fake.addRemoteSubnetMutex.RLock() - defer fake.addRemoteSubnetMutex.RUnlock() - argsForCall := fake.addRemoteSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) AddRemoteSubnetReturns(result1 error) { - fake.addRemoteSubnetMutex.Lock() - defer fake.addRemoteSubnetMutex.Unlock() - fake.AddRemoteSubnetStub = nil - fake.addRemoteSubnetReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) AddRemoteSubnetReturnsOnCall(i int, result1 error) { - fake.addRemoteSubnetMutex.Lock() - defer fake.addRemoteSubnetMutex.Unlock() - fake.AddRemoteSubnetStub = nil - if fake.addRemoteSubnetReturnsOnCall == nil { - fake.addRemoteSubnetReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.addRemoteSubnetReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) AddServiceSubnet(arg1 int, arg2 int) error { - fake.addServiceSubnetMutex.Lock() - ret, specificReturn := fake.addServiceSubnetReturnsOnCall[len(fake.addServiceSubnetArgsForCall)] - fake.addServiceSubnetArgsForCall = append(fake.addServiceSubnetArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.AddServiceSubnetStub - fakeReturns := fake.addServiceSubnetReturns - fake.recordInvocation("AddServiceSubnet", []interface{}{arg1, arg2}) - fake.addServiceSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) AddServiceSubnetCallCount() int { - fake.addServiceSubnetMutex.RLock() - defer fake.addServiceSubnetMutex.RUnlock() - return len(fake.addServiceSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) AddServiceSubnetCalls(stub func(int, int) error) { - fake.addServiceSubnetMutex.Lock() - defer fake.addServiceSubnetMutex.Unlock() - fake.AddServiceSubnetStub = stub -} - -func (fake *FakeIPSECManager) AddServiceSubnetArgsForCall(i int) (int, int) { - fake.addServiceSubnetMutex.RLock() - defer fake.addServiceSubnetMutex.RUnlock() - argsForCall := fake.addServiceSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) AddServiceSubnetReturns(result1 error) { - fake.addServiceSubnetMutex.Lock() - defer fake.addServiceSubnetMutex.Unlock() - fake.AddServiceSubnetStub = nil - fake.addServiceSubnetReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) AddServiceSubnetReturnsOnCall(i int, result1 error) { - fake.addServiceSubnetMutex.Lock() - defer fake.addServiceSubnetMutex.Unlock() - fake.AddServiceSubnetStub = nil - if fake.addServiceSubnetReturnsOnCall == nil { - fake.addServiceSubnetReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.addServiceSubnetReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) ApplyConfiguration(arg1 int) error { - fake.applyConfigurationMutex.Lock() - ret, specificReturn := fake.applyConfigurationReturnsOnCall[len(fake.applyConfigurationArgsForCall)] - fake.applyConfigurationArgsForCall = append(fake.applyConfigurationArgsForCall, struct { - arg1 int - }{arg1}) - stub := fake.ApplyConfigurationStub - fakeReturns := fake.applyConfigurationReturns - fake.recordInvocation("ApplyConfiguration", []interface{}{arg1}) - fake.applyConfigurationMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) ApplyConfigurationCallCount() int { - fake.applyConfigurationMutex.RLock() - defer fake.applyConfigurationMutex.RUnlock() - return len(fake.applyConfigurationArgsForCall) -} - -func (fake *FakeIPSECManager) ApplyConfigurationCalls(stub func(int) error) { - fake.applyConfigurationMutex.Lock() - defer fake.applyConfigurationMutex.Unlock() - fake.ApplyConfigurationStub = stub -} - -func (fake *FakeIPSECManager) ApplyConfigurationArgsForCall(i int) int { - fake.applyConfigurationMutex.RLock() - defer fake.applyConfigurationMutex.RUnlock() - argsForCall := fake.applyConfigurationArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeIPSECManager) ApplyConfigurationReturns(result1 error) { - fake.applyConfigurationMutex.Lock() - defer fake.applyConfigurationMutex.Unlock() - fake.ApplyConfigurationStub = nil - fake.applyConfigurationReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) ApplyConfigurationReturnsOnCall(i int, result1 error) { - fake.applyConfigurationMutex.Lock() - defer fake.applyConfigurationMutex.Unlock() - fake.ApplyConfigurationStub = nil - if fake.applyConfigurationReturnsOnCall == nil { - fake.applyConfigurationReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.applyConfigurationReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) CancelTunnelContext(arg1 int, arg2 bool, arg3 string) error { - fake.cancelTunnelContextMutex.Lock() - ret, specificReturn := fake.cancelTunnelContextReturnsOnCall[len(fake.cancelTunnelContextArgsForCall)] - fake.cancelTunnelContextArgsForCall = append(fake.cancelTunnelContextArgsForCall, struct { - arg1 int - arg2 bool - arg3 string - }{arg1, arg2, arg3}) - stub := fake.CancelTunnelContextStub - fakeReturns := fake.cancelTunnelContextReturns - fake.recordInvocation("CancelTunnelContext", []interface{}{arg1, arg2, arg3}) - fake.cancelTunnelContextMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) CancelTunnelContextCallCount() int { - fake.cancelTunnelContextMutex.RLock() - defer fake.cancelTunnelContextMutex.RUnlock() - return len(fake.cancelTunnelContextArgsForCall) -} - -func (fake *FakeIPSECManager) CancelTunnelContextCalls(stub func(int, bool, string) error) { - fake.cancelTunnelContextMutex.Lock() - defer fake.cancelTunnelContextMutex.Unlock() - fake.CancelTunnelContextStub = stub -} - -func (fake *FakeIPSECManager) CancelTunnelContextArgsForCall(i int) (int, bool, string) { - fake.cancelTunnelContextMutex.RLock() - defer fake.cancelTunnelContextMutex.RUnlock() - argsForCall := fake.cancelTunnelContextArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeIPSECManager) CancelTunnelContextReturns(result1 error) { - fake.cancelTunnelContextMutex.Lock() - defer fake.cancelTunnelContextMutex.Unlock() - fake.CancelTunnelContextStub = nil - fake.cancelTunnelContextReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) CancelTunnelContextReturnsOnCall(i int, result1 error) { - fake.cancelTunnelContextMutex.Lock() - defer fake.cancelTunnelContextMutex.Unlock() - fake.CancelTunnelContextStub = nil - if fake.cancelTunnelContextReturnsOnCall == nil { - fake.cancelTunnelContextReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.cancelTunnelContextReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) CreateRemoteSubnet(arg1 int, arg2 string, arg3 int) (datatypes.Network_Customer_Subnet, error) { - fake.createRemoteSubnetMutex.Lock() - ret, specificReturn := fake.createRemoteSubnetReturnsOnCall[len(fake.createRemoteSubnetArgsForCall)] - fake.createRemoteSubnetArgsForCall = append(fake.createRemoteSubnetArgsForCall, struct { - arg1 int - arg2 string - arg3 int - }{arg1, arg2, arg3}) - stub := fake.CreateRemoteSubnetStub - fakeReturns := fake.createRemoteSubnetReturns - fake.recordInvocation("CreateRemoteSubnet", []interface{}{arg1, arg2, arg3}) - fake.createRemoteSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) CreateRemoteSubnetCallCount() int { - fake.createRemoteSubnetMutex.RLock() - defer fake.createRemoteSubnetMutex.RUnlock() - return len(fake.createRemoteSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) CreateRemoteSubnetCalls(stub func(int, string, int) (datatypes.Network_Customer_Subnet, error)) { - fake.createRemoteSubnetMutex.Lock() - defer fake.createRemoteSubnetMutex.Unlock() - fake.CreateRemoteSubnetStub = stub -} - -func (fake *FakeIPSECManager) CreateRemoteSubnetArgsForCall(i int) (int, string, int) { - fake.createRemoteSubnetMutex.RLock() - defer fake.createRemoteSubnetMutex.RUnlock() - argsForCall := fake.createRemoteSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeIPSECManager) CreateRemoteSubnetReturns(result1 datatypes.Network_Customer_Subnet, result2 error) { - fake.createRemoteSubnetMutex.Lock() - defer fake.createRemoteSubnetMutex.Unlock() - fake.CreateRemoteSubnetStub = nil - fake.createRemoteSubnetReturns = struct { - result1 datatypes.Network_Customer_Subnet - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) CreateRemoteSubnetReturnsOnCall(i int, result1 datatypes.Network_Customer_Subnet, result2 error) { - fake.createRemoteSubnetMutex.Lock() - defer fake.createRemoteSubnetMutex.Unlock() - fake.CreateRemoteSubnetStub = nil - if fake.createRemoteSubnetReturnsOnCall == nil { - fake.createRemoteSubnetReturnsOnCall = make(map[int]struct { - result1 datatypes.Network_Customer_Subnet - result2 error - }) - } - fake.createRemoteSubnetReturnsOnCall[i] = struct { - result1 datatypes.Network_Customer_Subnet - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) CreateTranslation(arg1 int, arg2 string, arg3 string, arg4 string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - fake.createTranslationMutex.Lock() - ret, specificReturn := fake.createTranslationReturnsOnCall[len(fake.createTranslationArgsForCall)] - fake.createTranslationArgsForCall = append(fake.createTranslationArgsForCall, struct { - arg1 int - arg2 string - arg3 string - arg4 string - }{arg1, arg2, arg3, arg4}) - stub := fake.CreateTranslationStub - fakeReturns := fake.createTranslationReturns - fake.recordInvocation("CreateTranslation", []interface{}{arg1, arg2, arg3, arg4}) - fake.createTranslationMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3, arg4) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) CreateTranslationCallCount() int { - fake.createTranslationMutex.RLock() - defer fake.createTranslationMutex.RUnlock() - return len(fake.createTranslationArgsForCall) -} - -func (fake *FakeIPSECManager) CreateTranslationCalls(stub func(int, string, string, string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error)) { - fake.createTranslationMutex.Lock() - defer fake.createTranslationMutex.Unlock() - fake.CreateTranslationStub = stub -} - -func (fake *FakeIPSECManager) CreateTranslationArgsForCall(i int) (int, string, string, string) { - fake.createTranslationMutex.RLock() - defer fake.createTranslationMutex.RUnlock() - argsForCall := fake.createTranslationArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 -} - -func (fake *FakeIPSECManager) CreateTranslationReturns(result1 datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.createTranslationMutex.Lock() - defer fake.createTranslationMutex.Unlock() - fake.CreateTranslationStub = nil - fake.createTranslationReturns = struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) CreateTranslationReturnsOnCall(i int, result1 datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.createTranslationMutex.Lock() - defer fake.createTranslationMutex.Unlock() - fake.CreateTranslationStub = nil - if fake.createTranslationReturnsOnCall == nil { - fake.createTranslationReturnsOnCall = make(map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }) - } - fake.createTranslationReturnsOnCall[i] = struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) DeleteRemoteSubnet(arg1 int, arg2 int) error { - fake.deleteRemoteSubnetMutex.Lock() - ret, specificReturn := fake.deleteRemoteSubnetReturnsOnCall[len(fake.deleteRemoteSubnetArgsForCall)] - fake.deleteRemoteSubnetArgsForCall = append(fake.deleteRemoteSubnetArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.DeleteRemoteSubnetStub - fakeReturns := fake.deleteRemoteSubnetReturns - fake.recordInvocation("DeleteRemoteSubnet", []interface{}{arg1, arg2}) - fake.deleteRemoteSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) DeleteRemoteSubnetCallCount() int { - fake.deleteRemoteSubnetMutex.RLock() - defer fake.deleteRemoteSubnetMutex.RUnlock() - return len(fake.deleteRemoteSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) DeleteRemoteSubnetCalls(stub func(int, int) error) { - fake.deleteRemoteSubnetMutex.Lock() - defer fake.deleteRemoteSubnetMutex.Unlock() - fake.DeleteRemoteSubnetStub = stub -} - -func (fake *FakeIPSECManager) DeleteRemoteSubnetArgsForCall(i int) (int, int) { - fake.deleteRemoteSubnetMutex.RLock() - defer fake.deleteRemoteSubnetMutex.RUnlock() - argsForCall := fake.deleteRemoteSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) DeleteRemoteSubnetReturns(result1 error) { - fake.deleteRemoteSubnetMutex.Lock() - defer fake.deleteRemoteSubnetMutex.Unlock() - fake.DeleteRemoteSubnetStub = nil - fake.deleteRemoteSubnetReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) DeleteRemoteSubnetReturnsOnCall(i int, result1 error) { - fake.deleteRemoteSubnetMutex.Lock() - defer fake.deleteRemoteSubnetMutex.Unlock() - fake.DeleteRemoteSubnetStub = nil - if fake.deleteRemoteSubnetReturnsOnCall == nil { - fake.deleteRemoteSubnetReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.deleteRemoteSubnetReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) GetTranslation(arg1 int, arg2 int) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - fake.getTranslationMutex.Lock() - ret, specificReturn := fake.getTranslationReturnsOnCall[len(fake.getTranslationArgsForCall)] - fake.getTranslationArgsForCall = append(fake.getTranslationArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.GetTranslationStub - fakeReturns := fake.getTranslationReturns - fake.recordInvocation("GetTranslation", []interface{}{arg1, arg2}) - fake.getTranslationMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) GetTranslationCallCount() int { - fake.getTranslationMutex.RLock() - defer fake.getTranslationMutex.RUnlock() - return len(fake.getTranslationArgsForCall) -} - -func (fake *FakeIPSECManager) GetTranslationCalls(stub func(int, int) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error)) { - fake.getTranslationMutex.Lock() - defer fake.getTranslationMutex.Unlock() - fake.GetTranslationStub = stub -} - -func (fake *FakeIPSECManager) GetTranslationArgsForCall(i int) (int, int) { - fake.getTranslationMutex.RLock() - defer fake.getTranslationMutex.RUnlock() - argsForCall := fake.getTranslationArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) GetTranslationReturns(result1 datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.getTranslationMutex.Lock() - defer fake.getTranslationMutex.Unlock() - fake.GetTranslationStub = nil - fake.getTranslationReturns = struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) GetTranslationReturnsOnCall(i int, result1 datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.getTranslationMutex.Lock() - defer fake.getTranslationMutex.Unlock() - fake.GetTranslationStub = nil - if fake.getTranslationReturnsOnCall == nil { - fake.getTranslationReturnsOnCall = make(map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }) - } - fake.getTranslationReturnsOnCall[i] = struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) GetTranslations(arg1 int) ([]datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - fake.getTranslationsMutex.Lock() - ret, specificReturn := fake.getTranslationsReturnsOnCall[len(fake.getTranslationsArgsForCall)] - fake.getTranslationsArgsForCall = append(fake.getTranslationsArgsForCall, struct { - arg1 int - }{arg1}) - stub := fake.GetTranslationsStub - fakeReturns := fake.getTranslationsReturns - fake.recordInvocation("GetTranslations", []interface{}{arg1}) - fake.getTranslationsMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) GetTranslationsCallCount() int { - fake.getTranslationsMutex.RLock() - defer fake.getTranslationsMutex.RUnlock() - return len(fake.getTranslationsArgsForCall) -} - -func (fake *FakeIPSECManager) GetTranslationsCalls(stub func(int) ([]datatypes.Network_Tunnel_Module_Context_Address_Translation, error)) { - fake.getTranslationsMutex.Lock() - defer fake.getTranslationsMutex.Unlock() - fake.GetTranslationsStub = stub -} - -func (fake *FakeIPSECManager) GetTranslationsArgsForCall(i int) int { - fake.getTranslationsMutex.RLock() - defer fake.getTranslationsMutex.RUnlock() - argsForCall := fake.getTranslationsArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeIPSECManager) GetTranslationsReturns(result1 []datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.getTranslationsMutex.Lock() - defer fake.getTranslationsMutex.Unlock() - fake.GetTranslationsStub = nil - fake.getTranslationsReturns = struct { - result1 []datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) GetTranslationsReturnsOnCall(i int, result1 []datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.getTranslationsMutex.Lock() - defer fake.getTranslationsMutex.Unlock() - fake.GetTranslationsStub = nil - if fake.getTranslationsReturnsOnCall == nil { - fake.getTranslationsReturnsOnCall = make(map[int]struct { - result1 []datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }) - } - fake.getTranslationsReturnsOnCall[i] = struct { - result1 []datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) GetTunnelContext(arg1 int, arg2 string) (datatypes.Network_Tunnel_Module_Context, error) { - fake.getTunnelContextMutex.Lock() - ret, specificReturn := fake.getTunnelContextReturnsOnCall[len(fake.getTunnelContextArgsForCall)] - fake.getTunnelContextArgsForCall = append(fake.getTunnelContextArgsForCall, struct { - arg1 int - arg2 string - }{arg1, arg2}) - stub := fake.GetTunnelContextStub - fakeReturns := fake.getTunnelContextReturns - fake.recordInvocation("GetTunnelContext", []interface{}{arg1, arg2}) - fake.getTunnelContextMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) GetTunnelContextCallCount() int { - fake.getTunnelContextMutex.RLock() - defer fake.getTunnelContextMutex.RUnlock() - return len(fake.getTunnelContextArgsForCall) -} - -func (fake *FakeIPSECManager) GetTunnelContextCalls(stub func(int, string) (datatypes.Network_Tunnel_Module_Context, error)) { - fake.getTunnelContextMutex.Lock() - defer fake.getTunnelContextMutex.Unlock() - fake.GetTunnelContextStub = stub -} - -func (fake *FakeIPSECManager) GetTunnelContextArgsForCall(i int) (int, string) { - fake.getTunnelContextMutex.RLock() - defer fake.getTunnelContextMutex.RUnlock() - argsForCall := fake.getTunnelContextArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) GetTunnelContextReturns(result1 datatypes.Network_Tunnel_Module_Context, result2 error) { - fake.getTunnelContextMutex.Lock() - defer fake.getTunnelContextMutex.Unlock() - fake.GetTunnelContextStub = nil - fake.getTunnelContextReturns = struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) GetTunnelContextReturnsOnCall(i int, result1 datatypes.Network_Tunnel_Module_Context, result2 error) { - fake.getTunnelContextMutex.Lock() - defer fake.getTunnelContextMutex.Unlock() - fake.GetTunnelContextStub = nil - if fake.getTunnelContextReturnsOnCall == nil { - fake.getTunnelContextReturnsOnCall = make(map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - }) - } - fake.getTunnelContextReturnsOnCall[i] = struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) GetTunnelContexts(arg1 int, arg2 string) ([]datatypes.Network_Tunnel_Module_Context, error) { - fake.getTunnelContextsMutex.Lock() - ret, specificReturn := fake.getTunnelContextsReturnsOnCall[len(fake.getTunnelContextsArgsForCall)] - fake.getTunnelContextsArgsForCall = append(fake.getTunnelContextsArgsForCall, struct { - arg1 int - arg2 string - }{arg1, arg2}) - stub := fake.GetTunnelContextsStub - fakeReturns := fake.getTunnelContextsReturns - fake.recordInvocation("GetTunnelContexts", []interface{}{arg1, arg2}) - fake.getTunnelContextsMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) GetTunnelContextsCallCount() int { - fake.getTunnelContextsMutex.RLock() - defer fake.getTunnelContextsMutex.RUnlock() - return len(fake.getTunnelContextsArgsForCall) -} - -func (fake *FakeIPSECManager) GetTunnelContextsCalls(stub func(int, string) ([]datatypes.Network_Tunnel_Module_Context, error)) { - fake.getTunnelContextsMutex.Lock() - defer fake.getTunnelContextsMutex.Unlock() - fake.GetTunnelContextsStub = stub -} - -func (fake *FakeIPSECManager) GetTunnelContextsArgsForCall(i int) (int, string) { - fake.getTunnelContextsMutex.RLock() - defer fake.getTunnelContextsMutex.RUnlock() - argsForCall := fake.getTunnelContextsArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) GetTunnelContextsReturns(result1 []datatypes.Network_Tunnel_Module_Context, result2 error) { - fake.getTunnelContextsMutex.Lock() - defer fake.getTunnelContextsMutex.Unlock() - fake.GetTunnelContextsStub = nil - fake.getTunnelContextsReturns = struct { - result1 []datatypes.Network_Tunnel_Module_Context - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) GetTunnelContextsReturnsOnCall(i int, result1 []datatypes.Network_Tunnel_Module_Context, result2 error) { - fake.getTunnelContextsMutex.Lock() - defer fake.getTunnelContextsMutex.Unlock() - fake.GetTunnelContextsStub = nil - if fake.getTunnelContextsReturnsOnCall == nil { - fake.getTunnelContextsReturnsOnCall = make(map[int]struct { - result1 []datatypes.Network_Tunnel_Module_Context - result2 error - }) - } - fake.getTunnelContextsReturnsOnCall[i] = struct { - result1 []datatypes.Network_Tunnel_Module_Context - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) OrderTunnelContext(arg1 string) (datatypes.Container_Product_Order_Receipt, error) { - fake.orderTunnelContextMutex.Lock() - ret, specificReturn := fake.orderTunnelContextReturnsOnCall[len(fake.orderTunnelContextArgsForCall)] - fake.orderTunnelContextArgsForCall = append(fake.orderTunnelContextArgsForCall, struct { - arg1 string - }{arg1}) - stub := fake.OrderTunnelContextStub - fakeReturns := fake.orderTunnelContextReturns - fake.recordInvocation("OrderTunnelContext", []interface{}{arg1}) - fake.orderTunnelContextMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) OrderTunnelContextCallCount() int { - fake.orderTunnelContextMutex.RLock() - defer fake.orderTunnelContextMutex.RUnlock() - return len(fake.orderTunnelContextArgsForCall) -} - -func (fake *FakeIPSECManager) OrderTunnelContextCalls(stub func(string) (datatypes.Container_Product_Order_Receipt, error)) { - fake.orderTunnelContextMutex.Lock() - defer fake.orderTunnelContextMutex.Unlock() - fake.OrderTunnelContextStub = stub -} - -func (fake *FakeIPSECManager) OrderTunnelContextArgsForCall(i int) string { - fake.orderTunnelContextMutex.RLock() - defer fake.orderTunnelContextMutex.RUnlock() - argsForCall := fake.orderTunnelContextArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeIPSECManager) OrderTunnelContextReturns(result1 datatypes.Container_Product_Order_Receipt, result2 error) { - fake.orderTunnelContextMutex.Lock() - defer fake.orderTunnelContextMutex.Unlock() - fake.OrderTunnelContextStub = nil - fake.orderTunnelContextReturns = struct { - result1 datatypes.Container_Product_Order_Receipt - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) OrderTunnelContextReturnsOnCall(i int, result1 datatypes.Container_Product_Order_Receipt, result2 error) { - fake.orderTunnelContextMutex.Lock() - defer fake.orderTunnelContextMutex.Unlock() - fake.OrderTunnelContextStub = nil - if fake.orderTunnelContextReturnsOnCall == nil { - fake.orderTunnelContextReturnsOnCall = make(map[int]struct { - result1 datatypes.Container_Product_Order_Receipt - result2 error - }) - } - fake.orderTunnelContextReturnsOnCall[i] = struct { - result1 datatypes.Container_Product_Order_Receipt - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) RemoveInternalSubnet(arg1 int, arg2 int) error { - fake.removeInternalSubnetMutex.Lock() - ret, specificReturn := fake.removeInternalSubnetReturnsOnCall[len(fake.removeInternalSubnetArgsForCall)] - fake.removeInternalSubnetArgsForCall = append(fake.removeInternalSubnetArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.RemoveInternalSubnetStub - fakeReturns := fake.removeInternalSubnetReturns - fake.recordInvocation("RemoveInternalSubnet", []interface{}{arg1, arg2}) - fake.removeInternalSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) RemoveInternalSubnetCallCount() int { - fake.removeInternalSubnetMutex.RLock() - defer fake.removeInternalSubnetMutex.RUnlock() - return len(fake.removeInternalSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) RemoveInternalSubnetCalls(stub func(int, int) error) { - fake.removeInternalSubnetMutex.Lock() - defer fake.removeInternalSubnetMutex.Unlock() - fake.RemoveInternalSubnetStub = stub -} - -func (fake *FakeIPSECManager) RemoveInternalSubnetArgsForCall(i int) (int, int) { - fake.removeInternalSubnetMutex.RLock() - defer fake.removeInternalSubnetMutex.RUnlock() - argsForCall := fake.removeInternalSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) RemoveInternalSubnetReturns(result1 error) { - fake.removeInternalSubnetMutex.Lock() - defer fake.removeInternalSubnetMutex.Unlock() - fake.RemoveInternalSubnetStub = nil - fake.removeInternalSubnetReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) RemoveInternalSubnetReturnsOnCall(i int, result1 error) { - fake.removeInternalSubnetMutex.Lock() - defer fake.removeInternalSubnetMutex.Unlock() - fake.RemoveInternalSubnetStub = nil - if fake.removeInternalSubnetReturnsOnCall == nil { - fake.removeInternalSubnetReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.removeInternalSubnetReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) RemoveRemoteSubnet(arg1 int, arg2 int) error { - fake.removeRemoteSubnetMutex.Lock() - ret, specificReturn := fake.removeRemoteSubnetReturnsOnCall[len(fake.removeRemoteSubnetArgsForCall)] - fake.removeRemoteSubnetArgsForCall = append(fake.removeRemoteSubnetArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.RemoveRemoteSubnetStub - fakeReturns := fake.removeRemoteSubnetReturns - fake.recordInvocation("RemoveRemoteSubnet", []interface{}{arg1, arg2}) - fake.removeRemoteSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) RemoveRemoteSubnetCallCount() int { - fake.removeRemoteSubnetMutex.RLock() - defer fake.removeRemoteSubnetMutex.RUnlock() - return len(fake.removeRemoteSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) RemoveRemoteSubnetCalls(stub func(int, int) error) { - fake.removeRemoteSubnetMutex.Lock() - defer fake.removeRemoteSubnetMutex.Unlock() - fake.RemoveRemoteSubnetStub = stub -} - -func (fake *FakeIPSECManager) RemoveRemoteSubnetArgsForCall(i int) (int, int) { - fake.removeRemoteSubnetMutex.RLock() - defer fake.removeRemoteSubnetMutex.RUnlock() - argsForCall := fake.removeRemoteSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) RemoveRemoteSubnetReturns(result1 error) { - fake.removeRemoteSubnetMutex.Lock() - defer fake.removeRemoteSubnetMutex.Unlock() - fake.RemoveRemoteSubnetStub = nil - fake.removeRemoteSubnetReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) RemoveRemoteSubnetReturnsOnCall(i int, result1 error) { - fake.removeRemoteSubnetMutex.Lock() - defer fake.removeRemoteSubnetMutex.Unlock() - fake.RemoveRemoteSubnetStub = nil - if fake.removeRemoteSubnetReturnsOnCall == nil { - fake.removeRemoteSubnetReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.removeRemoteSubnetReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) RemoveServiceSubnet(arg1 int, arg2 int) error { - fake.removeServiceSubnetMutex.Lock() - ret, specificReturn := fake.removeServiceSubnetReturnsOnCall[len(fake.removeServiceSubnetArgsForCall)] - fake.removeServiceSubnetArgsForCall = append(fake.removeServiceSubnetArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.RemoveServiceSubnetStub - fakeReturns := fake.removeServiceSubnetReturns - fake.recordInvocation("RemoveServiceSubnet", []interface{}{arg1, arg2}) - fake.removeServiceSubnetMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) RemoveServiceSubnetCallCount() int { - fake.removeServiceSubnetMutex.RLock() - defer fake.removeServiceSubnetMutex.RUnlock() - return len(fake.removeServiceSubnetArgsForCall) -} - -func (fake *FakeIPSECManager) RemoveServiceSubnetCalls(stub func(int, int) error) { - fake.removeServiceSubnetMutex.Lock() - defer fake.removeServiceSubnetMutex.Unlock() - fake.RemoveServiceSubnetStub = stub -} - -func (fake *FakeIPSECManager) RemoveServiceSubnetArgsForCall(i int) (int, int) { - fake.removeServiceSubnetMutex.RLock() - defer fake.removeServiceSubnetMutex.RUnlock() - argsForCall := fake.removeServiceSubnetArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) RemoveServiceSubnetReturns(result1 error) { - fake.removeServiceSubnetMutex.Lock() - defer fake.removeServiceSubnetMutex.Unlock() - fake.RemoveServiceSubnetStub = nil - fake.removeServiceSubnetReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) RemoveServiceSubnetReturnsOnCall(i int, result1 error) { - fake.removeServiceSubnetMutex.Lock() - defer fake.removeServiceSubnetMutex.Unlock() - fake.RemoveServiceSubnetStub = nil - if fake.removeServiceSubnetReturnsOnCall == nil { - fake.removeServiceSubnetReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.removeServiceSubnetReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) RemoveTranslation(arg1 int, arg2 int) error { - fake.removeTranslationMutex.Lock() - ret, specificReturn := fake.removeTranslationReturnsOnCall[len(fake.removeTranslationArgsForCall)] - fake.removeTranslationArgsForCall = append(fake.removeTranslationArgsForCall, struct { - arg1 int - arg2 int - }{arg1, arg2}) - stub := fake.RemoveTranslationStub - fakeReturns := fake.removeTranslationReturns - fake.recordInvocation("RemoveTranslation", []interface{}{arg1, arg2}) - fake.removeTranslationMutex.Unlock() - if stub != nil { - return stub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeIPSECManager) RemoveTranslationCallCount() int { - fake.removeTranslationMutex.RLock() - defer fake.removeTranslationMutex.RUnlock() - return len(fake.removeTranslationArgsForCall) -} - -func (fake *FakeIPSECManager) RemoveTranslationCalls(stub func(int, int) error) { - fake.removeTranslationMutex.Lock() - defer fake.removeTranslationMutex.Unlock() - fake.RemoveTranslationStub = stub -} - -func (fake *FakeIPSECManager) RemoveTranslationArgsForCall(i int) (int, int) { - fake.removeTranslationMutex.RLock() - defer fake.removeTranslationMutex.RUnlock() - argsForCall := fake.removeTranslationArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeIPSECManager) RemoveTranslationReturns(result1 error) { - fake.removeTranslationMutex.Lock() - defer fake.removeTranslationMutex.Unlock() - fake.RemoveTranslationStub = nil - fake.removeTranslationReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) RemoveTranslationReturnsOnCall(i int, result1 error) { - fake.removeTranslationMutex.Lock() - defer fake.removeTranslationMutex.Unlock() - fake.RemoveTranslationStub = nil - if fake.removeTranslationReturnsOnCall == nil { - fake.removeTranslationReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.removeTranslationReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeIPSECManager) UpdateTranslation(arg1 int, arg2 int, arg3 string, arg4 string, arg5 string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error) { - fake.updateTranslationMutex.Lock() - ret, specificReturn := fake.updateTranslationReturnsOnCall[len(fake.updateTranslationArgsForCall)] - fake.updateTranslationArgsForCall = append(fake.updateTranslationArgsForCall, struct { - arg1 int - arg2 int - arg3 string - arg4 string - arg5 string - }{arg1, arg2, arg3, arg4, arg5}) - stub := fake.UpdateTranslationStub - fakeReturns := fake.updateTranslationReturns - fake.recordInvocation("UpdateTranslation", []interface{}{arg1, arg2, arg3, arg4, arg5}) - fake.updateTranslationMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3, arg4, arg5) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) UpdateTranslationCallCount() int { - fake.updateTranslationMutex.RLock() - defer fake.updateTranslationMutex.RUnlock() - return len(fake.updateTranslationArgsForCall) -} - -func (fake *FakeIPSECManager) UpdateTranslationCalls(stub func(int, int, string, string, string) (datatypes.Network_Tunnel_Module_Context_Address_Translation, error)) { - fake.updateTranslationMutex.Lock() - defer fake.updateTranslationMutex.Unlock() - fake.UpdateTranslationStub = stub -} - -func (fake *FakeIPSECManager) UpdateTranslationArgsForCall(i int) (int, int, string, string, string) { - fake.updateTranslationMutex.RLock() - defer fake.updateTranslationMutex.RUnlock() - argsForCall := fake.updateTranslationArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 -} - -func (fake *FakeIPSECManager) UpdateTranslationReturns(result1 datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.updateTranslationMutex.Lock() - defer fake.updateTranslationMutex.Unlock() - fake.UpdateTranslationStub = nil - fake.updateTranslationReturns = struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) UpdateTranslationReturnsOnCall(i int, result1 datatypes.Network_Tunnel_Module_Context_Address_Translation, result2 error) { - fake.updateTranslationMutex.Lock() - defer fake.updateTranslationMutex.Unlock() - fake.UpdateTranslationStub = nil - if fake.updateTranslationReturnsOnCall == nil { - fake.updateTranslationReturnsOnCall = make(map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }) - } - fake.updateTranslationReturnsOnCall[i] = struct { - result1 datatypes.Network_Tunnel_Module_Context_Address_Translation - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) UpdateTunnelContext(arg1 int, arg2 string, arg3 string, arg4 string, arg5 string, arg6 string, arg7 int, arg8 int, arg9 string, arg10 string, arg11 int, arg12 int, arg13 int) (datatypes.Network_Tunnel_Module_Context, error) { - fake.updateTunnelContextMutex.Lock() - ret, specificReturn := fake.updateTunnelContextReturnsOnCall[len(fake.updateTunnelContextArgsForCall)] - fake.updateTunnelContextArgsForCall = append(fake.updateTunnelContextArgsForCall, struct { - arg1 int - arg2 string - arg3 string - arg4 string - arg5 string - arg6 string - arg7 int - arg8 int - arg9 string - arg10 string - arg11 int - arg12 int - arg13 int - }{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13}) - stub := fake.UpdateTunnelContextStub - fakeReturns := fake.updateTunnelContextReturns - fake.recordInvocation("UpdateTunnelContext", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13}) - fake.updateTunnelContextMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeIPSECManager) UpdateTunnelContextCallCount() int { - fake.updateTunnelContextMutex.RLock() - defer fake.updateTunnelContextMutex.RUnlock() - return len(fake.updateTunnelContextArgsForCall) -} - -func (fake *FakeIPSECManager) UpdateTunnelContextCalls(stub func(int, string, string, string, string, string, int, int, string, string, int, int, int) (datatypes.Network_Tunnel_Module_Context, error)) { - fake.updateTunnelContextMutex.Lock() - defer fake.updateTunnelContextMutex.Unlock() - fake.UpdateTunnelContextStub = stub -} - -func (fake *FakeIPSECManager) UpdateTunnelContextArgsForCall(i int) (int, string, string, string, string, string, int, int, string, string, int, int, int) { - fake.updateTunnelContextMutex.RLock() - defer fake.updateTunnelContextMutex.RUnlock() - argsForCall := fake.updateTunnelContextArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7, argsForCall.arg8, argsForCall.arg9, argsForCall.arg10, argsForCall.arg11, argsForCall.arg12, argsForCall.arg13 -} - -func (fake *FakeIPSECManager) UpdateTunnelContextReturns(result1 datatypes.Network_Tunnel_Module_Context, result2 error) { - fake.updateTunnelContextMutex.Lock() - defer fake.updateTunnelContextMutex.Unlock() - fake.UpdateTunnelContextStub = nil - fake.updateTunnelContextReturns = struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) UpdateTunnelContextReturnsOnCall(i int, result1 datatypes.Network_Tunnel_Module_Context, result2 error) { - fake.updateTunnelContextMutex.Lock() - defer fake.updateTunnelContextMutex.Unlock() - fake.UpdateTunnelContextStub = nil - if fake.updateTunnelContextReturnsOnCall == nil { - fake.updateTunnelContextReturnsOnCall = make(map[int]struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - }) - } - fake.updateTunnelContextReturnsOnCall[i] = struct { - result1 datatypes.Network_Tunnel_Module_Context - result2 error - }{result1, result2} -} - -func (fake *FakeIPSECManager) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.addInternalSubnetMutex.RLock() - defer fake.addInternalSubnetMutex.RUnlock() - fake.addRemoteSubnetMutex.RLock() - defer fake.addRemoteSubnetMutex.RUnlock() - fake.addServiceSubnetMutex.RLock() - defer fake.addServiceSubnetMutex.RUnlock() - fake.applyConfigurationMutex.RLock() - defer fake.applyConfigurationMutex.RUnlock() - fake.cancelTunnelContextMutex.RLock() - defer fake.cancelTunnelContextMutex.RUnlock() - fake.createRemoteSubnetMutex.RLock() - defer fake.createRemoteSubnetMutex.RUnlock() - fake.createTranslationMutex.RLock() - defer fake.createTranslationMutex.RUnlock() - fake.deleteRemoteSubnetMutex.RLock() - defer fake.deleteRemoteSubnetMutex.RUnlock() - fake.getTranslationMutex.RLock() - defer fake.getTranslationMutex.RUnlock() - fake.getTranslationsMutex.RLock() - defer fake.getTranslationsMutex.RUnlock() - fake.getTunnelContextMutex.RLock() - defer fake.getTunnelContextMutex.RUnlock() - fake.getTunnelContextsMutex.RLock() - defer fake.getTunnelContextsMutex.RUnlock() - fake.orderTunnelContextMutex.RLock() - defer fake.orderTunnelContextMutex.RUnlock() - fake.removeInternalSubnetMutex.RLock() - defer fake.removeInternalSubnetMutex.RUnlock() - fake.removeRemoteSubnetMutex.RLock() - defer fake.removeRemoteSubnetMutex.RUnlock() - fake.removeServiceSubnetMutex.RLock() - defer fake.removeServiceSubnetMutex.RUnlock() - fake.removeTranslationMutex.RLock() - defer fake.removeTranslationMutex.RUnlock() - fake.updateTranslationMutex.RLock() - defer fake.updateTranslationMutex.RUnlock() - fake.updateTunnelContextMutex.RLock() - defer fake.updateTunnelContextMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakeIPSECManager) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ managers.IPSECManager = new(FakeIPSECManager)