From 9833767fb245215d22d2787da9f87e3db57dd34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Fri, 2 Nov 2018 16:56:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=85=BE=E8=AE=AF?= =?UTF-8?q?=E4=BA=91=E8=B5=84=E6=BA=90=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gopkg.toml | 8 + cmd/climc/shell/cloudaccounts.go | 5 + cmd/qcloudcli/main.go | 127 +++ pkg/compute/guestdrivers/qcloud.go | 343 ++++++++ pkg/compute/models/cloudproviders.go | 1 + pkg/compute/models/guests.go | 5 +- pkg/compute/models/hosts.go | 3 +- pkg/compute/models/snapshots.go | 11 +- pkg/compute/service/service.go | 1 + pkg/util/aliyun/host.go | 1 + pkg/util/qcloud/disk.go | 365 +++++++++ pkg/util/qcloud/eip.go | 295 +++++++ pkg/util/qcloud/host.go | 268 +++++++ pkg/util/qcloud/image.go | 186 +++++ pkg/util/qcloud/instance.go | 730 ++++++++++++++++++ pkg/util/qcloud/instancenic.go | 40 + pkg/util/qcloud/instancetype.go | 42 + pkg/util/qcloud/keypair.go | 143 ++++ pkg/util/qcloud/latitud_and_longitude.go | 23 + pkg/util/qcloud/localdisk.go | 128 +++ pkg/util/qcloud/localstorage.go | 98 +++ pkg/util/qcloud/network.go | 132 ++++ pkg/util/qcloud/provider/doc.go | 1 + pkg/util/qcloud/provider/provider.go | 84 ++ pkg/util/qcloud/qcloud.go | 258 +++++++ pkg/util/qcloud/region.go | 528 +++++++++++++ pkg/util/qcloud/securitygroup.go | 415 ++++++++++ pkg/util/qcloud/shell/cos.go | 106 +++ pkg/util/qcloud/shell/disk.go | 77 ++ pkg/util/qcloud/shell/eip.go | 71 ++ pkg/util/qcloud/shell/image.go | 55 ++ pkg/util/qcloud/shell/instance.go | 176 +++++ pkg/util/qcloud/shell/keypair.go | 45 ++ pkg/util/qcloud/shell/network.go | 54 ++ pkg/util/qcloud/shell/printutils.go | 11 + pkg/util/qcloud/shell/region.go | 16 + pkg/util/qcloud/shell/securitygroup.go | 66 ++ pkg/util/qcloud/shell/snapshot.go | 45 ++ pkg/util/qcloud/shell/vpc.go | 41 + pkg/util/qcloud/shell/zone.go | 21 + pkg/util/qcloud/snapshot.go | 218 ++++++ pkg/util/qcloud/storage.go | 126 +++ pkg/util/qcloud/storagecache.go | 189 +++++ pkg/util/qcloud/vpc.go | 193 +++++ pkg/util/qcloud/wire.go | 142 ++++ pkg/util/qcloud/zone.go | 202 +++++ .../sdk/endpoints/location_resolver.go | 2 +- .../go-windows-terminal-sequences/go.mod | 1 + vendor/github.com/miekg/dns/.travis.yml | 7 +- vendor/github.com/miekg/dns/Gopkg.lock | 46 +- vendor/github.com/miekg/dns/Gopkg.toml | 12 + vendor/github.com/miekg/dns/client.go | 2 +- vendor/github.com/miekg/dns/generate.go | 4 +- vendor/github.com/miekg/dns/listen_go111.go | 3 +- .../github.com/miekg/dns/listen_go_not111.go | 2 +- vendor/github.com/miekg/dns/msg.go | 51 +- vendor/github.com/miekg/dns/msg_helpers.go | 30 +- vendor/github.com/miekg/dns/privaterr.go | 3 +- vendor/github.com/miekg/dns/scan.go | 7 +- vendor/github.com/miekg/dns/scanner.go | 2 +- vendor/github.com/miekg/dns/serve_mux.go | 147 ++++ vendor/github.com/miekg/dns/server.go | 201 ++--- vendor/github.com/miekg/dns/sig0.go | 3 +- vendor/github.com/miekg/dns/types.go | 150 ++-- vendor/github.com/miekg/dns/udp.go | 2 + vendor/github.com/miekg/dns/udp_windows.go | 37 + vendor/github.com/miekg/dns/version.go | 2 +- vendor/github.com/pierrec/lz4/block.go | 2 +- .../github.com/prometheus/procfs/.travis.yml | 12 - .../prometheus/procfs/internal/util/parse.go | 15 +- .../procfs/internal/util/sysreadfile_linux.go | 45 ++ .../github.com/sirupsen/logrus/CHANGELOG.md | 5 + vendor/github.com/sirupsen/logrus/entry.go | 16 +- .../github.com/sirupsen/logrus/formatter.go | 15 +- .../sirupsen/logrus/json_formatter.go | 10 +- .../sirupsen/logrus/terminal_appengine.go | 13 - .../sirupsen/logrus/terminal_bsd.go | 17 - .../sirupsen/logrus/terminal_linux.go | 21 - .../sirupsen/logrus/terminal_notwindows.go | 8 + .../sirupsen/logrus/text_formatter.go | 7 +- vendor/github.com/spf13/pflag/flag.go | 7 +- .../github.com/spf13/pflag/string_to_int.go | 149 ++++ .../spf13/pflag/string_to_string.go | 160 ++++ vendor/github.com/vmware/govmomi/.mailmap | 3 + vendor/github.com/vmware/govmomi/CHANGELOG.md | 8 +- vendor/github.com/vmware/govmomi/CONTRIBUTORS | 13 + vendor/github.com/vmware/govmomi/README.md | 2 + .../vmware/govmomi/session/keep_alive.go | 3 +- vendor/golang.org/x/crypto/ssh/server.go | 2 +- vendor/golang.org/x/net/bpf/constants.go | 24 +- vendor/golang.org/x/net/bpf/instructions.go | 194 ++--- vendor/golang.org/x/net/bpf/vm.go | 10 + .../golang.org/x/net/bpf/vm_instructions.go | 35 +- vendor/golang.org/x/sys/unix/mkerrors.sh | 2 + .../x/sys/unix/mksyscall_solaris.pl | 5 + .../golang.org/x/sys/unix/mksysctl_openbsd.pl | 1 + vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 2 +- vendor/golang.org/x/sys/unix/syscall_linux.go | 26 +- .../x/sys/unix/syscall_linux_amd64.go | 13 + .../x/sys/unix/syscall_linux_ppc64x.go | 13 + .../x/sys/unix/syscall_linux_s390x.go | 13 + .../golang.org/x/sys/unix/syscall_netbsd.go | 6 +- .../golang.org/x/sys/unix/syscall_openbsd.go | 17 + vendor/golang.org/x/sys/unix/syscall_unix.go | 8 +- vendor/golang.org/x/sys/unix/types_aix.go | 12 +- vendor/golang.org/x/sys/unix/types_darwin.go | 12 +- .../golang.org/x/sys/unix/types_dragonfly.go | 12 +- vendor/golang.org/x/sys/unix/types_freebsd.go | 12 +- vendor/golang.org/x/sys/unix/types_netbsd.go | 12 +- vendor/golang.org/x/sys/unix/types_openbsd.go | 19 +- vendor/golang.org/x/sys/unix/types_solaris.go | 12 +- .../x/sys/unix/zerrors_linux_386.go | 20 + .../x/sys/unix/zerrors_linux_amd64.go | 20 + .../x/sys/unix/zerrors_linux_arm.go | 20 + .../x/sys/unix/zerrors_linux_arm64.go | 20 + .../x/sys/unix/zerrors_linux_mips.go | 20 + .../x/sys/unix/zerrors_linux_mips64.go | 20 + .../x/sys/unix/zerrors_linux_mips64le.go | 20 + .../x/sys/unix/zerrors_linux_mipsle.go | 20 + .../x/sys/unix/zerrors_linux_ppc64.go | 20 + .../x/sys/unix/zerrors_linux_ppc64le.go | 20 + .../x/sys/unix/zerrors_linux_riscv64.go | 20 + .../x/sys/unix/zerrors_linux_s390x.go | 20 + .../x/sys/unix/zerrors_linux_sparc64.go | 350 +++++---- .../x/sys/unix/zerrors_openbsd_amd64.go | 4 + .../x/sys/unix/zsyscall_linux_amd64.go | 15 + .../x/sys/unix/zsyscall_linux_ppc64.go | 15 + .../x/sys/unix/zsyscall_linux_ppc64le.go | 15 + .../x/sys/unix/zsyscall_linux_s390x.go | 15 + .../x/sys/unix/zsyscall_solaris_amd64.go | 256 ++++++ .../x/sys/unix/zsysctl_openbsd_amd64.go | 13 + .../golang.org/x/sys/unix/ztypes_aix_ppc.go | 10 +- .../golang.org/x/sys/unix/ztypes_aix_ppc64.go | 10 +- .../x/sys/unix/ztypes_darwin_386.go | 10 +- .../x/sys/unix/ztypes_darwin_amd64.go | 10 +- .../x/sys/unix/ztypes_darwin_arm.go | 10 +- .../x/sys/unix/ztypes_darwin_arm64.go | 10 +- .../x/sys/unix/ztypes_dragonfly_amd64.go | 10 +- .../x/sys/unix/ztypes_freebsd_386.go | 10 +- .../x/sys/unix/ztypes_freebsd_amd64.go | 10 +- .../x/sys/unix/ztypes_freebsd_arm.go | 10 +- .../golang.org/x/sys/unix/ztypes_linux_386.go | 38 +- .../x/sys/unix/ztypes_linux_amd64.go | 38 +- .../golang.org/x/sys/unix/ztypes_linux_arm.go | 38 +- .../x/sys/unix/ztypes_linux_arm64.go | 38 +- .../x/sys/unix/ztypes_linux_mips.go | 38 +- .../x/sys/unix/ztypes_linux_mips64.go | 38 +- .../x/sys/unix/ztypes_linux_mips64le.go | 38 +- .../x/sys/unix/ztypes_linux_mipsle.go | 38 +- .../x/sys/unix/ztypes_linux_ppc64.go | 38 +- .../x/sys/unix/ztypes_linux_ppc64le.go | 38 +- .../x/sys/unix/ztypes_linux_riscv64.go | 38 +- .../x/sys/unix/ztypes_linux_s390x.go | 38 +- .../x/sys/unix/ztypes_linux_sparc64.go | 10 +- .../x/sys/unix/ztypes_netbsd_386.go | 10 +- .../x/sys/unix/ztypes_netbsd_amd64.go | 10 +- .../x/sys/unix/ztypes_netbsd_arm.go | 10 +- .../x/sys/unix/ztypes_openbsd_386.go | 101 ++- .../x/sys/unix/ztypes_openbsd_amd64.go | 101 ++- .../x/sys/unix/ztypes_openbsd_arm.go | 101 ++- .../x/sys/unix/ztypes_solaris_amd64.go | 10 +- vendor/yunion.io/x/jsonutils/yamlutils.go | 1 - 162 files changed, 8751 insertions(+), 884 deletions(-) create mode 100644 cmd/qcloudcli/main.go create mode 100644 pkg/compute/guestdrivers/qcloud.go create mode 100644 pkg/util/qcloud/disk.go create mode 100644 pkg/util/qcloud/eip.go create mode 100644 pkg/util/qcloud/host.go create mode 100644 pkg/util/qcloud/image.go create mode 100644 pkg/util/qcloud/instance.go create mode 100644 pkg/util/qcloud/instancenic.go create mode 100644 pkg/util/qcloud/instancetype.go create mode 100644 pkg/util/qcloud/keypair.go create mode 100644 pkg/util/qcloud/latitud_and_longitude.go create mode 100644 pkg/util/qcloud/localdisk.go create mode 100644 pkg/util/qcloud/localstorage.go create mode 100644 pkg/util/qcloud/network.go create mode 100644 pkg/util/qcloud/provider/doc.go create mode 100644 pkg/util/qcloud/provider/provider.go create mode 100644 pkg/util/qcloud/qcloud.go create mode 100644 pkg/util/qcloud/region.go create mode 100644 pkg/util/qcloud/securitygroup.go create mode 100644 pkg/util/qcloud/shell/cos.go create mode 100644 pkg/util/qcloud/shell/disk.go create mode 100644 pkg/util/qcloud/shell/eip.go create mode 100644 pkg/util/qcloud/shell/image.go create mode 100644 pkg/util/qcloud/shell/instance.go create mode 100644 pkg/util/qcloud/shell/keypair.go create mode 100644 pkg/util/qcloud/shell/network.go create mode 100644 pkg/util/qcloud/shell/printutils.go create mode 100644 pkg/util/qcloud/shell/region.go create mode 100644 pkg/util/qcloud/shell/securitygroup.go create mode 100644 pkg/util/qcloud/shell/snapshot.go create mode 100644 pkg/util/qcloud/shell/vpc.go create mode 100644 pkg/util/qcloud/shell/zone.go create mode 100644 pkg/util/qcloud/snapshot.go create mode 100644 pkg/util/qcloud/storage.go create mode 100644 pkg/util/qcloud/storagecache.go create mode 100644 pkg/util/qcloud/vpc.go create mode 100644 pkg/util/qcloud/wire.go create mode 100644 pkg/util/qcloud/zone.go create mode 100644 vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod create mode 100644 vendor/github.com/miekg/dns/serve_mux.go create mode 100644 vendor/github.com/miekg/dns/udp_windows.go delete mode 100644 vendor/github.com/prometheus/procfs/.travis.yml create mode 100644 vendor/github.com/prometheus/procfs/internal/util/sysreadfile_linux.go delete mode 100644 vendor/github.com/sirupsen/logrus/terminal_appengine.go delete mode 100644 vendor/github.com/sirupsen/logrus/terminal_bsd.go delete mode 100644 vendor/github.com/sirupsen/logrus/terminal_linux.go create mode 100644 vendor/github.com/sirupsen/logrus/terminal_notwindows.go create mode 100644 vendor/github.com/spf13/pflag/string_to_int.go create mode 100644 vendor/github.com/spf13/pflag/string_to_string.go diff --git a/Gopkg.toml b/Gopkg.toml index b70428fdfc..3d859a94b9 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -110,6 +110,14 @@ name = "github.com/360EntSecGroup-Skylar/excelize" version = "v1.3.0" +[[constraint]] + name = "github.com/tencentcloud/tencentcloud-sdk-go" + version = "=v3.0.0" + +[[constraint]] + name = "github.com/nelsonken/cos-go-sdk-v5" + version = "=v1.2.0" + [[constraint]] branch = "master" name = "github.com/tredoe/osutil" diff --git a/cmd/climc/shell/cloudaccounts.go b/cmd/climc/shell/cloudaccounts.go index 22ffde1d49..8c004dae37 100644 --- a/cmd/climc/shell/cloudaccounts.go +++ b/cmd/climc/shell/cloudaccounts.go @@ -37,6 +37,7 @@ func init() { PROVIDER string `help:"Driver for cloud account" choices:"VMware|Aliyun|Azure|Qcloud"` AccessURL string `helo:"hello" metavar:"Azure choices: "` Desc string `help:"Description"` + Enabled bool `help:"Enabled the account automatically"` Import bool `help:"Import all sub account automatically"` AutoSync bool `help:"Enabled the account automatically"` @@ -49,6 +50,10 @@ func init() { params.Add(jsonutils.NewString(args.SECRET), "secret") params.Add(jsonutils.NewString(args.PROVIDER), "provider") + if args.Enabled { + params.Add(jsonutils.JSONTrue, "enabled") + } + if args.Import { params.Add(jsonutils.JSONTrue, "import") if args.AutoSync { diff --git a/cmd/qcloudcli/main.go b/cmd/qcloudcli/main.go new file mode 100644 index 0000000000..7e22889f2e --- /dev/null +++ b/cmd/qcloudcli/main.go @@ -0,0 +1,127 @@ +package main + +import ( + "fmt" + "os" + + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" + "yunion.io/x/structarg" + + _ "yunion.io/x/onecloud/pkg/util/qcloud/shell" +) + +type BaseOptions struct { + Help bool `help:"Show help"` + AppID string `help:"AppID" default:"$QCLOUD_APPID"` + SecretID string `help:"Secret" default:"$QCLOUD_SECRET_ID"` + SecretKey string `help:"Access key" default:"$QCLOUD_SECRET_KEY"` + RegionId string `help:"RegionId" default:"$QCLOUD_REGION_ID"` + SUBCOMMAND string `help:"azurecli subcommand" subcommand:"true"` +} + +func getSubcommandParser() (*structarg.ArgumentParser, error) { + parse, e := structarg.NewArgumentParser(&BaseOptions{}, + "qcloudcli", + "Command-line interface to tencentcloud API.", + `See "tencentcli help COMMAND" for help on a specific command.`) + + if e != nil { + return nil, e + } + + subcmd := parse.GetSubcommand() + if subcmd == nil { + return nil, fmt.Errorf("No subcommand argument.") + } + type HelpOptions struct { + SUBCOMMAND string `help:"sub-command name"` + } + shellutils.R(&HelpOptions{}, "help", "Show help of a subcommand", func(args *HelpOptions) error { + helpstr, e := subcmd.SubHelpString(args.SUBCOMMAND) + if e != nil { + return e + } else { + fmt.Print(helpstr) + return nil + } + }) + for _, v := range shellutils.CommandTable { + _, e := subcmd.AddSubParser(v.Options, v.Command, v.Desc, v.Callback) + if e != nil { + return nil, e + } + } + return parse, nil +} + +func showErrorAndExit(e error) { + log.Errorf("%s", e) + os.Exit(1) +} + +func newClient(options *BaseOptions) (*qcloud.SRegion, error) { + if len(options.SecretKey) == 0 { + return nil, fmt.Errorf("Missing SecretKey") + } + + if len(options.SecretID) == 0 { + return nil, fmt.Errorf("Missing SecretID") + } + + account := options.SecretID + if len(options.AppID) > 0 { + account = fmt.Sprintf("%s/%s", account, options.AppID) + } + + if cli, err := qcloud.NewQcloudClient("", "", account, options.SecretKey); err != nil { + return nil, err + } else if region := cli.GetRegion(options.RegionId); region == nil { + return nil, fmt.Errorf("No such region %s", options.RegionId) + } else { + return region, nil + } +} + +func main() { + parser, e := getSubcommandParser() + if e != nil { + showErrorAndExit(e) + } + e = parser.ParseArgs(os.Args[1:], false) + options := parser.Options().(*BaseOptions) + + if options.Help { + fmt.Print(parser.HelpString()) + } else { + subcmd := parser.GetSubcommand() + subparser := subcmd.GetSubParser() + if e != nil { + if subparser != nil { + fmt.Print(subparser.Usage()) + } else { + fmt.Print(parser.Usage()) + } + showErrorAndExit(e) + } else { + suboptions := subparser.Options() + if options.SUBCOMMAND == "help" { + e = subcmd.Invoke(suboptions) + } else { + var region *qcloud.SRegion + if len(options.RegionId) == 0 { + options.RegionId = qcloud.QCLOUD_DEFAULT_REGION + } + region, e = newClient(options) + if e != nil { + showErrorAndExit(e) + } + e = subcmd.Invoke(region, suboptions) + } + if e != nil { + showErrorAndExit(e) + } + } + } +} diff --git a/pkg/compute/guestdrivers/qcloud.go b/pkg/compute/guestdrivers/qcloud.go new file mode 100644 index 0000000000..b9d0cc8dff --- /dev/null +++ b/pkg/compute/guestdrivers/qcloud.go @@ -0,0 +1,343 @@ +package guestdrivers + +import ( + "context" + "fmt" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/httperrors" + "yunion.io/x/onecloud/pkg/mcclient" + + "yunion.io/x/onecloud/pkg/cloudcommon/db" + "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/onecloud/pkg/util/seclib2" +) + +type SQcloudGuestDriver struct { + SManagedVirtualizedGuestDriver +} + +func init() { + driver := SQcloudGuestDriver{} + models.RegisterGuestDriver(&driver) +} + +func (self *SQcloudGuestDriver) GetHypervisor() string { + return models.HYPERVISOR_QCLOUD +} + +func (self *SQcloudGuestDriver) ChooseHostStorage(host *models.SHost, backend string) *models.SStorage { + storages := host.GetAttachedStorages("") + for i := 0; i < len(storages); i++ { + if storages[i].StorageType == backend { + return &storages[i] + } + } + for _, stype := range []string{"local_basic", "local_ssd", "cloud_basic", "cloud_ssd", "cloud_premium"} { + for i := 0; i < len(storages); i++ { + if storages[i].StorageType == stype { + return &storages[i] + } + } + } + return nil +} + +func (self *SQcloudGuestDriver) GetDetachDiskStatus() ([]string, error) { + return []string{models.VM_READY, models.VM_RUNNING}, nil +} + +func (self *SQcloudGuestDriver) RequestDetachDisk(ctx context.Context, guest *models.SGuest, task taskman.ITask) error { + return guest.StartSyncTask(ctx, task.GetUserCred(), false, task.GetTaskId()) +} + +func (self *SQcloudGuestDriver) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) { + data, err := self.SManagedVirtualizedGuestDriver.ValidateCreateData(ctx, userCred, data) + if err != nil { + return nil, err + } + if data.Contains("net.0") && data.Contains("net.1") { + return nil, httperrors.NewInputParameterError("cannot support more than 1 nic") + } + return data, nil +} + +func (self *SQcloudGuestDriver) RequestDeployGuestOnHost(ctx context.Context, guest *models.SGuest, host *models.SHost, task taskman.ITask) error { + config := guest.GetDeployConfigOnHost(ctx, host, task.GetParams()) + log.Debugf("RequestDeployGuestOnHost: %s", config) + /* onfinish, err := config.GetString("on_finish") + if err != nil { + return err + } */ + + action, err := config.GetString("action") + if err != nil { + return err + } + + publicKey, _ := config.GetString("public_key") + + adminPublicKey, _ := config.GetString("admin_public_key") + projectPublicKey, _ := config.GetString("project_public_key") + oUserData, _ := config.GetString("user_data") + + userData := generateUserData(adminPublicKey, projectPublicKey, oUserData) + + resetPassword := jsonutils.QueryBoolean(config, "reset_password", false) + passwd, _ := config.GetString("password") + if resetPassword && len(passwd) == 0 { + passwd = seclib2.RandomPassword2(12) + } + + ihost, err := host.GetIHost() + if err != nil { + return err + } + + desc := SManagedVMCreateConfig{} + err = config.Unmarshal(&desc, "desc") + if err != nil { + return err + } + + if action == "create" { + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + + nets := guest.GetNetworks() + net := nets[0].GetNetwork() + vpc := net.GetVpc() + + ivpc, err := vpc.GetIVpc() + if err != nil { + log.Errorf("getIVPC fail %s", err) + return nil, err + } + + secgrpId, err := ivpc.SyncSecurityGroup(desc.SecGroupId, desc.SecGroupName, desc.SecRules) + if err != nil { + log.Errorf("SyncSecurityGroup fail %s", err) + return nil, err + } + + iVM, err := ihost.CreateVM(desc.Name, desc.ExternalImageId, desc.SysDiskSize, desc.Cpu, desc.Memory, desc.ExternalNetworkId, + desc.IpAddr, desc.Description, passwd, desc.StorageType, desc.DataDisks, publicKey, secgrpId, userData) + if err != nil { + return nil, err + } + log.Debugf("VMcreated %s, wait status ready ...", iVM.GetGlobalId()) + err = cloudprovider.WaitStatus(iVM, models.VM_READY, time.Second*5, time.Second*1800) + if err != nil { + return nil, err + } + log.Debugf("VMcreated %s, and status is ready", iVM.GetGlobalId()) + + iVM, err = ihost.GetIVMById(iVM.GetGlobalId()) + if err != nil { + log.Errorf("cannot find vm %s", err) + return nil, err + } + data := fetchIVMinfo(desc, iVM, guest.Id, "root", passwd) + return data, nil + }) + } else if action == "deploy" { + iVM, err := ihost.GetIVMById(guest.GetExternalId()) + if err != nil || iVM == nil { + log.Errorf("cannot find vm %s", err) + return fmt.Errorf("cannot find vm") + } + + params := task.GetParams() + log.Debugf("Deploy VM params %s", params.String()) + + name, _ := params.GetString("name") + description, _ := params.GetString("description") + publicKey, _ := config.GetString("public_key") + deleteKeypair := jsonutils.QueryBoolean(params, "__delete_keypair__", false) + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + + if len(userData) > 0 { + err := iVM.UpdateUserData(userData) + if err != nil { + log.Errorf("update userdata fail %s", err) + } + } + + err := iVM.DeployVM(name, passwd, publicKey, deleteKeypair, description) + if err != nil { + return nil, err + } + + data := fetchIVMinfo(desc, iVM, guest.Id, "root", passwd) + return data, nil + }) + } else if action == "rebuild" { + + iVM, err := ihost.GetIVMById(guest.GetExternalId()) + if err != nil || iVM == nil { + log.Errorf("cannot find vm %s", err) + return fmt.Errorf("cannot find vm") + } + + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + if len(userData) > 0 { + err := iVM.UpdateUserData(userData) + if err != nil { + log.Errorf("update userdata fail %s", err) + } + } + + diskId, err := iVM.RebuildRoot(desc.ExternalImageId, passwd, publicKey, desc.SysDiskSize) + if err != nil { + return nil, err + } + + log.Debugf("VMrebuildRoot %s new diskID %s, wait status ready ...", iVM.GetGlobalId(), diskId) + + err = cloudprovider.WaitStatus(iVM, models.VM_READY, time.Second*5, time.Second*1800) + if err != nil { + return nil, err + } + log.Debugf("VMrebuildRoot %s, and status is ready", iVM.GetGlobalId()) + + maxWaitSecs := 300 + waited := 0 + + for { + // hack, wait disk number consistent + idisks, err := iVM.GetIDisks() + if err != nil { + log.Errorf("fail to find VM idisks %s", err) + return nil, err + } + if len(idisks) < len(desc.DataDisks)+1 { + if waited > maxWaitSecs { + log.Errorf("inconsistent disk number, wait timeout, must be something wrong on remote") + return nil, cloudprovider.ErrTimeout + } + log.Debugf("inconsistent disk number???? %d != %d", len(idisks), len(desc.DataDisks)+1) + time.Sleep(time.Second * 5) + waited += 5 + } else { + if idisks[0].GetGlobalId() != diskId { + log.Errorf("system disk id inconsistent %s != %s", idisks[0].GetGlobalId(), diskId) + return nil, fmt.Errorf("inconsistent sys disk id after rebuild root") + } + + break + } + } + + data := fetchIVMinfo(desc, iVM, guest.Id, "root", passwd) + + return data, nil + }) + + } else { + log.Errorf("RequestDeployGuestOnHost: Action %s not supported", action) + return fmt.Errorf("Action %s not supported", action) + } + + return nil +} + +func (self *SQcloudGuestDriver) OnGuestDeployTaskDataReceived(ctx context.Context, guest *models.SGuest, task taskman.ITask, data jsonutils.JSONObject) error { + + if data.Contains("disks") { + diskInfo := make([]SDiskInfo, 0) + err := data.Unmarshal(&diskInfo, "disks") + if err != nil { + return err + } + disks := guest.GetDisks() + if len(disks) != len(diskInfo) { + msg := fmt.Sprintf("inconsistent disk number: have %d want %d", len(disks), len(diskInfo)) + log.Errorf(msg) + return fmt.Errorf(msg) + } + for i := 0; i < len(diskInfo); i += 1 { + disk := disks[i].GetDisk() + _, err = disk.GetModelManager().TableSpec().Update(disk, func() error { + disk.DiskSize = diskInfo[i].Size + disk.ExternalId = diskInfo[i].Uuid + disk.DiskType = diskInfo[i].DiskType + disk.Status = models.DISK_READY + disk.BillingType = diskInfo[i].BillingType + disk.FsFormat = diskInfo[i].FsFromat + disk.AutoDelete = diskInfo[i].AutoDelete + disk.TemplateId = diskInfo[i].TemplateId + disk.DiskFormat = diskInfo[i].DiskFormat + disk.ExpiredAt = diskInfo[i].ExpiredAt + if len(diskInfo[i].Metadata) > 0 { + for key, value := range diskInfo[i].Metadata { + if err := disk.SetMetadata(ctx, key, value, task.GetUserCred()); err != nil { + log.Errorf("set disk %s mata %s => %s error: %v", disk.Name, key, value, err) + } + } + } + return nil + }) + if err != nil { + msg := fmt.Sprintf("save disk info failed %s", err) + log.Errorf(msg) + break + } else { + db.OpsLog.LogEvent(disk, db.ACT_ALLOCATE, disk.GetShortDesc(), task.GetUserCred()) + } + } + } + uuid, _ := data.GetString("uuid") + if len(uuid) > 0 { + guest.SetExternalId(uuid) + } + + if metaData, _ := data.Get("metadata"); metaData != nil { + meta := make(map[string]string, 0) + if err := metaData.Unmarshal(meta); err != nil { + log.Errorf("Get guest %s metadata error: %v", guest.Name, err) + } else { + for key, value := range meta { + if err := guest.SetMetadata(ctx, key, value, task.GetUserCred()); err != nil { + log.Errorf("set guest %s mata %s => %s error: %v", guest.Name, key, value, err) + } + } + } + } + + guest.SaveDeployInfo(ctx, task.GetUserCred(), data) + return nil +} + +func (self *SQcloudGuestDriver) AllowReconfigGuest() bool { + return true +} + +func (self *SQcloudGuestDriver) RequestDiskSnapshot(ctx context.Context, guest *models.SGuest, task taskman.ITask, snapshotId, diskId string) error { + iDisk, _ := models.DiskManager.FetchById(diskId) + disk := iDisk.(*models.SDisk) + providerDisk, err := disk.GetIDisk() + if err != nil { + return err + } + iSnapshot, _ := models.SnapshotManager.FetchById(snapshotId) + snapshot := iSnapshot.(*models.SSnapshot) + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + cloudSnapshot, err := providerDisk.CreateISnapshot(snapshot.Name, "") + if err != nil { + return nil, err + } + res := jsonutils.NewDict() + res.Set("snapshot_id", jsonutils.NewString(cloudSnapshot.GetId())) + res.Set("manager_id", jsonutils.NewString(cloudSnapshot.GetManagerId())) + cloudRegion, err := models.CloudregionManager.FetchByExternalId("Aliyun/" + cloudSnapshot.GetRegionId()) + if err != nil { + return nil, fmt.Errorf("Cloud region not found? %s", err) + } + res.Set("cloudregion_id", jsonutils.NewString(cloudRegion.GetId())) + return res, nil + }) + return nil +} diff --git a/pkg/compute/models/cloudproviders.go b/pkg/compute/models/cloudproviders.go index 27241408b9..60070e6f12 100644 --- a/pkg/compute/models/cloudproviders.go +++ b/pkg/compute/models/cloudproviders.go @@ -31,6 +31,7 @@ const ( CLOUD_PROVIDER_VMWARE = "VMware" CLOUD_PROVIDER_ALIYUN = "Aliyun" + CLOUD_PROVIDER_QCLOUD = "Qcloud" CLOUD_PROVIDER_AZURE = "Azure" ) diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index df16410468..584ef6af6a 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -123,6 +123,7 @@ const ( HYPERVISOR_ESXI = "esxi" HYPERVISOR_HYPERV = "hyperv" HYPERVISOR_ALIYUN = "aliyun" + HYPERVISOR_QCLOUD = "qcloud" HYPERVISOR_AZURE = "azure" // HYPERVISOR_DEFAULT = HYPERVISOR_KVM @@ -132,7 +133,7 @@ const ( var VM_RUNNING_STATUS = []string{VM_START_START, VM_STARTING, VM_RUNNING, VM_SNAPSHOT_STREAM} var VM_CREATING_STATUS = []string{VM_CREATE_NETWORK, VM_CREATE_DISK, VM_START_DEPLOY, VM_DEPLOYING} -var HYPERVISORS = []string{HYPERVISOR_KVM, HYPERVISOR_BAREMETAL, HYPERVISOR_ESXI, HYPERVISOR_CONTAINER, HYPERVISOR_ALIYUN, HYPERVISOR_AZURE} +var HYPERVISORS = []string{HYPERVISOR_KVM, HYPERVISOR_BAREMETAL, HYPERVISOR_ESXI, HYPERVISOR_CONTAINER, HYPERVISOR_ALIYUN, HYPERVISOR_AZURE, HYPERVISOR_QCLOUD} // var HYPERVISORS = []string{HYPERVISOR_ALIYUN} @@ -143,6 +144,7 @@ var HYPERVISOR_HOSTTYPE = map[string]string{ HYPERVISOR_CONTAINER: HOST_TYPE_KUBELET, HYPERVISOR_ALIYUN: HOST_TYPE_ALIYUN, HYPERVISOR_AZURE: HOST_TYPE_AZURE, + HYPERVISOR_QCLOUD: HOST_TYPE_QCLOUD, } var HOSTTYPE_HYPERVISOR = map[string]string{ @@ -152,6 +154,7 @@ var HOSTTYPE_HYPERVISOR = map[string]string{ HOST_TYPE_KUBELET: HYPERVISOR_CONTAINER, HOST_TYPE_ALIYUN: HYPERVISOR_ALIYUN, HOST_TYPE_AZURE: HYPERVISOR_AZURE, + HOST_TYPE_QCLOUD: HYPERVISOR_QCLOUD, } type SGuestManager struct { diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 18ce57c38e..06869f44aa 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -43,6 +43,7 @@ const ( HOST_TYPE_HYPERV = "hyperv" // # Microsoft Hyper-V HOST_TYPE_XEN = "xen" // # XenServer HOST_TYPE_ALIYUN = "aliyun" + HOST_TYPE_QCLOUD = "qcloud" HOST_TYPE_AZURE = "azure" HOST_TYPE_DEFAULT = HOST_TYPE_HYPERVISOR @@ -81,7 +82,7 @@ const ( HOST_STATUS_UNKNOWN = BAREMETAL_UNKNOWN ) -var HOST_TYPES = []string{HOST_TYPE_BAREMETAL, HOST_TYPE_HYPERVISOR, HOST_TYPE_ESXI, HOST_TYPE_KUBELET, HOST_TYPE_XEN, HOST_TYPE_ALIYUN, HOST_TYPE_AZURE} +var HOST_TYPES = []string{HOST_TYPE_BAREMETAL, HOST_TYPE_HYPERVISOR, HOST_TYPE_ESXI, HOST_TYPE_KUBELET, HOST_TYPE_XEN, HOST_TYPE_ALIYUN, HOST_TYPE_AZURE, HOST_TYPE_QCLOUD} var NIC_TYPES = []string{NIC_TYPE_IPMI, NIC_TYPE_ADMIN} type SHostManager struct { diff --git a/pkg/compute/models/snapshots.go b/pkg/compute/models/snapshots.go index dec7787f66..ff942013b8 100644 --- a/pkg/compute/models/snapshots.go +++ b/pkg/compute/models/snapshots.go @@ -25,11 +25,12 @@ const ( MANUAL = "manual" AUTO = "auto" - SNAPSHOT_CREATING = "creating" - SNAPSHOT_FAILED = "create_failed" - SNAPSHOT_READY = "ready" - SNAPSHOT_DELETING = "deleting" - SNAPSHOT_UNKNOWN = "unknown" + SNAPSHOT_CREATING = "creating" + SNAPSHOT_ROLLBACKING = "rollbacking" + SNAPSHOT_FAILED = "create_failed" + SNAPSHOT_READY = "ready" + SNAPSHOT_DELETING = "deleting" + SNAPSHOT_UNKNOWN = "unknown" ) type SSnapshotManager struct { diff --git a/pkg/compute/service/service.go b/pkg/compute/service/service.go index 0f0bcf950f..7698c22628 100644 --- a/pkg/compute/service/service.go +++ b/pkg/compute/service/service.go @@ -14,6 +14,7 @@ import ( _ "yunion.io/x/onecloud/pkg/util/aliyun/provider" _ "yunion.io/x/onecloud/pkg/util/azure/provider" _ "yunion.io/x/onecloud/pkg/util/esxi/provider" + _ "yunion.io/x/onecloud/pkg/util/qcloud/provider" "yunion.io/x/onecloud/pkg/cloudcommon" "yunion.io/x/onecloud/pkg/cloudcommon/consts" diff --git a/pkg/util/aliyun/host.go b/pkg/util/aliyun/host.go index c79b40d1bc..ad1e28e7a4 100644 --- a/pkg/util/aliyun/host.go +++ b/pkg/util/aliyun/host.go @@ -2,6 +2,7 @@ package aliyun import ( "fmt" + "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/onecloud/pkg/cloudprovider" diff --git a/pkg/util/qcloud/disk.go b/pkg/util/qcloud/disk.go new file mode 100644 index 0000000000..7a77a638f6 --- /dev/null +++ b/pkg/util/qcloud/disk.go @@ -0,0 +1,365 @@ +package qcloud + +import ( + "fmt" + "sort" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/pkg/utils" +) + +type Placement struct { + ProjectId int + Zone string +} + +type SDisk struct { + storage *SStorage + + Attached bool + AutoRenewFlagError bool + CreateTime time.Time + DeadlineError bool + DeadlineTime time.Time + DifferDaysOfDeadline int + DiskChargeType string + DiskId string + DiskName string + DiskSize int + DiskState string + DiskType string + DiskUsage string + Encrypt bool + InstanceId string + IsReturnable bool + Placement Placement + Portable bool + RenewFlag string + ReturnFailCode int + RollbackPercent int + Rollbacking bool + SnapshotAbility bool + DeleteWithInstance bool +} + +type SDiskSet []SDisk + +func (v SDiskSet) Len() int { + return len(v) +} + +func (v SDiskSet) Swap(i, j int) { + v[i], v[j] = v[j], v[i] +} + +func (v SDiskSet) Less(i, j int) bool { + if v[i].DiskUsage == "SYSTEM_DISK" || v[j].DiskUsage == "DATA_DISK" { + return true + } + return false +} + +func (self *SDisk) GetMetadata() *jsonutils.JSONDict { + // data := jsonutils.NewDict() + + // // The pricingInfo key structure is 'RegionId::DiskCategory::DiskType + // priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type) + // data.Add(jsonutils.NewString(priceKey), "price_key") + + // data.Add(jsonutils.NewString(models.HYPERVISOR_ALIYUN), "hypervisor") + + // return data + return nil +} + +func (self *SRegion) GetDisks(instanceId string, zoneId string, category string, diskIds []string, offset int, limit int) ([]SDisk, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + filter := 0 + + if len(zoneId) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "zone" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = zoneId + filter++ + } + + if len(instanceId) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "instance-id" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = instanceId + filter++ + } + + if len(category) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "disk-type" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = category + filter++ + } + if diskIds != nil && len(diskIds) > 0 { + for index, diskId := range diskIds { + params[fmt.Sprintf("DiskIds.%d", index)] = diskId + } + } + + body, err := self.cbsRequest("DescribeDisks", params) + if err != nil { + log.Errorf("GetDisks fail %s", err) + return nil, 0, err + } + + disks := make([]SDisk, 0) + err = body.Unmarshal(&disks, "DiskSet") + if err != nil { + log.Errorf("Unmarshal disk details fail %s", err) + return nil, 0, err + } + total, _ := body.Float("TotalCount") + sort.Sort(SDiskSet(disks)) + return disks, int(total), nil +} + +func (self *SRegion) GetDisk(diskId string) (*SDisk, error) { + disks, total, err := self.GetDisks("", "", "", []string{diskId}, 0, 1) + if err != nil { + return nil, err + } + if total != 1 { + return nil, cloudprovider.ErrNotFound + } + return &disks[0], nil +} + +func (self *SDisk) GetId() string { + return self.DiskId +} + +func (self *SRegion) DeleteDisk(diskId string) error { + params := make(map[string]string) + params["Region"] = self.Region + params["DiskIds.0"] = diskId + + _, err := self.cbsRequest("TerminateDisks", params) + return err +} + +func (self *SDisk) Delete() error { + return self.storage.zone.region.DeleteDisk(self.DiskId) +} + +func (self *SRegion) ResizeDisk(diskId string, sizeGb int64) error { + params := make(map[string]string) + params["DiskId"] = diskId + params["DiskSize"] = fmt.Sprintf("%d", sizeGb) + + _, err := self.cbsRequest("ResizeDisk", params) + if err != nil { + log.Errorf("ResizeDisk %s to %s GiB fail %s", diskId, sizeGb, err) + return err + } + return nil +} + +func (self *SDisk) Resize(size int64) error { + return self.storage.zone.region.ResizeDisk(self.DiskId, size) +} + +func (self *SDisk) GetName() string { + if len(self.DiskName) > 0 { + return self.DiskName + } + return self.DiskId +} + +func (self *SDisk) GetGlobalId() string { + return self.DiskId +} + +func (self *SDisk) IsEmulated() bool { + return false +} + +func (self *SDisk) GetIStorge() cloudprovider.ICloudStorage { + return self.storage +} + +func (self *SDisk) GetStatus() string { + switch self.DiskState { + case "ATTACHING", "DETACHING", "EXPANDING", "ROLLBACKING": + return models.DISK_ALLOCATING + default: + return models.DISK_READY + } +} + +func (self *SDisk) Refresh() error { + new, err := self.storage.zone.region.GetDisk(self.DiskId) + if err != nil { + return err + } + return jsonutils.Update(self, new) +} + +func (self *SDisk) CreateISnapshot(name, desc string) (cloudprovider.ICloudSnapshot, error) { + snapshotId, err := self.storage.zone.region.CreateSnapshot(self.DiskId, name, desc) + if err != nil { + log.Errorf("createSnapshot fail %s", err) + return nil, err + } + snapshots, total, err := self.storage.zone.region.GetSnapshots("", "", "", []string{snapshotId}, 0, 1) + if err != nil { + return nil, err + } + if total == 1 { + snapshot := &snapshots[0] + err := cloudprovider.WaitStatus(snapshot, string(SnapshotStatusAccomplished), 15*time.Second, 3600*time.Second) + if err != nil { + return nil, err + } + return snapshot, nil + } + return nil, nil +} + +func (self *SDisk) GetDiskType() string { + switch self.DiskUsage { + case "SYSTEM_DISK": + return models.DISK_TYPE_SYS + case "DATA_DISK": + return models.DISK_TYPE_DATA + default: + return models.DISK_TYPE_DATA + } +} + +func (self *SDisk) GetFsFormat() string { + return "" +} + +func (self *SDisk) GetIsNonPersistent() bool { + return false +} + +func (self *SDisk) GetDriver() string { + return "scsi" +} + +func (self *SDisk) GetCacheMode() string { + return "none" +} + +func (self *SDisk) GetMountpoint() string { + return "" +} + +func (self *SDisk) GetBillingType() string { + switch self.DiskChargeType { + case "PREPAID": + return models.BILLING_TYPE_PREPAID + case "POSTPAID_BY_HOUR": + return models.BILLING_TYPE_POSTPAID + default: + return models.BILLING_TYPE_PREPAID + } +} + +func (self *SDisk) GetDiskFormat() string { + return "vhd" +} + +func (self *SDisk) GetDiskSizeMB() int { + return self.DiskSize * 1024 +} + +func (self *SDisk) GetIsAutoDelete() bool { + return self.DeleteWithInstance +} + +func (self *SDisk) GetExpiredAt() time.Time { + return self.DeadlineTime +} + +func (self *SDisk) GetISnapshot(snapshotId string) (cloudprovider.ICloudSnapshot, error) { + snapshots, total, err := self.storage.zone.region.GetSnapshots("", "", "", []string{snapshotId}, 0, 1) + if err != nil { + return nil, err + } + if total == 1 { + return &snapshots[0], nil + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SDisk) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) { + snapshots := make([]SSnapshot, 0) + for { + parts, total, err := self.storage.zone.region.GetSnapshots("", self.DiskId, "", []string{}, 0, 20) + if err != nil { + log.Errorf("GetDisks fail %s", err) + return nil, err + } + snapshots = append(snapshots, parts...) + if len(snapshots) >= total { + break + } + } + isnapshots := make([]cloudprovider.ICloudSnapshot, len(snapshots)) + for i := 0; i < len(snapshots); i++ { + snapshots[i].region = self.storage.zone.region + isnapshots[i] = &snapshots[i] + } + return isnapshots, nil +} + +func (self *SDisk) GetTemplateId() string { + //return self.ImageId + return "" +} + +func (self *SRegion) ResetDisk(diskId, snapshotId string) error { + params := make(map[string]string) + params["Region"] = self.Region + params["DiskId"] = diskId + params["SnapshotId"] = snapshotId + _, err := self.cbsRequest("ApplySnapshot", params) + if err != nil { + log.Errorf("ResetDisk %s to snapshot %s fail %s", diskId, snapshotId, err) + return err + } + return nil +} + +func (self *SDisk) Reset(snapshotId string) error { + return self.storage.zone.region.ResetDisk(self.DiskId, snapshotId) +} + +func (self *SRegion) CreateDisk(zoneId string, category string, name string, sizeGb int, desc string) (string, error) { + params := make(map[string]string) + params["Region"] = self.Region + params["DiskType"] = category + params["DiskChargeType"] = "POSTPAID_BY_HOUR" + params["DiskName"] = name + params["Placement.Zone"] = zoneId + //params["Encrypted"] = "false" + params["DiskSize"] = fmt.Sprintf("%d", sizeGb) + params["ClientToken"] = utils.GenRequestId(20) + + body, err := self.cbsRequest("CreateDisks", params) + if err != nil { + return "", err + } + diskIdSet, err := body.GetArray("DiskIdSet") + if err != nil { + return "", err + } + if len(diskIdSet) < 1 { + return "", fmt.Errorf("Create Disk error") + } + return diskIdSet[0].String(), nil +} diff --git a/pkg/util/qcloud/eip.go b/pkg/util/qcloud/eip.go new file mode 100644 index 0000000000..e3d6501687 --- /dev/null +++ b/pkg/util/qcloud/eip.go @@ -0,0 +1,295 @@ +package qcloud + +import ( + "fmt" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type TInternetChargeType string + +const ( + InternetChargeByTraffic = TInternetChargeType("PayByTraffic") + InternetChargeByBandwidth = TInternetChargeType("PayByBandwidth") +) + +const ( + EIP_STATUS_ASSOCIATING = "Associating" + EIP_STATUS_UNASSOCIATING = "Unassociating" + EIP_STATUS_INUSE = "InUse" + EIP_STATUS_AVAILABLE = "Available" + + EIP_OPERATION_LOCK_FINANCIAL = "financial" + EIP_OPERATION_LOCK_SECURITY = "security" + + EIP_INSTANCE_TYPE_ECS = "EcsInstance" // (默认值):VPC类型的ECS实例 + EIP_INTANNCE_TYPE_SLB = "SlbInstance" // :VPC类型的SLB实例 + EIP_INSTANCE_TYPE_NAT = "Nat" // :NAT网关 + EIP_INSTANCE_TYPE_HAVIP = "HaVip" // :HAVIP +) + +type SEipAddress struct { + region *SRegion + + AddressId string // EIP的ID,是EIP的唯一标识。 + AddressName string // EIP名称。 + AddressStatus string // EIP状态。 + AddressIp string // 外网IP地址 + InstanceId string // 绑定的资源实例ID。可能是一个CVM,NAT。 + CreatedTime time.Time // 创建时间。按照ISO8601标准表示,并且使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ。 + NetworkInterfaceId string // 绑定的弹性网卡ID + PrivateAddressIp string // 绑定的资源内网ip + IsArrears bool // 资源隔离状态。true表示eip处于隔离状态,false表示资源处于未隔离装填 + IsBlocked bool // 资源封堵状态。true表示eip处于封堵状态,false表示eip处于未封堵状态 + IsEipDirectConnection bool // eip是否支持直通模式。true表示eip支持直通模式,false表示资源不支持直通模式 + AddressType string // eip资源类型,包括"CalcIP","WanIP","EIP","AnycastEIP"。其中"CalcIP"表示设备ip,“WanIP”表示普通公网ip,“EIP”表示弹性公网ip,“AnycastEip”表示加速EIP + CascadeRelease bool // eip是否在解绑后自动释放。true表示eip将会在解绑后自动释放,false表示eip在解绑后不会自动释放 +} + +func (self *SEipAddress) GetId() string { + return self.AddressId +} + +func (self *SEipAddress) GetName() string { + return self.AddressName +} + +func (self *SEipAddress) GetGlobalId() string { + return self.AddressId +} + +func (self *SEipAddress) GetStatus() string { + switch self.AddressStatus { + case EIP_STATUS_AVAILABLE, EIP_STATUS_INUSE: + return models.EIP_STATUS_READY + case EIP_STATUS_ASSOCIATING: + return models.EIP_STATUS_ASSOCIATE + case EIP_STATUS_UNASSOCIATING: + return models.EIP_STATUS_DISSOCIATE + default: + return models.EIP_STATUS_UNKNOWN + } +} + +func (self *SEipAddress) Refresh() error { + if self.IsEmulated() { + return nil + } + new, err := self.region.GetEip(self.AddressId) + if err != nil { + return err + } + return jsonutils.Update(self, new) +} + +func (self *SEipAddress) IsEmulated() bool { + if self.AddressId == self.InstanceId { + // fixed Public IP + return true + } else { + return false + } +} + +func (self *SEipAddress) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SEipAddress) GetIpAddr() string { + return self.AddressIp +} + +func (self *SEipAddress) GetMode() string { + if self.InstanceId == self.AddressId { + return models.EIP_MODE_INSTANCE_PUBLICIP + } + return models.EIP_MODE_STANDALONE_EIP +} + +func (self *SEipAddress) GetAssociationType() string { + switch self.AddressType { + case "EIP", "AnycastEIP", "WanIP": + return "server" + case "CalcIP": + return "server" + default: + log.Fatalf("unsupported type: %s", self.AddressType) + return "unsupported" + } +} + +func (self *SEipAddress) GetAssociationExternalId() string { + return self.InstanceId +} + +func (self *SEipAddress) GetManagerId() string { + return self.region.client.providerId +} + +func (self *SEipAddress) Delete() error { + return self.region.DeallocateEIP(self.AddressId) +} + +func (self *SEipAddress) GetBandwidth() int { + return 100 + //return self.Bandwidth +} + +func (self *SEipAddress) GetInternetChargeType() string { + // switch self.InternetChargeType { + // case string(InternetChargeByTraffic): + // return models.EIP_CHARGE_TYPE_BY_TRAFFIC + // case string(InternetChargeByBandwidth): + // return models.EIP_CHARGE_TYPE_BY_BANDWIDTH + // default: + // return models.EIP_CHARGE_TYPE_BY_TRAFFIC + // } + return "unkonw" +} + +func (self *SEipAddress) Associate(instanceId string) error { + err := self.region.AssociateEip(self.AddressId, instanceId) + if err != nil { + return err + } + return cloudprovider.WaitStatus(self, models.EIP_STATUS_READY, 10*time.Second, 180*time.Second) +} + +func (self *SEipAddress) Dissociate() error { + err := self.region.DissociateEip(self.AddressId) + if err != nil { + return err + } + return cloudprovider.WaitStatus(self, models.EIP_STATUS_READY, 10*time.Second, 180*time.Second) +} + +func (self *SEipAddress) ChangeBandwidth(bw int) error { + return self.region.UpdateEipBandwidth(self.AddressId, bw) +} + +func (region *SRegion) GetEips(eipId string, offset int, limit int) ([]SEipAddress, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + + if len(eipId) > 0 { + params["AddressIds.0"] = eipId + } + + body, err := region.vpcRequest("DescribeAddresses", params) + if err != nil { + log.Errorf("DescribeEipAddresses fail %s", err) + return nil, 0, err + } + + eips := make([]SEipAddress, 0) + err = body.Unmarshal(&eips, "AddressSet") + if err != nil { + log.Errorf("Unmarshal EipAddress details fail %s", err) + return nil, 0, err + } + total, _ := body.Int("TotalCount") + for i := 0; i < len(eips); i++ { + eips[i].region = region + } + return eips, int(total), nil +} + +func (region *SRegion) GetEip(eipId string) (*SEipAddress, error) { + eips, total, err := region.GetEips(eipId, 0, 1) + if err != nil { + return nil, err + } + if total != 1 { + return nil, cloudprovider.ErrNotFound + } + return &eips[0], nil +} + +func (region *SRegion) AllocateEIP(name string, bwMbps int, chargeType TInternetChargeType) (*SEipAddress, error) { + params := make(map[string]string) + params["Region"] = region.Region + addRessSet := []string{} + body, err := region.vpcRequest("AllocateAddresses", params) + if err != nil { + return nil, err + } + if err := body.Unmarshal(&addRessSet, "AddressSet"); err == nil && len(addRessSet) > 0 { + params["AddressId"] = addRessSet[0] + params["AddressName"] = name + if _, err := region.vpcRequest("ModifyAddressAttribute", params); err != nil { + return nil, err + } else if err := region.UpdateEipBandwidth(addRessSet[0], bwMbps); err != nil { + return nil, err + } + return region.GetEip(addRessSet[0]) + } + return nil, cloudprovider.ErrNotFound +} + +func (region *SRegion) CreateEIP(name string, bwMbps int, chargeType string) (cloudprovider.ICloudEIP, error) { + var ctype TInternetChargeType + switch chargeType { + case models.EIP_CHARGE_TYPE_BY_TRAFFIC: + ctype = InternetChargeByTraffic + case models.EIP_CHARGE_TYPE_BY_BANDWIDTH: + ctype = InternetChargeByBandwidth + } + return region.AllocateEIP(name, bwMbps, ctype) +} + +func (region *SRegion) DeallocateEIP(eipId string) error { + params := make(map[string]string) + params["Region"] = region.Region + params["AddressIds.0"] = eipId + + _, err := region.vpcRequest("ReleaseAddresses", params) + if err != nil { + log.Errorf("ReleaseAddresses fail %s", err) + } + return err +} + +func (region *SRegion) AssociateEip(eipId string, instanceId string) error { + params := make(map[string]string) + params["AllocationId"] = eipId + params["InstanceId"] = instanceId + + _, err := region.vpcRequest("AssociateEipAddress", params) + if err != nil { + log.Errorf("AssociateEipAddress fail %s", err) + } + return err +} + +func (region *SRegion) DissociateEip(eipId string) error { + params := make(map[string]string) + params["Region"] = region.Region + params["AddressId"] = eipId + + _, err := region.vpcRequest("DisassociateAddress", params) + if err != nil { + log.Errorf("UnassociateEipAddress fail %s", err) + } + return err +} + +func (region *SRegion) UpdateEipBandwidth(eipId string, bw int) error { + // params := make(map[string]string) + // params["Region"] = region.Region + // params["AddressIds.0"] = eipId + // params["InternetMaxBandwidthOut"] = fmt.Sprintf("%d", bw) + + // _, err := region.vpcRequest("ModifyAddressesBandwidth", params) + // return err + // 腾讯云这个接口目前有问题 + return nil +} diff --git a/pkg/util/qcloud/host.go b/pkg/util/qcloud/host.go new file mode 100644 index 0000000000..9b84e4f524 --- /dev/null +++ b/pkg/util/qcloud/host.go @@ -0,0 +1,268 @@ +package qcloud + +import ( + "fmt" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type SHost struct { + zone *SZone +} + +func (self *SHost) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SHost) GetId() string { + return fmt.Sprintf("%s-%s", self.zone.region.client.providerId, self.zone.GetId()) +} + +func (self *SHost) GetName() string { + return fmt.Sprintf("%s-%s", self.zone.region.client.providerName, self.zone.GetId()) +} + +func (self *SHost) GetGlobalId() string { + return fmt.Sprintf("%s-%s", self.zone.region.client.providerId, self.zone.GetId()) +} + +func (self *SHost) GetInstanceById(instanceId string) (*SInstance, error) { + inst, err := self.zone.region.GetInstance(instanceId) + if err != nil { + return nil, err + } + inst.host = self + return inst, nil +} + +func (self *SHost) CreateVM(name string, imgId string, sysDiskSize int, cpu int, memMB int, + vswitchId string, ipAddr string, desc string, passwd string, + storageType string, diskSizes []int, publicKey string, secgroupId string, userData string) (cloudprovider.ICloudVM, error) { + vmId, err := self._createVM(name, imgId, sysDiskSize, cpu, memMB, vswitchId, ipAddr, desc, passwd, storageType, diskSizes, publicKey, secgroupId, userData) + if err != nil { + return nil, err + } + vm, err := self.GetInstanceById(vmId) + if err != nil { + return nil, err + } + return vm, err +} + +func (self *SHost) _createVM(name string, imgId string, sysDiskSize int, cpu int, memMB int, + networkId string, ipAddr string, desc string, passwd string, + storageType string, diskSizes []int, publicKey string, secgroupId string, userData string) (string, error) { + + net := self.zone.getNetworkById(networkId) + if net == nil { + return "", fmt.Errorf("invalid network ID %s", networkId) + } + if net.wire == nil { + log.Errorf("network's wire is empty") + return "", fmt.Errorf("network's wire is empty") + } + if net.wire.vpc == nil { + log.Errorf("network's wire' vpc is empty") + return "", fmt.Errorf("network's wire's vpc is empty") + } + + // var err error + + // if len(secgroupId) == 0 { + // secgroups, err := net.wire.vpc.GetISecurityGroups() + // if err != nil { + // return "", fmt.Errorf("get security group error %s", err) + // } + + // if len(secgroups) == 0 { + // secId, err := self.zone.region.createDefaultSecurityGroup(net.wire.vpc.VpcId) + // if err != nil { + // return "", fmt.Errorf("no secgroup for vpc and failed to create a default One!!") + // } else { + // secgroupId = secId + // } + // } else { + // secgroupId = secgroups[0].GetId() + // } + // } + + keypair := "" + // if len(publicKey) > 0 { + // keypair, err = self.zone.region.syncKeypair(publicKey) + // if err != nil { + // return "", err + // } + // } + + img, err := self.zone.region.GetImage(imgId) + if err != nil { + log.Errorf("getiamge fail %s", err) + return "", err + } + if img.ImageState != ImageStatusAvailable { + log.Errorf("image %s status %s", imgId, img.ImageState) + return "", fmt.Errorf("image not ready") + } + + _, err = self.zone.getStorageByCategory(storageType) + if err != nil { + return "", fmt.Errorf("Storage %s not avaiable: %s", storageType, err) + } + + disks := make([]SDisk, len(diskSizes)+1) + disks[0].DiskSize = img.ImageSize + if sysDiskSize > 0 && sysDiskSize > img.ImageSize { + disks[0].DiskSize = sysDiskSize + } + disks[0].DiskType = storageType + + for i, sz := range diskSizes { + disks[i+1].DiskSize = sz + disks[i+1].DiskType = storageType + } + + instanceTypes, err := self.zone.region.GetMatchInstanceTypes(cpu, memMB, 0, self.zone.Zone) + if err != nil { + return "", err + } + if len(instanceTypes) == 0 { + return "", fmt.Errorf("instance type %dC%dMB not avaiable", cpu, memMB) + } + + for _, instType := range instanceTypes { + instanceTypeId := instType.InstanceType + log.Debugf("Try instancetype : %s", instanceTypeId) + vmId, err := self.zone.region.CreateInstance(name, imgId, instanceTypeId, secgroupId, self.zone.Zone, desc, passwd, disks, networkId, ipAddr, keypair) + if err != nil { + log.Errorf("Failed for %s: %s", instanceTypeId, err) + } else { + return vmId, nil + } + } + + return "", fmt.Errorf("Failed to create, specification not supported") +} + +func (self *SHost) Refresh() error { + return nil +} + +func (self *SHost) GetAccessIp() string { + return "" +} + +func (self *SHost) GetAccessMac() string { + return "" +} + +func (self *SHost) GetSN() string { + return "" +} + +func (self *SHost) GetCpuCount() int8 { + return 0 +} + +func (self *SHost) GetNodeCount() int8 { + return 0 +} + +func (self *SHost) GetCpuDesc() string { + return "" +} + +func (self *SHost) GetCpuMhz() int { + return 0 +} + +func (self *SHost) GetMemSizeMB() int { + return 0 +} + +func (self *SHost) GetStorageSizeMB() int { + return 0 +} + +func (self *SHost) GetEnabled() bool { + return true +} + +func (self *SHost) GetStatus() string { + return models.HOST_STATUS_RUNNING +} + +func (self *SHost) GetHostStatus() string { + return models.HOST_ONLINE +} + +func (self *SHost) GetHostType() string { + return models.HOST_TYPE_QCLOUD +} + +func (self *SHost) GetStorageType() string { + return models.DISK_TYPE_HYBRID +} + +func (self *SHost) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) { + return self.zone.GetIStorageById(id) +} + +func (self *SHost) GetIStorages() ([]cloudprovider.ICloudStorage, error) { + return self.zone.GetIStorages() +} + +func (self *SHost) GetIVMById(gid string) (cloudprovider.ICloudVM, error) { + parts, _, err := self.zone.region.GetInstances(self.zone.Zone, []string{gid}, 0, 1) + if err != nil { + return nil, err + } + if len(parts) == 0 { + return nil, cloudprovider.ErrNotFound + } + if len(parts) > 1 { + return nil, cloudprovider.ErrDuplicateId + } + parts[0].host = self + return &parts[0], nil +} + +func (self *SHost) GetIVMs() ([]cloudprovider.ICloudVM, error) { + vms := make([]SInstance, 0) + for { + parts, total, err := self.zone.region.GetInstances(self.zone.Zone, nil, len(vms), 50) + if err != nil { + return nil, err + } + vms = append(vms, parts...) + if len(vms) >= total { + break + } + } + ivms := make([]cloudprovider.ICloudVM, len(vms)) + for i := 0; i < len(vms); i++ { + vms[i].host = self + ivms[i] = &vms[i] + } + return ivms, nil +} + +func (self *SHost) GetIWires() ([]cloudprovider.ICloudWire, error) { + return self.zone.GetIWires() +} + +func (self *SHost) GetManagerId() string { + return self.zone.region.client.providerId +} + +func (self *SHost) GetSysInfo() jsonutils.JSONObject { + info := jsonutils.NewDict() + info.Add(jsonutils.NewString(CLOUD_PROVIDER_QCLOUD), "manufacture") + return info +} + +func (self *SHost) IsEmulated() bool { + return true +} diff --git a/pkg/util/qcloud/image.go b/pkg/util/qcloud/image.go new file mode 100644 index 0000000000..0fe586200a --- /dev/null +++ b/pkg/util/qcloud/image.go @@ -0,0 +1,186 @@ +package qcloud + +import ( + "fmt" + "strconv" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" +) + +type ImageStatusType string + +const ( + ImageStatusCreating ImageStatusType = "Creating" + ImageStatusAvailable ImageStatusType = "NORMAL" + ImageStatusUnAvailable ImageStatusType = "UnAvailable" + ImageStatusCreateFailed ImageStatusType = "CreateFailed" +) + +type SImage struct { + storageCache *SStoragecache + + ImageId string // 镜像ID + OsName string // 镜像操作系统 + ImageType string // 镜像类型 + CreatedTime time.Time // 镜像创建时间 + ImageName string // 镜像名称 + ImageDescription string // 镜像描述 + ImageSize int // 镜像大小 + Architecture string // 镜像架构 + ImageState ImageStatusType // 镜像状态 + Platform string // 镜像来源平台 + ImageCreator string // 镜像创建者 + ImageSource string // 镜像来源 + SyncPercent int // 同步百分比 + IsSupportCloudinit bool // 镜像是否支持cloud-init +} + +func (self *SRegion) GetImages(status string, owner string, imageIds []string, name string, offset int, limit int) ([]SImage, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + + filter := 0 + if len(status) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "image-state" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = status + filter++ + } + if imageIds != nil && len(imageIds) > 0 { + for index, imageId := range imageIds { + params[fmt.Sprintf("ImageIds.%d", index)] = imageId + } + } + if len(owner) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "image-type" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = owner + filter++ + } + + if len(name) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "image-name" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = name + filter++ + } + + images := make([]SImage, 0) + if body, err := self.cvmRequest("DescribeImages", params); err != nil { + return nil, 0, err + } else if err := body.Unmarshal(&images, "ImageSet"); err != nil { + return nil, 0, err + } else { + total, _ := body.Int("TotalCount") + return images, int(total), nil + } +} +func (self *SImage) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SImage) GetId() string { + return self.ImageId +} + +func (self *SImage) GetName() string { + return self.ImageName +} + +func (self *SImage) IsEmulated() bool { + return false +} + +func (self *SImage) GetGlobalId() string { + return fmt.Sprintf("%s-%s") +} + +func (self *SImage) Delete() error { + return self.storageCache.region.DeleteImage(self.ImageId) +} + +func (self *SImage) GetStatus() string { + return string(self.ImageState) +} + +func (self *SImage) Refresh() error { + new, err := self.storageCache.region.GetImage(self.ImageId) + if err != nil { + return err + } + return jsonutils.Update(self, new) +} + +func (self *SRegion) GetImage(imageId string) (*SImage, error) { + images, _, err := self.GetImages("", "", []string{imageId}, "", 0, 1) + if err != nil { + return nil, err + } + if len(images) == 0 { + return nil, fmt.Errorf("image %s not found", imageId) + } + return &images[0], nil +} + +func (self *SImage) GetIStoragecache() cloudprovider.ICloudStoragecache { + return self.storageCache +} + +func (self *SRegion) DeleteImage(imageId string) error { + params := make(map[string]string) + params["ImageIds.0"] = imageId + + _, err := self.cvmRequest("DeleteImages", params) + return err +} + +func (self *SRegion) GetImageStatus(imageId string) (ImageStatusType, error) { + image, err := self.GetImage(imageId) + if err != nil { + return "", err + } + return image.ImageState, nil +} + +func (self *SRegion) GetImageByName(name string) (*SImage, error) { + images, _, err := self.GetImages("", "", nil, name, 0, 1) + if err != nil { + return nil, err + } + if len(images) == 0 { + return nil, cloudprovider.ErrNotFound + } + return &images[0], nil +} + +func (self *SRegion) ImportImage(name string, osArch string, osType string, osVersion string, imageUrl string) (*SImage, error) { + params := make(map[string]string) + params["ImageName"] = name + if _, err := strconv.Atoi(osVersion); len(osVersion) == 0 || err != nil { + osVersion = "-" + } + params["OsVersion"] = osVersion // "6|7|8|-" + params["OsType"] = osType // "CentOS|Ubuntu|Debian|OpenSUSE|SUSE|CoreOS|FreeBSD|Other Linux|Windows Server 2008|Windows Server 2012|Windows Server 2016" + params["Architecture"] = osArch // "x86_64|i386" + params["ImageUrl"] = imageUrl + params["Force"] = "true" + + log.Debugf("Upload image with params %#v", params) + + if _, err := self.cvmRequest("ImportImage", params); err != nil { + return nil, err + } else { + for i := 0; i < 3; i++ { + image, err := self.GetImageByName(name) + if err == nil { + return image, nil + } + time.Sleep(time.Minute * time.Duration(i)) + } + return nil, cloudprovider.ErrNotFound + } +} diff --git a/pkg/util/qcloud/instance.go b/pkg/util/qcloud/instance.go new file mode 100644 index 0000000000..9981d6671a --- /dev/null +++ b/pkg/util/qcloud/instance.go @@ -0,0 +1,730 @@ +package qcloud + +import ( + "fmt" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/pkg/util/secrules" + "yunion.io/x/pkg/utils" +) + +const ( + // PENDING:表示创建中 + // LAUNCH_FAILED:表示创建失败 + // RUNNING:表示运行中 + // STOPPED:表示关机 + // STARTING:表示开机中 + // STOPPING:表示关机中 + // REBOOTING:表示重启中 + // SHUTDOWN:表示停止待销毁 + // TERMINATING:表示销毁中。 + + InstanceStatusStopped = "STOPPED" + InstanceStatusRunning = "RUNNING" + InstanceStatusStopping = "STOPPING" + InstanceStatusStarting = "STARTING" +) + +type SystemDisk struct { + DiskType string //系统盘类型。系统盘类型限制详见CVM实例配置。取值范围:LOCAL_BASIC:本地硬盘 LOCAL_SSD:本地SSD硬盘 CLOUD_BASIC:普通云硬盘 CLOUD_SSD:SSD云硬盘 CLOUD_PREMIUM:高性能云硬盘 默认取值:CLOUD_BASIC。 + DiskId string // 系统盘ID。LOCAL_BASIC 和 LOCAL_SSD 类型没有ID。暂时不支持该参数。 + DiskSize float32 //系统盘大小,单位:GB。默认值为 50 +} + +type DataDisk struct { + DiskSize float32 // 数据盘大小,单位:GB。最小调整步长为10G,不同数据盘类型取值范围不同,具体限制详见:CVM实例配置。默认值为0,表示不购买数据盘。更多限制详见产品文档。 + DiskType string // 数据盘类型。数据盘类型限制详见CVM实例配置。取值范围:LOCAL_BASIC:本地硬盘 LOCAL_SSD:本地SSD硬盘 CLOUD_BASIC:普通云硬盘 CLOUD_PREMIUM:高性能云硬盘 CLOUD_SSD:SSD云硬盘 默认取值:LOCAL_BASIC。 该参数对ResizeInstanceDisk接口无效。 + DiskId string // 数据盘ID。LOCAL_BASIC 和 LOCAL_SSD 类型没有ID。暂时不支持该参数。 + DeleteWithInstance bool // 数据盘是否随子机销毁。取值范围:TRUE:子机销毁时,销毁数据盘 FALSE:子机销毁时,保留数据盘 默认取值:TRUE 该参数目前仅用于 RunInstances 接口。 +} + +type InternetAccessible struct { + InternetChargeType string //网络计费类型。取值范围:BANDWIDTH_PREPAID:预付费按带宽结算 TRAFFIC_POSTPAID_BY_HOUR:流量按小时后付费 BANDWIDTH_POSTPAID_BY_HOUR:带宽按小时后付费 BANDWIDTH_PACKAGE:带宽包用户 默认取值:非带宽包用户默认与子机付费类型保持一致。 + InternetMaxBandwidthOut int // 公网出带宽上限,单位:Mbps。默认值:0Mbps。不同机型带宽上限范围不一致,具体限制详见购买网络带宽。 + PublicIpAssigned bool // 是否分配公网IP。取值范围: TRUE:表示分配公网IP FALSE:表示不分配公网IP 当公网带宽大于0Mbps时,可自由选择开通与否,默认开通公网IP;当公网带宽为0,则不允许分配公网IP。 +} + +type VirtualPrivateCloud struct { + VpcId string // 私有网络ID,形如vpc-xxx。有效的VpcId可通过登录控制台查询;也可以调用接口 DescribeVpcEx ,从接口返回中的unVpcId字段获取。 + SubnetId string // 私有网络子网ID,形如subnet-xxx。有效的私有网络子网ID可通过登录控制台查询;也可以调用接口 DescribeSubnets ,从接口返回中的unSubnetId字段获取。 + AsVpcGateway bool // 是否用作公网网关。公网网关只有在实例拥有公网IP以及处于私有网络下时才能正常使用。取值范围:TRUE:表示用作公网网关 FALSE:表示不用作公网网关 默认取值:FALSE。 + PrivateIpAddresses []string // 私有网络子网 IP 数组,在创建实例、修改实例vpc属性操作中可使用此参数。当前仅批量创建多台实例时支持传入相同子网的多个 IP。 +} + +type LoginSettings struct { + Password string //实例登录密码。不同操作系统类型密码复杂度限制不一样,具体如下:Linux实例密码必须8到16位,至少包括两项[a-z,A-Z]、[0-9] 和 [( ) ~ ! @ # $ % ^ & * - + = | { } [ ] : ; ' , . ? / ]中的特殊符号。
  • Windows实例密码必须12到16位,至少包括三项[a-z],[A-Z],[0-9] 和 [( ) ~ ! @ # $ % ^ & * - + = { } [ ] : ; ' , . ? /]中的特殊符号。 若不指定该参数,则由系统随机生成密码,并通过站内信方式通知到用户。 + KeyIds []string // 密钥ID列表。关联密钥后,就可以通过对应的私钥来访问实例;KeyId可通过接口DescribeKeyPairs获取,密钥与密码不能同时指定,同时Windows操作系统不支持指定密钥。当前仅支持购买的时候指定一个密钥。 + KeepImageLogin string // 保持镜像的原始设置。该参数与Password或KeyIds.N不能同时指定。只有使用自定义镜像、共享镜像或外部导入镜像创建实例时才能指定该参数为TRUE。取值范围: TRUE:表示保持镜像的登录设置 FALSE:表示不保持镜像的登录设置 默认取值:FALSE。 +} + +type Tag struct { + Key string + Value string +} + +type SInstance struct { + host *SHost + + image *SImage + idisks []cloudprovider.ICloudDisk + + Placement Placement + InstanceId string + InstanceType string + CPU int8 + Memory int + RestrictState string //NORMAL EXPIRED PROTECTIVELY_ISOLATED + InstanceName string + InstanceChargeType InstanceChargeType //PREPAID:表示预付费,即包年包月 POSTPAID_BY_HOUR:表示后付费,即按量计费 CDHPAID:CDH付费,即只对CDH计费,不对CDH上的实例计费。 + SystemDisk SystemDisk //实例系统盘信息。 + DataDisks []DataDisk //实例数据盘信息。只包含随实例购买的数据盘。 + PrivateIpAddresses []string //实例主网卡的内网IP列表。 + PublicIpAddresses []string //实例主网卡的公网IP列表。 + InternetAccessible InternetAccessible //实例带宽信息。 + VirtualPrivateCloud VirtualPrivateCloud //实例所属虚拟私有网络信息。 + ImageId string // 生产实例所使用的镜像ID。 + RenewFlag string // 自动续费标识。取值范围:NOTIFY_AND_MANUAL_RENEW:表示通知即将过期,但不自动续费 NOTIFY_AND_AUTO_RENEW:表示通知即将过期,而且自动续费 DISABLE_NOTIFY_AND_MANUAL_RENEW:表示不通知即将过期,也不自动续费。 + CreatedTime time.Time // 创建时间。按照ISO8601标准表示,并且使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ。 + ExpiredTime time.Time // 到期时间。按照ISO8601标准表示,并且使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ。 + OsName string // 操作系统名称。 + SecurityGroupIds []string // 实例所属安全组。该参数可以通过调用 DescribeSecurityGroups 的返回值中的sgId字段来获取。 + LoginSettings LoginSettings //实例登录设置。目前只返回实例所关联的密钥。 + InstanceState string // 实例状态。取值范围:PENDING:表示创建中 LAUNCH_FAILED:表示创建失败 RUNNING:表示运行中 STOPPED:表示关机 STARTING:表示开机中 STOPPING:表示关机中 REBOOTING:表示重启中 SHUTDOWN:表示停止待销毁 TERMINATING:表示销毁中。 + Tags []Tag +} + +func (self *SRegion) GetInstances(zoneId string, ids []string, offset int, limit int) ([]SInstance, int, error) { + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + instances := make([]SInstance, 0) + if ids != nil && len(ids) > 0 { + for index, id := range ids { + params[fmt.Sprintf("InstanceIds.%d", index)] = id + } + } else { + if len(zoneId) > 0 { + params["Filters.0.Name"] = "zone" + params["Filters.0.Values.0"] = zoneId + } + } + body, err := self.cvmRequest("DescribeInstances", params) + if err != nil { + return nil, 0, err + } + err = body.Unmarshal(&instances, "InstanceSet") + if err != nil { + return nil, 0, err + } + total, _ := body.Float("TotalCount") + return instances, int(total), nil +} + +func (self *SInstance) GetMetadata() *jsonutils.JSONDict { + data := jsonutils.NewDict() + if self.image == nil { + image, err := self.host.zone.region.GetImage(self.ImageId) + if err == nil { + self.image = image + } + } + + if self.image != nil { + data.Add(jsonutils.NewString(self.image.OsName), "os_distribution") + } + + return data +} + +func (self *SInstance) GetCreateTime() time.Time { + return self.CreatedTime +} + +func (self *SInstance) GetIHost() cloudprovider.ICloudHost { + return self.host +} + +func (self *SInstance) GetId() string { + return self.InstanceId +} + +func (self *SInstance) GetName() string { + return self.InstanceName +} + +func (self *SInstance) GetGlobalId() string { + return self.InstanceId +} + +func (self *SInstance) IsEmulated() bool { + return false +} + +func (self *SInstance) getVpc() (*SVpc, error) { + return self.host.zone.region.getVpc(self.VirtualPrivateCloud.VpcId) +} + +func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) { + disks, total, err := self.host.zone.region.GetDisks(self.InstanceId, "", "", nil, 0, 50) + if err != nil { + log.Errorf("fetchDisks fail %s", err) + return nil, err + } + if total > len(disks) { + disks, _, err = self.host.zone.region.GetDisks(self.InstanceId, "", "", nil, 0, total) + } + idisks := make([]cloudprovider.ICloudDisk, len(disks)) + for i := 0; i < len(disks); i += 1 { + store, err := self.host.zone.getStorageByCategory(disks[i].DiskType) + if err != nil { + return nil, err + } + disks[i].storage = store + idisks[i] = &disks[i] + } + if utils.IsInStringArray(self.SystemDisk.DiskType, []string{"LOCAL_BASIC", "LOCAL_SSD"}) { + storage := SLocalStorage{zone: self.host.zone, storageType: self.SystemDisk.DiskType} + disk := SLocalDisk{ + storage: &storage, + DiskId: self.SystemDisk.DiskId, + DiskSize: self.SystemDisk.DiskSize, + DisktType: self.SystemDisk.DiskType, + DiskUsage: "SYSTEM_DISK", + } + idisks = append(idisks, &disk) + } + + for i := 0; i < len(self.DataDisks); i++ { + if utils.IsInStringArray(self.DataDisks[i].DiskType, []string{"LOCAL_BASIC", "LOCAL_SSD"}) { + storage := SLocalStorage{zone: self.host.zone, storageType: self.DataDisks[i].DiskType} + disk := SLocalDisk{ + storage: &storage, + DiskId: self.DataDisks[i].DiskId, + DiskSize: self.DataDisks[i].DiskSize, + DisktType: self.DataDisks[i].DiskType, + DiskUsage: "DATA_DISK", + } + idisks = append(idisks, &disk) + } + } + + return idisks, nil +} + +func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) { + nics := make([]cloudprovider.ICloudNic, 0) + for _, ip := range self.VirtualPrivateCloud.PrivateIpAddresses { + nic := SInstanceNic{instance: self, ipAddr: ip} + nics = append(nics, &nic) + } + return nics, nil +} + +func (self *SInstance) GetVcpuCount() int8 { + return self.CPU +} + +func (self *SInstance) GetVmemSizeMB() int { + return self.Memory * 1024 +} + +func (self *SInstance) GetBootOrder() string { + return "dcn" +} + +func (self *SInstance) GetVga() string { + return "std" +} + +func (self *SInstance) GetVdi() string { + return "vnc" +} + +func (self *SInstance) GetOSType() string { + if self.image == nil { + image, err := self.host.zone.region.GetImage(self.ImageId) + if err != nil { + return self.OsName + } + self.image = image + } + if self.image != nil { + switch self.image.Platform { + case "Windows": + return "Windows" + case "CentOS", "Debian", "FreeBSD", "SUSE", "openSUSE": + return "Linux" + default: + return "Linux" + } + } + return self.OsName +} + +func (self *SInstance) GetOSName() string { + return self.OsName +} + +func (self *SInstance) GetBios() string { + return "BIOS" +} + +func (self *SInstance) GetMachine() string { + return "pc" +} + +func (self *SInstance) GetStatus() string { + switch self.InstanceState { + case "PENDING": + return models.VM_DEPLOYING + case "LAUNCH_FAILED": + return models.VM_DEPLOY_FAILED + case "RUNNING": + return models.VM_RUNNING + case "STOPPED": + return models.VM_READY + case "STARTING", "REBOOTING": + return models.VM_STARTING + case "STOPPING": + return models.VM_STOPPING + case "SHUTDOWN": + return models.VM_DEALLOCATED + case "TERMINATING": + return models.VM_DELETING + default: + return models.VM_UNKNOWN + } +} + +func (self *SInstance) Refresh() error { + new, err := self.host.zone.region.GetInstance(self.InstanceId) + if err != nil { + return err + } + return jsonutils.Update(self, new) +} + +func (self *SInstance) GetHypervisor() string { + return models.HYPERVISOR_QCLOUD +} + +func (self *SInstance) StartVM() error { + timeout := 300 * time.Second + interval := 15 * time.Second + + startTime := time.Now() + for time.Now().Sub(startTime) < timeout { + err := self.Refresh() + if err != nil { + return err + } + log.Debugf("status %s expect %s", self.GetStatus(), models.VM_RUNNING) + if self.GetStatus() == models.VM_RUNNING { + return nil + } + if self.GetStatus() == models.VM_READY { + err := self.host.zone.region.StartVM(self.InstanceId) + if err != nil { + return err + } + } + time.Sleep(interval) + } + return cloudprovider.ErrTimeout +} + +func (self *SInstance) StopVM(isForce bool) error { + err := self.host.zone.region.StopVM(self.InstanceId, isForce) + if err != nil { + return err + } + return cloudprovider.WaitStatus(self, models.VM_READY, 10*time.Second, 300*time.Second) // 5mintues +} + +func (self *SInstance) GetVNCInfo() (jsonutils.JSONObject, error) { + url, err := self.host.zone.region.GetInstanceVNCUrl(self.InstanceId) + if err != nil { + return nil, err + } + ret := jsonutils.NewDict() + ret.Add(jsonutils.NewString("https://img.qcloud.com/qcloud/app/active_vnc/index.html?InstanceVncUrl="+url), "url") + ret.Add(jsonutils.NewString("qcloud"), "protocol") + ret.Add(jsonutils.NewString(self.InstanceId), "instance_id") + return ret, nil +} + +func (self *SInstance) UpdateVM(name string) error { + return self.host.zone.region.UpdateVM(self.InstanceId, name) +} + +func (self *SInstance) DeployVM(name string, password string, publicKey string, deleteKeypair bool, description string) error { + var keypairName string + // if len(publicKey) > 0 { + // var err error + // keypairName, err = self.host.zone.region.syncKeypair(publicKey) + // if err != nil { + // return err + // } + // } + + return self.host.zone.region.DeployVM(self.InstanceId, name, password, keypairName, deleteKeypair, description) +} + +func (self *SInstance) RebuildRoot(imageId string, passwd string, publicKey string, sysSizeGB int) (string, error) { + keypair := "" + // if len(publicKey) > 0 { + // var err error + // keypair, err = self.host.zone.region.syncKeypair(publicKey) + // if err != nil { + // return "", err + // } + // } + return self.host.zone.region.ReplaceSystemDisk(self.InstanceId, imageId, passwd, keypair, sysSizeGB) +} + +func (self *SInstance) ChangeConfig(instanceId string, ncpu int, vmem int) error { + return nil + //return self.host.zone.region.ChangeVMConfig(self.ZoneId, self.InstanceId, ncpu, vmem, nil) +} + +func (self *SInstance) AttachDisk(diskId string) error { + return self.host.zone.region.AttachDisk(self.InstanceId, diskId) +} + +func (self *SInstance) DetachDisk(diskId string) error { + return self.host.zone.region.DetachDisk(self.InstanceId, diskId) +} + +func (self *SRegion) GetInstance(instanceId string) (*SInstance, error) { + instances, _, err := self.GetInstances("", []string{instanceId}, 0, 1) + if err != nil { + return nil, err + } + if len(instances) == 0 { + return nil, cloudprovider.ErrNotFound + } + return &instances[0], nil +} + +func (self *SRegion) CreateInstance(name string, imageId string, instanceType string, securityGroupId string, + zoneId string, desc string, passwd string, disks []SDisk, networkId string, ipAddr string, + keypair string) (string, error) { + params := make(map[string]string) + params["Region"] = self.Region + params["ImageId"] = imageId + params["InstanceType"] = instanceType + //params["SecurityGroupId"] = securityGroupId + params["Placement.Zone"] = zoneId + params["InstanceName"] = name + params["Description"] = desc + params["InstanceChargeType"] = "POSTPAID_BY_HOUR" + params["InternetAccessible.InternetMaxBandwidthOut"] = "100" + params["HostName"] = name + if len(passwd) > 0 { + params["LoginSettings.Password"] = passwd + } else { + params["PasswordInherit"] = "True" + } + //params["IoOptimized"] = "optimized" + for i, d := range disks { + if i == 0 { + params["SystemDisk.DiskType"] = d.DiskType + params["SystemDisk.DiskSize"] = fmt.Sprintf("%d", d.DiskSize) + } else { + params[fmt.Sprintf("DataDisks.%d.DiskSize", i-1)] = fmt.Sprintf("%d", d.DiskSize) + params[fmt.Sprintf("DataDisks.%d.DiskType", i-1)] = d.DiskType + } + } + network, err := self.GetNetwork(networkId) + if err != nil { + return "", err + } + params["VirtualPrivateCloud.SubnetId"] = networkId + params["VirtualPrivateCloud.VpcId"] = network.VpcId + if len(ipAddr) > 0 { + params["VirtualPrivateCloud.PrivateIpAddresses.0"] = ipAddr + } + // if len(keypair) > 0 { + // params["KeyPairName"] = keypair + // } + params["ClientToken"] = utils.GenRequestId(20) + //log.Errorf("create params: %s", jsonutils.Marshal(params).PrettyString()) + instanceIdSet := []string{} + body, err := self.cvmRequest("RunInstances", params) + if err != nil { + log.Errorf("RunInstances fail %s", err) + return "", err + } + err = body.Unmarshal(&instanceIdSet, "InstanceIdSet") + if err == nil && len(instanceIdSet) > 0 { + return instanceIdSet[0], nil + } + return "", fmt.Errorf("Failed to create instance") +} + +func (self *SRegion) doStartVM(instanceId string) error { + return self.instanceOperation(instanceId, "StartInstances", nil) +} + +func (self *SRegion) doStopVM(instanceId string, isForce bool) error { + params := make(map[string]string) + if isForce { + params["ForceStop"] = "true" + } else { + params["ForceStop"] = "false" + } + return self.instanceOperation(instanceId, "StopInstances", params) +} + +func (self *SRegion) doDeleteVM(instanceId string) error { + params := make(map[string]string) + return self.instanceOperation(instanceId, "TerminateInstances", params) +} + +func (self *SRegion) StartVM(instanceId string) error { + status, err := self.GetInstanceStatus(instanceId) + if err != nil { + log.Errorf("Fail to get instance status on StartVM: %s", err) + return err + } + if status != InstanceStatusStopped { + log.Errorf("StartVM: vm status is %s expect %s", status, InstanceStatusStopped) + return cloudprovider.ErrInvalidStatus + } + return self.doStartVM(instanceId) +} + +func (self *SRegion) StopVM(instanceId string, isForce bool) error { + status, err := self.GetInstanceStatus(instanceId) + if err != nil { + log.Errorf("Fail to get instance status on StopVM: %s", err) + return err + } + if status != InstanceStatusRunning { + log.Errorf("StopVM: vm status is %s expect %s", status, InstanceStatusRunning) + return cloudprovider.ErrInvalidStatus + } + return self.doStopVM(instanceId, isForce) +} + +func (self *SRegion) DeleteVM(instanceId string) error { + status, err := self.GetInstanceStatus(instanceId) + if err != nil { + log.Errorf("Fail to get instance status on DeleteVM: %s", err) + return err + } + log.Debugf("Instance status on delete is %s", status) + if status != InstanceStatusStopped { + log.Warningf("DeleteVM: vm status is %s expect %s", status, InstanceStatusStopped) + } + return self.doDeleteVM(instanceId) +} + +func (self *SRegion) DeployVM(instanceId string, name string, password string, keypairName string, deleteKeypair bool, description string) error { + instance, err := self.GetInstance(instanceId) + if err != nil { + return err + } + + // // 修改密钥时直接返回 + // if deleteKeypair { + // err = self.DetachKeyPair(instanceId, instance.KeyPairName) + // if err != nil { + // return err + // } + // } + + // if len(keypairName) > 0 { + // err = self.AttachKeypair(instanceId, keypairName) + // if err != nil { + // return err + // } + // } + + params := make(map[string]string) + + // if resetPassword { + // params["Password"] = seclib2.RandomPassword2(12) + // } + // 指定密码的情况下,使用指定的密码 + if len(password) > 0 { + params["Password"] = password + } + + if len(name) > 0 && instance.InstanceName != name { + params["InstanceName"] = name + params["HostName"] = name + } + + // if len(description) > 0 && instance.Description != description { + // params["Description"] = description + // } + + if len(params) > 0 { + return self.modifyInstanceAttribute(instanceId, params) + } else { + return nil + } +} + +func (self *SInstance) DeleteVM() error { + for { + err := self.host.zone.region.DeleteVM(self.InstanceId) + if err != nil { + // if isError(err, "IncorrectInstanceStatus.Initializing") { + // log.Infof("The instance is initializing, try later ...") + // time.Sleep(10 * time.Second) + // } else { + // return err + // } + } else { + break + } + } + return cloudprovider.WaitDeleted(self, 10*time.Second, 300*time.Second) // 5minutes +} + +func (self *SRegion) UpdateVM(instanceId string, hostname string) error { + params := make(map[string]string) + params["HostName"] = hostname + return self.modifyInstanceAttribute(instanceId, params) +} + +func (self *SRegion) modifyInstanceAttribute(instanceId string, params map[string]string) error { + return self.instanceOperation(instanceId, "ModifyInstanceAttribute", params) +} + +func (self *SRegion) ReplaceSystemDisk(instanceId string, imageId string, passwd string, keypairName string, sysDiskSizeGB int) (string, error) { + params := make(map[string]string) + params["RegionId"] = self.Region + params["InstanceId"] = instanceId + params["ImageId"] = imageId + if len(passwd) > 0 { + params["Password"] = passwd + } else { + params["PasswordInherit"] = "True" + } + if len(keypairName) > 0 { + params["KeyPairName"] = keypairName + } + if sysDiskSizeGB > 0 { + params["SystemDisk.Size"] = fmt.Sprintf("%d", sysDiskSizeGB) + } + body, err := self.cvmRequest("ReplaceSystemDisk", params) + if err != nil { + return "", err + } + // log.Debugf("%s", body.String()) + return body.GetString("DiskId") +} + +func (self *SRegion) ChangeVMConfig(zoneId string, instanceId string, ncpu int, vmem int, disks []*SDisk) error { + // todo: support change disk config? + // params := make(map[string]string) + // instanceTypes, e := self.GetMatchInstanceTypes(ncpu, vmem, 0, zoneId) + // if e != nil { + // return e + // } + + // for _, instancetype := range instanceTypes { + // params["InstanceType"] = instancetype.InstanceTypeId + // params["ClientToken"] = utils.GenRequestId(20) + // if err := self.instanceOperation(instanceId, "ModifyInstanceSpec", params); err != nil { + // log.Errorf("Failed for %s: %s", instancetype.InstanceTypeId, err) + // } else { + // return nil + // } + // } + + return fmt.Errorf("Failed to change vm config, specification not supported") +} + +func (self *SRegion) DetachDisk(instanceId string, diskId string) error { + params := make(map[string]string) + params["InstanceId"] = instanceId + params["DiskId"] = diskId + log.Infof("Detach instance %s disk %s", instanceId, diskId) + _, err := self.cvmRequest("DetachDisk", params) + if err != nil { + log.Errorf("DetachDisk %s to %s fail %s", diskId, instanceId, err) + return err + } + + return nil +} + +func (self *SRegion) AttachDisk(instanceId string, diskId string) error { + params := make(map[string]string) + params["InstanceId"] = instanceId + params["DiskId"] = diskId + _, err := self.cvmRequest("AttachDisk", params) + if err != nil { + log.Errorf("AttachDisk %s to %s fail %s", diskId, instanceId, err) + return err + } + + return nil +} + +func (self *SInstance) SyncSecurityGroup(secgroupId string, name string, rules []secrules.SecurityRule) error { + // if vpc, err := self.getVpc(); err != nil { + // return err + // } else if len(secgroupId) == 0 { + // for index, secgrpId := range self.SecurityGroupIds.SecurityGroupId { + // if err := vpc.revokeSecurityGroup(secgrpId, self.InstanceId, index == 0); err != nil { + // return err + // } + // } + // } else if secgrpId, err := vpc.SyncSecurityGroup(secgroupId, name, rules); err != nil { + // return err + // } else if err := vpc.assignSecurityGroup(secgrpId, self.InstanceId); err != nil { + // return err + // } else { + // for _, secgroupId := range self.SecurityGroupIds.SecurityGroupId { + // if secgroupId != secgrpId { + // if err := vpc.revokeSecurityGroup(secgroupId, self.InstanceId, false); err != nil { + // return err + // } + // } + // } + // self.SecurityGroupIds.SecurityGroupId = []string{secgrpId} + // } + return nil +} + +func (self *SInstance) GetIEIP() (cloudprovider.ICloudEIP, error) { + if len(self.PublicIpAddresses) > 0 { + eip := SEipAddress{region: self.host.zone.region} + eip.AddressIp = self.PublicIpAddresses[0] + eip.InstanceId = self.InstanceId + eip.AddressId = self.InstanceId + eip.AddressName = self.PublicIpAddresses[0] + eip.AddressType = "WanIP" + eip.AddressStatus = EIP_STATUS_INUSE + return &eip, nil + } + return nil, nil +} + +func (self *SInstance) GetBillingType() string { + switch self.InstanceChargeType { + case PrePaidInstanceChargeType: + return models.BILLING_TYPE_PREPAID + case PostPaidInstanceChargeType: + return models.BILLING_TYPE_POSTPAID + default: + return models.BILLING_TYPE_PREPAID + } +} + +func (self *SInstance) GetExpiredAt() time.Time { + return self.ExpiredTime +} + +func (self *SInstance) UpdateUserData(userData string) error { + return cloudprovider.ErrNotImplemented +} diff --git a/pkg/util/qcloud/instancenic.go b/pkg/util/qcloud/instancenic.go new file mode 100644 index 0000000000..82e36130dd --- /dev/null +++ b/pkg/util/qcloud/instancenic.go @@ -0,0 +1,40 @@ +package qcloud + +import ( + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/pkg/util/netutils" +) + +type SInstanceNic struct { + instance *SInstance + ipAddr string +} + +func (self *SInstanceNic) GetIP() string { + return self.ipAddr +} + +func (self *SInstanceNic) GetMAC() string { + ip, _ := netutils.NewIPV4Addr(self.ipAddr) + return ip.ToMac("00:16:") +} + +func (self *SInstanceNic) GetDriver() string { + return "virtio" +} + +func (self *SInstanceNic) GetINetwork() cloudprovider.ICloudNetwork { + networkId := self.instance.VirtualPrivateCloud.VpcId + wires, err := self.instance.host.GetIWires() + if err != nil { + return nil + } + for i := 0; i < len(wires); i++ { + wire := wires[i].(*SWire) + net := wire.getNetworkById(networkId) + if net != nil { + return net + } + } + return nil +} diff --git a/pkg/util/qcloud/instancetype.go b/pkg/util/qcloud/instancetype.go new file mode 100644 index 0000000000..09b2f2cb72 --- /dev/null +++ b/pkg/util/qcloud/instancetype.go @@ -0,0 +1,42 @@ +package qcloud + +import "yunion.io/x/log" + +// "time" + +// {"CpuCoreCount":1,"EniQuantity":1,"GPUAmount":0,"GPUSpec":"","InstanceTypeFamily":"ecs.t1","InstanceTypeId":"ecs.t1.xsmall","LocalStorageCategory":"","MemorySize":0.500000} +// InstanceBandwidthRx":26214400,"InstanceBandwidthTx":26214400,"InstancePpsRx":4500000,"InstancePpsTx":4500000 + +type SInstanceType struct { + Zone string // 可用区。 + InstanceType string // 实例机型。 + InstanceFamily string // 实例机型系列。 + GPU int // GPU核数,单位:核。 + CPU int // CPU核数,单位:核。 + Memory int // 内存容量,单位:GB。 + CbsSupport string // 是否支持云硬盘。取值范围:TRUE:表示支持云硬盘;FALSE:表示不支持云硬盘。 + InstanceTypeState string // 机型状态。取值范围:AVAILABLE:表示机型可用;UNAVAILABLE:表示机型不可用。 +} + +func (self *SRegion) GetInstanceTypes() ([]SInstanceType, error) { + params := make(map[string]string) + params["Region"] = self.Region + + body, err := self.cvmRequest("DescribeInstanceTypeConfigs", params) + if err != nil { + log.Errorf("DescribeInstanceTypeConfigs fail %s", err) + return nil, err + } + + instanceTypes := make([]SInstanceType, 0) + err = body.Unmarshal(&instanceTypes, "InstanceTypeConfigSet") + if err != nil { + log.Errorf("Unmarshal instance type details fail %s", err) + return nil, err + } + return instanceTypes, nil +} + +func (self *SInstanceType) memoryMB() int { + return int(self.Memory * 1024) +} diff --git a/pkg/util/qcloud/keypair.go b/pkg/util/qcloud/keypair.go new file mode 100644 index 0000000000..012b478788 --- /dev/null +++ b/pkg/util/qcloud/keypair.go @@ -0,0 +1,143 @@ +package qcloud + +import ( + "fmt" + "strconv" + "time" + + "github.com/aokoli/goutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" +) + +type SKeypair struct { + AssociatedInstanceIds []string + CreateTime time.Time + Description string + KeyId string + KeyName string + PublicKey string +} + +func (self *SRegion) GetKeypairs(name string, keyIds []string, offset int, limit int) ([]SKeypair, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + params := map[string]string{} + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + + if len(keyIds) > 0 { + for i := 0; i < len(keyIds); i++ { + params[fmt.Sprintf("KeyIds.%d", i)] = keyIds[i] + } + } else { + if len(name) > 0 { + params["Filters.0.Name"] = "key-name" + params["Filters.0.Values.0"] = name + } + } + + body, err := self.cvmRequest("DescribeKeyPairs", params) + if err != nil { + log.Errorf("GetKeypairs fail %s", err) + return nil, 0, err + } + + keypairs := []SKeypair{} + err = body.Unmarshal(&keypairs, "KeyPairSet") + if err != nil { + log.Errorf("Unmarshal keypair fail %s", err) + return nil, 0, err + } + total, _ := body.Int("TotalCount") + return keypairs, int(total), nil +} + +func (self *SRegion) ImportKeypair(name string, pubKey string) (*SKeypair, error) { + params := map[string]string{} + params["PublicKey"] = pubKey + params["ProjectId"] = "0" + params["KeyName"] = name + + body, err := self.cvmRequest("ImportKeyPair", params) + if err != nil { + log.Errorf("ImportKeypair fail %s", err) + return nil, err + } + + keypairID, err := body.GetString("KeyId") + if err != nil { + return nil, err + } + keypairs, total, err := self.GetKeypairs("", []string{keypairID}, 0, 1) + if err != nil { + return nil, err + } + if total != 1 { + return nil, cloudprovider.ErrNotFound + } + return &keypairs[0], nil +} + +func (self *SRegion) AttachKeypair(instanceId string, keypairId string) error { + params := map[string]string{} + params["InstanceIds.0"] = instanceId + params["KeyIds.0"] = keypairId + _, err := self.cvmRequest("AssociateInstancesKeyPairs", params) + return err +} + +func (self *SRegion) DetachKeyPair(instanceId string, keypairId string) error { + params := make(map[string]string) + params["InstanceIds.0"] = instanceId + params["KeyIds.0"] = keypairId + _, err := self.cvmRequest("DisassociateInstancesKeyPairs", params) + return err +} + +func (self *SRegion) CreateKeyPair(name string) (*SKeypair, error) { + params := make(map[string]string) + params["KeyName"] = name + params["ProjectId"] = "0" + body, err := self.cvmRequest("CreateKeyPair", params) + keypair := SKeypair{} + err = body.Unmarshal(&keypair, "KeyPair") + if err != nil { + return nil, err + } + return &keypair, err +} + +func (self *SRegion) lookUpAliyunKeypair(publicKey string) (string, error) { + keypairs, _, err := self.GetKeypairs("", []string{}, 0, 0) + if err != nil { + return "", err + } + + for i := 0; i < len(keypairs); i++ { + if keypairs[i].PublicKey == publicKey { + return keypairs[i].KeyId, nil + } + } + return "", cloudprovider.ErrNotFound +} + +func (self *SRegion) syncKeypair(publicKey string) (string, error) { + keypairId, e := self.lookUpAliyunKeypair(publicKey) + if e == nil { + return keypairId, nil + } + + prefix, e := goutils.RandomAlphabetic(6) + if e != nil { + return "", fmt.Errorf("publicKey error %s", e) + } + + name := prefix + strconv.FormatInt(time.Now().Unix(), 10) + keypair, err := self.ImportKeypair(name, publicKey) + if err != nil { + return "", err + } + return keypair.KeyId, nil +} diff --git a/pkg/util/qcloud/latitud_and_longitude.go b/pkg/util/qcloud/latitud_and_longitude.go new file mode 100644 index 0000000000..bc5e9999e5 --- /dev/null +++ b/pkg/util/qcloud/latitud_and_longitude.go @@ -0,0 +1,23 @@ +package qcloud + +var LatitudeAndLongitude = map[string]map[string]float32{ + "ap-bangkok": {"latitude": 13.756330, "longitude": 100.501762}, // 腾讯云 亚太地区(曼谷) + "ap-beijing": {"latitude": 39.904202, "longitude": 116.407394}, // 腾讯云 华北地区(北京) + "ap-chengdu": {"latitude": 30.572815, "longitude": 104.066803}, // 腾讯云 西南地区(成都) + "ap-chongqing": {"latitude": 29.431585, "longitude": 106.912254}, // 腾讯云 西南地区(重庆) + "ap-guangzhou": {"latitude": 23.129110, "longitude": 113.264381}, // 腾讯云 华南地区(广州) + "ap-guangzhou-open": {"latitude": 23.126593, "longitude": 113.273415}, // 腾讯云 华南地区(广州Open) + "ap-hongkong": {"latitude": 22.396427, "longitude": 114.109497}, // 腾讯云 东南亚地区(香港) + "ap-mumbai": {"latitude": 19.075983, "longitude": 72.877655}, // 腾讯云 亚太地区(孟买) + "ap-seoul": {"latitude": 37.566536, "longitude": 126.977966}, // 腾讯云 东南亚地区(首尔) + "ap-shanghai": {"latitude": 31.230391, "longitude": 121.473701}, // 腾讯云 华东地区(上海) + "ap-shanghai-fsi": {"latitude": 31.311033, "longitude": 121.536217}, // 腾讯云 华东地区(上海金融) + "ap-shenzhen-fsi": {"latitude": 22.531544, "longitude": 114.025467}, // 腾讯云 华南地区(深圳金融) + "ap-singapore": {"latitude": 1.352083, "longitude": 103.819839}, // 腾讯云 东南亚地区(新加坡) + "ap-tokyo": {"latitude": 35.709026, "longitude": 139.731995}, // 腾讯云 亚太地区(东京) + "eu-frankfurt": {"latitude": 51.165691, "longitude": 10.451526}, // 腾讯云 欧洲地区(德国) + "eu-moscow": {"latitude": 55.755825, "longitude": 37.617298}, // 腾讯云 欧洲地区(莫斯科) + "na-ashburn": {"latitude": 37.431572, "longitude": -78.656891}, // 腾讯云 美国东部(弗吉尼亚) + "na-siliconvalley": {"latitude": 37.387474, "longitude": -122.057541}, // 腾讯云 美国西部(硅谷) + "na-toronto": {"latitude": 43.653225, "longitude": -79.383186}, // 腾讯云 北美地区(多伦多) +} diff --git a/pkg/util/qcloud/localdisk.go b/pkg/util/qcloud/localdisk.go new file mode 100644 index 0000000000..ad91c8a764 --- /dev/null +++ b/pkg/util/qcloud/localdisk.go @@ -0,0 +1,128 @@ +package qcloud + +import ( + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type SLocalDisk struct { + storage *SLocalStorage + DiskId string + DiskSize float32 + DisktType string + DiskUsage string +} + +func (self *SLocalDisk) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SLocalDisk) CreateISnapshot(name, desc string) (cloudprovider.ICloudSnapshot, error) { + return nil, cloudprovider.ErrNotSupported +} + +func (self *SLocalDisk) Delete() error { + return nil +} + +func (self *SLocalDisk) GetBillingType() string { + return "" +} + +func (self *SLocalDisk) GetFsFormat() string { + return "" +} + +func (self *SLocalDisk) GetIsNonPersistent() bool { + return false +} + +func (self *SLocalDisk) GetDriver() string { + return "scsi" +} + +func (self *SLocalDisk) GetCacheMode() string { + return "none" +} + +func (self *SLocalDisk) GetMountpoint() string { + return "" +} + +func (self *SLocalDisk) GetDiskFormat() string { + return "vhd" +} + +func (self *SLocalDisk) GetDiskSizeMB() int { + return int(self.DiskSize) * 1024 +} + +func (self *SLocalDisk) GetIsAutoDelete() bool { + return true +} + +func (self *SLocalDisk) GetExpiredAt() time.Time { + return time.Now() +} + +func (self *SLocalDisk) GetDiskType() string { + switch self.DiskUsage { + case "SYSTEM_DISK": + return models.DISK_TYPE_SYS + case "DATA_DISK": + return models.DISK_TYPE_DATA + default: + return models.DISK_TYPE_DATA + } +} + +func (self *SLocalDisk) Refresh() error { + return nil +} + +func (self *SLocalDisk) Reset(snapshotId string) error { + return cloudprovider.ErrNotSupported +} + +func (self *SLocalDisk) GetTemplateId() string { + return "" +} + +func (self *SLocalDisk) GetStatus() string { + return models.DISK_READY +} + +func (self *SLocalDisk) GetName() string { + return self.DiskId +} + +func (self *SLocalDisk) GetId() string { + return self.DiskId +} + +func (self *SLocalDisk) GetGlobalId() string { + return self.DiskId +} + +func (self *SLocalDisk) IsEmulated() bool { + return false +} + +func (self *SLocalDisk) GetISnapshot(snapshotId string) (cloudprovider.ICloudSnapshot, error) { + return nil, nil +} + +func (self *SLocalDisk) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) { + return nil, nil +} + +func (self *SLocalDisk) GetIStorge() cloudprovider.ICloudStorage { + return self.storage +} + +func (self *SLocalDisk) Resize(size int64) error { + return cloudprovider.ErrNotSupported +} diff --git a/pkg/util/qcloud/localstorage.go b/pkg/util/qcloud/localstorage.go new file mode 100644 index 0000000000..38d57186c1 --- /dev/null +++ b/pkg/util/qcloud/localstorage.go @@ -0,0 +1,98 @@ +package qcloud + +import ( + "fmt" + "strings" + + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type SLocalStorage struct { + zone *SZone + storageType string +} + +func (self *SLocalStorage) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SLocalStorage) GetId() string { + return fmt.Sprintf("%s-%s-%s", self.zone.region.client.providerId, self.zone.GetId(), self.storageType) +} + +func (self *SLocalStorage) GetName() string { + return fmt.Sprintf("%s-%s-%s", self.zone.region.client.providerName, self.zone.GetId(), self.storageType) +} + +func (self *SLocalStorage) GetGlobalId() string { + return fmt.Sprintf("%s-%s-%s", self.zone.region.client.providerId, self.zone.GetGlobalId(), self.storageType) +} + +func (self *SLocalStorage) IsEmulated() bool { + return true +} + +func (self *SLocalStorage) GetIZone() cloudprovider.ICloudZone { + return self.zone +} + +func (self *SLocalStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) { + disks := []SLocalDisk{} + idisks := make([]cloudprovider.ICloudDisk, len(disks)) + for i := 0; i < len(disks); i++ { + disks[i].storage = self + idisks[i] = &disks[i] + } + return idisks, nil +} + +func (self *SLocalStorage) GetStorageType() string { + return strings.ToLower(self.storageType) +} + +func (self *SLocalStorage) GetMediumType() string { + if strings.HasSuffix(self.storageType, "_BASIC") { + return models.DISK_TYPE_ROTATE + } + return models.DISK_TYPE_SSD +} + +func (self *SLocalStorage) GetCapacityMB() int { + return 0 // unlimited +} + +func (self *SLocalStorage) GetStorageConf() jsonutils.JSONObject { + conf := jsonutils.NewDict() + return conf +} + +func (self *SLocalStorage) GetManagerId() string { + return self.zone.region.client.providerId +} + +func (self *SLocalStorage) GetStatus() string { + return models.STORAGE_ONLINE +} + +func (self *SLocalStorage) Refresh() error { + // do nothing + return nil +} + +func (self *SLocalStorage) GetEnabled() bool { + return true +} + +func (self *SLocalStorage) GetIStoragecache() cloudprovider.ICloudStoragecache { + return self.zone.region.getStoragecache() +} + +func (self *SLocalStorage) CreateIDisk(name string, sizeGb int, desc string) (cloudprovider.ICloudDisk, error) { + return nil, cloudprovider.ErrNotSupported +} + +func (self *SLocalStorage) GetIDisk(idStr string) (cloudprovider.ICloudDisk, error) { + return &SLocalDisk{storage: self, DiskId: idStr}, nil +} diff --git a/pkg/util/qcloud/network.go b/pkg/util/qcloud/network.go new file mode 100644 index 0000000000..fa6ce8a6f2 --- /dev/null +++ b/pkg/util/qcloud/network.go @@ -0,0 +1,132 @@ +package qcloud + +import ( + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/pkg/util/netutils" +) + +type SNetwork struct { + wire *SWire + + CidrBlock string + Zone string + SubnetId string + VpcId string + SubnetName string + AvailableIpAddressCount int + CreatedTime time.Time + EnableBroadcast bool + IsDefault bool + RouteTableId string +} + +func (self *SNetwork) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SNetwork) GetId() string { + return self.SubnetId +} + +func (self *SNetwork) GetName() string { + if len(self.SubnetName) > 0 { + return self.SubnetName + } + return self.SubnetId +} + +func (self *SNetwork) GetGlobalId() string { + return self.SubnetId +} + +func (self *SNetwork) IsEmulated() bool { + return false +} + +func (self *SNetwork) GetStatus() string { + return models.NETWORK_STATUS_AVAILABLE +} + +func (self *SNetwork) Delete() error { + return self.wire.zone.region.DeleteNetwork(self.SubnetId) +} + +func (self *SRegion) DeleteNetwork(networkId string) error { + params := make(map[string]string) + params["SubnetId"] = networkId + + _, err := self.vpcRequest("DeleteSubnet", params) + return err +} + +func (self *SNetwork) GetIWire() cloudprovider.ICloudWire { + return self.wire +} + +func (self *SNetwork) GetAllocTimeoutSeconds() int { + return 120 // 2 minutes +} + +func (self *SNetwork) GetGateway() string { + pref, _ := netutils.NewIPV4Prefix(self.CidrBlock) + endIp := pref.Address.BroadcastAddr(pref.MaskLen) // 255 + endIp = endIp.StepDown() // 254 + return endIp.String() +} + +func (self *SNetwork) GetIpStart() string { + pref, _ := netutils.NewIPV4Prefix(self.CidrBlock) + startIp := pref.Address.NetAddr(pref.MaskLen) // 0 + startIp = startIp.StepUp() // 1 + return startIp.String() +} + +func (self *SNetwork) GetIpEnd() string { + pref, _ := netutils.NewIPV4Prefix(self.CidrBlock) + endIp := pref.Address.BroadcastAddr(pref.MaskLen) // 255 + endIp = endIp.StepDown() // 254 + endIp = endIp.StepDown() // 253 + endIp = endIp.StepDown() // 252 + return endIp.String() +} + +func (self *SNetwork) GetIpMask() int8 { + pref, _ := netutils.NewIPV4Prefix(self.CidrBlock) + return pref.MaskLen +} + +func (self *SNetwork) GetIsPublic() bool { + // return self.IsDefault + return true +} + +func (self *SNetwork) GetServerType() string { + return models.SERVER_TYPE_GUEST +} + +func (self *SNetwork) Refresh() error { + log.Debugf("network refresh %s", self.SubnetId) + new, err := self.wire.zone.region.GetNetwork(self.SubnetId) + if err != nil { + return err + } + return jsonutils.Update(self, new) +} + +func (self *SRegion) CreateNetwork(zoneId string, vpcId string, name string, cidr string, desc string) (string, error) { + params := make(map[string]string) + params["Zone"] = zoneId + params["VpcId"] = vpcId + params["CidrBlock"] = cidr + params["SubnetName"] = name + body, err := self.vpcRequest("CreateSubnet", params) + if err != nil { + return "", err + } + return body.GetString("Subnet", "SubnetId") +} diff --git a/pkg/util/qcloud/provider/doc.go b/pkg/util/qcloud/provider/doc.go new file mode 100644 index 0000000000..4f504f6688 --- /dev/null +++ b/pkg/util/qcloud/provider/doc.go @@ -0,0 +1 @@ +package provider diff --git a/pkg/util/qcloud/provider/provider.go b/pkg/util/qcloud/provider/provider.go new file mode 100644 index 0000000000..b378439509 --- /dev/null +++ b/pkg/util/qcloud/provider/provider.go @@ -0,0 +1,84 @@ +package provider + +import ( + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/util/qcloud" +) + +type STencentProviderFactory struct { + // providerTable map[string]*SAliyunProvider +} + +func (self *STencentProviderFactory) GetId() string { + return qcloud.CLOUD_PROVIDER_QCLOUD +} + +func (self *STencentProviderFactory) GetProvider(providerId, providerName, url, account, secret string) (cloudprovider.ICloudProvider, error) { + client, err := qcloud.NewQcloudClient(providerId, providerName, account, secret) + if err != nil { + return nil, err + } + return &STencentProvider{client: client}, nil +} + +func init() { + factory := STencentProviderFactory{} + cloudprovider.RegisterFactory(&factory) +} + +type STencentProvider struct { + client *qcloud.SQcloudClient +} + +func (self *STencentProvider) IsPublicCloud() bool { + return true +} + +func (self *STencentProvider) GetId() string { + return qcloud.CLOUD_PROVIDER_QCLOUD +} + +func (self *STencentProvider) GetName() string { + return qcloud.CLOUD_PROVIDER_QCLOUD_CN +} + +func (self *STencentProvider) GetSysInfo() (jsonutils.JSONObject, error) { + regions := self.client.GetIRegions() + info := jsonutils.NewDict() + info.Add(jsonutils.NewInt(int64(len(regions))), "region_count") + info.Add(jsonutils.NewString(qcloud.QCLOUD_API_VERSION), "api_version") + return info, nil +} + +func (self *STencentProvider) GetSubAccounts() ([]cloudprovider.SSubAccount, error) { + return self.client.GetSubAccounts() +} + +func (self *STencentProvider) GetIRegions() []cloudprovider.ICloudRegion { + return self.client.GetIRegions() +} + +func (self *STencentProvider) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) { + return self.client.GetIRegionById(id) +} + +func (self *STencentProvider) GetIHostById(id string) (cloudprovider.ICloudHost, error) { + return self.client.GetIHostById(id) +} + +func (self *STencentProvider) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) { + return self.client.GetIVpcById(id) +} + +func (self *STencentProvider) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) { + return self.client.GetIStorageById(id) +} + +func (self *STencentProvider) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) { + return self.client.GetIStoragecacheById(id) +} + +func (self *STencentProvider) GetBalance() (float64, error) { + return 0.0, nil +} diff --git a/pkg/util/qcloud/qcloud.go b/pkg/util/qcloud/qcloud.go new file mode 100644 index 0000000000..7dca5b987e --- /dev/null +++ b/pkg/util/qcloud/qcloud.go @@ -0,0 +1,258 @@ +package qcloud + +import ( + "strings" + + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" + tchttp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" +) + +const ( + CLOUD_PROVIDER_QCLOUD = models.CLOUD_PROVIDER_QCLOUD + CLOUD_PROVIDER_QCLOUD_CN = "腾讯云" + + QCLOUD_DEFAULT_REGION = "ap-beijing" + + QCLOUD_API_VERSION = "2017-03-12" +) + +type SQcloudClient struct { + providerId string + providerName string + AppID string + SecretID string + SecretKey string + iregions []cloudprovider.ICloudRegion +} + +func NewQcloudClient(providerId string, providerName string, secretID string, secretKey string) (*SQcloudClient, error) { + client := SQcloudClient{providerId: providerId, providerName: providerName, SecretID: secretID, SecretKey: secretKey} + if account := strings.Split(secretID, "/"); len(account) == 2 { + client.SecretID = account[0] + client.AppID = account[1] + } + err := client.fetchRegions() + if err != nil { + return nil, err + } + return &client, nil +} + +func jsonRequest(client *common.Client, apiName string, params map[string]string) (jsonutils.JSONObject, error) { + domain := "cvm.tencentcloudapi.com" + if region, ok := params["Region"]; ok && strings.HasSuffix(region, "-fsi") { + domain = "cvm." + region + ".tencentcloudapi.com" + } + return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params) +} + +func vpcRequest(client *common.Client, apiName string, params map[string]string) (jsonutils.JSONObject, error) { + domain := "vpc.tencentcloudapi.com" + if region, ok := params["Region"]; ok && strings.HasSuffix(region, "-fsi") { + domain = "vpc." + region + ".tencentcloudapi.com" + } + return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params) +} + +func cbsRequest(client *common.Client, apiName string, params map[string]string) (jsonutils.JSONObject, error) { + domain := "cbs.tencentcloudapi.com" + if region, ok := params["Region"]; ok && strings.HasSuffix(region, "-fsi") { + domain = "cbs." + region + ".tencentcloudapi.com" + } + return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params) +} + +type QcloudResponse struct { + *tchttp.BaseResponse + Response *interface{} `json:"Response"` +} + +func _jsonRequest(client *common.Client, domain string, version string, apiName string, params map[string]string) (jsonutils.JSONObject, error) { + req := &tchttp.BaseRequest{} + if region, ok := params["Region"]; ok { + client = client.Init(region) + } + client.WithProfile(profile.NewClientProfile()) + service := strings.Split(domain, ".")[0] + req.Init().WithApiInfo(service, version, apiName) + req.SetDomain(domain) + + for k, v := range params { + req.GetParams()[k] = v + } + resp := &QcloudResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + err := client.Send(req, resp) + if err != nil { + log.Errorf("request error %s", err) + return nil, err + } + + //log.Debugf(jsonutils.Marshal(resp.Response).PrettyString()) + + return jsonutils.Marshal(resp.Response), nil +} + +func (client *SQcloudClient) GetRegions() []SRegion { + regions := make([]SRegion, len(client.iregions)) + for i := 0; i < len(regions); i++ { + region := client.iregions[i].(*SRegion) + regions[i] = *region + } + return regions +} + +func (client *SQcloudClient) getDefaultClient() (*common.Client, error) { + return common.NewClientWithSecretId(client.SecretID, client.SecretKey, QCLOUD_DEFAULT_REGION) +} + +func (client *SQcloudClient) vpcRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) { + cli, err := client.getDefaultClient() + if err != nil { + return nil, err + } + return vpcRequest(cli, apiName, params) +} + +func (client *SQcloudClient) cbsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) { + cli, err := client.getDefaultClient() + if err != nil { + return nil, err + } + return cbsRequest(cli, apiName, params) +} + +func (client *SQcloudClient) jsonRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) { + cli, err := client.getDefaultClient() + if err != nil { + return nil, err + } + return jsonRequest(cli, apiName, params) +} + +func (client *SQcloudClient) fetchRegions() error { + body, err := client.jsonRequest("DescribeRegions", nil) + if err != nil { + log.Errorf("fetchRegions fail %s", err) + return err + } + + regions := make([]SRegion, 0) + err = body.Unmarshal(®ions, "RegionSet") + if err != nil { + log.Errorf("unmarshal json error %s", err) + return err + } + client.iregions = make([]cloudprovider.ICloudRegion, len(regions)) + for i := 0; i < len(regions); i++ { + regions[i].client = client + client.iregions[i] = ®ions[i] + } + return nil +} + +func (client *SQcloudClient) GetSubAccounts() ([]cloudprovider.SSubAccount, error) { + err := client.fetchRegions() + if err != nil { + return nil, err + } + subAccount := cloudprovider.SSubAccount{} + subAccount.Name = client.providerName + subAccount.Account = client.SecretKey + return []cloudprovider.SSubAccount{subAccount}, nil +} + +func (client *SQcloudClient) GetIRegions() []cloudprovider.ICloudRegion { + return client.iregions +} + +func (client *SQcloudClient) getDefaultRegion() (cloudprovider.ICloudRegion, error) { + if len(client.iregions) > 0 { + return client.iregions[0], nil + } + return nil, cloudprovider.ErrNotFound +} + +func (client *SQcloudClient) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) { + for i := 0; i < len(client.iregions); i++ { + if client.iregions[i].GetGlobalId() == id { + return client.iregions[i], nil + } + } + return nil, cloudprovider.ErrNotFound +} + +func (client *SQcloudClient) GetRegion(regionId string) *SRegion { + for i := 0; i < len(client.iregions); i++ { + if client.iregions[i].GetId() == regionId { + return client.iregions[i].(*SRegion) + } + } + return nil +} + +func (client *SQcloudClient) GetIHostById(id string) (cloudprovider.ICloudHost, error) { + for i := 0; i < len(client.iregions); i++ { + ihost, err := client.iregions[i].GetIHostById(id) + if err == nil { + return ihost, nil + } else if err != cloudprovider.ErrNotFound { + return nil, err + } + } + return nil, cloudprovider.ErrNotFound +} + +func (client *SQcloudClient) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) { + for i := 0; i < len(client.iregions); i++ { + ihost, err := client.iregions[i].GetIVpcById(id) + if err == nil { + return ihost, nil + } else if err != cloudprovider.ErrNotFound { + return nil, err + } + } + return nil, cloudprovider.ErrNotFound +} + +func (client *SQcloudClient) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) { + for i := 0; i < len(client.iregions); i++ { + ihost, err := client.iregions[i].GetIStorageById(id) + if err == nil { + return ihost, nil + } else if err != cloudprovider.ErrNotFound { + return nil, err + } + } + return nil, cloudprovider.ErrNotFound +} + +func (client *SQcloudClient) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) { + for i := 0; i < len(client.iregions); i++ { + ihost, err := client.iregions[i].GetIStoragecacheById(id) + if err == nil { + return ihost, nil + } else if err != cloudprovider.ErrNotFound { + return nil, err + } + } + return nil, cloudprovider.ErrNotFound +} + +type SAccountBalance struct { + AvailableAmount float64 + AvailableCashAmount float64 + CreditAmount float64 + MybankCreditAmount float64 + Currency string +} + +func (client *SQcloudClient) QueryAccountBalance() (*SAccountBalance, error) { + return nil, nil +} diff --git a/pkg/util/qcloud/region.go b/pkg/util/qcloud/region.go new file mode 100644 index 0000000000..3516c436b2 --- /dev/null +++ b/pkg/util/qcloud/region.go @@ -0,0 +1,528 @@ +package qcloud + +import ( + "fmt" + + "github.com/nelsonken/cos-go-sdk-v5/cos" + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/pkg/utils" +) + +type SRegion struct { + client *SQcloudClient + cosClient *cos.Client + + izones []cloudprovider.ICloudZone + ivpcs []cloudprovider.ICloudVpc + + storageCache *SStoragecache + + instanceTypes []SInstanceType + + Region string + RegionName string + RegionState string + + Latitude float64 + Longitude float64 + fetchLocation bool +} + +func (self *SRegion) GetId() string { + return self.Region +} + +func (self *SRegion) GetName() string { + return fmt.Sprintf("%s %s", CLOUD_PROVIDER_QCLOUD_CN, self.RegionName) +} + +func (self *SRegion) GetGlobalId() string { + return fmt.Sprintf("%s/%s", CLOUD_PROVIDER_QCLOUD, self.Region) +} + +func (self *SRegion) IsEmulated() bool { + return false +} + +func (self *SRegion) GetProvider() string { + return CLOUD_PROVIDER_QCLOUD +} + +func (self *SRegion) CreateIVpc(name string, desc string, cidr string) (cloudprovider.ICloudVpc, error) { + params := make(map[string]string) + if len(cidr) > 0 { + params["CidrBlock"] = cidr + } + if len(name) > 0 { + params["VpcName"] = name + } + body, err := self.vpcRequest("CreateVpc", params) + if err != nil { + return nil, err + } + vpcId, err := body.GetString("Vpc", "VpcId") + if err != nil { + return nil, err + } + err = self.fetchInfrastructure() + if err != nil { + return nil, err + } + return self.GetIVpcById(vpcId) +} + +func (self *SRegion) GetCosClient() (*cos.Client, error) { + if self.cosClient == nil { + self.cosClient = cos.New(&cos.Option{ + AppID: self.client.AppID, + SecretID: self.client.SecretID, + SecretKey: self.client.SecretKey, + Region: self.Region, + }) + } + return self.cosClient, nil +} + +func (self *SRegion) GetClient() *SQcloudClient { + return self.client +} + +func (self *SRegion) GetIEipById(eipId string) (cloudprovider.ICloudEIP, error) { + eips, total, err := self.GetEips(eipId, 0, 1) + if err != nil { + return nil, err + } + if total == 0 { + return nil, cloudprovider.ErrNotFound + } + if total > 1 { + return nil, cloudprovider.ErrDuplicateId + } + return &eips[0], nil +} + +func (self *SRegion) GetIEips() ([]cloudprovider.ICloudEIP, error) { + eips, total, err := self.GetEips("", 0, 50) + if err != nil { + return nil, err + } + for len(eips) < total { + var parts []SEipAddress + parts, total, err = self.GetEips("", len(eips), 50) + if err != nil { + return nil, err + } + eips = append(eips, parts...) + } + ret := make([]cloudprovider.ICloudEIP, len(eips)) + for i := 0; i < len(eips); i++ { + ret[i] = &eips[i] + } + return ret, nil +} + +func (self *SRegion) GetIHostById(id string) (cloudprovider.ICloudHost, error) { + izones, err := self.GetIZones() + if err != nil { + return nil, err + } + for i := 0; i < len(izones); i += 1 { + ihost, err := izones[i].GetIHostById(id) + if err == nil { + return ihost, nil + } else if err != cloudprovider.ErrNotFound { + return nil, err + } + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SRegion) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) { + izones, err := self.GetIZones() + if err != nil { + return nil, err + } + for i := 0; i < len(izones); i += 1 { + istore, err := izones[i].GetIStorageById(id) + if err == nil { + return istore, nil + } else if err != cloudprovider.ErrNotFound { + return nil, err + } + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SRegion) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) { + storageCache := self.getStoragecache() + if storageCache.GetGlobalId() == id { + return self.storageCache, nil + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SRegion) updateInstance(instId string, name, desc, passwd, hostname string) error { + params := make(map[string]string) + params["InstanceId"] = instId + if len(name) > 0 { + params["InstanceName"] = name + } + if len(desc) > 0 { + params["Description"] = desc + } + if len(passwd) > 0 { + params["Password"] = passwd + } + if len(hostname) > 0 { + params["HostName"] = hostname + } + _, err := self.cvmRequest("ModifyInstanceAttribute", params) + return err +} + +func (self *SRegion) UpdateInstancePassword(instId string, passwd string) error { + return self.updateInstance(instId, "", "", passwd, "") +} + +func (self *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) { + ivpcs, err := self.GetIVpcs() + if err != nil { + return nil, err + } + for i := 0; i < len(ivpcs); i++ { + if ivpcs[i].GetGlobalId() == id { + return ivpcs[i], nil + } + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SRegion) getZoneById(id string) (*SZone, error) { + izones, err := self.GetIZones() + if err != nil { + return nil, err + } + for i := 0; i < len(izones); i += 1 { + zone := izones[i].(*SZone) + if zone.Zone == id { + return zone, nil + } + } + return nil, fmt.Errorf("no such zone %s", id) +} + +func (self *SRegion) GetIVpcs() ([]cloudprovider.ICloudVpc, error) { + if self.ivpcs == nil { + err := self.fetchInfrastructure() + if err != nil { + return nil, err + } + } + return self.ivpcs, nil +} + +func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) { + return nil, nil +} + +func (self *SRegion) GetIZones() ([]cloudprovider.ICloudZone, error) { + if self.izones == nil { + var err error + err = self.fetchInfrastructure() + if err != nil { + return nil, err + } + } + return self.izones, nil +} + +func (self *SRegion) _fetchZones() error { + params := make(map[string]string) + params["Region"] = self.Region + zones := make([]SZone, 0) + body, err := self.client.jsonRequest("DescribeZones", params) + if err != nil { + return err + } + err = body.Unmarshal(&zones, "ZoneSet") + if err != nil { + return err + } + self.izones = make([]cloudprovider.ICloudZone, len(zones)) + for i := 0; i < len(zones); i++ { + zones[i].region = self + self.izones[i] = &zones[i] + } + return nil +} + +func (self *SRegion) fetchInfrastructure() error { + err := self._fetchZones() + if err != nil { + return err + } + err = self.fetchIVpcs() + if err != nil { + return err + } + for i := 0; i < len(self.ivpcs); i += 1 { + for j := 0; j < len(self.izones); j += 1 { + zone := self.izones[j].(*SZone) + vpc := self.ivpcs[i].(*SVpc) + wire := SWire{zone: zone, vpc: vpc} + zone.addWire(&wire) + vpc.addWire(&wire) + } + } + return nil +} + +func (self *SRegion) DeleteVpc(vpcId string) error { + params := make(map[string]string) + params["VpcId"] = vpcId + + _, err := self.vpcRequest("DeleteVpc", params) + return err +} + +func (self *SRegion) getVpc(vpcId string) (*SVpc, error) { + vpcs, total, err := self.GetVpcs([]string{vpcId}, 0, 1) + if err != nil { + return nil, err + } + if total != 1 { + return nil, cloudprovider.ErrNotFound + } + vpcs[0].region = self + return &vpcs[0], nil +} + +func (self *SRegion) fetchIVpcs() error { + vpcs := make([]SVpc, 0) + for { + part, total, err := self.GetVpcs(nil, len(vpcs), 50) + if err != nil { + return err + } + vpcs = append(vpcs, part...) + if len(vpcs) >= total { + break + } + } + self.ivpcs = make([]cloudprovider.ICloudVpc, len(vpcs)) + for i := 0; i < len(vpcs); i += 1 { + vpcs[i].region = self + self.ivpcs[i] = &vpcs[i] + } + return nil +} + +func (self *SRegion) GetVpcs(vpcIds []string, offset int, limit int) ([]SVpc, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + if vpcIds != nil && len(vpcIds) > 0 { + for index, vpcId := range vpcIds { + params[fmt.Sprintf("VpcIds.%d", index)] = vpcId + } + } + body, err := self.vpcRequest("DescribeVpcs", params) + if err != nil { + return nil, 0, err + } + vpcs := make([]SVpc, 0) + err = body.Unmarshal(&vpcs, "VpcSet") + if err != nil { + log.Errorf("Unmarshal vpc fail %s", err) + return nil, 0, err + } + total, _ := body.Float("TotalCount") + return vpcs, int(total), nil +} + +func (self *SRegion) GetLatitude() float32 { + if info, ok := LatitudeAndLongitude[self.Region]; ok { + return info["latitude"] + } + return 0.0 +} + +func (self *SRegion) GetLongitude() float32 { + if info, ok := LatitudeAndLongitude[self.Region]; ok { + return info["longitude"] + } + return 0.0 +} + +func (self *SRegion) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SRegion) GetStatus() string { + if self.RegionState == "AVAILABLE" { + return models.CLOUD_REGION_STATUS_INSERVER + } + return models.CLOUD_REGION_STATUS_OUTOFSERVICE +} + +func (self *SRegion) Refresh() error { + // do nothing + return nil +} + +func (self *SRegion) vpcRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) { + params["Region"] = self.Region + return self.client.vpcRequest(apiName, params) +} + +func (self *SRegion) cvmRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) { + params["Region"] = self.Region + return self.client.jsonRequest(apiName, params) +} + +func (self *SRegion) cbsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) { + params["Region"] = self.Region + return self.client.cbsRequest(apiName, params) +} + +func (self *SRegion) GetNetworks(ids []string, vpcId string, offset int, limit int) ([]SNetwork, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + base := 0 + if ids != nil && len(ids) > 0 { + for index, networkId := range ids { + params[fmt.Sprintf("SubnetIds.%d", index)] = networkId + } + base += len(ids) + } + if len(vpcId) > 0 { + params["Filters.0.Name"] = "vpc-id" + params["Filters.0.Values.0"] = vpcId + } + + body, err := self.vpcRequest("DescribeSubnets", params) + if err != nil { + log.Errorf("DescribeSubnets fail %s", err) + return nil, 0, err + } + + networks := make([]SNetwork, 0) + err = body.Unmarshal(&networks, "SubnetSet") + if err != nil { + log.Errorf("Unmarshal network fail %s", err) + return nil, 0, err + } + total, _ := body.Float("TotalCount") + return networks, int(total), nil +} + +func (self *SRegion) GetNetwork(networkId string) (*SNetwork, error) { + networks, total, err := self.GetNetworks([]string{networkId}, "", 0, 1) + if err != nil { + return nil, err + } + if total > 1 { + return nil, cloudprovider.ErrDuplicateId + } + if total == 0 { + return nil, cloudprovider.ErrNotFound + } + return &networks[0], nil +} + +func (self *SRegion) getStoragecache() *SStoragecache { + if self.storageCache == nil { + self.storageCache = &SStoragecache{region: self} + } + return self.storageCache +} + +func (self *SRegion) GetMatchInstanceTypes(cpu int, memMB int, gpu int, zoneId string) ([]SInstanceType, error) { + if self.instanceTypes == nil { + types, err := self.GetInstanceTypes() + if err != nil { + log.Errorf("GetInstanceTypes %s", err) + return nil, err + } + self.instanceTypes = types + } + + var available []string + if len(zoneId) > 0 { + zone, err := self.getZoneById(zoneId) + if err != nil { + return nil, err + } + available = zone.getAvaliableInstanceTypes() + } + ret := make([]SInstanceType, 0) + for _, t := range self.instanceTypes { + if t.CPU == cpu && memMB == t.memoryMB() && gpu == t.GPU { + if available == nil || utils.IsInStringArray(t.InstanceType, available) { + ret = append(ret, t) + } + } + } + return ret, nil +} + +func (self *SRegion) CreateInstanceSimple(name string, imgId string, cpu int, memGB int, storageType string, dataDiskSizesGB []int, networkId string, passwd string, publicKey string) (*SInstance, error) { + izones, err := self.GetIZones() + if err != nil { + return nil, err + } + for i := 0; i < len(izones); i += 1 { + z := izones[i].(*SZone) + log.Debugf("Search in zone %s", z.Zone) + net := z.getNetworkById(networkId) + if net != nil { + inst, err := z.getHost().CreateVM(name, imgId, 0, cpu, memGB*1024, networkId, "", "", passwd, storageType, dataDiskSizesGB, publicKey, "", "") + if err != nil { + return nil, err + } + return inst.(*SInstance), nil + } + } + return nil, fmt.Errorf("cannot find network %s", networkId) +} + +func (self *SRegion) instanceOperation(instanceId string, opname string, extra map[string]string) error { + params := make(map[string]string) + params["Region"] = self.Region + params["InstanceIds.0"] = instanceId + if extra != nil && len(extra) > 0 { + for k, v := range extra { + params[k] = v + } + } + _, err := self.cvmRequest(opname, params) + return err +} + +func (self *SRegion) GetInstanceVNCUrl(instanceId string) (string, error) { + params := make(map[string]string) + params["InstanceId"] = instanceId + body, err := self.cvmRequest("DescribeInstanceVncUrl", params) + if err != nil { + return "", err + } + return body.GetString("InstanceVncUrl") +} + +func (self *SRegion) GetInstanceStatus(instanceId string) (string, error) { + instance, err := self.GetInstance(instanceId) + if err != nil { + return "", err + } + return instance.InstanceState, nil +} diff --git a/pkg/util/qcloud/securitygroup.go b/pkg/util/qcloud/securitygroup.go new file mode 100644 index 0000000000..ad1d1d35eb --- /dev/null +++ b/pkg/util/qcloud/securitygroup.go @@ -0,0 +1,415 @@ +package qcloud + +import ( + "fmt" + "net" + "sort" + "strconv" + "strings" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/pkg/util/secrules" + "yunion.io/x/pkg/utils" +) + +type SecurityGroupPolicy struct { + vpc *SVpc + PolicyIndex int // 安全组规则索引号。 + Protocol string // 协议, 取值: TCP,UDP, ICMP。 + Port string // 端口(all, 离散port, range)。 + ServiceTemplate ServiceTemplateSpecification // 协议端口ID或者协议端口组ID。ServiceTemplate和Protocol+Port互斥。 + CidrBlock string // 网段或IP(互斥)。 + SecurityGroupId string // 已绑定安全组的网段或IP。 + AddressTemplate AddressTemplateSpecification // IP地址ID或者ID地址组ID。 + Action string // ACCEPT 或 DROP。 + PolicyDescription string // 安全组规则描述。 + direction string +} + +type ServiceTemplateSpecification struct { + ServiceId string // 协议端口ID,例如:ppm-f5n1f8da。 + ServiceGroupId string // 协议端口组ID,例如:ppmg-f5n1f8da。 +} + +type AddressTemplateSpecification struct { + AddressId string // IP地址ID,例如:ipm-2uw6ujo6。 + AddressGroupId string // IP地址组ID,例如:ipmg-2uw6ujo6。 +} + +type SecurityGroupPolicySet struct { + Version string + Egress []SecurityGroupPolicy // 出站规则。 + Ingress []SecurityGroupPolicy // 入站规则。 +} + +type SSecurityGroup struct { + vpc *SVpc + SecurityGroupId string // 安全组实例ID,例如:sg-ohuuioma。 + SecurityGroupName string // 安全组名称,可任意命名,但不得超过60个字符。 + SecurityGroupDesc string // 安全组备注,最多100个字符。 + ProjectId string // 项目id,默认0。可在qcloud控制台项目管理页面查询到。 + IsDefault bool // 是否是默认安全组,默认安全组不支持删除。 + CreatedTime time.Time // 安全组创建时间。 + SecurityGroupPolicySet SecurityGroupPolicySet +} + +type SecurityGroupRuleSet []SecurityGroupPolicy + +func (v SecurityGroupRuleSet) Len() int { + return len(v) +} + +func (v SecurityGroupRuleSet) Swap(i, j int) { + v[i], v[j] = v[j], v[i] +} + +func (v SecurityGroupRuleSet) Less(i, j int) bool { + if v[i].PolicyIndex < v[j].PolicyIndex { + return true + } else if v[i].PolicyIndex == v[j].PolicyIndex { + return strings.Compare(v[i].String(), v[j].String()) <= 0 + } + return false +} + +func (self *SRegion) GetSecurityGroups(vpcId string, offset int, limit int) ([]SSecurityGroup, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + + body, err := self.vpcRequest("DescribeSecurityGroups", params) + if err != nil { + log.Errorf("GetSecurityGroups fail %s", err) + return nil, 0, err + } + + secgrps := make([]SSecurityGroup, 0) + err = body.Unmarshal(&secgrps, "SecurityGroupSet") + if err != nil { + log.Errorf("Unmarshal security groups fail %s", err) + return nil, 0, err + } + total, _ := body.Float("TotalCount") + return secgrps, int(total), nil +} + +func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SSecurityGroup) GetId() string { + return self.SecurityGroupId +} + +func (self *SSecurityGroup) GetGlobalId() string { + return self.SecurityGroupId +} + +func (self *SSecurityGroup) GetDescription() string { + return self.SecurityGroupDesc +} + +func (self *SSecurityGroup) GetName() string { + if len(self.SecurityGroupName) > 0 { + return self.SecurityGroupName + } + return self.SecurityGroupId +} + +func (self *SecurityGroupPolicy) String() string { + rules := self.toRules() + result := []string{} + for _, rule := range rules { + result = append(result, rule.String()) + } + return strings.Join(result, ";") +} + +func parseCIDR(cidr string) (*net.IPNet, error) { + if strings.Index(cidr, "/") > 0 { + _, ipnet, err := net.ParseCIDR(cidr) + return ipnet, err + } + ip := net.ParseIP(cidr) + if ip == nil { + return nil, fmt.Errorf("Parse ip %s error", cidr) + } + return &net.IPNet{IP: ip, Mask: net.CIDRMask(32, 32)}, nil +} + +func (self *SecurityGroupPolicy) toRules() []secrules.SecurityRule { + result := []secrules.SecurityRule{} + rule := secrules.SecurityRule{ + Action: secrules.SecurityRuleAllow, + Protocol: secrules.PROTO_ANY, + Direction: secrules.TSecurityRuleDirection(self.direction), + Ports: []int{}, + PortStart: -1, + PortEnd: -1, + } + if len(self.SecurityGroupId) != 0 { + //安全组关联安全组的规则忽略 + return nil + } + if strings.ToLower(self.Action) == "drop" { + rule.Action = secrules.SecurityRuleDeny + } + if utils.IsInStringArray(strings.ToLower(self.Protocol), []string{"tcp", "udp", "icmp"}) { + rule.Protocol = strings.ToLower(self.Protocol) + } + if strings.Index(self.Port, ",") > 0 { + for _, _port := range strings.Split(self.Port, ",") { + port, err := strconv.Atoi(_port) + if err != nil { + log.Errorf("parse secgroup port %s %s error %v", self.Port, _port, err) + continue + } + rule.Ports = append(rule.Ports, port) + } + } else if strings.Index(self.Port, "-") > 0 { + ports := strings.Split(self.Port, "-") + if len(ports) == 2 { + portStart, err := strconv.Atoi(ports[0]) + if err != nil { + return nil + } + portEnd, err := strconv.Atoi(ports[1]) + if err != nil { + return nil + } + rule.PortStart, rule.PortEnd = portStart, portEnd + } + } else if strings.ToLower(self.Port) != "all" { + port, err := strconv.Atoi(self.Port) + if err != nil { + return nil + } + rule.PortStart, rule.PortEnd = port, port + } + + if len(self.AddressTemplate.AddressGroupId) > 0 { + addressGroup, total, err := self.vpc.region.AddressGroupList(self.AddressTemplate.AddressGroupId, "", 0, 1) + if err != nil { + log.Errorf("Get AddressList %s failed %v", self.AddressTemplate.AddressId, err) + return nil + } + if total != 1 { + return nil + } + for i := 0; i < len(addressGroup[0].AddressTemplateIdSet); i++ { + rules, err := self.getAddressRules(rule, addressGroup[0].AddressTemplateIdSet[i]) + if err != nil { + return nil + } + result = append(result, rules...) + } + } else if len(self.AddressTemplate.AddressId) > 0 { + rules, err := self.getAddressRules(rule, self.AddressTemplate.AddressId) + if err != nil { + return nil + } + result = append(result, rules...) + } else if len(self.CidrBlock) > 0 { + ipnet, err := parseCIDR(self.CidrBlock) + if err != nil { + return nil + } + rule.IPNet = ipnet + result = append(result, rule) + } + return result +} + +func (self *SecurityGroupPolicy) getAddressRules(rule secrules.SecurityRule, addressId string) ([]secrules.SecurityRule, error) { + result := []secrules.SecurityRule{} + address, total, err := self.vpc.region.AddressList(addressId, "", 0, 1) + if err != nil { + log.Errorf("Get AddressList %s failed %v", self.AddressTemplate.AddressId, err) + return nil, err + } + if total != 1 { + return nil, fmt.Errorf("failed to find address %s", addressId) + } + for _, ip := range address[0].AddressSet { + ipnet, err := parseCIDR(ip) + if err != nil { + return nil, nil + } + rule.IPNet = ipnet + result = append(result, rule) + } + return result, nil +} + +func (self *SSecurityGroup) GetRules() ([]secrules.SecurityRule, error) { + secgroup, err := self.vpc.region.GetSecurityGroupDetails(self.SecurityGroupId) + if err != nil { + return nil, err + } + for i := 0; i < len(secgroup.SecurityGroupPolicySet.Egress); i++ { + secgroup.SecurityGroupPolicySet.Egress[i].direction = "out" + } + for i := 0; i < len(secgroup.SecurityGroupPolicySet.Ingress); i++ { + secgroup.SecurityGroupPolicySet.Ingress[i].direction = "in" + } + originRules := []SecurityGroupPolicy{} + originRules = append(secgroup.SecurityGroupPolicySet.Egress) + originRules = append(secgroup.SecurityGroupPolicySet.Ingress) + sort.Sort(SecurityGroupRuleSet(originRules)) + rules := []secrules.SecurityRule{} + priority := 100 + for _, rule := range originRules { + rule.vpc = self.vpc + subRules := rule.toRules() + for i := 0; i < len(subRules); i++ { + subRules[i].Priority = priority + } + if len(subRules) > 0 { + priority-- + } + rules = append(rules, subRules...) + } + return rules, nil +} + +func (self *SSecurityGroup) GetStatus() string { + return "" +} + +func (self *SSecurityGroup) IsEmulated() bool { + return false +} + +func (self *SSecurityGroup) Refresh() error { + if new, err := self.vpc.region.GetSecurityGroupDetails(self.SecurityGroupId); err != nil { + return err + } else { + return jsonutils.Update(self, new) + } +} + +func (self *SRegion) GetSecurityGroupDetails(secGroupId string) (*SSecurityGroup, error) { + params := make(map[string]string) + params["Region"] = self.Region + params["SecurityGroupId"] = secGroupId + + body, err := self.vpcRequest("DescribeSecurityGroupPolicies", params) + if err != nil { + log.Errorf("DescribeSecurityGroupAttribute fail %s", err) + return nil, err + } + + secgrp := SSecurityGroup{SecurityGroupId: secGroupId} + err = body.Unmarshal(&secgrp.SecurityGroupPolicySet, "SecurityGroupPolicySet") + if err != nil { + log.Errorf("Unmarshal security group details fail %s", err) + return nil, err + } + return &secgrp, nil +} + +func (self *SRegion) DeleteSecurityGroup(secGroupId string) error { + params := make(map[string]string) + params["Region"] = self.Region + params["SecurityGroupId"] = secGroupId + _, err := self.vpcRequest("DeleteSecurityGroup", params) + return err +} + +type AddressTemplate struct { + AddressSet []string + AddressTemplateId string + AddressTemplateName string + CreatedTime time.Time +} + +func (self *SRegion) AddressList(addressId, addressName string, offset, limit int) ([]AddressTemplate, int, error) { + params := map[string]string{} + filter := 0 + if len(addressId) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "address-template-id" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = addressId + filter++ + } + if len(addressName) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "address-template-name" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = addressName + filter++ + } + params["Offset"] = fmt.Sprintf("%d", offset) + if limit == 0 { + limit = 20 + } + params["Limit"] = fmt.Sprintf("%d", limit) + body, err := self.vpcRequest("DescribeAddressTemplates", params) + if err != nil { + return nil, 0, err + } + addressTemplates := []AddressTemplate{} + err = body.Unmarshal(&addressTemplates, "AddressTemplateSet") + if err != nil { + return nil, 0, err + } + total, _ := body.Float("TotalCount") + return addressTemplates, int(total), nil +} + +type AddressTemplateGroup struct { + AddressTemplateIdSet []string + AddressTemplateGroupName string + AddressTemplateGroupId string + CreatedTime time.Time +} + +func (self *SRegion) AddressGroupList(groupId, groupName string, offset, limit int) ([]AddressTemplateGroup, int, error) { + params := map[string]string{} + filter := 0 + if len(groupId) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "address-template-group-id" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = groupId + filter++ + } + if len(groupName) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "address-template-group-name" + params[fmt.Sprintf("Filters.%d.Values.0", filter)] = groupName + filter++ + } + params["Offset"] = fmt.Sprintf("%d", offset) + if limit == 0 { + limit = 20 + } + params["Limit"] = fmt.Sprintf("%d", limit) + body, err := self.vpcRequest("DescribeAddressTemplateGroups", params) + if err != nil { + return nil, 0, err + } + addressTemplateGroups := []AddressTemplateGroup{} + err = body.Unmarshal(&addressTemplateGroups, "AddressTemplateGroupSet") + if err != nil { + return nil, 0, err + } + total, _ := body.Float("TotalCount") + return addressTemplateGroups, int(total), nil +} + +func (self *SRegion) CreateSecurityGroup(name, description string) (*SSecurityGroup, error) { + params := make(map[string]string) + params["Region"] = self.Region + params["GroupName"] = name + params["GroupDescription"] = description + if len(description) == 0 { + params["GroupDescription"] = "Customize Create" + } + secgroup := SSecurityGroup{} + if body, err := self.vpcRequest("CreateSecurityGroup", params); err != nil { + return nil, err + } else if err := body.Unmarshal(&secgroup, "SecurityGroup"); err != nil { + return nil, err + } + return &secgroup, nil +} diff --git a/pkg/util/qcloud/shell/cos.go b/pkg/util/qcloud/shell/cos.go new file mode 100644 index 0000000000..374244b2e0 --- /dev/null +++ b/pkg/util/qcloud/shell/cos.go @@ -0,0 +1,106 @@ +package shell + +import ( + "context" + "os" + + coslib "github.com/nelsonken/cos-go-sdk-v5/cos" + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type CosListOptions struct { + } + shellutils.R(&CosListOptions{}, "cos-list", "List COS buckets", func(cli *qcloud.SRegion, args *CosListOptions) error { + cos, err := cli.GetCosClient() + if err != nil { + return err + } + result, err := cos.GetBucketList(context.Background()) + if err != nil { + return err + } + printList(result.Buckets.Bucket, len(result.Buckets.Bucket), 0, len(result.Buckets.Bucket), nil) + return nil + }) + + type CosListBucketOptions struct { + BUCKET string `help:"bucket name"` + } + + shellutils.R(&CosListBucketOptions{}, "cos-bucket-list", "List content of a OSS bucket", func(cli *qcloud.SRegion, args *CosListBucketOptions) error { + cos, err := cli.GetCosClient() + if err != nil { + return err + } + result, err := cos.ListBucketContents(context.Background(), args.BUCKET, &coslib.QueryCondition{}) + if err != nil { + return err + } + printList(result.Contents, len(result.Contents), 0, len(result.Contents), nil) + return nil + }) + + shellutils.R(&CosListBucketOptions{}, "cos-bucket-create", "Create a OSS bucket", func(cli *qcloud.SRegion, args *CosListBucketOptions) error { + cos, err := cli.GetCosClient() + if err != nil { + return err + } + return cos.CreateBucket(context.Background(), args.BUCKET, &coslib.AccessControl{}) + }) + + type CosUploadOptions struct { + BUCKET string `help:"bucket name"` + KEY string `help:"Object key"` + FILE string `help:"Local file path"` + Acl string `help:"Object ACL" choices:"private|public-read|public-read-write"` + } + shellutils.R(&CosUploadOptions{}, "cos-upload", "Upload a file to a Cos bucket", func(cli *qcloud.SRegion, args *CosUploadOptions) error { + cos, err := cli.GetCosClient() + if err != nil { + return err + } + return cos.Bucket(args.BUCKET).UploadObjectBySlice(context.Background(), args.KEY, args.FILE, 3, nil) + }) + + type CosDownloadOptions struct { + BUCKET string `help:"bucket name"` + NAME string `help:"File name"` + } + shellutils.R(&CosDownloadOptions{}, "cos-download", "Download a file", func(cli *qcloud.SRegion, args *CosDownloadOptions) error { + cos, err := cli.GetCosClient() + if err != nil { + return err + } + //file + return cos.Bucket(args.BUCKET).DownloadObject(context.Background(), args.NAME, os.Stdout) + //return cos.Bucket(args.BUCKET).UploadObjectBySlice(context.Background(), args.KEY, args.FILE, 3, nil) + }) + + type CosObjectAclOptions struct { + BUCKET string `help:"bucket name"` + KEY string `help:"object key"` + ACL string `help:"ACL" choices:"private|public-read|public-read-write"` + } + shellutils.R(&CosObjectAclOptions{}, "cos-set-acl", "Set acl for a object", func(cli *qcloud.SRegion, args *CosObjectAclOptions) error { + cos, err := cli.GetCosClient() + if err != nil { + return err + } + return cos.SetBucketACL(context.Background(), args.KEY, &coslib.AccessControl{ACL: args.ACL}) + }) + + type CosDeleteOptions struct { + BUCKET string `help:"bucket name"` + KEY string `help:"Object key"` + } + + shellutils.R(&CosDeleteOptions{}, "cos-delete", "Delete a file from a Cos bucket", func(cli *qcloud.SRegion, args *CosDeleteOptions) error { + cos, err := cli.GetCosClient() + if err != nil { + return err + } + return cos.Bucket(args.BUCKET).DeleteObject(context.Background(), args.KEY) + }) +} diff --git a/pkg/util/qcloud/shell/disk.go b/pkg/util/qcloud/shell/disk.go new file mode 100644 index 0000000000..70f8e2dacb --- /dev/null +++ b/pkg/util/qcloud/shell/disk.go @@ -0,0 +1,77 @@ +package shell + +import ( + "fmt" + + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type DiskListOptions struct { + Instance string `help:"Instance ID"` + Zone string `help:"Zone ID"` + Category string `help:"Disk category"` + Offset int `help:"List offset"` + Limit int `help:"List limit"` + } + shellutils.R(&DiskListOptions{}, "disk-list", "List disks", func(cli *qcloud.SRegion, args *DiskListOptions) error { + disks, total, e := cli.GetDisks(args.Instance, args.Zone, args.Category, nil, args.Offset, args.Limit) + if e != nil { + return e + } + printList(disks, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type DiskOptions struct { + ID string `help:"Disk ID"` + } + shellutils.R(&DiskOptions{}, "disk-delete", "Delete disks", func(cli *qcloud.SRegion, args *DiskOptions) error { + e := cli.DeleteDisk(args.ID) + if e != nil { + return e + } + return nil + }) + + shellutils.R(&DiskOptions{}, "disk-show", "Show disk", func(cli *qcloud.SRegion, args *DiskOptions) error { + disk, err := cli.GetDisk(args.ID) + if err != nil { + return err + } + printObject(disk) + return nil + }) + + type DiskCreateOptions struct { + ZONE string `help:"Zone ID"` + CATEGORY string `help:"Disk category" choices:"CLOUD_BASIC|CLOUD_PREMIUM|CLOUD_SSD"` + NAME string `help:"Disk Name"` + SIZE int `help:"Disk Size GB"` + } + shellutils.R(&DiskCreateOptions{}, "disk-create", "Create disk", func(cli *qcloud.SRegion, args *DiskCreateOptions) error { + diskId, err := cli.CreateDisk(args.ZONE, args.CATEGORY, args.NAME, args.SIZE, "") + if err != nil { + return err + } + fmt.Println(diskId) + return nil + }) + + type DiskResizeOptions struct { + ID string `help:"Disk ID"` + SIZE int64 `help:"Disk Size GB"` + } + shellutils.R(&DiskResizeOptions{}, "disk-resize", "Resize disk", func(cli *qcloud.SRegion, args *DiskResizeOptions) error { + return cli.ResizeDisk(args.ID, args.SIZE) + }) + + type DiskResetOptions struct { + ID string `help:"Disk ID"` + SNAPSHOT string `help:"Snapshot ID"` + } + shellutils.R(&DiskResetOptions{}, "disk-reset", "Reset disk", func(cli *qcloud.SRegion, args *DiskResetOptions) error { + return cli.ResetDisk(args.ID, args.SNAPSHOT) + }) +} diff --git a/pkg/util/qcloud/shell/eip.go b/pkg/util/qcloud/shell/eip.go new file mode 100644 index 0000000000..ae6cb1f0db --- /dev/null +++ b/pkg/util/qcloud/shell/eip.go @@ -0,0 +1,71 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type EipListOptions struct { + Eip string `help:"EIP ID"` + Offset int `help:"List offset"` + Limit int `help:"List limit"` + } + shellutils.R(&EipListOptions{}, "eip-list", "List eips", func(cli *qcloud.SRegion, args *EipListOptions) error { + eips, total, err := cli.GetEips(args.Eip, args.Offset, args.Limit) + if err != nil { + return err + } + printList(eips, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type EipAllocateOptions struct { + BANDWIDTH int `help:"EIP bandwoidth"` + NAME string `help:"EIP Name"` + ChargeType qcloud.TInternetChargeType `help:"EIP ChargeType"` + } + shellutils.R(&EipAllocateOptions{}, "eip-create", "Allocate an EIP", func(cli *qcloud.SRegion, args *EipAllocateOptions) error { + eip, err := cli.AllocateEIP(args.NAME, args.BANDWIDTH, args.ChargeType) + if err != nil { + return err + } + printObject(eip) + return nil + }) + + type EipReleaseOptions struct { + ID string `help:"EIP allocation ID"` + } + shellutils.R(&EipReleaseOptions{}, "eip-delete", "Release an EIP", func(cli *qcloud.SRegion, args *EipReleaseOptions) error { + return cli.DeallocateEIP(args.ID) + }) + + type EipShowOptions struct { + ID string `help:"EIP ID"` + } + shellutils.R(&EipShowOptions{}, "eip-show", "Show an EIP", func(cli *qcloud.SRegion, args *EipShowOptions) error { + eip, err := cli.GetEip(args.ID) + if err != nil { + return err + } + printObject(eip) + return nil + }) + + type EipAssociateOptions struct { + ID string `help:"EIP allocation ID"` + INSTANCE string `help:"Instance ID"` + } + shellutils.R(&EipAssociateOptions{}, "eip-associate", "Associate an EIP", func(cli *qcloud.SRegion, args *EipAssociateOptions) error { + return cli.AssociateEip(args.ID, args.INSTANCE) + }) + + type EipDissociateOptions struct { + ID string `help:"EIP allocation ID"` + } + + shellutils.R(&EipDissociateOptions{}, "eip-dissociate", "Dissociate an EIP", func(cli *qcloud.SRegion, args *EipDissociateOptions) error { + return cli.DissociateEip(args.ID) + }) +} diff --git a/pkg/util/qcloud/shell/image.go b/pkg/util/qcloud/shell/image.go new file mode 100644 index 0000000000..0f2bbe71a9 --- /dev/null +++ b/pkg/util/qcloud/shell/image.go @@ -0,0 +1,55 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type ImageListOptions struct { + Status string `help:"Image status"` + Owner string `help:"Image owner" choices:"PRIVATE_IMAGE|PUBLIC_IMAGE|MARKET_IMAGE|SHARED_IMAGE"` + Image string `help:"Image Id"` + Name string `help:"Image Name"` + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&ImageListOptions{}, "image-list", "List images", func(cli *qcloud.SRegion, args *ImageListOptions) error { + imageIds := []string{} + if len(args.Image) > 0 { + imageIds = append(imageIds, args.Image) + } + images, total, err := cli.GetImages(args.Status, args.Owner, imageIds, args.Name, args.Offset, args.Limit) + if err != nil { + return err + } + printList(images, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type ImageCreateOptions struct { + NAME string `helo:"Image name"` + OSTYPE string `helo:"Operation system" choices:"CentOS|Ubuntu|Debian|OpenSUSE|SUSE|CoreOS|FreeBSD|Other Linux|Windows Server 2008|Windows Server 2012|Windows Server 2016"` + OSARCH string `help:"OS Architecture" choices:"x86_64|i386"` + osVersion string `help:"OS Version"` + URL string `helo:"Cos URL"` + } + + shellutils.R(&ImageCreateOptions{}, "image-create", "Create image", func(cli *qcloud.SRegion, args *ImageCreateOptions) error { + image, err := cli.ImportImage(args.NAME, args.OSARCH, args.OSTYPE, args.osVersion, args.URL) + if err != nil { + return err + } + printObject(image) + return nil + }) + + type ImageDeleteOptions struct { + ID string `helo:"Image ID"` + } + + shellutils.R(&ImageDeleteOptions{}, "image-delete", "Delete image", func(cli *qcloud.SRegion, args *ImageDeleteOptions) error { + return cli.DeleteImage(args.ID) + }) + +} diff --git a/pkg/util/qcloud/shell/instance.go b/pkg/util/qcloud/shell/instance.go new file mode 100644 index 0000000000..1343410391 --- /dev/null +++ b/pkg/util/qcloud/shell/instance.go @@ -0,0 +1,176 @@ +package shell + +import ( + "fmt" + + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type InstanceListOptions struct { + Id []string `help:"IDs of instances to show"` + Zone string `help:"Zone ID"` + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&InstanceListOptions{}, "instance-list", "List intances", func(cli *qcloud.SRegion, args *InstanceListOptions) error { + instances, total, e := cli.GetInstances(args.Zone, args.Id, args.Offset, args.Limit) + if e != nil { + return e + } + printList(instances, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type InstanceCrateOptions struct { + NAME string `help:"name of instance"` + IMAGE string `help:"image ID"` + CPU int `help:"CPU count"` + MEMORYGB int `help:"MemoryGB"` + Disk []int `help:"Data disk sizes int GB"` + STORAGE string `help:"Storage type" choices:"LOCAL_BASIC|LOCAL_SSD|CLOUD_BASIC|CLOUD_PREMIUM|CLOUD_SSD"` + NETWORK string `help:"Network ID"` + PASSWD string `help:"password"` + PublicKey string `help:"PublicKey"` + } + + shellutils.R(&InstanceCrateOptions{}, "instance-create", "Create a instance", func(cli *qcloud.SRegion, args *InstanceCrateOptions) error { + instance, e := cli.CreateInstanceSimple(args.NAME, args.IMAGE, args.CPU, args.MEMORYGB, args.STORAGE, args.Disk, args.NETWORK, args.PASSWD, args.PublicKey) + if e != nil { + return e + } + printObject(instance) + return nil + }) + + type InstanceDiskOperationOptions struct { + ID string `help:"instance ID"` + DISK string `help:"disk ID"` + } + + shellutils.R(&InstanceDiskOperationOptions{}, "instance-attach-disk", "Attach a disk to instance", func(cli *qcloud.SRegion, args *InstanceDiskOperationOptions) error { + err := cli.AttachDisk(args.ID, args.DISK) + if err != nil { + return err + } + return nil + }) + + shellutils.R(&InstanceDiskOperationOptions{}, "instance-detach-disk", "Detach a disk to instance", func(cli *qcloud.SRegion, args *InstanceDiskOperationOptions) error { + err := cli.DetachDisk(args.ID, args.DISK) + if err != nil { + return err + } + return nil + }) + + type InstanceOperationOptions struct { + ID string `help:"instance ID"` + } + shellutils.R(&InstanceOperationOptions{}, "instance-start", "Start a instance", func(cli *qcloud.SRegion, args *InstanceOperationOptions) error { + err := cli.StartVM(args.ID) + if err != nil { + return err + } + return nil + }) + + shellutils.R(&InstanceOperationOptions{}, "instance-vnc", "Get a instance VNC url", func(cli *qcloud.SRegion, args *InstanceOperationOptions) error { + url, err := cli.GetInstanceVNCUrl(args.ID) + if err != nil { + return err + } + fmt.Println(url) + return nil + }) + + type InstanceStopOptions struct { + ID string `help:"instance ID"` + Force bool `help:"Force stop instance"` + } + shellutils.R(&InstanceStopOptions{}, "instance-stop", "Stop a instance", func(cli *qcloud.SRegion, args *InstanceStopOptions) error { + err := cli.StopVM(args.ID, args.Force) + if err != nil { + return err + } + return nil + }) + shellutils.R(&InstanceOperationOptions{}, "instance-delete", "Delete a instance", func(cli *qcloud.SRegion, args *InstanceOperationOptions) error { + err := cli.DeleteVM(args.ID) + if err != nil { + return err + } + return nil + }) + + /* + server-change-config 更改系统配置 + server-reset + */ + type InstanceDeployOptions struct { + ID string `help:"instance ID"` + Name string `help:"new instance name"` + Hostname string `help:"new hostname"` + Keypair string `help:"Keypair Name"` + DeleteKeypair bool `help:"Remove SSH keypair"` + Password string `help:"new password"` + // ResetPassword bool `help:"Force reset password"` + Description string `help:"new instances description"` + } + + shellutils.R(&InstanceDeployOptions{}, "instance-deploy", "Deploy keypair/password to a stopped virtual server", func(cli *qcloud.SRegion, args *InstanceDeployOptions) error { + err := cli.DeployVM(args.ID, args.Name, args.Password, args.Keypair, args.DeleteKeypair, args.Description) + if err != nil { + return err + } + return nil + }) + + type InstanceRebuildRootOptions struct { + ID string `help:"instance ID"` + Image string `help:"Image ID"` + Password string `help:"pasword"` + Keypair string `help:"keypair name"` + Size int `help:"system disk size in GB"` + } + + shellutils.R(&InstanceRebuildRootOptions{}, "instance-rebuild-root", "Reinstall virtual server system image", func(cli *qcloud.SRegion, args *InstanceRebuildRootOptions) error { + diskID, err := cli.ReplaceSystemDisk(args.ID, args.Image, args.Password, args.Keypair, args.Size) + if err != nil { + return err + } + fmt.Printf("New diskID is %s", diskID) + return nil + }) + + type InstanceChangeConfigOptions struct { + ID string `help:"instance ID"` + Ncpu int `help:"number of CPU"` + Vmem int `help:"MiB of memory"` + Disk []int `help:"Data disk sizes int GB"` + } + + shellutils.R(&InstanceChangeConfigOptions{}, "instance-change-config", "Deploy keypair/password to a stopped virtual server", func(cli *qcloud.SRegion, args *InstanceChangeConfigOptions) error { + instance, e := cli.GetInstance(args.ID) + if e != nil { + return e + } + + // todo : add create disks + err := cli.ChangeVMConfig(instance.Placement.Zone, args.ID, args.Ncpu, args.Vmem, nil) + if err != nil { + return err + } + return nil + }) + + type InstanceUpdatePasswordOptions struct { + ID string `help:"Instance ID"` + PASSWD string `help:"new password"` + } + shellutils.R(&InstanceUpdatePasswordOptions{}, "instance-update-password", "Update instance password", func(cli *qcloud.SRegion, args *InstanceUpdatePasswordOptions) error { + err := cli.UpdateInstancePassword(args.ID, args.PASSWD) + return err + }) +} diff --git a/pkg/util/qcloud/shell/keypair.go b/pkg/util/qcloud/shell/keypair.go new file mode 100644 index 0000000000..99cd96d389 --- /dev/null +++ b/pkg/util/qcloud/shell/keypair.go @@ -0,0 +1,45 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type KeyPairListOptions struct { + Name string `help:"Keypair Name"` + IDs []string `help:"Keypari ids"` + Offset int `help:"List offset"` + Limit int `help:"List limit"` + } + shellutils.R(&KeyPairListOptions{}, "keypair-list", "List keypair", func(cli *qcloud.SRegion, args *KeyPairListOptions) error { + keypairs, total, err := cli.GetKeypairs(args.Name, args.IDs, args.Offset, args.Limit) + if err != nil { + return err + } + printList(keypairs, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type KeyPairCreateOptions struct { + NAME string `help:"Keypair Name"` + } + shellutils.R(&KeyPairCreateOptions{}, "keypair-create", "Create keypair", func(cli *qcloud.SRegion, args *KeyPairCreateOptions) error { + keypair, err := cli.CreateKeyPair(args.NAME) + if err != nil { + return err + } + printObject(keypair) + return nil + }) + + type KeyPairAssociateOptions struct { + KEYPAIRID string `help:"Keypair ID"` + INSTANCEID string `help:"Instance ID"` + } + + shellutils.R(&KeyPairAssociateOptions{}, "keypair-associate-instance", "Attach Keypair to a instance", func(cli *qcloud.SRegion, args *KeyPairAssociateOptions) error { + return cli.AttachKeypair(args.INSTANCEID, args.KEYPAIRID) + }) + +} diff --git a/pkg/util/qcloud/shell/network.go b/pkg/util/qcloud/shell/network.go new file mode 100644 index 0000000000..3e16e834a8 --- /dev/null +++ b/pkg/util/qcloud/shell/network.go @@ -0,0 +1,54 @@ +package shell + +import ( + "fmt" + + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type NetworkListOptions struct { + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&NetworkListOptions{}, "network-list", "List networks", func(cli *qcloud.SRegion, args *NetworkListOptions) error { + networks, total, e := cli.GetNetworks(nil, "", args.Offset, args.Limit) + if e != nil { + return e + } + printList(networks, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type NetworkOptions struct { + ID string `help:"Network ID"` + } + shellutils.R(&NetworkOptions{}, "network-delete", "Delete network", func(cli *qcloud.SRegion, args *NetworkOptions) error { + return cli.DeleteNetwork(args.ID) + }) + + shellutils.R(&NetworkOptions{}, "network-show", "Show network", func(cli *qcloud.SRegion, args *NetworkOptions) error { + network, err := cli.GetNetwork(args.ID) + if err != nil { + return err + } + printObject(network) + return nil + }) + + type NetworkCreateOptions struct { + ZONE string `help:"Zone ID"` + VPC string `help:"VPC ID"` + CIDR string `help:"Network CIDR"` + NAME string `help:"Network Name"` + } + shellutils.R(&NetworkCreateOptions{}, "network-create", "Create network", func(cli *qcloud.SRegion, args *NetworkCreateOptions) error { + networkId, err := cli.CreateNetwork(args.ZONE, args.VPC, args.NAME, args.CIDR, "") + if err != nil { + return err + } + fmt.Println(networkId) + return nil + }) +} diff --git a/pkg/util/qcloud/shell/printutils.go b/pkg/util/qcloud/shell/printutils.go new file mode 100644 index 0000000000..6d573bce88 --- /dev/null +++ b/pkg/util/qcloud/shell/printutils.go @@ -0,0 +1,11 @@ +package shell + +import "yunion.io/x/onecloud/pkg/util/printutils" + +func printList(data interface{}, total, offset, limit int, columns []string) { + printutils.PrintInterfaceList(data, total, offset, limit, columns) +} + +func printObject(obj interface{}) { + printutils.PrintInterfaceObject(obj) +} diff --git a/pkg/util/qcloud/shell/region.go b/pkg/util/qcloud/shell/region.go new file mode 100644 index 0000000000..0c8c7b9425 --- /dev/null +++ b/pkg/util/qcloud/shell/region.go @@ -0,0 +1,16 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type RegionListOptions struct { + } + shellutils.R(&RegionListOptions{}, "region-list", "List regions", func(cli *qcloud.SRegion, args *RegionListOptions) error { + regions := cli.GetClient().GetRegions() + printList(regions, 0, 0, 0, nil) + return nil + }) +} diff --git a/pkg/util/qcloud/shell/securitygroup.go b/pkg/util/qcloud/shell/securitygroup.go new file mode 100644 index 0000000000..35d6536d34 --- /dev/null +++ b/pkg/util/qcloud/shell/securitygroup.go @@ -0,0 +1,66 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type SecurityGroupListOptions struct { + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&SecurityGroupListOptions{}, "security-group-list", "List SecurityGroup", func(cli *qcloud.SRegion, args *SecurityGroupListOptions) error { + secgrps, total, err := cli.GetSecurityGroups("", args.Limit, args.Offset) + if err != nil { + return err + } + printList(secgrps, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type SecurityGroupOptions struct { + ID string `help:"SecurityGroup ID"` + } + shellutils.R(&SecurityGroupOptions{}, "security-group-show", "Show SecurityGroup", func(cli *qcloud.SRegion, args *SecurityGroupOptions) error { + secgroup, err := cli.GetSecurityGroupDetails(args.ID) + if err != nil { + return err + } + printObject(secgroup) + return nil + }) + + shellutils.R(&SecurityGroupOptions{}, "security-group-delete", "Delete SecurityGroup", func(cli *qcloud.SRegion, args *SecurityGroupOptions) error { + return cli.DeleteSecurityGroup(args.ID) + }) + + type SecurityGroupCreateOptions struct { + NAME string `help:"SecurityGroup Name"` + Desc string `help:"SecurityGroup Description"` + } + + shellutils.R(&SecurityGroupCreateOptions{}, "security-group-create", "Create SecurityGroup", func(cli *qcloud.SRegion, args *SecurityGroupCreateOptions) error { + secgrp, err := cli.CreateSecurityGroup(args.NAME, args.Desc) + if err != nil { + return err + } + printObject(secgrp) + return nil + }) + + type AddressShowOptions struct { + Id string `help:"IP address ID"` + Name string `help:"IP address name"` + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&AddressShowOptions{}, "address-list", "Show address", func(cli *qcloud.SRegion, args *AddressShowOptions) error { + address, total, err := cli.AddressList(args.Id, args.Name, args.Offset, args.Limit) + if err != nil { + return err + } + printList(address, total, args.Offset, args.Limit, []string{}) + return nil + }) +} diff --git a/pkg/util/qcloud/shell/snapshot.go b/pkg/util/qcloud/shell/snapshot.go new file mode 100644 index 0000000000..997f921f26 --- /dev/null +++ b/pkg/util/qcloud/shell/snapshot.go @@ -0,0 +1,45 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type SnapshotListOptions struct { + DiskId string `help:"Disk ID"` + InstanceId string `help:"Instance ID"` + SnapshotIds []string `helo:"Snapshot ids"` + Name string `help:"Snapshot Name"` + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&SnapshotListOptions{}, "snapshot-list", "List snapshot", func(cli *qcloud.SRegion, args *SnapshotListOptions) error { + snapshots, total, err := cli.GetSnapshots(args.InstanceId, args.DiskId, args.Name, args.SnapshotIds, args.Offset, args.Limit) + if err != nil { + return err + } + printList(snapshots, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type SnapshotDeleteOptions struct { + ID string `help:"Snapshot ID"` + } + + shellutils.R(&SnapshotDeleteOptions{}, "snapshot-delete", "Delete snapshot", func(cli *qcloud.SRegion, args *SnapshotDeleteOptions) error { + return cli.DeleteSnapshot(args.ID) + }) + + type SnapshotCreateOptions struct { + DISK string `help:"Disk ID"` + Name string `help:"Snapeshot Name"` + Desc string `help:"Snapshot Desc"` + } + + shellutils.R(&SnapshotCreateOptions{}, "snapshot-create", "Create snapshot", func(cli *qcloud.SRegion, args *SnapshotCreateOptions) error { + _, err := cli.CreateSnapshot(args.DISK, args.Name, args.Desc) + return err + }) + +} diff --git a/pkg/util/qcloud/shell/vpc.go b/pkg/util/qcloud/shell/vpc.go new file mode 100644 index 0000000000..67f1920524 --- /dev/null +++ b/pkg/util/qcloud/shell/vpc.go @@ -0,0 +1,41 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type VpcListOptions struct { + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&VpcListOptions{}, "vpc-list", "List vpcs", func(cli *qcloud.SRegion, args *VpcListOptions) error { + vpcs, total, err := cli.GetVpcs(nil, args.Offset, args.Limit) + if err != nil { + return err + } + printList(vpcs, total, args.Offset, args.Limit, []string{}) + return nil + }) + + type VpcCreateOptions struct { + NAME string `help:"Name for vpc"` + CIDR string `help:"Cidr for vpc" choices:"10.0.0.0/16|172.16.0.0/12|192.168.0.0/16"` + } + shellutils.R(&VpcCreateOptions{}, "vpc-create", "Create vpc", func(cli *qcloud.SRegion, args *VpcCreateOptions) error { + vpc, err := cli.CreateIVpc(args.NAME, "", args.CIDR) + if err != nil { + return err + } + printObject(vpc) + return nil + }) + + type VpcDeleteOptions struct { + ID string `help:"VPC ID or Name"` + } + shellutils.R(&VpcDeleteOptions{}, "vpc-delete", "Delete vpc", func(cli *qcloud.SRegion, args *VpcDeleteOptions) error { + return cli.DeleteVpc(args.ID) + }) +} diff --git a/pkg/util/qcloud/shell/zone.go b/pkg/util/qcloud/shell/zone.go new file mode 100644 index 0000000000..5ae269ecb0 --- /dev/null +++ b/pkg/util/qcloud/shell/zone.go @@ -0,0 +1,21 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/util/qcloud" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type ZoneListOptions struct { + Limit int `help:"page size"` + Offset int `help:"page offset"` + } + shellutils.R(&ZoneListOptions{}, "zone-list", "List zones", func(cli *qcloud.SRegion, args *ZoneListOptions) error { + zones, err := cli.GetIZones() + if err != nil { + return err + } + printList(zones, len(zones), args.Offset, args.Limit, []string{}) + return nil + }) +} diff --git a/pkg/util/qcloud/snapshot.go b/pkg/util/qcloud/snapshot.go new file mode 100644 index 0000000000..7f53083b0e --- /dev/null +++ b/pkg/util/qcloud/snapshot.go @@ -0,0 +1,218 @@ +package qcloud + +import ( + "fmt" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type SnapshotStatusType string + +const ( + SnapshotStatusAccomplished SnapshotStatusType = "NORMAL" + SnapshotStatusProgress SnapshotStatusType = "CREATING" + SnapshotStatusFailed SnapshotStatusType = "failed" +) + +type SSnapshot struct { + region *SRegion + + SnapshotId string // 快照ID。 + Placement Placement // 快照所在的位置。 + DiskUsage string // 创建此快照的云硬盘类型。取值范围:SYSTEM_DISK:系统盘 DATA_DISK:数据盘。 + DiskId string // 创建此快照的云硬盘ID。 + DiskSize int32 // 创建此快照的云硬盘大小,单位GB。 + SnapshotState SnapshotStatusType // 快照的状态。取值范围: NORMAL:正常 CREATING:创建中 ROLLBACKING:回滚中 COPYING_FROM_REMOTE:跨地域复制快照拷贝中。 + SnapshotName string // 快照名称,用户自定义的快照别名。调用ModifySnapshotAttribute可修改此字段。 + Percent int // 快照创建进度百分比,快照创建成功后此字段恒为100。 + CreateTime time.Time // 快照的创建时间。 + DeadlineTime time.Time // 快照到期时间。如果快照为永久保留,此字段为空。 + Encrypt bool // 是否为加密盘创建的快照。取值范围:true:该快照为加密盘创建的 false:非加密盘创建的快照。 + IsPermanent bool // 是否为永久快照。取值范围: true:永久快照 false:非永久快照。 + CopyingToRegions []string // 快照正在跨地域复制的目的地域,默认取值为[]。 + CopyFromRemote bool // 是否为跨地域复制的快照。取值范围:true:表示为跨地域复制的快照。 false:本地域的快照。 +} + +func (self *SRegion) GetISnapshotById(snapshotId string) (cloudprovider.ICloudSnapshot, error) { + snapshots, total, err := self.GetSnapshots("", "", "", []string{snapshotId}, 0, 1) + if err != nil { + return nil, err + } + if total > 1 { + return nil, cloudprovider.ErrDuplicateId + } + if total == 0 { + return nil, cloudprovider.ErrNotFound + } + return &snapshots[0], nil +} + +func (self *SSnapshot) GetStatus() string { + // NORMAL:正常 + // CREATING:创建中 + // ROLLBACKING:回滚中 + // COPYING_FROM_REMOTE:跨地域复制快照拷贝中。 + switch self.SnapshotState { + case "NORMAL", "COPYING_FROM_REMOTE": + return models.SNAPSHOT_READY + case "CREATING": + return models.SNAPSHOT_CREATING + case "ROLLBACKING": + return models.SNAPSHOT_ROLLBACKING + } + return models.SNAPSHOT_UNKNOWN +} + +func (self *SSnapshot) IsEmulated() bool { + return false +} + +func (self *SSnapshot) Refresh() error { + snapshots, total, err := self.region.GetSnapshots("", "", "", []string{self.SnapshotId}, 0, 1) + if err != nil { + return err + } + if total > 1 { + return cloudprovider.ErrDuplicateId + } + + if total == 0 { + return cloudprovider.ErrNotFound + } + return jsonutils.Update(self, snapshots[0]) +} + +func (self *SRegion) GetSnapshots(instanceId string, diskId string, snapshotName string, snapshotIds []string, offset int, limit int) ([]SSnapshot, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } + params := make(map[string]string) + params["Limit"] = fmt.Sprintf("%d", limit) + params["Offset"] = fmt.Sprintf("%d", offset) + + filter := 0 + if len(instanceId) > 0 { + } + if len(diskId) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "disk-id" + params[fmt.Sprintf("Filters.%d.Values", filter)] = diskId + filter++ + } + if len(snapshotName) > 0 { + params[fmt.Sprintf("Filters.%d.Name", filter)] = "snapshot-name" + params[fmt.Sprintf("Filters.%d.Values", filter)] = snapshotName + filter++ + } + if snapshotIds != nil && len(snapshotIds) > 0 { + for index, snapshotId := range snapshotIds { + params[fmt.Sprintf("SnapshotIds.%d", index)] = snapshotId + } + } + snapshots := []SSnapshot{} + body, err := self.cbsRequest("DescribeSnapshots", params) + if err != nil { + log.Errorf("GetSnapshots fail %s", err) + return nil, 0, err + } + body.Unmarshal(&snapshots, "SnapshotSet") + if err != nil { + return nil, 0, err + } + total, _ := body.Float("TotalCount") + for i := 0; i < len(snapshots); i++ { + snapshots[i].region = self + } + return snapshots, int(total), nil +} + +func (self *SRegion) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) { + snapshots, total, err := self.GetSnapshots("", "", "", []string{}, 0, 50) + if err != nil { + return nil, err + } + for len(snapshots) < total { + var parts []SSnapshot + parts, total, err = self.GetSnapshots("", "", "", []string{}, len(snapshots), 50) + if err != nil { + return nil, err + } + snapshots = append(snapshots, parts...) + } + ret := make([]cloudprovider.ICloudSnapshot, len(snapshots)) + for i := 0; i < len(snapshots); i++ { + ret[i] = &snapshots[i] + } + return ret, nil +} + +func (self *SSnapshot) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SSnapshot) GetRegionId() string { + return self.region.GetId() +} + +func (self *SSnapshot) GetManagerId() string { + return self.region.client.providerId +} + +func (self *SSnapshot) GetSize() int32 { + return self.DiskSize +} + +func (self *SSnapshot) GetDiskId() string { + return self.DiskId +} + +func (self *SSnapshot) GetId() string { + return self.SnapshotId +} + +func (self *SSnapshot) GetGlobalId() string { + return fmt.Sprintf("%s", self.SnapshotId) +} + +func (self *SSnapshot) GetName() string { + return self.SnapshotName +} + +func (self *SSnapshot) Delete() error { + if self.region == nil { + return fmt.Errorf("not init region for snapshot %s", self.SnapshotId) + } + return self.region.DeleteSnapshot(self.SnapshotId) +} + +func (self *SSnapshot) GetDiskType() string { + switch self.DiskUsage { + case "SYSTEM_DISK": + return models.DISK_TYPE_SYS + case "DATA_DISK": + return models.DISK_TYPE_DATA + } + return models.DISK_TYPE_DATA +} + +func (self *SRegion) DeleteSnapshot(snapshotId string) error { + params := map[string]string{"SnapshotIds.0": snapshotId} + _, err := self.cbsRequest("DeleteSnapshots", params) + return err +} + +func (self *SRegion) CreateSnapshot(diskId, name, desc string) (string, error) { + params := make(map[string]string) + params["DiskId"] = diskId + params["SnapshotName"] = name + + body, err := self.cbsRequest("CreateSnapshot", params) + if err != nil { + log.Errorf("CreateSnapshot fail %s", err) + return "", err + } + return body.GetString("SnapshotId") +} diff --git a/pkg/util/qcloud/storage.go b/pkg/util/qcloud/storage.go new file mode 100644 index 0000000000..1f3ddfbb80 --- /dev/null +++ b/pkg/util/qcloud/storage.go @@ -0,0 +1,126 @@ +package qcloud + +import ( + "fmt" + "strings" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type SStorage struct { + zone *SZone + storageType string +} + +func (self *SStorage) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SStorage) GetId() string { + return fmt.Sprintf("%s-%s-%s", self.zone.region.client.providerId, self.zone.GetId(), self.storageType) +} + +func (self *SStorage) GetName() string { + return fmt.Sprintf("%s-%s-%s", self.zone.region.client.providerName, self.zone.GetId(), self.storageType) +} + +func (self *SStorage) GetGlobalId() string { + return fmt.Sprintf("%s-%s-%s", self.zone.region.client.providerId, self.zone.GetGlobalId(), self.storageType) +} + +func (self *SStorage) IsEmulated() bool { + return true +} + +func (self *SStorage) GetIZone() cloudprovider.ICloudZone { + return self.zone +} + +func (self *SStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) { + disks := make([]SDisk, 0) + for { + parts, total, err := self.zone.region.GetDisks("", self.zone.GetId(), self.storageType, nil, len(disks), 50) + if err != nil { + log.Errorf("GetDisks fail %s", err) + return nil, err + } + disks = append(disks, parts...) + if len(disks) >= total { + break + } + } + idisks := make([]cloudprovider.ICloudDisk, len(disks)) + for i := 0; i < len(disks); i++ { + disks[i].storage = self + idisks[i] = &disks[i] + } + return idisks, nil +} + +func (self *SStorage) GetStorageType() string { + return strings.ToLower(self.storageType) +} + +func (self *SStorage) GetMediumType() string { + if strings.HasSuffix(self.storageType, "_BASIC") { + return models.DISK_TYPE_ROTATE + } + return models.DISK_TYPE_SSD +} + +func (self *SStorage) GetCapacityMB() int { + return 0 // unlimited +} + +func (self *SStorage) GetStorageConf() jsonutils.JSONObject { + conf := jsonutils.NewDict() + return conf +} + +func (self *SStorage) GetManagerId() string { + return self.zone.region.client.providerId +} + +func (self *SStorage) GetStatus() string { + return models.STORAGE_ONLINE +} + +func (self *SStorage) Refresh() error { + // do nothing + return nil +} + +func (self *SStorage) GetEnabled() bool { + return true +} + +func (self *SStorage) GetIStoragecache() cloudprovider.ICloudStoragecache { + return self.zone.region.getStoragecache() +} + +func (self *SStorage) CreateIDisk(name string, sizeGb int, desc string) (cloudprovider.ICloudDisk, error) { + diskId, err := self.zone.region.CreateDisk(self.zone.Zone, self.storageType, name, sizeGb, desc) + if err != nil { + log.Errorf("createDisk fail %s", err) + return nil, err + } + disk, err := self.zone.region.GetDisk(diskId) + if err != nil { + log.Errorf("getDisk fail %s", err) + return nil, err + } + disk.storage = self + return disk, nil +} + +func (self *SStorage) GetIDisk(idStr string) (cloudprovider.ICloudDisk, error) { + disk, err := self.zone.region.GetDisk(idStr) + if err != nil { + return nil, err + } + disk.storage = self + return disk, nil +} diff --git a/pkg/util/qcloud/storagecache.go b/pkg/util/qcloud/storagecache.go new file mode 100644 index 0000000000..8630752591 --- /dev/null +++ b/pkg/util/qcloud/storagecache.go @@ -0,0 +1,189 @@ +package qcloud + +import ( + "context" + "fmt" + "strings" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/options" + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/mcclient/auth" + "yunion.io/x/onecloud/pkg/mcclient/modules" + + coslib "github.com/nelsonken/cos-go-sdk-v5/cos" +) + +type SStoragecache struct { + region *SRegion + + iimages []cloudprovider.ICloudImage +} + +func (self *SStoragecache) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SStoragecache) GetId() string { + return fmt.Sprintf("%s-%s", self.region.client.providerId, self.region.GetId()) +} + +func (self *SStoragecache) GetName() string { + return fmt.Sprintf("%s-%s", self.region.client.providerName, self.region.GetId()) +} + +func (self *SStoragecache) GetStatus() string { + return "available" +} + +func (self *SStoragecache) Refresh() error { + return nil +} + +func (self *SStoragecache) GetGlobalId() string { + return fmt.Sprintf("%s-%s", self.region.client.providerId, self.region.GetGlobalId()) +} + +func (self *SStoragecache) IsEmulated() bool { + return false +} + +func (self *SStoragecache) GetManagerId() string { + return self.region.client.providerId +} + +func (self *SStoragecache) CreateIImage(snapshoutId, imageName, osType, imageDesc string) (cloudprovider.ICloudImage, error) { + // if imageId, err := self.region.createIImage(snapshoutId, imageName, imageDesc); err != nil { + // return nil, err + // } else if image, err := self.region.GetImage(imageId); err != nil { + // return nil, err + // } else { + // image.storageCache = self + // iimage := make([]cloudprovider.ICloudImage, 1) + // iimage[0] = image + // if err := cloudprovider.WaitStatus(iimage[0], compute.IMAGE_STATUS_ACTIVE, 15*time.Second, 3600*time.Second); err != nil { + // return nil, err + // } + // return iimage[0], nil + // } + return nil, nil +} + +func (self *SStoragecache) DownloadImage(userCred mcclient.TokenCredential, imageId string, extId string, path string) (jsonutils.JSONObject, error) { + //return self.downloadImage(userCred, imageId, extId, path) + return nil, nil +} + +func (self *SStoragecache) fetchImages() error { + images := make([]SImage, 0) + for { + parts, total, err := self.region.GetImages("", "PRIVATE_IMAGE", nil, "", len(images), 50) + if err != nil { + return err + } + images = append(images, parts...) + if len(images) >= total { + break + } + } + self.iimages = make([]cloudprovider.ICloudImage, len(images)) + for i := 0; i < len(images); i += 1 { + images[i].storageCache = self + self.iimages[i] = &images[i] + } + return nil +} + +func (self *SStoragecache) GetIImages() ([]cloudprovider.ICloudImage, error) { + if self.iimages == nil { + err := self.fetchImages() + if err != nil { + return nil, err + } + } + return self.iimages, nil +} + +func (self *SStoragecache) UploadImage(userCred mcclient.TokenCredential, imageId string, osArch, osType, osDist string, extId string, isForce bool) (string, error) { + if len(extId) > 0 { + log.Debugf("UploadImage: Image external ID exists %s", extId) + + status, err := self.region.GetImageStatus(extId) + if err != nil { + log.Errorf("GetImageStatus error %s", err) + } + if status == ImageStatusAvailable && !isForce { + return extId, nil + } + } else { + log.Debugf("UploadImage: no external ID") + } + return self.uploadImage(userCred, imageId, osArch, osType, osDist, isForce) +} + +func (self *SRegion) getCosUrl(bucket, object string) string { + return fmt.Sprintf("http://%s-%s.cosd.myqcloud.com/%s", bucket, self.client.AppID, object) +} + +func (self *SStoragecache) uploadImage(userCred mcclient.TokenCredential, imageId string, osArch, osType, osDist string, isForce bool) (string, error) { + // first upload image to oss + s := auth.GetAdminSession(options.Options.Region, "") + + meta, reader, err := modules.Images.Download(s, imageId) + if err != nil { + return "", err + } + log.Infof("meta data %s", meta) + cos, err := self.region.GetCosClient() + if err != nil { + log.Errorf("GetOssClient err %s", err) + return "", err + } + bucketName := strings.ToLower(fmt.Sprintf("imgcache-%s-%s", self.region.GetId(), self.region.client.providerId)) + if err := cos.BucketExists(context.Background(), bucketName); err != nil { + log.Debugf("Bucket %s not exists, to create ...", bucketName) + if err := cos.CreateBucket(context.Background(), bucketName, &coslib.AccessControl{ACL: "public-read"}); err != nil { + log.Errorf("Create bucket error %s", err) + return "", err + } + } else { + log.Debugf("Bucket %s exists", bucketName) + } + log.Debugf("To upload image to bucket %s ...", bucketName) + if err := cos.Bucket(bucketName).UploadObject(context.Background(), imageId, reader, &coslib.AccessControl{}); err != nil { + log.Errorf("UploadObject error %s %s", imageId, err) + return "", err + } + imageBaseName := imageId + if imageBaseName[0] >= '0' && imageBaseName[0] <= '9' { + imageBaseName = fmt.Sprintf("img%s", imageId) + } + imageName := imageBaseName + nameIdx := 1 + + // check image name, avoid name conflict + for { + _, err = self.region.GetImageByName(imageName) + if err != nil { + if err == cloudprovider.ErrNotFound { + break + } else { + return "", err + } + } + imageName = fmt.Sprintf("%s-%d", imageBaseName, nameIdx) + nameIdx++ + } + + log.Debugf("Import image %s", imageName) + if image, err := self.region.ImportImage(imageName, osArch, osType, osDist, self.region.getCosUrl(bucketName, imageId)); err != nil { + return "", err + } else if cloudprovider.WaitStatus(image, string(ImageStatusAvailable), 15*time.Second, 3600*time.Second); err != nil { + return "", err + } else { + return image.ImageId, nil + } +} diff --git a/pkg/util/qcloud/vpc.go b/pkg/util/qcloud/vpc.go new file mode 100644 index 0000000000..5aee1b7161 --- /dev/null +++ b/pkg/util/qcloud/vpc.go @@ -0,0 +1,193 @@ +package qcloud + +import ( + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/pkg/util/secrules" +) + +type SVpc struct { + region *SRegion + + iwires []cloudprovider.ICloudWire + + secgroups []cloudprovider.ICloudSecurityGroup + + CidrBlock string + CreatedTime time.Time + DhcpOptionsId string + DnsServerSet []string + DomainName string + EnableMulticast bool + IsDefault bool + VpcId string + VpcName string +} + +func (self *SVpc) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SVpc) GetId() string { + return self.VpcId +} + +func (self *SVpc) GetName() string { + if len(self.VpcName) > 0 { + return self.VpcName + } + return self.VpcId +} + +func (self *SVpc) GetGlobalId() string { + return self.VpcId +} + +func (self *SVpc) IsEmulated() bool { + return false +} + +func (self *SVpc) GetIsDefault() bool { + return self.IsDefault +} + +func (self *SVpc) GetCidrBlock() string { + return self.CidrBlock +} + +func (self *SVpc) GetStatus() string { + return models.VPC_STATUS_AVAILABLE +} + +func (self *SVpc) Delete() error { + return self.region.DeleteVpc(self.VpcId) +} + +func (self *SVpc) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) { + secgroups := make([]SSecurityGroup, 0) + for { + parts, total, err := self.region.GetSecurityGroups(self.VpcId, len(secgroups), 50) + if err != nil { + return nil, err + } + secgroups = append(secgroups, parts...) + if len(secgroups) >= total { + break + } + } + isecgroups := make([]cloudprovider.ICloudSecurityGroup, len(secgroups)) + for i := 0; i < len(secgroups); i++ { + secgroups[i].vpc = self + isecgroups[i] = &secgroups[i] + } + return isecgroups, nil +} + +func (self *SVpc) getWireByZoneId(zoneId string) *SWire { + for i := 0; i <= len(self.iwires); i++ { + wire := self.iwires[i].(*SWire) + if wire.zone.Zone == zoneId { + return wire + } + } + return nil +} + +func (self *SVpc) fetchNetworks() error { + networks, total, err := self.region.GetNetworks(nil, self.VpcId, 0, 50) + if err != nil { + return err + } + if total > len(networks) { + networks, _, err = self.region.GetNetworks(nil, self.VpcId, 0, total) + if err != nil { + return err + } + } + for i := 0; i < len(networks); i += 1 { + wire := self.getWireByZoneId(networks[i].Zone) + networks[i].wire = wire + wire.addNetwork(&networks[i]) + } + return nil +} + +func (self *SVpc) GetIWireById(wireId string) (cloudprovider.ICloudWire, error) { + if self.iwires == nil { + err := self.fetchNetworks() + if err != nil { + return nil, err + } + } + for i := 0; i < len(self.iwires); i += 1 { + if self.iwires[i].GetGlobalId() == wireId { + return self.iwires[i], nil + } + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SVpc) GetIWires() ([]cloudprovider.ICloudWire, error) { + if self.iwires == nil { + err := self.fetchNetworks() + if err != nil { + return nil, err + } + } + return self.iwires, nil +} + +func (self *SVpc) GetManagerId() string { + return self.region.client.providerId +} + +func (self *SVpc) GetRegion() cloudprovider.ICloudRegion { + return self.region +} + +func (self *SVpc) Refresh() error { + new, err := self.region.getVpc(self.VpcId) + if err != nil { + return err + } + return jsonutils.Update(self, new) +} + +func (self *SVpc) SyncSecurityGroup(secgroupId string, name string, rules []secrules.SecurityRule) (string, error) { + secgrpId := "" + // if secgroup, err := self.region.getSecurityGroupByTag(self.VpcId, secgroupId); err != nil { + // if secgrpId, err = self.region.createSecurityGroup(self.VpcId, name, ""); err != nil { + // return "", err + // } else if err := self.region.addTagToSecurityGroup(secgrpId, "id", secgroupId, 1); err != nil { + // return "", err + // } + // //addRules + // log.Debugf("Add Rules for %s", secgrpId) + // for _, rule := range rules { + // if err := self.region.addSecurityGroupRule(secgrpId, &rule); err != nil { + // return "", err + // } + // } + // } else { + // //syncRules + // secgrpId = secgroup.SecurityGroupId + // log.Debugf("Sync Rules for %s", secgroup.GetName()) + // if secgroup.GetName() != name { + // if err := self.region.modifySecurityGroup(secgrpId, name, ""); err != nil { + // log.Errorf("Change SecurityGroup name to %s failed: %v", name, err) + // } + // } + // self.region.syncSecgroupRules(secgrpId, rules) + // } + return secgrpId, nil +} + +func (self *SVpc) addWire(wire *SWire) { + if self.iwires == nil { + self.iwires = make([]cloudprovider.ICloudWire, 0) + } + self.iwires = append(self.iwires, wire) +} diff --git a/pkg/util/qcloud/wire.go b/pkg/util/qcloud/wire.go new file mode 100644 index 0000000000..41e331429d --- /dev/null +++ b/pkg/util/qcloud/wire.go @@ -0,0 +1,142 @@ +package qcloud + +import ( + "fmt" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" +) + +type SWire struct { + zone *SZone + vpc *SVpc + + inetworks []cloudprovider.ICloudNetwork +} + +func (self *SWire) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SWire) GetId() string { + return fmt.Sprintf("%s-%s", self.vpc.GetId(), self.zone.GetId()) +} + +func (self *SWire) GetName() string { + return self.GetId() +} + +func (self *SWire) IsEmulated() bool { + return true +} + +func (self *SWire) GetStatus() string { + return "available" +} + +func (self *SWire) Refresh() error { + return nil +} + +func (self *SWire) GetGlobalId() string { + return fmt.Sprintf("%s-%s", self.vpc.GetGlobalId(), self.zone.GetGlobalId()) +} + +func (self *SWire) GetIVpc() cloudprovider.ICloudVpc { + return self.vpc +} + +func (self *SWire) GetIZone() cloudprovider.ICloudZone { + return self.zone +} + +func (self *SWire) GetBandwidth() int { + return 10000 +} + +func (self *SWire) GetNetworkById(networkId string) *SNetwork { + networks, err := self.GetINetworks() + if err != nil { + return nil + } + log.Debugf("search for networks %d", len(networks)) + for i := 0; i < len(networks); i += 1 { + log.Debugf("search %s", networks[i].GetName()) + network := networks[i].(*SNetwork) + if network.SubnetId == networkId { + return network + } + } + return nil +} + +func (self *SWire) CreateINetwork(name string, cidr string, desc string) (cloudprovider.ICloudNetwork, error) { + networkId, err := self.zone.region.CreateNetwork(self.zone.Zone, self.vpc.VpcId, name, cidr, desc) + if err != nil { + log.Errorf("CreateNetwork error %s", err) + return nil, err + } + self.inetworks = nil + network := self.GetNetworkById(networkId) + if network == nil { + log.Errorf("cannot find vswitch after create????") + return nil, cloudprovider.ErrNotFound + } + return network, nil +} + +func (self *SWire) GetINetworkById(netid string) (cloudprovider.ICloudNetwork, error) { + networks, err := self.GetINetworks() + if err != nil { + return nil, err + } + for i := 0; i < len(networks); i += 1 { + if networks[i].GetGlobalId() == netid { + return networks[i], nil + } + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SWire) getNetworkById(networkId string) *SNetwork { + networks, err := self.GetINetworks() + if err != nil { + return nil + } + log.Debugf("search for networks %d", len(networks)) + for i := 0; i < len(networks); i += 1 { + log.Debugf("search %s", networks[i].GetName()) + network := networks[i].(*SNetwork) + if network.SubnetId == networkId { + return network + } + } + return nil +} + +func (self *SWire) GetINetworks() ([]cloudprovider.ICloudNetwork, error) { + if self.inetworks == nil { + err := self.vpc.fetchNetworks() + if err != nil { + return nil, err + } + } + return self.inetworks, nil +} + +func (self *SWire) addNetwork(network *SNetwork) { + if self.inetworks == nil { + self.inetworks = make([]cloudprovider.ICloudNetwork, 0) + } + find := false + for i := 0; i < len(self.inetworks); i += 1 { + if self.inetworks[i].GetId() == network.SubnetId { + find = true + break + } + } + if !find { + self.inetworks = append(self.inetworks, network) + } +} diff --git a/pkg/util/qcloud/zone.go b/pkg/util/qcloud/zone.go new file mode 100644 index 0000000000..b4eb50f024 --- /dev/null +++ b/pkg/util/qcloud/zone.go @@ -0,0 +1,202 @@ +package qcloud + +import ( + "fmt" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/pkg/utils" +) + +type InstanceChargeType string + +const ( + PrePaidInstanceChargeType InstanceChargeType = "PREPAID" + PostPaidInstanceChargeType InstanceChargeType = "POSTPAID_BY_HOUR" + CdhPaidInstanceChargeType InstanceChargeType = "CDHPAID" + DefaultInstanceChargeType = PostPaidInstanceChargeType +) + +type SZone struct { + region *SRegion + + iwires []cloudprovider.ICloudWire + + host *SHost + + istorages []cloudprovider.ICloudStorage + + instanceTypes []string + refreshTime time.Time + + Zone string + ZoneId string + ZoneName string + ZoneState string +} + +func (self *SZone) GetMetadata() *jsonutils.JSONDict { + return nil +} + +func (self *SZone) GetId() string { + return self.Zone +} + +func (self *SZone) GetName() string { + return fmt.Sprintf("%s %s", CLOUD_PROVIDER_QCLOUD_CN, self.ZoneName) +} + +func (self *SZone) GetGlobalId() string { + return fmt.Sprintf("%s/%s", self.region.GetGlobalId(), self.Zone) +} + +func (self *SZone) IsEmulated() bool { + return false +} + +func (self *SZone) Refresh() error { + // do nothing + return nil +} + +func (self *SZone) GetStatus() string { + if self.ZoneState == "AVAILABLE" { + return models.ZONE_ENABLE + } + return models.ZONE_SOLDOUT +} + +func (self *SZone) GetIHostById(id string) (cloudprovider.ICloudHost, error) { + host := self.getHost() + if host.GetGlobalId() == id { + return host, nil + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SZone) GetIHosts() ([]cloudprovider.ICloudHost, error) { + return []cloudprovider.ICloudHost{self.getHost()}, nil +} + +func (self *SZone) getHost() *SHost { + if self.host == nil { + self.host = &SHost{zone: self} + } + return self.host +} + +func (self *SZone) GetIRegion() cloudprovider.ICloudRegion { + return self.region +} + +func (self *SZone) fetchStorages() error { + self.istorages = []cloudprovider.ICloudStorage{} + for _, storageType := range []string{"CLOUD_BASIC", "CLOUD_PREMIUM", "CLOUD_SSD"} { + storage := SStorage{zone: self, storageType: storageType} + self.istorages = append(self.istorages, &storage) + } + for _, localstorageType := range []string{"LOCAL_BASIC", "LOCAL_SSD"} { + storage := SLocalStorage{zone: self, storageType: localstorageType} + self.istorages = append(self.istorages, &storage) + } + return nil +} + +func (self *SZone) GetIStorages() ([]cloudprovider.ICloudStorage, error) { + if self.istorages == nil { + self.fetchStorages() + } + return self.istorages, nil +} + +func (self *SZone) getLocalStorageByCategory(category string) (*SLocalStorage, error) { + return &SLocalStorage{zone: self, storageType: category}, nil +} + +func (self *SZone) getStorageByCategory(category string) (*SStorage, error) { + storages, err := self.GetIStorages() + if err != nil { + return nil, err + } + for i := 0; i < len(storages); i++ { + if utils.IsInStringArray(storages[i].GetStorageType(), []string{"local_basic", "local_ssd"}) { + continue + } + storage := storages[i].(*SStorage) + if storage.storageType == category { + return storage, nil + } + } + return nil, fmt.Errorf("No such storage %s", category) +} + +func (self *SZone) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) { + if self.istorages == nil { + self.fetchStorages() + } + for i := 0; i < len(self.istorages); i += 1 { + if self.istorages[i].GetGlobalId() == id { + return self.istorages[i], nil + } + } + return nil, cloudprovider.ErrNotFound +} + +func (self *SZone) addWire(wire *SWire) { + if self.iwires == nil { + self.iwires = make([]cloudprovider.ICloudWire, 0) + } + self.iwires = append(self.iwires, wire) +} + +func (self *SZone) GetIWires() ([]cloudprovider.ICloudWire, error) { + return self.iwires, nil +} + +func (self *SZone) getNetworkById(networkId string) *SNetwork { + log.Debugf("Search in wires %d", len(self.iwires)) + for i := 0; i < len(self.iwires); i += 1 { + log.Debugf("Search in wire %s", self.iwires[i].GetName()) + wire := self.iwires[i].(*SWire) + net := wire.getNetworkById(networkId) + if net != nil { + return net + } + } + return nil +} + +func (self *SZone) fetchInstanceTypes() { + self.instanceTypes = []string{} + params := map[string]string{} + params["Region"] = self.region.Region + params["Filters.0.Name"] = "zone" + params["Filters.0.Values.0"] = self.Zone + if body, err := self.region.cvmRequest("DescribeInstanceTypeConfigs", params); err != nil { + log.Errorf("DescribeInstanceTypeConfigs error: %v", err) + } else if configSet, err := body.GetArray("InstanceTypeConfigSet"); err != nil { + log.Errorf("Get InstanceTypeConfigSet error: %v", err) + } else { + for _, config := range configSet { + if instanceType, err := config.GetString("InstanceType"); err == nil && !utils.IsInStringArray(instanceType, self.instanceTypes) { + self.instanceTypes = append(self.instanceTypes, instanceType) + } + } + self.refreshTime = time.Now() + } +} + +func (self *SZone) getAvaliableInstanceTypes() []string { + if self.instanceTypes == nil || len(self.instanceTypes) == 0 || time.Now().Sub(self.refreshTime).Hours() > refreshHours() { + self.fetchInstanceTypes() + } + return self.instanceTypes +} + +func refreshHours() float64 { + return 5 +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go index 803bc57d5a..a7f553d38f 100644 --- a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go @@ -57,7 +57,7 @@ func (resolver *LocationResolver) TryResolve(param *ResolveParam) (endpoint stri getEndpointRequest.Product = "Location" getEndpointRequest.Version = "2015-06-12" getEndpointRequest.ApiName = "DescribeEndpoints" - getEndpointRequest.Domain = "location.aliyuncs.com" + getEndpointRequest.Domain = "location-readonly.aliyuncs.com" getEndpointRequest.Method = "GET" getEndpointRequest.Scheme = requests.HTTPS diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod new file mode 100644 index 0000000000..716c613125 --- /dev/null +++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod @@ -0,0 +1 @@ +module github.com/konsorten/go-windows-terminal-sequences diff --git a/vendor/github.com/miekg/dns/.travis.yml b/vendor/github.com/miekg/dns/.travis.yml index 13e312b4f3..18259374e5 100644 --- a/vendor/github.com/miekg/dns/.travis.yml +++ b/vendor/github.com/miekg/dns/.travis.yml @@ -1,21 +1,18 @@ language: go sudo: false + go: - 1.10.x - 1.11.x - tip -env: - - TESTS="-race -v -bench=. -coverprofile=coverage.txt -covermode=atomic" - - TESTS="-race -v ./..." - before_install: # don't use the miekg/dns when testing forks - mkdir -p $GOPATH/src/github.com/miekg - ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/miekg/ || true script: - - go test $TESTS + - go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./... after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/miekg/dns/Gopkg.lock b/vendor/github.com/miekg/dns/Gopkg.lock index 4455c9836f..686632207a 100644 --- a/vendor/github.com/miekg/dns/Gopkg.lock +++ b/vendor/github.com/miekg/dns/Gopkg.lock @@ -3,19 +3,55 @@ [[projects]] branch = "master" + digest = "1:6914c49eed986dfb8dffb33516fa129c49929d4d873f41e073c83c11c372b870" name = "golang.org/x/crypto" - packages = ["ed25519","ed25519/internal/edwards25519"] - revision = "b47b1587369238182299fe4dad77d05b8b461e06" + packages = [ + "ed25519", + "ed25519/internal/edwards25519", + ] + pruneopts = "" + revision = "e3636079e1a4c1f337f212cc5cd2aca108f6c900" [[projects]] branch = "master" + digest = "1:08e41d63f8dac84d83797368b56cf0b339e42d0224e5e56668963c28aec95685" name = "golang.org/x/net" - packages = ["bpf","internal/iana","internal/socket","ipv4","ipv6"] - revision = "1e491301e022f8f977054da4c2d852decd59571f" + packages = [ + "bpf", + "context", + "internal/iana", + "internal/socket", + "ipv4", + "ipv6", + ] + pruneopts = "" + revision = "4dfa2610cdf3b287375bbba5b8f2a14d3b01d8de" + +[[projects]] + branch = "master" + digest = "1:b2ea75de0ccb2db2ac79356407f8a4cd8f798fe15d41b381c00abf3ae8e55ed1" + name = "golang.org/x/sync" + packages = ["errgroup"] + pruneopts = "" + revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca" + +[[projects]] + branch = "master" + digest = "1:149a432fabebb8221a80f77731b1cd63597197ded4f14af606ebe3a0959004ec" + name = "golang.org/x/sys" + packages = ["unix"] + pruneopts = "" + revision = "e4b3c5e9061176387e7cea65e4dc5853801f3fb7" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "c4abc38abaeeeeb9be92455c9c02cae32841122b8982aaa067ef25bb8e86ff9d" + input-imports = [ + "golang.org/x/crypto/ed25519", + "golang.org/x/net/ipv4", + "golang.org/x/net/ipv6", + "golang.org/x/sync/errgroup", + "golang.org/x/sys/unix", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/miekg/dns/Gopkg.toml b/vendor/github.com/miekg/dns/Gopkg.toml index 2f655b2c7b..85e6ff31b2 100644 --- a/vendor/github.com/miekg/dns/Gopkg.toml +++ b/vendor/github.com/miekg/dns/Gopkg.toml @@ -24,3 +24,15 @@ [[constraint]] branch = "master" name = "golang.org/x/crypto" + +[[constraint]] + branch = "master" + name = "golang.org/x/net" + +[[constraint]] + branch = "master" + name = "golang.org/x/sys" + +[[constraint]] + branch = "master" + name = "golang.org/x/sync" diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go index 7a319b02c3..63ced2bd06 100644 --- a/vendor/github.com/miekg/dns/client.go +++ b/vendor/github.com/miekg/dns/client.go @@ -567,7 +567,7 @@ func (c *Client) ExchangeContext(ctx context.Context, m *Msg, a string) (r *Msg, if deadline, ok := ctx.Deadline(); !ok { timeout = 0 } else { - timeout = deadline.Sub(time.Now()) + timeout = time.Until(deadline) } // not passing the context to the underlying calls, as the API does not support // context. For timeouts you should set up Client.Dialer and call Client.Exchange. diff --git a/vendor/github.com/miekg/dns/generate.go b/vendor/github.com/miekg/dns/generate.go index 3a559793ff..91d928c834 100644 --- a/vendor/github.com/miekg/dns/generate.go +++ b/vendor/github.com/miekg/dns/generate.go @@ -107,6 +107,8 @@ BuildRR: mod, offset, err = modToPrintf(s[j+2 : j+2+sep]) if err != nil { return err.Error() + } else if start + offset < 0 || end + offset > 1<<31-1 { + return "bad offset in $GENERATE" } j += 2 + sep // Jump to it } @@ -152,7 +154,7 @@ func modToPrintf(s string) (string, int, error) { return "", 0, errors.New("bad base in $GENERATE") } offset, err := strconv.Atoi(xs[0]) - if err != nil || offset > 255 { + if err != nil { return "", 0, errors.New("bad offset in $GENERATE") } width, err := strconv.Atoi(xs[1]) diff --git a/vendor/github.com/miekg/dns/listen_go111.go b/vendor/github.com/miekg/dns/listen_go111.go index bd024c8938..fad195cfeb 100644 --- a/vendor/github.com/miekg/dns/listen_go111.go +++ b/vendor/github.com/miekg/dns/listen_go111.go @@ -1,4 +1,5 @@ -// +build go1.11,!windows +// +build go1.11 +// +build aix darwin dragonfly freebsd linux netbsd openbsd package dns diff --git a/vendor/github.com/miekg/dns/listen_go_not111.go b/vendor/github.com/miekg/dns/listen_go_not111.go index f1fc652c4d..b9201417ab 100644 --- a/vendor/github.com/miekg/dns/listen_go_not111.go +++ b/vendor/github.com/miekg/dns/listen_go_not111.go @@ -1,4 +1,4 @@ -// +build !go1.11 windows +// +build !go1.11 !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd package dns diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go index f8b847650f..47ac6cf281 100644 --- a/vendor/github.com/miekg/dns/msg.go +++ b/vendor/github.com/miekg/dns/msg.go @@ -302,6 +302,12 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c } // If we did compression and we find something add the pointer here if pointer != -1 { + // Clear the msg buffer after the pointer location, otherwise + // packDataNsec writes the wrong data to msg. + tainted := msg[nameoffset:off] + for i := range tainted { + tainted[i] = 0 + } // We have two bytes (14 bits) to put the pointer in // if msg == nil, we will never do compression binary.BigEndian.PutUint16(msg[nameoffset:], uint16(pointer^0xC000)) @@ -367,12 +373,10 @@ Loop: var buf [3]byte bufs := strconv.AppendInt(buf[:0], int64(b), 10) s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { + for i := len(bufs); i < 3; i++ { s = append(s, '0') } - for _, r := range bufs { - s = append(s, r) - } + s = append(s, bufs...) // presentation-format \DDD escapes add 3 extra bytes maxLen += 3 } else { @@ -512,7 +516,7 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) { off = off0 var s string for off < len(msg) && err == nil { - s, off, err = unpackTxtString(msg, off) + s, off, err = unpackString(msg, off) if err == nil { ss = append(ss, s) } @@ -520,39 +524,6 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) { return } -func unpackTxtString(msg []byte, offset int) (string, int, error) { - if offset+1 > len(msg) { - return "", offset, &Error{err: "overflow unpacking txt"} - } - l := int(msg[offset]) - if offset+l+1 > len(msg) { - return "", offset, &Error{err: "overflow unpacking txt"} - } - s := make([]byte, 0, l) - for _, b := range msg[offset+1 : offset+1+l] { - switch b { - case '"', '\\': - s = append(s, '\\', b) - default: - if b < 32 || b > 127 { // unprintable - var buf [3]byte - bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') - } - for _, r := range bufs { - s = append(s, r) - } - } else { - s = append(s, b) - } - } - } - offset += 1 + l - return string(s), offset, nil -} - // Helpers for dealing with escaped bytes func isDigit(b byte) bool { return b >= '0' && b <= '9' } @@ -560,6 +531,10 @@ func dddToByte(s []byte) byte { return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0')) } +func dddStringToByte(s string) byte { + return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0')) +} + // Helper function for packing and unpacking func intToBytes(i *big.Int, length int) []byte { buf := i.Bytes() diff --git a/vendor/github.com/miekg/dns/msg_helpers.go b/vendor/github.com/miekg/dns/msg_helpers.go index ec8cd9a851..81fc2b1be3 100644 --- a/vendor/github.com/miekg/dns/msg_helpers.go +++ b/vendor/github.com/miekg/dns/msg_helpers.go @@ -6,7 +6,7 @@ import ( "encoding/binary" "encoding/hex" "net" - "strconv" + "strings" ) // helper functions called from the generated zmsg.go @@ -267,29 +267,21 @@ func unpackString(msg []byte, off int) (string, int, error) { if off+l+1 > len(msg) { return "", off, &Error{err: "overflow unpacking txt"} } - s := make([]byte, 0, l) + var s strings.Builder + s.Grow(l) for _, b := range msg[off+1 : off+1+l] { - switch b { - case '"', '\\': - s = append(s, '\\', b) + switch { + case b == '"' || b == '\\': + s.WriteByte('\\') + s.WriteByte(b) + case b < ' ' || b > '~': // unprintable + writeEscapedByte(&s, b) default: - if b < 32 || b > 127 { // unprintable - var buf [3]byte - bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') - } - for _, r := range bufs { - s = append(s, r) - } - } else { - s = append(s, b) - } + s.WriteByte(b) } } off += 1 + l - return string(s), off, nil + return s.String(), off, nil } func packString(s string, msg []byte, off int) (int, error) { diff --git a/vendor/github.com/miekg/dns/privaterr.go b/vendor/github.com/miekg/dns/privaterr.go index 41989e7aee..d931da7efb 100644 --- a/vendor/github.com/miekg/dns/privaterr.go +++ b/vendor/github.com/miekg/dns/privaterr.go @@ -134,7 +134,7 @@ func PrivateHandle(rtypestr string, rtype uint16, generator func() PrivateRdata) typeToparserFunc[rtype] = parserFunc{setPrivateRR, true} } -// PrivateHandleRemove removes defenitions required to support private RR type. +// PrivateHandleRemove removes definitions required to support private RR type. func PrivateHandleRemove(rtype uint16) { rtypestr, ok := TypeToString[rtype] if ok { @@ -144,5 +144,4 @@ func PrivateHandleRemove(rtype uint16) { delete(StringToType, rtypestr) delete(typeToUnpack, rtype) } - return } diff --git a/vendor/github.com/miekg/dns/scan.go b/vendor/github.com/miekg/dns/scan.go index f9cd47401d..a752dbd018 100644 --- a/vendor/github.com/miekg/dns/scan.go +++ b/vendor/github.com/miekg/dns/scan.go @@ -10,7 +10,6 @@ import ( ) const maxTok = 2048 // Largest token we can return. -const maxUint16 = 1<<16 - 1 // Tokinize a RFC 1035 zone file. The tokenizer will normalize it: // * Add ownernames if they are left blank; @@ -80,9 +79,9 @@ type lex struct { length int // length of the token err bool // when true, token text has lexer error value uint8 // value: zString, _BLANK, etc. + torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar line int // line in the file column int // column in the file - torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar comment string // any comment text seen } @@ -209,10 +208,9 @@ func parseZone(r io.Reader, origin, f string, defttl *ttlState, t chan *Token, i var prevName string for l := range c { // Lexer spotted an error already - if l.err == true { + if l.err { t <- &Token{Error: &ParseError{f, l.token, l}} return - } switch st { case zExpectOwnerDir: @@ -639,7 +637,6 @@ func zlexer(s *scan, c chan lex) { if quote { str[stri] = x stri++ - break } // discard if outside of quotes case '\n': diff --git a/vendor/github.com/miekg/dns/scanner.go b/vendor/github.com/miekg/dns/scanner.go index 424e5af9f5..5b124ec595 100644 --- a/vendor/github.com/miekg/dns/scanner.go +++ b/vendor/github.com/miekg/dns/scanner.go @@ -42,7 +42,7 @@ func (s *scan) tokenText() (byte, error) { // delay the newline handling until the next token is delivered, // fixes off-by-one errors when reporting a parse error. - if s.eof == true { + if s.eof { s.position.Line++ s.position.Column = 0 s.eof = false diff --git a/vendor/github.com/miekg/dns/serve_mux.go b/vendor/github.com/miekg/dns/serve_mux.go new file mode 100644 index 0000000000..ae304db530 --- /dev/null +++ b/vendor/github.com/miekg/dns/serve_mux.go @@ -0,0 +1,147 @@ +package dns + +import ( + "strings" + "sync" +) + +// ServeMux is an DNS request multiplexer. It matches the zone name of +// each incoming request against a list of registered patterns add calls +// the handler for the pattern that most closely matches the zone name. +// +// ServeMux is DNSSEC aware, meaning that queries for the DS record are +// redirected to the parent zone (if that is also registered), otherwise +// the child gets the query. +// +// ServeMux is also safe for concurrent access from multiple goroutines. +// +// The zero ServeMux is empty and ready for use. +type ServeMux struct { + z map[string]Handler + m sync.RWMutex +} + +// NewServeMux allocates and returns a new ServeMux. +func NewServeMux() *ServeMux { + return new(ServeMux) +} + +// DefaultServeMux is the default ServeMux used by Serve. +var DefaultServeMux = NewServeMux() + +func (mux *ServeMux) match(q string, t uint16) Handler { + mux.m.RLock() + defer mux.m.RUnlock() + if mux.z == nil { + return nil + } + + var handler Handler + + // TODO(tmthrgd): Once https://go-review.googlesource.com/c/go/+/137575 + // lands in a go release, replace the following with strings.ToLower. + var sb strings.Builder + for i := 0; i < len(q); i++ { + c := q[i] + if !(c >= 'A' && c <= 'Z') { + continue + } + + sb.Grow(len(q)) + sb.WriteString(q[:i]) + + for ; i < len(q); i++ { + c := q[i] + if c >= 'A' && c <= 'Z' { + c += 'a' - 'A' + } + + sb.WriteByte(c) + } + + q = sb.String() + break + } + + for off, end := 0, false; !end; off, end = NextLabel(q, off) { + if h, ok := mux.z[q[off:]]; ok { + if t != TypeDS { + return h + } + // Continue for DS to see if we have a parent too, if so delegate to the parent + handler = h + } + } + + // Wildcard match, if we have found nothing try the root zone as a last resort. + if h, ok := mux.z["."]; ok { + return h + } + + return handler +} + +// Handle adds a handler to the ServeMux for pattern. +func (mux *ServeMux) Handle(pattern string, handler Handler) { + if pattern == "" { + panic("dns: invalid pattern " + pattern) + } + mux.m.Lock() + if mux.z == nil { + mux.z = make(map[string]Handler) + } + mux.z[Fqdn(pattern)] = handler + mux.m.Unlock() +} + +// HandleFunc adds a handler function to the ServeMux for pattern. +func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { + mux.Handle(pattern, HandlerFunc(handler)) +} + +// HandleRemove deregisters the handler specific for pattern from the ServeMux. +func (mux *ServeMux) HandleRemove(pattern string) { + if pattern == "" { + panic("dns: invalid pattern " + pattern) + } + mux.m.Lock() + delete(mux.z, Fqdn(pattern)) + mux.m.Unlock() +} + +// ServeDNS dispatches the request to the handler whose pattern most +// closely matches the request message. +// +// ServeDNS is DNSSEC aware, meaning that queries for the DS record +// are redirected to the parent zone (if that is also registered), +// otherwise the child gets the query. +// +// If no handler is found, or there is no question, a standard SERVFAIL +// message is returned +func (mux *ServeMux) ServeDNS(w ResponseWriter, req *Msg) { + var h Handler + if len(req.Question) >= 1 { // allow more than one question + h = mux.match(req.Question[0].Name, req.Question[0].Qtype) + } + + if h != nil { + h.ServeDNS(w, req) + } else { + HandleFailed(w, req) + } +} + +// Handle registers the handler with the given pattern +// in the DefaultServeMux. The documentation for +// ServeMux explains how patterns are matched. +func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) } + +// HandleRemove deregisters the handle with the given pattern +// in the DefaultServeMux. +func HandleRemove(pattern string) { DefaultServeMux.HandleRemove(pattern) } + +// HandleFunc registers the handler function with the given pattern +// in the DefaultServeMux. +func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { + DefaultServeMux.HandleFunc(pattern, handler) +} diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go index 2901f8724c..4b4ec33c8d 100644 --- a/vendor/github.com/miekg/dns/server.go +++ b/vendor/github.com/miekg/dns/server.go @@ -41,6 +41,17 @@ type Handler interface { ServeDNS(w ResponseWriter, r *Msg) } +// The HandlerFunc type is an adapter to allow the use of +// ordinary functions as DNS handlers. If f is a function +// with the appropriate signature, HandlerFunc(f) is a +// Handler object that calls f. +type HandlerFunc func(ResponseWriter, *Msg) + +// ServeDNS calls f(w, r). +func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) { + f(w, r) +} + // A ResponseWriter interface is used by an DNS handler to // construct an DNS response. type ResponseWriter interface { @@ -72,8 +83,8 @@ type ConnectionStater interface { type response struct { msg []byte hijacked bool // connection has been hijacked by handler - tsigStatus error tsigTimersOnly bool + tsigStatus error tsigRequestMAC string tsigSecret map[string]string // the tsig secrets udp *net.UDPConn // i/o connection if UDP was used @@ -83,35 +94,6 @@ type response struct { wg *sync.WaitGroup // for gracefull shutdown } -// ServeMux is an DNS request multiplexer. It matches the -// zone name of each incoming request against a list of -// registered patterns add calls the handler for the pattern -// that most closely matches the zone name. ServeMux is DNSSEC aware, meaning -// that queries for the DS record are redirected to the parent zone (if that -// is also registered), otherwise the child gets the query. -// ServeMux is also safe for concurrent access from multiple goroutines. -type ServeMux struct { - z map[string]Handler - m *sync.RWMutex -} - -// NewServeMux allocates and returns a new ServeMux. -func NewServeMux() *ServeMux { return &ServeMux{z: make(map[string]Handler), m: new(sync.RWMutex)} } - -// DefaultServeMux is the default ServeMux used by Serve. -var DefaultServeMux = NewServeMux() - -// The HandlerFunc type is an adapter to allow the use of -// ordinary functions as DNS handlers. If f is a function -// with the appropriate signature, HandlerFunc(f) is a -// Handler object that calls f. -type HandlerFunc func(ResponseWriter, *Msg) - -// ServeDNS calls f(w, r). -func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) { - f(w, r) -} - // HandleFailed returns a HandlerFunc that returns SERVFAIL for every request it gets. func HandleFailed(w ResponseWriter, r *Msg) { m := new(Msg) @@ -120,8 +102,6 @@ func HandleFailed(w ResponseWriter, r *Msg) { w.WriteMsg(m) } -func failedHandler() Handler { return HandlerFunc(HandleFailed) } - // ListenAndServe Starts a server on address and network specified Invoke handler // for incoming queries. func ListenAndServe(addr string, network string, handler Handler) error { @@ -160,99 +140,6 @@ func ActivateAndServe(l net.Listener, p net.PacketConn, handler Handler) error { return server.ActivateAndServe() } -func (mux *ServeMux) match(q string, t uint16) Handler { - mux.m.RLock() - defer mux.m.RUnlock() - var handler Handler - b := make([]byte, len(q)) // worst case, one label of length q - off := 0 - end := false - for { - l := len(q[off:]) - for i := 0; i < l; i++ { - b[i] = q[off+i] - if b[i] >= 'A' && b[i] <= 'Z' { - b[i] |= 'a' - 'A' - } - } - if h, ok := mux.z[string(b[:l])]; ok { // causes garbage, might want to change the map key - if t != TypeDS { - return h - } - // Continue for DS to see if we have a parent too, if so delegeate to the parent - handler = h - } - off, end = NextLabel(q, off) - if end { - break - } - } - // Wildcard match, if we have found nothing try the root zone as a last resort. - if h, ok := mux.z["."]; ok { - return h - } - return handler -} - -// Handle adds a handler to the ServeMux for pattern. -func (mux *ServeMux) Handle(pattern string, handler Handler) { - if pattern == "" { - panic("dns: invalid pattern " + pattern) - } - mux.m.Lock() - mux.z[Fqdn(pattern)] = handler - mux.m.Unlock() -} - -// HandleFunc adds a handler function to the ServeMux for pattern. -func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { - mux.Handle(pattern, HandlerFunc(handler)) -} - -// HandleRemove deregistrars the handler specific for pattern from the ServeMux. -func (mux *ServeMux) HandleRemove(pattern string) { - if pattern == "" { - panic("dns: invalid pattern " + pattern) - } - mux.m.Lock() - delete(mux.z, Fqdn(pattern)) - mux.m.Unlock() -} - -// ServeDNS dispatches the request to the handler whose -// pattern most closely matches the request message. If DefaultServeMux -// is used the correct thing for DS queries is done: a possible parent -// is sought. -// If no handler is found a standard SERVFAIL message is returned -// If the request message does not have exactly one question in the -// question section a SERVFAIL is returned, unlesss Unsafe is true. -func (mux *ServeMux) ServeDNS(w ResponseWriter, request *Msg) { - var h Handler - if len(request.Question) < 1 { // allow more than one question - h = failedHandler() - } else { - if h = mux.match(request.Question[0].Name, request.Question[0].Qtype); h == nil { - h = failedHandler() - } - } - h.ServeDNS(w, request) -} - -// Handle registers the handler with the given pattern -// in the DefaultServeMux. The documentation for -// ServeMux explains how patterns are matched. -func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) } - -// HandleRemove deregisters the handle with the given pattern -// in the DefaultServeMux. -func HandleRemove(pattern string) { DefaultServeMux.HandleRemove(pattern) } - -// HandleFunc registers the handler function with the given pattern -// in the DefaultServeMux. -func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { - DefaultServeMux.HandleFunc(pattern, handler) -} - // Writer writes raw DNS messages; each call to Write should send an entire message. type Writer interface { io.Writer @@ -529,14 +416,13 @@ func (srv *Server) Shutdown() error { // to terminate. func (srv *Server) ShutdownContext(ctx context.Context) error { srv.lock.Lock() - started := srv.started - srv.started = false - srv.lock.Unlock() - - if !started { + if !srv.started { + srv.lock.Unlock() return &Error{err: "server not started"} } + srv.started = false + if srv.PacketConn != nil { srv.PacketConn.SetReadDeadline(aLongTimeAgo) // Unblock reads } @@ -545,10 +431,10 @@ func (srv *Server) ShutdownContext(ctx context.Context) error { srv.Listener.Close() } - srv.lock.Lock() for rw := range srv.conns { rw.SetReadDeadline(aLongTimeAgo) // Unblock reads } + srv.lock.Unlock() if testShutdownNotify != nil { @@ -735,20 +621,23 @@ func (srv *Server) serve(w *response) { } } -func (srv *Server) serveDNS(w *response) { - req := new(Msg) - err := req.Unpack(w.msg) +func (srv *Server) disposeBuffer(w *response) { if w.udp != nil && cap(w.msg) == srv.UDPSize { srv.udpPool.Put(w.msg[:srv.UDPSize]) } w.msg = nil +} + +func (srv *Server) serveDNS(w *response) { + req := new(Msg) + err := req.Unpack(w.msg) if err != nil { // Send a FormatError back x := new(Msg) x.SetRcodeFormatError(req) w.WriteMsg(x) - return } - if !srv.Unsafe && req.Response { + if err != nil || !srv.Unsafe && req.Response { + srv.disposeBuffer(w) return } @@ -765,6 +654,8 @@ func (srv *Server) serveDNS(w *response) { } } + srv.disposeBuffer(w) + handler := srv.Handler if handler == nil { handler = DefaultServeMux @@ -774,7 +665,16 @@ func (srv *Server) serveDNS(w *response) { } func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error) { - conn.SetReadDeadline(time.Now().Add(timeout)) + // If we race with ShutdownContext, the read deadline may + // have been set in the distant past to unblock the read + // below. We must not override it, otherwise we may block + // ShutdownContext. + srv.lock.RLock() + if srv.started { + conn.SetReadDeadline(time.Now().Add(timeout)) + } + srv.lock.RUnlock() + l := make([]byte, 2) n, err := conn.Read(l) if err != nil || n != 2 { @@ -809,7 +709,13 @@ func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error) } func (srv *Server) readUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error) { - conn.SetReadDeadline(time.Now().Add(timeout)) + srv.lock.RLock() + if srv.started { + // See the comment in readTCP above. + conn.SetReadDeadline(time.Now().Add(timeout)) + } + srv.lock.RUnlock() + m := srv.udpPool.Get().([]byte) n, s, err := ReadFromSessionUDP(conn, m) if err != nil { @@ -861,24 +767,33 @@ func (w *response) Write(m []byte) (int, error) { n, err := io.Copy(w.tcp, bytes.NewReader(m)) return int(n), err + default: + panic("dns: Write called after Close") } - panic("not reached") } // LocalAddr implements the ResponseWriter.LocalAddr method. func (w *response) LocalAddr() net.Addr { - if w.tcp != nil { + switch { + case w.udp != nil: + return w.udp.LocalAddr() + case w.tcp != nil: return w.tcp.LocalAddr() + default: + panic("dns: LocalAddr called after Close") } - return w.udp.LocalAddr() } // RemoteAddr implements the ResponseWriter.RemoteAddr method. func (w *response) RemoteAddr() net.Addr { - if w.tcp != nil { + switch { + case w.udpSession != nil: + return w.udpSession.RemoteAddr() + case w.tcp != nil: return w.tcp.RemoteAddr() + default: + panic("dns: RemoteAddr called after Close") } - return w.udpSession.RemoteAddr() } // TsigStatus implements the ResponseWriter.TsigStatus method. diff --git a/vendor/github.com/miekg/dns/sig0.go b/vendor/github.com/miekg/dns/sig0.go index f31e9e6843..07c2acb196 100644 --- a/vendor/github.com/miekg/dns/sig0.go +++ b/vendor/github.com/miekg/dns/sig0.go @@ -127,8 +127,7 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error { if offset+1 >= buflen { continue } - var rdlen uint16 - rdlen = binary.BigEndian.Uint16(buf[offset:]) + rdlen := binary.BigEndian.Uint16(buf[offset:]) offset += 2 offset += int(rdlen) } diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go index a64f4d7d83..115f2c7bd0 100644 --- a/vendor/github.com/miekg/dns/types.go +++ b/vendor/github.com/miekg/dns/types.go @@ -419,128 +419,130 @@ type TXT struct { func (rr *TXT) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } func sprintName(s string) string { - src := []byte(s) - dst := make([]byte, 0, len(src)) - for i := 0; i < len(src); { - if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' { - dst = append(dst, src[i:i+2]...) + var dst strings.Builder + dst.Grow(len(s)) + for i := 0; i < len(s); { + if i+1 < len(s) && s[i] == '\\' && s[i+1] == '.' { + dst.WriteString(s[i : i+2]) i += 2 - } else { - b, n := nextByte(src, i) - if n == 0 { - i++ // dangling back slash - } else if b == '.' { - dst = append(dst, b) - } else { - dst = appendDomainNameByte(dst, b) - } - i += n + continue } + + b, n := nextByte(s, i) + switch { + case n == 0: + i++ // dangling back slash + case b == '.': + dst.WriteByte('.') + default: + writeDomainNameByte(&dst, b) + } + i += n } - return string(dst) + return dst.String() } func sprintTxtOctet(s string) string { - src := []byte(s) - dst := make([]byte, 0, len(src)) - dst = append(dst, '"') - for i := 0; i < len(src); { - if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' { - dst = append(dst, src[i:i+2]...) + var dst strings.Builder + dst.Grow(2 + len(s)) + dst.WriteByte('"') + for i := 0; i < len(s); { + if i+1 < len(s) && s[i] == '\\' && s[i+1] == '.' { + dst.WriteString(s[i : i+2]) i += 2 - } else { - b, n := nextByte(src, i) - if n == 0 { - i++ // dangling back slash - } else if b == '.' { - dst = append(dst, b) - } else { - if b < ' ' || b > '~' { - dst = appendByte(dst, b) - } else { - dst = append(dst, b) - } - } - i += n + continue } + + b, n := nextByte(s, i) + switch { + case n == 0: + i++ // dangling back slash + case b == '.': + dst.WriteByte('.') + case b < ' ' || b > '~': + writeEscapedByte(&dst, b) + default: + dst.WriteByte(b) + } + i += n } - dst = append(dst, '"') - return string(dst) + dst.WriteByte('"') + return dst.String() } func sprintTxt(txt []string) string { - var out []byte + var out strings.Builder for i, s := range txt { + out.Grow(3 + len(s)) if i > 0 { - out = append(out, ` "`...) + out.WriteString(` "`) } else { - out = append(out, '"') + out.WriteByte('"') } - bs := []byte(s) - for j := 0; j < len(bs); { - b, n := nextByte(bs, j) + for j := 0; j < len(s); { + b, n := nextByte(s, j) if n == 0 { break } - out = appendTXTStringByte(out, b) + writeTXTStringByte(&out, b) j += n } - out = append(out, '"') + out.WriteByte('"') } - return string(out) + return out.String() } -func appendDomainNameByte(s []byte, b byte) []byte { +func writeDomainNameByte(s *strings.Builder, b byte) { switch b { case '.', ' ', '\'', '@', ';', '(', ')': // additional chars to escape - return append(s, '\\', b) + s.WriteByte('\\') + s.WriteByte(b) + default: + writeTXTStringByte(s, b) } - return appendTXTStringByte(s, b) } -func appendTXTStringByte(s []byte, b byte) []byte { - switch b { - case '"', '\\': - return append(s, '\\', b) +func writeTXTStringByte(s *strings.Builder, b byte) { + switch { + case b == '"' || b == '\\': + s.WriteByte('\\') + s.WriteByte(b) + case b < ' ' || b > '~': + writeEscapedByte(s, b) + default: + s.WriteByte(b) } - if b < ' ' || b > '~' { - return appendByte(s, b) - } - return append(s, b) } -func appendByte(s []byte, b byte) []byte { +func writeEscapedByte(s *strings.Builder, b byte) { var buf [3]byte bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') + s.WriteByte('\\') + for i := len(bufs); i < 3; i++ { + s.WriteByte('0') } - for _, r := range bufs { - s = append(s, r) - } - return s + s.Write(bufs) } -func nextByte(b []byte, offset int) (byte, int) { - if offset >= len(b) { +func nextByte(s string, offset int) (byte, int) { + if offset >= len(s) { return 0, 0 } - if b[offset] != '\\' { + if s[offset] != '\\' { // not an escape sequence - return b[offset], 1 + return s[offset], 1 } - switch len(b) - offset { + switch len(s) - offset { case 1: // dangling escape return 0, 0 case 2, 3: // too short to be \ddd default: // maybe \ddd - if isDigit(b[offset+1]) && isDigit(b[offset+2]) && isDigit(b[offset+3]) { - return dddToByte(b[offset+1:]), 4 + if isDigit(s[offset+1]) && isDigit(s[offset+2]) && isDigit(s[offset+3]) { + return dddStringToByte(s[offset+1:]), 4 } } // not \ddd, just an RFC 1035 "quoted" character - return b[offset+1], 2 + return s[offset+1], 2 } // SPF RR. See RFC 4408, Section 3.1.1. diff --git a/vendor/github.com/miekg/dns/udp.go b/vendor/github.com/miekg/dns/udp.go index 82ead69399..a4826ee2ff 100644 --- a/vendor/github.com/miekg/dns/udp.go +++ b/vendor/github.com/miekg/dns/udp.go @@ -1,3 +1,5 @@ +// +build !windows + package dns import ( diff --git a/vendor/github.com/miekg/dns/udp_windows.go b/vendor/github.com/miekg/dns/udp_windows.go new file mode 100644 index 0000000000..6778c3c6cf --- /dev/null +++ b/vendor/github.com/miekg/dns/udp_windows.go @@ -0,0 +1,37 @@ +// +build windows + +package dns + +import "net" + +// SessionUDP holds the remote address +type SessionUDP struct { + raddr *net.UDPAddr +} + +// RemoteAddr returns the remote network address. +func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr } + +// ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a +// net.UDPAddr. +// TODO(fastest963): Once go1.10 is released, use ReadMsgUDP. +func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) { + n, raddr, err := conn.ReadFrom(b) + if err != nil { + return n, nil, err + } + session := &SessionUDP{raddr.(*net.UDPAddr)} + return n, session, err +} + +// WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr. +// TODO(fastest963): Once go1.10 is released, use WriteMsgUDP. +func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) { + n, err := conn.WriteTo(b, session.raddr) + return n, err +} + +// TODO(fastest963): Once go1.10 is released and we can use *MsgUDP methods +// use the standard method in udp.go for these. +func setUDPSocketOptions(*net.UDPConn) error { return nil } +func parseDstFromOOB([]byte, net.IP) net.IP { return nil } diff --git a/vendor/github.com/miekg/dns/version.go b/vendor/github.com/miekg/dns/version.go index ade7586dc1..403b9ef978 100644 --- a/vendor/github.com/miekg/dns/version.go +++ b/vendor/github.com/miekg/dns/version.go @@ -3,7 +3,7 @@ package dns import "fmt" // Version is current version of this library. -var Version = V{1, 0, 10} +var Version = V{1, 0, 13} // V holds the version of this library. type V struct { diff --git a/vendor/github.com/pierrec/lz4/block.go b/vendor/github.com/pierrec/lz4/block.go index ef24f17e57..00b1111b92 100644 --- a/vendor/github.com/pierrec/lz4/block.go +++ b/vendor/github.com/pierrec/lz4/block.go @@ -286,7 +286,7 @@ func CompressBlockHC(src, dst []byte, depth int) (di int, err error) { for ml < sn-si && src[next+ml] == src[si+ml] { ml++ } - if ml+1 < minMatch || ml <= mLen { + if ml < minMatch || ml <= mLen { // Match too small ( 0 && first[0] == '-' { //--unknown --next-flag ... return args } //--unknown arg ... (args will be arg ...) - return args[1:] + if len(args) > 1 { + return args[1:] + } + return nil } func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []string, err error) { diff --git a/vendor/github.com/spf13/pflag/string_to_int.go b/vendor/github.com/spf13/pflag/string_to_int.go new file mode 100644 index 0000000000..5ceda3965d --- /dev/null +++ b/vendor/github.com/spf13/pflag/string_to_int.go @@ -0,0 +1,149 @@ +package pflag + +import ( + "bytes" + "fmt" + "strconv" + "strings" +) + +// -- stringToInt Value +type stringToIntValue struct { + value *map[string]int + changed bool +} + +func newStringToIntValue(val map[string]int, p *map[string]int) *stringToIntValue { + ssv := new(stringToIntValue) + ssv.value = p + *ssv.value = val + return ssv +} + +// Format: a=1,b=2 +func (s *stringToIntValue) Set(val string) error { + ss := strings.Split(val, ",") + out := make(map[string]int, len(ss)) + for _, pair := range ss { + kv := strings.SplitN(pair, "=", 2) + if len(kv) != 2 { + return fmt.Errorf("%s must be formatted as key=value", pair) + } + var err error + out[kv[0]], err = strconv.Atoi(kv[1]) + if err != nil { + return err + } + } + if !s.changed { + *s.value = out + } else { + for k, v := range out { + (*s.value)[k] = v + } + } + s.changed = true + return nil +} + +func (s *stringToIntValue) Type() string { + return "stringToInt" +} + +func (s *stringToIntValue) String() string { + var buf bytes.Buffer + i := 0 + for k, v := range *s.value { + if i > 0 { + buf.WriteRune(',') + } + buf.WriteString(k) + buf.WriteRune('=') + buf.WriteString(strconv.Itoa(v)) + i++ + } + return "[" + buf.String() + "]" +} + +func stringToIntConv(val string) (interface{}, error) { + val = strings.Trim(val, "[]") + // An empty string would cause an empty map + if len(val) == 0 { + return map[string]int{}, nil + } + ss := strings.Split(val, ",") + out := make(map[string]int, len(ss)) + for _, pair := range ss { + kv := strings.SplitN(pair, "=", 2) + if len(kv) != 2 { + return nil, fmt.Errorf("%s must be formatted as key=value", pair) + } + var err error + out[kv[0]], err = strconv.Atoi(kv[1]) + if err != nil { + return nil, err + } + } + return out, nil +} + +// GetStringToInt return the map[string]int value of a flag with the given name +func (f *FlagSet) GetStringToInt(name string) (map[string]int, error) { + val, err := f.getFlagType(name, "stringToInt", stringToIntConv) + if err != nil { + return map[string]int{}, err + } + return val.(map[string]int), nil +} + +// StringToIntVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a map[string]int variable in which to store the values of the multiple flags. +// The value of each argument will not try to be separated by comma +func (f *FlagSet) StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) { + f.VarP(newStringToIntValue(value, p), name, "", usage) +} + +// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) { + f.VarP(newStringToIntValue(value, p), name, shorthand, usage) +} + +// StringToIntVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a map[string]int variable in which to store the value of the flag. +// The value of each argument will not try to be separated by comma +func StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) { + CommandLine.VarP(newStringToIntValue(value, p), name, "", usage) +} + +// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash. +func StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) { + CommandLine.VarP(newStringToIntValue(value, p), name, shorthand, usage) +} + +// StringToInt defines a string flag with specified name, default value, and usage string. +// The return value is the address of a map[string]int variable that stores the value of the flag. +// The value of each argument will not try to be separated by comma +func (f *FlagSet) StringToInt(name string, value map[string]int, usage string) *map[string]int { + p := map[string]int{} + f.StringToIntVarP(&p, name, "", value, usage) + return &p +} + +// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int { + p := map[string]int{} + f.StringToIntVarP(&p, name, shorthand, value, usage) + return &p +} + +// StringToInt defines a string flag with specified name, default value, and usage string. +// The return value is the address of a map[string]int variable that stores the value of the flag. +// The value of each argument will not try to be separated by comma +func StringToInt(name string, value map[string]int, usage string) *map[string]int { + return CommandLine.StringToIntP(name, "", value, usage) +} + +// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash. +func StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int { + return CommandLine.StringToIntP(name, shorthand, value, usage) +} diff --git a/vendor/github.com/spf13/pflag/string_to_string.go b/vendor/github.com/spf13/pflag/string_to_string.go new file mode 100644 index 0000000000..890a01afc0 --- /dev/null +++ b/vendor/github.com/spf13/pflag/string_to_string.go @@ -0,0 +1,160 @@ +package pflag + +import ( + "bytes" + "encoding/csv" + "fmt" + "strings" +) + +// -- stringToString Value +type stringToStringValue struct { + value *map[string]string + changed bool +} + +func newStringToStringValue(val map[string]string, p *map[string]string) *stringToStringValue { + ssv := new(stringToStringValue) + ssv.value = p + *ssv.value = val + return ssv +} + +// Format: a=1,b=2 +func (s *stringToStringValue) Set(val string) error { + var ss []string + n := strings.Count(val, "=") + switch n { + case 0: + return fmt.Errorf("%s must be formatted as key=value", val) + case 1: + ss = append(ss, strings.Trim(val, `"`)) + default: + r := csv.NewReader(strings.NewReader(val)) + var err error + ss, err = r.Read() + if err != nil { + return err + } + } + + out := make(map[string]string, len(ss)) + for _, pair := range ss { + kv := strings.SplitN(pair, "=", 2) + if len(kv) != 2 { + return fmt.Errorf("%s must be formatted as key=value", pair) + } + out[kv[0]] = kv[1] + } + if !s.changed { + *s.value = out + } else { + for k, v := range out { + (*s.value)[k] = v + } + } + s.changed = true + return nil +} + +func (s *stringToStringValue) Type() string { + return "stringToString" +} + +func (s *stringToStringValue) String() string { + records := make([]string, 0, len(*s.value)>>1) + for k, v := range *s.value { + records = append(records, k+"="+v) + } + + var buf bytes.Buffer + w := csv.NewWriter(&buf) + if err := w.Write(records); err != nil { + panic(err) + } + w.Flush() + return "[" + strings.TrimSpace(buf.String()) + "]" +} + +func stringToStringConv(val string) (interface{}, error) { + val = strings.Trim(val, "[]") + // An empty string would cause an empty map + if len(val) == 0 { + return map[string]string{}, nil + } + r := csv.NewReader(strings.NewReader(val)) + ss, err := r.Read() + if err != nil { + return nil, err + } + out := make(map[string]string, len(ss)) + for _, pair := range ss { + kv := strings.SplitN(pair, "=", 2) + if len(kv) != 2 { + return nil, fmt.Errorf("%s must be formatted as key=value", pair) + } + out[kv[0]] = kv[1] + } + return out, nil +} + +// GetStringToString return the map[string]string value of a flag with the given name +func (f *FlagSet) GetStringToString(name string) (map[string]string, error) { + val, err := f.getFlagType(name, "stringToString", stringToStringConv) + if err != nil { + return map[string]string{}, err + } + return val.(map[string]string), nil +} + +// StringToStringVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a map[string]string variable in which to store the values of the multiple flags. +// The value of each argument will not try to be separated by comma +func (f *FlagSet) StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) { + f.VarP(newStringToStringValue(value, p), name, "", usage) +} + +// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) { + f.VarP(newStringToStringValue(value, p), name, shorthand, usage) +} + +// StringToStringVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a map[string]string variable in which to store the value of the flag. +// The value of each argument will not try to be separated by comma +func StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) { + CommandLine.VarP(newStringToStringValue(value, p), name, "", usage) +} + +// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash. +func StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) { + CommandLine.VarP(newStringToStringValue(value, p), name, shorthand, usage) +} + +// StringToString defines a string flag with specified name, default value, and usage string. +// The return value is the address of a map[string]string variable that stores the value of the flag. +// The value of each argument will not try to be separated by comma +func (f *FlagSet) StringToString(name string, value map[string]string, usage string) *map[string]string { + p := map[string]string{} + f.StringToStringVarP(&p, name, "", value, usage) + return &p +} + +// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string { + p := map[string]string{} + f.StringToStringVarP(&p, name, shorthand, value, usage) + return &p +} + +// StringToString defines a string flag with specified name, default value, and usage string. +// The return value is the address of a map[string]string variable that stores the value of the flag. +// The value of each argument will not try to be separated by comma +func StringToString(name string, value map[string]string, usage string) *map[string]string { + return CommandLine.StringToStringP(name, "", value, usage) +} + +// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash. +func StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string { + return CommandLine.StringToStringP(name, shorthand, value, usage) +} diff --git a/vendor/github.com/vmware/govmomi/.mailmap b/vendor/github.com/vmware/govmomi/.mailmap index 704c5b736c..d3fcbc5bfe 100644 --- a/vendor/github.com/vmware/govmomi/.mailmap +++ b/vendor/github.com/vmware/govmomi/.mailmap @@ -19,3 +19,6 @@ Anfernee Yongkun Gui Anfernee Yongkun Gui Yongkun Anfernee Gui Zach Tucker Zee Yang +Jiatong Wang jiatongw +Uwe Bessle Uwe Bessle +Uwe Bessle Uwe Bessle diff --git a/vendor/github.com/vmware/govmomi/CHANGELOG.md b/vendor/github.com/vmware/govmomi/CHANGELOG.md index c8afb958f4..aef1957569 100644 --- a/vendor/github.com/vmware/govmomi/CHANGELOG.md +++ b/vendor/github.com/vmware/govmomi/CHANGELOG.md @@ -1,6 +1,12 @@ # changelog -### unreleased +### 0.19.0 (2018-09-30) + +* New vapi/rest and and vapi/tags packages + +* Allowing the use of STS for exchanging tokens + +* Add object.VirtualMachine.UUID method * SetRootCAs on the soap.Client returns an error for invalid certificates diff --git a/vendor/github.com/vmware/govmomi/CONTRIBUTORS b/vendor/github.com/vmware/govmomi/CONTRIBUTORS index 1fd37b609d..d2a9a7aaa9 100644 --- a/vendor/github.com/vmware/govmomi/CONTRIBUTORS +++ b/vendor/github.com/vmware/govmomi/CONTRIBUTORS @@ -29,6 +29,7 @@ Cédric Blomart Chris Marchesi Christian Höltje Clint Greenwood +CuiHaozhi Danny Lockard Dave Tucker Davide Agnello @@ -42,6 +43,7 @@ Erik Hollensbe Fabio Rapposelli Faiyaz Ahmed forkbomber +freebsdly Gavin Gray Gavrie Philipson George Hicken @@ -54,17 +56,27 @@ Ivan Porto Carrero Jason Kincl Jeremy Canady jeremy-clerc +Jiatong Wang João Pereira Jorge Sevilla +kayrus +Kevin George leslie-qiwa Louie Jiang Marc Carmier +Maria Ntalla +Marin Atanasov Nikolov Matthew Cosgrove +Matt Moriarity Mevan Samaratunga +Michal Jankowski +mingwei Nicolas Lamirault Omar Kohl Parham Alvani Pieter Noordhuis +prydin +Rowan Jacobs runner.mei S.Çağlar Onur Sergey Ignatov @@ -74,6 +86,7 @@ tanishi Ted Zlatanov Thibaut Ackermann Trevor Dawe +Uwe Bessle Vadim Egorov Volodymyr Bobyr Witold Krecicki diff --git a/vendor/github.com/vmware/govmomi/README.md b/vendor/github.com/vmware/govmomi/README.md index 5cd8c5adf6..da5d426ea2 100644 --- a/vendor/github.com/vmware/govmomi/README.md +++ b/vendor/github.com/vmware/govmomi/README.md @@ -75,6 +75,8 @@ Refer to the [CHANGELOG](CHANGELOG.md) for version to version changes. * [Libretto](https://github.com/apcera/libretto/tree/master/virtualmachine/vsphere) +* [Telegraf](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/vsphere) + ## Related projects * [rbvmomi](https://github.com/vmware/rbvmomi) diff --git a/vendor/github.com/vmware/govmomi/session/keep_alive.go b/vendor/github.com/vmware/govmomi/session/keep_alive.go index a9d4c141c9..3b44f5ffb6 100644 --- a/vendor/github.com/vmware/govmomi/session/keep_alive.go +++ b/vendor/github.com/vmware/govmomi/session/keep_alive.go @@ -114,10 +114,9 @@ func (k *keepAlive) RoundTrip(ctx context.Context, req, res soap.HasFault) error if err != nil { return err } - // Start ticker on login, stop ticker on logout. switch req.(type) { - case *methods.LoginBody, *methods.LoginExtensionByCertificateBody: + case *methods.LoginBody, *methods.LoginExtensionByCertificateBody, *methods.LoginByTokenBody: k.start() case *methods.LogoutBody: k.stop() diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go index d0f4825319..122c03e70a 100644 --- a/vendor/golang.org/x/crypto/ssh/server.go +++ b/vendor/golang.org/x/crypto/ssh/server.go @@ -404,7 +404,7 @@ userAuthLoop: perms, authErr = config.PasswordCallback(s, password) case "keyboard-interactive": if config.KeyboardInteractiveCallback == nil { - authErr = errors.New("ssh: keyboard-interactive auth not configubred") + authErr = errors.New("ssh: keyboard-interactive auth not configured") break } diff --git a/vendor/golang.org/x/net/bpf/constants.go b/vendor/golang.org/x/net/bpf/constants.go index b89ca35239..12f3ee835a 100644 --- a/vendor/golang.org/x/net/bpf/constants.go +++ b/vendor/golang.org/x/net/bpf/constants.go @@ -38,6 +38,7 @@ const ( type JumpTest uint16 // Supported operators for conditional jumps. +// K can be RegX for JumpIfX const ( // K == A JumpEqual JumpTest = iota @@ -134,12 +135,9 @@ const ( opMaskLoadDest = 0x01 opMaskLoadWidth = 0x18 opMaskLoadMode = 0xe0 - // opClsALU - opMaskOperandSrc = 0x08 - opMaskOperator = 0xf0 - // opClsJump - opMaskJumpConst = 0x0f - opMaskJumpCond = 0xf0 + // opClsALU & opClsJump + opMaskOperand = 0x08 + opMaskOperator = 0xf0 ) const ( @@ -192,15 +190,21 @@ const ( opLoadWidth1 ) -// Operator defined by ALUOp* +// Operand for ALU and Jump instructions +type opOperand uint16 +// Supported operand sources. const ( - opALUSrcConstant uint16 = iota << 3 - opALUSrcX + opOperandConstant opOperand = iota << 3 + opOperandX ) +// An jumpOp is a conditional jump condition. +type jumpOp uint16 + +// Supported jump conditions. const ( - opJumpAlways = iota << 4 + opJumpAlways jumpOp = iota << 4 opJumpEqual opJumpGT opJumpGE diff --git a/vendor/golang.org/x/net/bpf/instructions.go b/vendor/golang.org/x/net/bpf/instructions.go index f9dc0e8ee7..3cffcaa014 100644 --- a/vendor/golang.org/x/net/bpf/instructions.go +++ b/vendor/golang.org/x/net/bpf/instructions.go @@ -89,10 +89,14 @@ func (ri RawInstruction) Disassemble() Instruction { case opClsALU: switch op := ALUOp(ri.Op & opMaskOperator); op { case ALUOpAdd, ALUOpSub, ALUOpMul, ALUOpDiv, ALUOpOr, ALUOpAnd, ALUOpShiftLeft, ALUOpShiftRight, ALUOpMod, ALUOpXor: - if ri.Op&opMaskOperandSrc != 0 { + switch operand := opOperand(ri.Op & opMaskOperand); operand { + case opOperandX: return ALUOpX{Op: op} + case opOperandConstant: + return ALUOpConstant{Op: op, Val: ri.K} + default: + return ri } - return ALUOpConstant{Op: op, Val: ri.K} case aluOpNeg: return NegateA{} default: @@ -100,63 +104,18 @@ func (ri RawInstruction) Disassemble() Instruction { } case opClsJump: - if ri.Op&opMaskJumpConst != opClsJump { - return ri - } - switch ri.Op & opMaskJumpCond { + switch op := jumpOp(ri.Op & opMaskOperator); op { case opJumpAlways: return Jump{Skip: ri.K} - case opJumpEqual: - if ri.Jt == 0 { - return JumpIf{ - Cond: JumpNotEqual, - Val: ri.K, - SkipTrue: ri.Jf, - SkipFalse: 0, - } - } - return JumpIf{ - Cond: JumpEqual, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, - } - case opJumpGT: - if ri.Jt == 0 { - return JumpIf{ - Cond: JumpLessOrEqual, - Val: ri.K, - SkipTrue: ri.Jf, - SkipFalse: 0, - } - } - return JumpIf{ - Cond: JumpGreaterThan, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, - } - case opJumpGE: - if ri.Jt == 0 { - return JumpIf{ - Cond: JumpLessThan, - Val: ri.K, - SkipTrue: ri.Jf, - SkipFalse: 0, - } - } - return JumpIf{ - Cond: JumpGreaterOrEqual, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, - } - case opJumpSet: - return JumpIf{ - Cond: JumpBitsSet, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, + case opJumpEqual, opJumpGT, opJumpGE, opJumpSet: + cond, skipTrue, skipFalse := jumpOpToTest(op, ri.Jt, ri.Jf) + switch operand := opOperand(ri.Op & opMaskOperand); operand { + case opOperandX: + return JumpIfX{Cond: cond, SkipTrue: skipTrue, SkipFalse: skipFalse} + case opOperandConstant: + return JumpIf{Cond: cond, Val: ri.K, SkipTrue: skipTrue, SkipFalse: skipFalse} + default: + return ri } default: return ri @@ -187,6 +146,41 @@ func (ri RawInstruction) Disassemble() Instruction { } } +func jumpOpToTest(op jumpOp, skipTrue uint8, skipFalse uint8) (JumpTest, uint8, uint8) { + var test JumpTest + + // Decode "fake" jump conditions that don't appear in machine code + // Ensures the Assemble -> Disassemble stage recreates the same instructions + // See https://github.com/golang/go/issues/18470 + if skipTrue == 0 { + switch op { + case opJumpEqual: + test = JumpNotEqual + case opJumpGT: + test = JumpLessOrEqual + case opJumpGE: + test = JumpLessThan + case opJumpSet: + test = JumpBitsNotSet + } + + return test, skipFalse, 0 + } + + switch op { + case opJumpEqual: + test = JumpEqual + case opJumpGT: + test = JumpGreaterThan + case opJumpGE: + test = JumpGreaterOrEqual + case opJumpSet: + test = JumpBitsSet + } + + return test, skipTrue, skipFalse +} + // LoadConstant loads Val into register Dst. type LoadConstant struct { Dst Register @@ -413,7 +407,7 @@ type ALUOpConstant struct { // Assemble implements the Instruction Assemble method. func (a ALUOpConstant) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsALU | opALUSrcConstant | uint16(a.Op), + Op: opClsALU | uint16(opOperandConstant) | uint16(a.Op), K: a.Val, }, nil } @@ -454,7 +448,7 @@ type ALUOpX struct { // Assemble implements the Instruction Assemble method. func (a ALUOpX) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsALU | opALUSrcX | uint16(a.Op), + Op: opClsALU | uint16(opOperandX) | uint16(a.Op), }, nil } @@ -509,7 +503,7 @@ type Jump struct { // Assemble implements the Instruction Assemble method. func (a Jump) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsJump | opJumpAlways, + Op: opClsJump | uint16(opJumpAlways), K: a.Skip, }, nil } @@ -530,11 +524,39 @@ type JumpIf struct { // Assemble implements the Instruction Assemble method. func (a JumpIf) Assemble() (RawInstruction, error) { + return jumpToRaw(a.Cond, opOperandConstant, a.Val, a.SkipTrue, a.SkipFalse) +} + +// String returns the instruction in assembler notation. +func (a JumpIf) String() string { + return jumpToString(a.Cond, fmt.Sprintf("#%d", a.Val), a.SkipTrue, a.SkipFalse) +} + +// JumpIfX skips the following Skip instructions in the program if A +// X is true. +type JumpIfX struct { + Cond JumpTest + SkipTrue uint8 + SkipFalse uint8 +} + +// Assemble implements the Instruction Assemble method. +func (a JumpIfX) Assemble() (RawInstruction, error) { + return jumpToRaw(a.Cond, opOperandX, 0, a.SkipTrue, a.SkipFalse) +} + +// String returns the instruction in assembler notation. +func (a JumpIfX) String() string { + return jumpToString(a.Cond, "x", a.SkipTrue, a.SkipFalse) +} + +// jumpToRaw assembles a jump instruction into a RawInstruction +func jumpToRaw(test JumpTest, operand opOperand, k uint32, skipTrue, skipFalse uint8) (RawInstruction, error) { var ( - cond uint16 + cond jumpOp flip bool ) - switch a.Cond { + switch test { case JumpEqual: cond = opJumpEqual case JumpNotEqual: @@ -552,63 +574,63 @@ func (a JumpIf) Assemble() (RawInstruction, error) { case JumpBitsNotSet: cond, flip = opJumpSet, true default: - return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", a.Cond) + return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", test) } - jt, jf := a.SkipTrue, a.SkipFalse + jt, jf := skipTrue, skipFalse if flip { jt, jf = jf, jt } return RawInstruction{ - Op: opClsJump | cond, + Op: opClsJump | uint16(cond) | uint16(operand), Jt: jt, Jf: jf, - K: a.Val, + K: k, }, nil } -// String returns the instruction in assembler notation. -func (a JumpIf) String() string { - switch a.Cond { +// jumpToString converts a jump instruction to assembler notation +func jumpToString(cond JumpTest, operand string, skipTrue, skipFalse uint8) string { + switch cond { // K == A case JumpEqual: - return conditionalJump(a, "jeq", "jneq") + return conditionalJump(operand, skipTrue, skipFalse, "jeq", "jneq") // K != A case JumpNotEqual: - return fmt.Sprintf("jneq #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jneq %s,%d", operand, skipTrue) // K > A case JumpGreaterThan: - return conditionalJump(a, "jgt", "jle") + return conditionalJump(operand, skipTrue, skipFalse, "jgt", "jle") // K < A case JumpLessThan: - return fmt.Sprintf("jlt #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jlt %s,%d", operand, skipTrue) // K >= A case JumpGreaterOrEqual: - return conditionalJump(a, "jge", "jlt") + return conditionalJump(operand, skipTrue, skipFalse, "jge", "jlt") // K <= A case JumpLessOrEqual: - return fmt.Sprintf("jle #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jle %s,%d", operand, skipTrue) // K & A != 0 case JumpBitsSet: - if a.SkipFalse > 0 { - return fmt.Sprintf("jset #%d,%d,%d", a.Val, a.SkipTrue, a.SkipFalse) + if skipFalse > 0 { + return fmt.Sprintf("jset %s,%d,%d", operand, skipTrue, skipFalse) } - return fmt.Sprintf("jset #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jset %s,%d", operand, skipTrue) // K & A == 0, there is no assembler instruction for JumpBitNotSet, use JumpBitSet and invert skips case JumpBitsNotSet: - return JumpIf{Cond: JumpBitsSet, SkipTrue: a.SkipFalse, SkipFalse: a.SkipTrue, Val: a.Val}.String() + return jumpToString(JumpBitsSet, operand, skipFalse, skipTrue) default: - return fmt.Sprintf("unknown instruction: %#v", a) + return fmt.Sprintf("unknown JumpTest %#v", cond) } } -func conditionalJump(inst JumpIf, positiveJump, negativeJump string) string { - if inst.SkipTrue > 0 { - if inst.SkipFalse > 0 { - return fmt.Sprintf("%s #%d,%d,%d", positiveJump, inst.Val, inst.SkipTrue, inst.SkipFalse) +func conditionalJump(operand string, skipTrue, skipFalse uint8, positiveJump, negativeJump string) string { + if skipTrue > 0 { + if skipFalse > 0 { + return fmt.Sprintf("%s %s,%d,%d", positiveJump, operand, skipTrue, skipFalse) } - return fmt.Sprintf("%s #%d,%d", positiveJump, inst.Val, inst.SkipTrue) + return fmt.Sprintf("%s %s,%d", positiveJump, operand, skipTrue) } - return fmt.Sprintf("%s #%d,%d", negativeJump, inst.Val, inst.SkipFalse) + return fmt.Sprintf("%s %s,%d", negativeJump, operand, skipFalse) } // RetA exits the BPF program, returning the value of register A. diff --git a/vendor/golang.org/x/net/bpf/vm.go b/vendor/golang.org/x/net/bpf/vm.go index 4c656f1e12..73f57f1f72 100644 --- a/vendor/golang.org/x/net/bpf/vm.go +++ b/vendor/golang.org/x/net/bpf/vm.go @@ -35,6 +35,13 @@ func NewVM(filter []Instruction) (*VM, error) { if check <= int(ins.SkipFalse) { return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) } + case JumpIfX: + if check <= int(ins.SkipTrue) { + return nil, fmt.Errorf("cannot jump %d instructions in true case; jumping past program bounds", ins.SkipTrue) + } + if check <= int(ins.SkipFalse) { + return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) + } // Check for division or modulus by zero case ALUOpConstant: if ins.Val != 0 { @@ -109,6 +116,9 @@ func (v *VM) Run(in []byte) (int, error) { case JumpIf: jump := jumpIf(ins, regA) i += jump + case JumpIfX: + jump := jumpIfX(ins, regA, regX) + i += jump case LoadAbsolute: regA, ok = loadAbsolute(ins, in) case LoadConstant: diff --git a/vendor/golang.org/x/net/bpf/vm_instructions.go b/vendor/golang.org/x/net/bpf/vm_instructions.go index 516f9462b9..f0d2e55bdc 100644 --- a/vendor/golang.org/x/net/bpf/vm_instructions.go +++ b/vendor/golang.org/x/net/bpf/vm_instructions.go @@ -55,34 +55,41 @@ func aluOpCommon(op ALUOp, regA uint32, value uint32) uint32 { } } -func jumpIf(ins JumpIf, value uint32) int { - var ok bool - inV := uint32(ins.Val) +func jumpIf(ins JumpIf, regA uint32) int { + return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, ins.Val) +} - switch ins.Cond { +func jumpIfX(ins JumpIfX, regA uint32, regX uint32) int { + return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, regX) +} + +func jumpIfCommon(cond JumpTest, skipTrue, skipFalse uint8, regA uint32, value uint32) int { + var ok bool + + switch cond { case JumpEqual: - ok = value == inV + ok = regA == value case JumpNotEqual: - ok = value != inV + ok = regA != value case JumpGreaterThan: - ok = value > inV + ok = regA > value case JumpLessThan: - ok = value < inV + ok = regA < value case JumpGreaterOrEqual: - ok = value >= inV + ok = regA >= value case JumpLessOrEqual: - ok = value <= inV + ok = regA <= value case JumpBitsSet: - ok = (value & inV) != 0 + ok = (regA & value) != 0 case JumpBitsNotSet: - ok = (value & inV) == 0 + ok = (regA & value) == 0 } if ok { - return int(ins.SkipTrue) + return int(skipTrue) } - return int(ins.SkipFalse) + return int(skipFalse) } func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) { diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index ec8e613226..7943853ff1 100755 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -193,6 +193,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -445,6 +446,7 @@ ccflags="$@" $2 ~ /^(MS|MNT|UMOUNT)_/ || $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || $2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ || + $2 ~ /^KEXEC_/ || $2 ~ /^LINUX_REBOOT_CMD_/ || $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || $2 !~ "NLA_TYPE_MASK" && diff --git a/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl b/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl index 3e6ed9df8e..a354df5a6b 100755 --- a/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl +++ b/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl @@ -92,6 +92,11 @@ while(<>) { my @in = parseparamlist($in); my @out = parseparamlist($out); + # Try in vain to keep people from editing this file. + # The theory is that they jump into the middle of the file + # without reading the header. + $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"; + # So file name. if($modname eq "") { $modname = "libc"; diff --git a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl index 49f186f832..20632e1460 100755 --- a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl +++ b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl @@ -32,6 +32,7 @@ my @headers = qw ( sys/sem.h sys/shm.h sys/vmmeter.h + uvm/uvmexp.h uvm/uvm_param.h uvm/uvm_swap_encrypt.h ddb/db_var.h diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index f153c0673d..9dd2f32f50 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -12,7 +12,7 @@ import "unsafe" // Round the length of a raw sockaddr up to align it properly. func cmsgAlignOf(salen int) int { - salign := sizeofPtr + salign := SizeofPtr // NOTE: It seems like 64-bit Darwin, DragonFly BSD and // Solaris kernels still require 32-bit aligned access to // network subsystem. diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 02cf204a12..bfa20a971d 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1122,7 +1122,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro // The ptrace syscall differs from glibc's ptrace. // Peeks returns the word in *data, not as the return value. - var buf [sizeofPtr]byte + var buf [SizeofPtr]byte // Leading edge. PEEKTEXT/PEEKDATA don't require aligned // access (PEEKUSER warns that it might), but if we don't @@ -1130,12 +1130,12 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro // boundary and not get the bytes leading up to the page // boundary. n := 0 - if addr%sizeofPtr != 0 { - err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if addr%SizeofPtr != 0 { + err = ptrace(req, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return 0, err } - n += copy(out, buf[addr%sizeofPtr:]) + n += copy(out, buf[addr%SizeofPtr:]) out = out[n:] } @@ -1173,15 +1173,15 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c // Leading edge. n := 0 - if addr%sizeofPtr != 0 { - var buf [sizeofPtr]byte - err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if addr%SizeofPtr != 0 { + var buf [SizeofPtr]byte + err = ptrace(peekReq, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return 0, err } - n += copy(buf[addr%sizeofPtr:], data) + n += copy(buf[addr%SizeofPtr:], data) word := *((*uintptr)(unsafe.Pointer(&buf[0]))) - err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word) + err = ptrace(pokeReq, pid, addr-addr%SizeofPtr, word) if err != nil { return 0, err } @@ -1189,19 +1189,19 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c } // Interior. - for len(data) > sizeofPtr { + for len(data) > SizeofPtr { word := *((*uintptr)(unsafe.Pointer(&data[0]))) err = ptrace(pokeReq, pid, addr+uintptr(n), word) if err != nil { return n, err } - n += sizeofPtr - data = data[sizeofPtr:] + n += SizeofPtr + data = data[SizeofPtr:] } // Trailing edge. if len(data) > 0 { - var buf [sizeofPtr]byte + var buf [SizeofPtr]byte err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return n, err diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 5f9b2454ad..5247d9f908 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -160,3 +160,16 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { } return poll(&fds[0], len(fds), timeout) } + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 6a38dfd5b1..41451854bc 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -136,3 +136,16 @@ func SyncFileRange(fd int, off int64, n int64, flags int) error { // order of their arguments. return syncFileRange2(fd, flags, off, n) } + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index 6e4ee0cf2a..f52f148f9f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -322,3 +322,16 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { } return poll(&fds[0], len(fds), timeout) } + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 639bcdef74..206ce2af80 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -100,14 +100,14 @@ func SysctlClockinfo(name string) (*Clockinfo, error) { } n := uintptr(SizeofClockinfo) - buf := make([]byte, SizeofClockinfo) - if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { + var ci Clockinfo + if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil { return nil, err } if n != SizeofClockinfo { return nil, EIO } - return (*Clockinfo)(unsafe.Pointer(&buf[0])), nil + return &ci, nil } //sysnb pipe() (fd1 int, fd2 int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 07e6669cab..2c674a5c8a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -43,6 +43,23 @@ func nametomib(name string) (mib []_C_int, err error) { return nil, EINVAL } +func SysctlUvmexp(name string) (*Uvmexp, error) { + mib, err := sysctlmib(name) + if err != nil { + return nil, err + } + + n := uintptr(SizeofUvmexp) + var u Uvmexp + if err := sysctl(mib, (*byte)(unsafe.Pointer(&u)), &n, nil, 0); err != nil { + return nil, err + } + if n != SizeofUvmexp { + return nil, EIO + } + return &u, nil +} + //sysnb pipe(p *[2]_C_int) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 13956b7954..64fcda4aef 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -22,10 +22,10 @@ var ( ) const ( - darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 - dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 - netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4 - solaris64Bit = runtime.GOOS == "solaris" && sizeofPtr == 8 + darwin64Bit = runtime.GOOS == "darwin" && SizeofPtr == 8 + dragonfly64Bit = runtime.GOOS == "dragonfly" && SizeofPtr == 8 + netbsd32Bit = runtime.GOOS == "netbsd" && SizeofPtr == 4 + solaris64Bit = runtime.GOOS == "solaris" && SizeofPtr == 8 ) // Do the interface allocations only once for common diff --git a/vendor/golang.org/x/sys/unix/types_aix.go b/vendor/golang.org/x/sys/unix/types_aix.go index 18fbddd52c..25e834940d 100644 --- a/vendor/golang.org/x/sys/unix/types_aix.go +++ b/vendor/golang.org/x/sys/unix/types_aix.go @@ -59,14 +59,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong PathMax = C.PATH_MAX ) diff --git a/vendor/golang.org/x/sys/unix/types_darwin.go b/vendor/golang.org/x/sys/unix/types_darwin.go index 46b9908e03..9fd2aaa6a2 100644 --- a/vendor/golang.org/x/sys/unix/types_darwin.go +++ b/vendor/golang.org/x/sys/unix/types_darwin.go @@ -70,14 +70,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_dragonfly.go b/vendor/golang.org/x/sys/unix/types_dragonfly.go index 386d5f89ff..3365dd79d0 100644 --- a/vendor/golang.org/x/sys/unix/types_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/types_dragonfly.go @@ -65,14 +65,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_freebsd.go b/vendor/golang.org/x/sys/unix/types_freebsd.go index e84a892d63..a0a5843b92 100644 --- a/vendor/golang.org/x/sys/unix/types_freebsd.go +++ b/vendor/golang.org/x/sys/unix/types_freebsd.go @@ -154,14 +154,14 @@ struct if_msghdr8 { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_netbsd.go b/vendor/golang.org/x/sys/unix/types_netbsd.go index c49621ce52..1edbf1ba71 100644 --- a/vendor/golang.org/x/sys/unix/types_netbsd.go +++ b/vendor/golang.org/x/sys/unix/types_netbsd.go @@ -67,14 +67,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_openbsd.go b/vendor/golang.org/x/sys/unix/types_openbsd.go index 8f2fe704c8..297e40d37e 100644 --- a/vendor/golang.org/x/sys/unix/types_openbsd.go +++ b/vendor/golang.org/x/sys/unix/types_openbsd.go @@ -38,6 +38,7 @@ package unix #include #include #include +#include #include #include #include @@ -66,14 +67,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types @@ -263,3 +264,9 @@ const ( // Uname type Utsname C.struct_utsname + +// Uvmexp + +const SizeofUvmexp = C.sizeof_struct_uvmexp + +type Uvmexp C.struct_uvmexp diff --git a/vendor/golang.org/x/sys/unix/types_solaris.go b/vendor/golang.org/x/sys/unix/types_solaris.go index 8cef71bd45..2b716f9348 100644 --- a/vendor/golang.org/x/sys/unix/types_solaris.go +++ b/vendor/golang.org/x/sys/unix/types_solaris.go @@ -75,14 +75,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong PathMax = C.PATH_MAX MaxHostNameLen = C.MAXHOSTNAMELEN ) diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index fe564160bf..86b980a5aa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -879,6 +879,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index dcfa667495..286311572e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -879,6 +879,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index c2ef50c658..1b58da1e78 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 1a820d668f..08377eb4fb 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -881,6 +881,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index b515b2a63f..5de2c7aa40 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 29a88f0e5e..51015f354e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 0767ac1b0d..fdd388debd 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 269b813182..2d15046129 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index eb52e9689f..cd8fcd35ce 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x400 IXON = 0x200 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 0563d34b31..cdb6088760 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x400 IXON = 0x200 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index e95e3f6778..9e9472bec5 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index bad17418e8..f33d031add 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -878,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index 7fdc85b172..ba93f3e53c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -1,10 +1,10 @@ -// mkerrors.sh -m64 -// Code generated by the command above; DO NOT EDIT. +// mkerrors.sh -Wall -Werror -static -I/tmp/include +// Code generated by the command above; see README.md. DO NOT EDIT. // +build sparc64,linux -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs -- -m64 _const.go +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go package unix @@ -1969,174 +1969,182 @@ const ( ) // Error table -var errors = [...]string{ - 1: "operation not permitted", - 2: "no such file or directory", - 3: "no such process", - 4: "interrupted system call", - 5: "input/output error", - 6: "no such device or address", - 7: "argument list too long", - 8: "exec format error", - 9: "bad file descriptor", - 10: "no child processes", - 11: "resource temporarily unavailable", - 12: "cannot allocate memory", - 13: "permission denied", - 14: "bad address", - 15: "block device required", - 16: "device or resource busy", - 17: "file exists", - 18: "invalid cross-device link", - 19: "no such device", - 20: "not a directory", - 21: "is a directory", - 22: "invalid argument", - 23: "too many open files in system", - 24: "too many open files", - 25: "inappropriate ioctl for device", - 26: "text file busy", - 27: "file too large", - 28: "no space left on device", - 29: "illegal seek", - 30: "read-only file system", - 31: "too many links", - 32: "broken pipe", - 33: "numerical argument out of domain", - 34: "numerical result out of range", - 36: "operation now in progress", - 37: "operation already in progress", - 38: "socket operation on non-socket", - 39: "destination address required", - 40: "message too long", - 41: "protocol wrong type for socket", - 42: "protocol not available", - 43: "protocol not supported", - 44: "socket type not supported", - 45: "operation not supported", - 46: "protocol family not supported", - 47: "address family not supported by protocol", - 48: "address already in use", - 49: "cannot assign requested address", - 50: "network is down", - 51: "network is unreachable", - 52: "network dropped connection on reset", - 53: "software caused connection abort", - 54: "connection reset by peer", - 55: "no buffer space available", - 56: "transport endpoint is already connected", - 57: "transport endpoint is not connected", - 58: "cannot send after transport endpoint shutdown", - 59: "too many references: cannot splice", - 60: "connection timed out", - 61: "connection refused", - 62: "too many levels of symbolic links", - 63: "file name too long", - 64: "host is down", - 65: "no route to host", - 66: "directory not empty", - 67: "too many processes", - 68: "too many users", - 69: "disk quota exceeded", - 70: "stale file handle", - 71: "object is remote", - 72: "device not a stream", - 73: "timer expired", - 74: "out of streams resources", - 75: "no message of desired type", - 76: "bad message", - 77: "identifier removed", - 78: "resource deadlock avoided", - 79: "no locks available", - 80: "machine is not on the network", - 81: "unknown error 81", - 82: "link has been severed", - 83: "advertise error", - 84: "srmount error", - 85: "communication error on send", - 86: "protocol error", - 87: "multihop attempted", - 88: "RFS specific error", - 89: "remote address changed", - 90: "function not implemented", - 91: "streams pipe error", - 92: "value too large for defined data type", - 93: "file descriptor in bad state", - 94: "channel number out of range", - 95: "level 2 not synchronized", - 96: "level 3 halted", - 97: "level 3 reset", - 98: "link number out of range", - 99: "protocol driver not attached", - 100: "no CSI structure available", - 101: "level 2 halted", - 102: "invalid exchange", - 103: "invalid request descriptor", - 104: "exchange full", - 105: "no anode", - 106: "invalid request code", - 107: "invalid slot", - 108: "file locking deadlock error", - 109: "bad font file format", - 110: "cannot exec a shared library directly", - 111: "no data available", - 112: "accessing a corrupted shared library", - 113: "package not installed", - 114: "can not access a needed shared library", - 115: "name not unique on network", - 116: "interrupted system call should be restarted", - 117: "structure needs cleaning", - 118: "not a XENIX named type file", - 119: "no XENIX semaphores available", - 120: "is a named type file", - 121: "remote I/O error", - 122: "invalid or incomplete multibyte or wide character", - 123: "attempting to link in too many shared libraries", - 124: ".lib section in a.out corrupted", - 125: "no medium found", - 126: "wrong medium type", - 127: "operation canceled", - 128: "required key not available", - 129: "key has expired", - 130: "key has been revoked", - 131: "key was rejected by service", - 132: "owner died", - 133: "state not recoverable", - 134: "operation not possible due to RF-kill", - 135: "memory page has hardware error", +var errorList = [...]struct { + num syscall.Errno + name string + desc string +}{ + {1, "EPERM", "operation not permitted"}, + {2, "ENOENT", "no such file or directory"}, + {3, "ESRCH", "no such process"}, + {4, "EINTR", "interrupted system call"}, + {5, "EIO", "input/output error"}, + {6, "ENXIO", "no such device or address"}, + {7, "E2BIG", "argument list too long"}, + {8, "ENOEXEC", "exec format error"}, + {9, "EBADF", "bad file descriptor"}, + {10, "ECHILD", "no child processes"}, + {11, "EAGAIN", "resource temporarily unavailable"}, + {12, "ENOMEM", "cannot allocate memory"}, + {13, "EACCES", "permission denied"}, + {14, "EFAULT", "bad address"}, + {15, "ENOTBLK", "block device required"}, + {16, "EBUSY", "device or resource busy"}, + {17, "EEXIST", "file exists"}, + {18, "EXDEV", "invalid cross-device link"}, + {19, "ENODEV", "no such device"}, + {20, "ENOTDIR", "not a directory"}, + {21, "EISDIR", "is a directory"}, + {22, "EINVAL", "invalid argument"}, + {23, "ENFILE", "too many open files in system"}, + {24, "EMFILE", "too many open files"}, + {25, "ENOTTY", "inappropriate ioctl for device"}, + {26, "ETXTBSY", "text file busy"}, + {27, "EFBIG", "file too large"}, + {28, "ENOSPC", "no space left on device"}, + {29, "ESPIPE", "illegal seek"}, + {30, "EROFS", "read-only file system"}, + {31, "EMLINK", "too many links"}, + {32, "EPIPE", "broken pipe"}, + {33, "EDOM", "numerical argument out of domain"}, + {34, "ERANGE", "numerical result out of range"}, + {36, "EINPROGRESS", "operation now in progress"}, + {37, "EALREADY", "operation already in progress"}, + {38, "ENOTSOCK", "socket operation on non-socket"}, + {39, "EDESTADDRREQ", "destination address required"}, + {40, "EMSGSIZE", "message too long"}, + {41, "EPROTOTYPE", "protocol wrong type for socket"}, + {42, "ENOPROTOOPT", "protocol not available"}, + {43, "EPROTONOSUPPORT", "protocol not supported"}, + {44, "ESOCKTNOSUPPORT", "socket type not supported"}, + {45, "ENOTSUP", "operation not supported"}, + {46, "EPFNOSUPPORT", "protocol family not supported"}, + {47, "EAFNOSUPPORT", "address family not supported by protocol"}, + {48, "EADDRINUSE", "address already in use"}, + {49, "EADDRNOTAVAIL", "cannot assign requested address"}, + {50, "ENETDOWN", "network is down"}, + {51, "ENETUNREACH", "network is unreachable"}, + {52, "ENETRESET", "network dropped connection on reset"}, + {53, "ECONNABORTED", "software caused connection abort"}, + {54, "ECONNRESET", "connection reset by peer"}, + {55, "ENOBUFS", "no buffer space available"}, + {56, "EISCONN", "transport endpoint is already connected"}, + {57, "ENOTCONN", "transport endpoint is not connected"}, + {58, "ESHUTDOWN", "cannot send after transport endpoint shutdown"}, + {59, "ETOOMANYREFS", "too many references: cannot splice"}, + {60, "ETIMEDOUT", "connection timed out"}, + {61, "ECONNREFUSED", "connection refused"}, + {62, "ELOOP", "too many levels of symbolic links"}, + {63, "ENAMETOOLONG", "file name too long"}, + {64, "EHOSTDOWN", "host is down"}, + {65, "EHOSTUNREACH", "no route to host"}, + {66, "ENOTEMPTY", "directory not empty"}, + {67, "EPROCLIM", "too many processes"}, + {68, "EUSERS", "too many users"}, + {69, "EDQUOT", "disk quota exceeded"}, + {70, "ESTALE", "stale file handle"}, + {71, "EREMOTE", "object is remote"}, + {72, "ENOSTR", "device not a stream"}, + {73, "ETIME", "timer expired"}, + {74, "ENOSR", "out of streams resources"}, + {75, "ENOMSG", "no message of desired type"}, + {76, "EBADMSG", "bad message"}, + {77, "EIDRM", "identifier removed"}, + {78, "EDEADLK", "resource deadlock avoided"}, + {79, "ENOLCK", "no locks available"}, + {80, "ENONET", "machine is not on the network"}, + {81, "ERREMOTE", "unknown error 81"}, + {82, "ENOLINK", "link has been severed"}, + {83, "EADV", "advertise error"}, + {84, "ESRMNT", "srmount error"}, + {85, "ECOMM", "communication error on send"}, + {86, "EPROTO", "protocol error"}, + {87, "EMULTIHOP", "multihop attempted"}, + {88, "EDOTDOT", "RFS specific error"}, + {89, "EREMCHG", "remote address changed"}, + {90, "ENOSYS", "function not implemented"}, + {91, "ESTRPIPE", "streams pipe error"}, + {92, "EOVERFLOW", "value too large for defined data type"}, + {93, "EBADFD", "file descriptor in bad state"}, + {94, "ECHRNG", "channel number out of range"}, + {95, "EL2NSYNC", "level 2 not synchronized"}, + {96, "EL3HLT", "level 3 halted"}, + {97, "EL3RST", "level 3 reset"}, + {98, "ELNRNG", "link number out of range"}, + {99, "EUNATCH", "protocol driver not attached"}, + {100, "ENOCSI", "no CSI structure available"}, + {101, "EL2HLT", "level 2 halted"}, + {102, "EBADE", "invalid exchange"}, + {103, "EBADR", "invalid request descriptor"}, + {104, "EXFULL", "exchange full"}, + {105, "ENOANO", "no anode"}, + {106, "EBADRQC", "invalid request code"}, + {107, "EBADSLT", "invalid slot"}, + {108, "EDEADLOCK", "file locking deadlock error"}, + {109, "EBFONT", "bad font file format"}, + {110, "ELIBEXEC", "cannot exec a shared library directly"}, + {111, "ENODATA", "no data available"}, + {112, "ELIBBAD", "accessing a corrupted shared library"}, + {113, "ENOPKG", "package not installed"}, + {114, "ELIBACC", "can not access a needed shared library"}, + {115, "ENOTUNIQ", "name not unique on network"}, + {116, "ERESTART", "interrupted system call should be restarted"}, + {117, "EUCLEAN", "structure needs cleaning"}, + {118, "ENOTNAM", "not a XENIX named type file"}, + {119, "ENAVAIL", "no XENIX semaphores available"}, + {120, "EISNAM", "is a named type file"}, + {121, "EREMOTEIO", "remote I/O error"}, + {122, "EILSEQ", "invalid or incomplete multibyte or wide character"}, + {123, "ELIBMAX", "attempting to link in too many shared libraries"}, + {124, "ELIBSCN", ".lib section in a.out corrupted"}, + {125, "ENOMEDIUM", "no medium found"}, + {126, "EMEDIUMTYPE", "wrong medium type"}, + {127, "ECANCELED", "operation canceled"}, + {128, "ENOKEY", "required key not available"}, + {129, "EKEYEXPIRED", "key has expired"}, + {130, "EKEYREVOKED", "key has been revoked"}, + {131, "EKEYREJECTED", "key was rejected by service"}, + {132, "EOWNERDEAD", "owner died"}, + {133, "ENOTRECOVERABLE", "state not recoverable"}, + {134, "ERFKILL", "operation not possible due to RF-kill"}, + {135, "EHWPOISON", "memory page has hardware error"}, } // Signal table -var signals = [...]string{ - 1: "hangup", - 2: "interrupt", - 3: "quit", - 4: "illegal instruction", - 5: "trace/breakpoint trap", - 6: "aborted", - 7: "EMT trap", - 8: "floating point exception", - 9: "killed", - 10: "bus error", - 11: "segmentation fault", - 12: "bad system call", - 13: "broken pipe", - 14: "alarm clock", - 15: "terminated", - 16: "urgent I/O condition", - 17: "stopped (signal)", - 18: "stopped", - 19: "continued", - 20: "child exited", - 21: "stopped (tty input)", - 22: "stopped (tty output)", - 23: "I/O possible", - 24: "CPU time limit exceeded", - 25: "file size limit exceeded", - 26: "virtual timer expired", - 27: "profiling timer expired", - 28: "window changed", - 29: "resource lost", - 30: "user defined signal 1", - 31: "user defined signal 2", +var signalList = [...]struct { + num syscall.Signal + name string + desc string +}{ + {1, "SIGHUP", "hangup"}, + {2, "SIGINT", "interrupt"}, + {3, "SIGQUIT", "quit"}, + {4, "SIGILL", "illegal instruction"}, + {5, "SIGTRAP", "trace/breakpoint trap"}, + {6, "SIGABRT", "aborted"}, + {7, "SIGEMT", "EMT trap"}, + {8, "SIGFPE", "floating point exception"}, + {9, "SIGKILL", "killed"}, + {10, "SIGBUS", "bus error"}, + {11, "SIGSEGV", "segmentation fault"}, + {12, "SIGSYS", "bad system call"}, + {13, "SIGPIPE", "broken pipe"}, + {14, "SIGALRM", "alarm clock"}, + {15, "SIGTERM", "terminated"}, + {16, "SIGURG", "urgent I/O condition"}, + {17, "SIGSTOP", "stopped (signal)"}, + {18, "SIGTSTP", "stopped"}, + {19, "SIGCONT", "continued"}, + {20, "SIGCHLD", "child exited"}, + {21, "SIGTTIN", "stopped (tty input)"}, + {22, "SIGTTOU", "stopped (tty output)"}, + {23, "SIGIO", "I/O possible"}, + {24, "SIGXCPU", "CPU time limit exceeded"}, + {25, "SIGXFSZ", "file size limit exceeded"}, + {26, "SIGVTALRM", "virtual timer expired"}, + {27, "SIGPROF", "profiling timer expired"}, + {28, "SIGWINCH", "window changed"}, + {29, "SIGLOST", "power failure"}, + {30, "SIGUSR1", "user defined signal 1"}, + {31, "SIGUSR2", "user defined signal 2"}, } diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go index 12261a562f..1f9e8a29ea 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go @@ -952,6 +952,7 @@ const ( MNT_NOATIME = 0x8000 MNT_NODEV = 0x10 MNT_NOEXEC = 0x4 + MNT_NOPERM = 0x20 MNT_NOSUID = 0x8 MNT_NOWAIT = 0x2 MNT_QUOTA = 0x2000 @@ -959,6 +960,7 @@ const ( MNT_RELOAD = 0x40000 MNT_ROOTFS = 0x4000 MNT_SOFTDEP = 0x4000000 + MNT_STALLED = 0x100000 MNT_SYNCHRONOUS = 0x2 MNT_UPDATE = 0x10000 MNT_VISFLAGMASK = 0x400ffff @@ -1441,6 +1443,8 @@ const ( TIOCUCNTL_CBRK = 0x7a TIOCUCNTL_SBRK = 0x7b TOSTOP = 0x400000 + UTIME_NOW = -0x2 + UTIME_OMIT = -0x1 VDISCARD = 0xf VDSUSP = 0xb VEOF = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 11a30786cf..46e9ddfb52 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -2296,3 +2296,18 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 8300814d2c..c8ca4279e4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -2343,3 +2343,18 @@ func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 002b4e175a..870c8f6db6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -2343,3 +2343,18 @@ func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 1a9ba99925..55e79d6407 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -2113,3 +2113,18 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index e2e5fc5e0a..97b22a499e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -399,6 +399,8 @@ var ( procrecvfrom syscallFunc ) +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe(p *[2]_C_int) (n int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe)), 1, uintptr(unsafe.Pointer(p)), 0, 0, 0, 0, 0) n = int(r0) @@ -408,6 +410,8 @@ func pipe(p *[2]_C_int) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) if e1 != 0 { @@ -416,6 +420,8 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getcwd(buf []byte) (n int, err error) { var _p0 *byte if len(buf) > 0 { @@ -429,6 +435,8 @@ func Getcwd(buf []byte) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func getgroups(ngid int, gid *_Gid_t) (n int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) n = int(r0) @@ -438,6 +446,8 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func setgroups(ngid int, gid *_Gid_t) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) if e1 != 0 { @@ -446,6 +456,8 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func wait4(pid int32, statusp *_C_int, options int, rusage *Rusage) (wpid int32, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwait4)), 4, uintptr(pid), uintptr(unsafe.Pointer(statusp)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) wpid = int32(r0) @@ -455,6 +467,8 @@ func wait4(pid int32, statusp *_C_int, options int, rusage *Rusage) (wpid int32, return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func gethostname(buf []byte) (n int, err error) { var _p0 *byte if len(buf) > 0 { @@ -468,6 +482,8 @@ func gethostname(buf []byte) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimes(path string, times *[2]Timeval) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -481,6 +497,8 @@ func utimes(path string, times *[2]Timeval) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -494,6 +512,8 @@ func utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func fcntl(fd int, cmd int, arg int) (val int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) val = int(r0) @@ -503,6 +523,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func futimesat(fildes int, path *byte, times *[2]Timeval) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfutimesat)), 3, uintptr(fildes), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)), 0, 0, 0) if e1 != 0 { @@ -511,6 +533,8 @@ func futimesat(fildes int, path *byte, times *[2]Timeval) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procaccept)), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) fd = int(r0) @@ -520,6 +544,8 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_recvmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) n = int(r0) @@ -529,6 +555,8 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_sendmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) n = int(r0) @@ -538,6 +566,8 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func acct(path *byte) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procacct)), 1, uintptr(unsafe.Pointer(path)), 0, 0, 0, 0, 0) if e1 != 0 { @@ -546,24 +576,32 @@ func acct(path *byte) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func __makedev(version int, major uint, minor uint) (val uint64) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&proc__makedev)), 3, uintptr(version), uintptr(major), uintptr(minor), 0, 0, 0) val = uint64(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func __major(version int, dev uint64) (val uint) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&proc__major)), 2, uintptr(version), uintptr(dev), 0, 0, 0, 0) val = uint(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func __minor(version int, dev uint64) (val uint) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&proc__minor)), 2, uintptr(version), uintptr(dev), 0, 0, 0, 0) val = uint(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) if e1 != 0 { @@ -572,6 +610,8 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procpoll)), 3, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout), 0, 0, 0) n = int(r0) @@ -581,6 +621,8 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -594,6 +636,8 @@ func Access(path string, mode uint32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAdjtime)), 2, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0, 0, 0, 0) if e1 != 0 { @@ -602,6 +646,8 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Chdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -615,6 +661,8 @@ func Chdir(path string) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Chmod(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -628,6 +676,8 @@ func Chmod(path string, mode uint32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Chown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -641,6 +691,8 @@ func Chown(path string, uid int, gid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Chroot(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -654,6 +706,8 @@ func Chroot(path string) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Close(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procClose)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -662,6 +716,8 @@ func Close(fd int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Creat(path string, mode uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -676,6 +732,8 @@ func Creat(path string, mode uint32) (fd int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(fd int) (nfd int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup)), 1, uintptr(fd), 0, 0, 0, 0, 0) nfd = int(r0) @@ -685,6 +743,8 @@ func Dup(fd int) (nfd int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup2(oldfd int, newfd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup2)), 2, uintptr(oldfd), uintptr(newfd), 0, 0, 0, 0) if e1 != 0 { @@ -693,11 +753,15 @@ func Dup2(oldfd int, newfd int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Exit(code int) { sysvicall6(uintptr(unsafe.Pointer(&procExit)), 1, uintptr(code), 0, 0, 0, 0, 0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -711,6 +775,8 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchdir(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchdir)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -719,6 +785,8 @@ func Fchdir(fd int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchmod(fd int, mode uint32) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmod)), 2, uintptr(fd), uintptr(mode), 0, 0, 0, 0) if e1 != 0 { @@ -727,6 +795,8 @@ func Fchmod(fd int, mode uint32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -740,6 +810,8 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchown)), 3, uintptr(fd), uintptr(uid), uintptr(gid), 0, 0, 0) if e1 != 0 { @@ -748,6 +820,8 @@ func Fchown(fd int, uid int, gid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -761,6 +835,8 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fdatasync(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFdatasync)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -769,6 +845,8 @@ func Fdatasync(fd int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Flock(fd int, how int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0) if e1 != 0 { @@ -777,6 +855,8 @@ func Flock(fd int, how int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fpathconf(fd int, name int) (val int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFpathconf)), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0) val = int(r0) @@ -786,6 +866,8 @@ func Fpathconf(fd int, name int) (val int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fstat(fd int, stat *Stat_t) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstat)), 2, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) if e1 != 0 { @@ -794,6 +876,8 @@ func Fstat(fd int, stat *Stat_t) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -807,6 +891,8 @@ func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstatvfs)), 2, uintptr(fd), uintptr(unsafe.Pointer(vfsstat)), 0, 0, 0, 0) if e1 != 0 { @@ -815,6 +901,8 @@ func Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { var _p0 *byte if len(buf) > 0 { @@ -828,18 +916,24 @@ func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getgid() (gid int) { r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetgid)), 0, 0, 0, 0, 0, 0, 0) gid = int(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getpid() (pid int) { r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpid)), 0, 0, 0, 0, 0, 0, 0) pid = int(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getpgid(pid int) (pgid int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) pgid = int(r0) @@ -849,6 +943,8 @@ func Getpgid(pid int) (pgid int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getpgrp() (pgid int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgrp)), 0, 0, 0, 0, 0, 0, 0) pgid = int(r0) @@ -858,24 +954,32 @@ func Getpgrp() (pgid int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Geteuid() (euid int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGeteuid)), 0, 0, 0, 0, 0, 0, 0) euid = int(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getegid() (egid int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetegid)), 0, 0, 0, 0, 0, 0, 0) egid = int(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getppid() (ppid int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetppid)), 0, 0, 0, 0, 0, 0, 0) ppid = int(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getpriority(which int, who int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetpriority)), 2, uintptr(which), uintptr(who), 0, 0, 0, 0) n = int(r0) @@ -885,6 +989,8 @@ func Getpriority(which int, who int) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) if e1 != 0 { @@ -893,6 +999,8 @@ func Getrlimit(which int, lim *Rlimit) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getrusage(who int, rusage *Rusage) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0) if e1 != 0 { @@ -901,6 +1009,8 @@ func Getrusage(who int, rusage *Rusage) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettimeofday(tv *Timeval) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGettimeofday)), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0) if e1 != 0 { @@ -909,12 +1019,16 @@ func Gettimeofday(tv *Timeval) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getuid() (uid int) { r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetuid)), 0, 0, 0, 0, 0, 0, 0) uid = int(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Kill(pid int, signum syscall.Signal) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procKill)), 2, uintptr(pid), uintptr(signum), 0, 0, 0, 0) if e1 != 0 { @@ -923,6 +1037,8 @@ func Kill(pid int, signum syscall.Signal) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -936,6 +1052,8 @@ func Lchown(path string, uid int, gid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Link(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -954,6 +1072,8 @@ func Link(path string, link string) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Listen(s int, backlog int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_llisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) if e1 != 0 { @@ -962,6 +1082,8 @@ func Listen(s int, backlog int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Lstat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -975,6 +1097,8 @@ func Lstat(path string, stat *Stat_t) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Madvise(b []byte, advice int) (err error) { var _p0 *byte if len(b) > 0 { @@ -987,6 +1111,8 @@ func Madvise(b []byte, advice int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdir(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1000,6 +1126,8 @@ func Mkdir(path string, mode uint32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1013,6 +1141,8 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1026,6 +1156,8 @@ func Mkfifo(path string, mode uint32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkfifoat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1039,6 +1171,8 @@ func Mkfifoat(dirfd int, path string, mode uint32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mknod(path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1052,6 +1186,8 @@ func Mknod(path string, mode uint32, dev int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1065,6 +1201,8 @@ func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mlock(b []byte) (err error) { var _p0 *byte if len(b) > 0 { @@ -1077,6 +1215,8 @@ func Mlock(b []byte) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mlockall(flags int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlockall)), 1, uintptr(flags), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1085,6 +1225,8 @@ func Mlockall(flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mprotect(b []byte, prot int) (err error) { var _p0 *byte if len(b) > 0 { @@ -1097,6 +1239,8 @@ func Mprotect(b []byte, prot int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Msync(b []byte, flags int) (err error) { var _p0 *byte if len(b) > 0 { @@ -1109,6 +1253,8 @@ func Msync(b []byte, flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlock(b []byte) (err error) { var _p0 *byte if len(b) > 0 { @@ -1121,6 +1267,8 @@ func Munlock(b []byte) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Munlockall() (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlockall)), 0, 0, 0, 0, 0, 0, 0) if e1 != 0 { @@ -1129,6 +1277,8 @@ func Munlockall() (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procNanosleep)), 2, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0, 0, 0, 0) if e1 != 0 { @@ -1137,6 +1287,8 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Open(path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1151,6 +1303,8 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1165,6 +1319,8 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Pathconf(path string, name int) (val int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1179,6 +1335,8 @@ func Pathconf(path string, name int) (val int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Pause() (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPause)), 0, 0, 0, 0, 0, 0, 0) if e1 != 0 { @@ -1187,6 +1345,8 @@ func Pause() (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1200,6 +1360,8 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1213,6 +1375,8 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func read(fd int, p []byte) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1226,6 +1390,8 @@ func read(fd int, p []byte) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Readlink(path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1244,6 +1410,8 @@ func Readlink(path string, buf []byte) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1262,6 +1430,8 @@ func Rename(from string, to string) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) @@ -1280,6 +1450,8 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Rmdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1293,6 +1465,8 @@ func Rmdir(path string) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclseek)), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0) newoffset = int64(r0) @@ -1302,6 +1476,8 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSelect)), 5, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) if e1 != 0 { @@ -1310,6 +1486,8 @@ func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setegid(egid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetegid)), 1, uintptr(egid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1318,6 +1496,8 @@ func Setegid(egid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Seteuid(euid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSeteuid)), 1, uintptr(euid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1326,6 +1506,8 @@ func Seteuid(euid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setgid(gid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetgid)), 1, uintptr(gid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1334,6 +1516,8 @@ func Setgid(gid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sethostname(p []byte) (err error) { var _p0 *byte if len(p) > 0 { @@ -1346,6 +1530,8 @@ func Sethostname(p []byte) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setpgid(pid int, pgid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetpgid)), 2, uintptr(pid), uintptr(pgid), 0, 0, 0, 0) if e1 != 0 { @@ -1354,6 +1540,8 @@ func Setpgid(pid int, pgid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setpriority(which int, who int, prio int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSetpriority)), 3, uintptr(which), uintptr(who), uintptr(prio), 0, 0, 0) if e1 != 0 { @@ -1362,6 +1550,8 @@ func Setpriority(which int, who int, prio int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setregid(rgid int, egid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetregid)), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0) if e1 != 0 { @@ -1370,6 +1560,8 @@ func Setregid(rgid int, egid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setreuid(ruid int, euid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetreuid)), 2, uintptr(ruid), uintptr(euid), 0, 0, 0, 0) if e1 != 0 { @@ -1378,6 +1570,8 @@ func Setreuid(ruid int, euid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) if e1 != 0 { @@ -1386,6 +1580,8 @@ func Setrlimit(which int, lim *Rlimit) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setsid() (pid int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetsid)), 0, 0, 0, 0, 0, 0, 0) pid = int(r0) @@ -1395,6 +1591,8 @@ func Setsid() (pid int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setuid(uid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetuid)), 1, uintptr(uid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1403,6 +1601,8 @@ func Setuid(uid int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Shutdown(s int, how int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procshutdown)), 2, uintptr(s), uintptr(how), 0, 0, 0, 0) if e1 != 0 { @@ -1411,6 +1611,8 @@ func Shutdown(s int, how int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Stat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1424,6 +1626,8 @@ func Stat(path string, stat *Stat_t) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Statvfs(path string, vfsstat *Statvfs_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1437,6 +1641,8 @@ func Statvfs(path string, vfsstat *Statvfs_t) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Symlink(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1455,6 +1661,8 @@ func Symlink(path string, link string) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Sync() (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSync)), 0, 0, 0, 0, 0, 0, 0) if e1 != 0 { @@ -1463,6 +1671,8 @@ func Sync() (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Times(tms *Tms) (ticks uintptr, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procTimes)), 1, uintptr(unsafe.Pointer(tms)), 0, 0, 0, 0, 0) ticks = uintptr(r0) @@ -1472,6 +1682,8 @@ func Times(tms *Tms) (ticks uintptr, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Truncate(path string, length int64) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1485,6 +1697,8 @@ func Truncate(path string, length int64) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Fsync(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFsync)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1493,6 +1707,8 @@ func Fsync(fd int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Ftruncate(fd int, length int64) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFtruncate)), 2, uintptr(fd), uintptr(length), 0, 0, 0, 0) if e1 != 0 { @@ -1501,12 +1717,16 @@ func Ftruncate(fd int, length int64) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Umask(mask int) (oldmask int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procUmask)), 1, uintptr(mask), 0, 0, 0, 0, 0) oldmask = int(r0) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Uname(buf *Utsname) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procUname)), 1, uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1515,6 +1735,8 @@ func Uname(buf *Utsname) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unmount(target string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(target) @@ -1528,6 +1750,8 @@ func Unmount(target string, flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unlink(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1541,6 +1765,8 @@ func Unlink(path string) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Unlinkat(dirfd int, path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1554,6 +1780,8 @@ func Unlinkat(dirfd int, path string, flags int) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Ustat(dev int, ubuf *Ustat_t) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUstat)), 2, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0, 0, 0, 0) if e1 != 0 { @@ -1562,6 +1790,8 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Utime(path string, buf *Utimbuf) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1575,6 +1805,8 @@ func Utime(path string, buf *Utimbuf) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_bind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { @@ -1583,6 +1815,8 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_connect)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { @@ -1591,6 +1825,8 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmmap)), 6, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) ret = uintptr(r0) @@ -1600,6 +1836,8 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func munmap(addr uintptr, length uintptr) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmunmap)), 2, uintptr(addr), uintptr(length), 0, 0, 0, 0) if e1 != 0 { @@ -1608,6 +1846,8 @@ func munmap(addr uintptr, length uintptr) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendfile)), 4, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) written = int(r0) @@ -1617,6 +1857,8 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { var _p0 *byte if len(buf) > 0 { @@ -1629,6 +1871,8 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func socket(domain int, typ int, proto int) (fd int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_socket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) fd = int(r0) @@ -1638,6 +1882,8 @@ func socket(domain int, typ int, proto int) (fd int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&proc__xnet_socketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) if e1 != 0 { @@ -1646,6 +1892,8 @@ func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func write(fd int, p []byte) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1659,6 +1907,8 @@ func write(fd int, p []byte) (n int, err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_getsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) if e1 != 0 { @@ -1667,6 +1917,8 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetpeername)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) if e1 != 0 { @@ -1675,6 +1927,8 @@ func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) if e1 != 0 { @@ -1683,6 +1937,8 @@ func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) return } +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { var _p0 *byte if len(p) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go index 90c95c2c75..d014451c9d 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go @@ -254,4 +254,17 @@ var sysctlMib = []mibentry{ {"net.mpls.ttl", []_C_int{4, 33, 2}}, {"net.pflow.stats", []_C_int{4, 34, 1}}, {"net.pipex.enable", []_C_int{4, 35, 1}}, + {"vm.anonmin", []_C_int{2, 7}}, + {"vm.loadavg", []_C_int{2, 2}}, + {"vm.maxslp", []_C_int{2, 10}}, + {"vm.nkmempages", []_C_int{2, 6}}, + {"vm.psstrings", []_C_int{2, 3}}, + {"vm.swapencrypt.enable", []_C_int{2, 5, 0}}, + {"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}}, + {"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}}, + {"vm.uspace", []_C_int{2, 11}}, + {"vm.uvmexp", []_C_int{2, 4}}, + {"vm.vmmeter", []_C_int{2, 1}}, + {"vm.vnodemin", []_C_int{2, 9}}, + {"vm.vtextmin", []_C_int{2, 8}}, } diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go index f1cfe7db15..cedc9b0f26 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x3ff ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go index 95581a3bc3..f46482d272 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x3ff ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go index 327af5fba1..2aeb52a886 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 116e6e0757..0d0d9f2ccb 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go index 2750ad7607..04e344b78d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -7,11 +7,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 8cead0996c..9fec185c18 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index c01ae67016..7b34e2e2c6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 8006c5638e..11380294ac 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index 716774ded0..a6fc127180 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index 92e07b00f5..6b3006d6b3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 793b3fdd21..3879002a9c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1937,3 +1937,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index c3548848a4..cbc2c7d073 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1959,3 +1959,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index c7b6994329..6ed804fa3c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1927,3 +1927,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 2339b21298..b5fe7ddf76 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1938,3 +1938,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 013462ba5d..7379ad2d81 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1932,3 +1932,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 86f0ab5520..0b131a24e1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1940,3 +1940,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 007537b4d3..9191020cc8 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1940,3 +1940,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index fc4a159124..8fcad32bfc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1932,3 +1932,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 377e9efdfc..a9d1b6c9ff 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1948,3 +1948,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index 595ba63030..f0f5214a53 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1948,3 +1948,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 0ccf5bc3e1..09c905866f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1965,3 +1965,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 06b07852d1..5e86e496cd 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1965,3 +1965,31 @@ type XDPDesc struct { Len uint32 Options uint32 } + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 8e7384b89c..1fc7f7dea9 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -5,11 +5,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go index 9e9088de11..1fdc5fd211 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go index ed3f17366a..711f780675 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go index d263b61476..fa1a16bae1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index 231f4e8ef3..c8509bf0e4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( @@ -465,3 +465,94 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Anonpages int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Nanonneeded int32 + Nfreeanon int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Obsolete_swapins int32 + Obsolete_swapouts int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Zeroaborts int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Pdreanon int32 + Pdrevnode int32 + Pdrevtext int32 + Fpswtch int32 + Kmapent int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index bb2c44886e..200575d941 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( @@ -465,3 +465,94 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Anonpages int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Nanonneeded int32 + Nfreeanon int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Obsolete_swapins int32 + Obsolete_swapouts int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Zeroaborts int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Pdreanon int32 + Pdrevnode int32 + Pdrevtext int32 + Fpswtch int32 + Kmapent int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go index 941367cab8..3e20cdf092 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( @@ -458,3 +458,94 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Anonpages int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Nanonneeded int32 + Nfreeanon int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Obsolete_swapins int32 + Obsolete_swapouts int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Zeroaborts int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Pdreanon int32 + Pdrevnode int32 + Pdrevtext int32 + Fpswtch int32 + Kmapent int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go index 0543e1a49a..8531a190f2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x400 MaxHostNameLen = 0x100 ) diff --git a/vendor/yunion.io/x/jsonutils/yamlutils.go b/vendor/yunion.io/x/jsonutils/yamlutils.go index fd2b978882..de45df9211 100644 --- a/vendor/yunion.io/x/jsonutils/yamlutils.go +++ b/vendor/yunion.io/x/jsonutils/yamlutils.go @@ -61,7 +61,6 @@ func parseYAMLDict(lines []string) (map[string]JSONObject, error) { } else { key := lines[i][0:keypos] val := strings.Trim(lines[i][keypos+1:], " ") - if len(val) > 0 && val != "|" { dict[key] = NewString(val) i++ From aab792ffa8ee7f873ab24d5d9ae66bc7ef3ec548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Sat, 3 Nov 2018 18:32:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86aliyun?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gopkg.toml | 8 +- cmd/qcloudcli/main.go | 2 +- pkg/compute/guestdrivers/qcloud.go | 34 +- pkg/compute/hostdrivers/qcloud.go | 209 +++++++++++ pkg/mcclient/options/servers.go | 2 +- pkg/scheduler/api/types.go | 2 + pkg/util/aliyun/instance.go | 5 + pkg/util/aliyun/shell/image.go | 45 +++ pkg/util/aliyun/shell/snapshot.go | 10 +- pkg/util/aliyun/storagecache.go | 4 + pkg/util/qcloud/disk.go | 26 +- pkg/util/qcloud/host.go | 26 +- pkg/util/qcloud/image.go | 42 ++- pkg/util/qcloud/instance.go | 172 ++++----- pkg/util/qcloud/provider/provider.go | 38 +- pkg/util/qcloud/qcloud.go | 17 +- pkg/util/qcloud/region.go | 20 +- pkg/util/qcloud/storage.go | 17 +- pkg/util/qcloud/storagecache.go | 33 +- pkg/util/qcloud/zone.go | 14 +- .../sdk/endpoints/location_resolver.go | 2 +- vendor/github.com/forhappy/cos-go-sdk/LICENSE | 201 ++++++++++ .../forhappy/cos-go-sdk/auth/auth.go | 99 +++++ .../forhappy/cos-go-sdk/http/LICENSE | 24 ++ .../go-windows-terminal-sequences/go.mod | 1 - vendor/github.com/miekg/dns/.travis.yml | 7 +- vendor/github.com/miekg/dns/Gopkg.lock | 46 +-- vendor/github.com/miekg/dns/Gopkg.toml | 12 - vendor/github.com/miekg/dns/client.go | 2 +- vendor/github.com/miekg/dns/generate.go | 4 +- vendor/github.com/miekg/dns/listen_go111.go | 3 +- .../github.com/miekg/dns/listen_go_not111.go | 2 +- vendor/github.com/miekg/dns/msg.go | 51 ++- vendor/github.com/miekg/dns/msg_helpers.go | 30 +- vendor/github.com/miekg/dns/privaterr.go | 3 +- vendor/github.com/miekg/dns/scan.go | 7 +- vendor/github.com/miekg/dns/scanner.go | 2 +- vendor/github.com/miekg/dns/serve_mux.go | 147 -------- vendor/github.com/miekg/dns/server.go | 201 +++++++--- vendor/github.com/miekg/dns/sig0.go | 3 +- vendor/github.com/miekg/dns/types.go | 150 ++++---- vendor/github.com/miekg/dns/udp.go | 2 - vendor/github.com/miekg/dns/udp_windows.go | 37 -- vendor/github.com/miekg/dns/version.go | 2 +- .../nelsonken/cos-go-sdk-v5/cos/auth.go | 128 +++++++ .../nelsonken/cos-go-sdk-v5/cos/bucket.go | 315 ++++++++++++++++ .../nelsonken/cos-go-sdk-v5/cos/client.go | 164 ++++++++ .../nelsonken/cos-go-sdk-v5/cos/conf.go | 31 ++ .../nelsonken/cos-go-sdk-v5/cos/conn.go | 141 +++++++ .../nelsonken/cos-go-sdk-v5/cos/option.go | 10 + .../nelsonken/cos-go-sdk-v5/cos/requests.go | 102 +++++ .../nelsonken/cos-go-sdk-v5/cos/response.go | 156 ++++++++ vendor/github.com/pierrec/lz4/block.go | 2 +- .../github.com/prometheus/procfs/.travis.yml | 12 + .../prometheus/procfs/internal/util/parse.go | 15 +- .../procfs/internal/util/sysreadfile_linux.go | 45 --- .../github.com/sirupsen/logrus/CHANGELOG.md | 5 - vendor/github.com/sirupsen/logrus/entry.go | 16 +- .../github.com/sirupsen/logrus/formatter.go | 15 +- .../sirupsen/logrus/json_formatter.go | 10 +- .../sirupsen/logrus/terminal_appengine.go | 13 + .../sirupsen/logrus/terminal_bsd.go | 17 + .../sirupsen/logrus/terminal_linux.go | 21 ++ .../sirupsen/logrus/terminal_notwindows.go | 8 - .../sirupsen/logrus/text_formatter.go | 7 +- vendor/github.com/spf13/pflag/flag.go | 7 +- .../github.com/spf13/pflag/string_to_int.go | 149 -------- .../spf13/pflag/string_to_string.go | 160 -------- .../tencentcloud/tencentcloud-sdk-go/LICENSE | 201 ++++++++++ .../tencentcloud/common/client.go | 88 +++++ .../tencentcloud/common/credentials.go | 40 ++ .../tencentcloud/common/errors/errors.go | 35 ++ .../tencentcloud/common/http/request.go | 231 ++++++++++++ .../tencentcloud/common/http/response.go | 69 ++++ .../common/profile/client_profile.go | 13 + .../common/profile/http_profile.go | 17 + .../tencentcloud/common/sign.go | 75 ++++ .../tencentcloud/common/types.go | 47 +++ vendor/github.com/vmware/govmomi/.mailmap | 3 - vendor/github.com/vmware/govmomi/CHANGELOG.md | 8 +- vendor/github.com/vmware/govmomi/CONTRIBUTORS | 13 - vendor/github.com/vmware/govmomi/README.md | 2 - .../vmware/govmomi/session/keep_alive.go | 3 +- vendor/golang.org/x/crypto/ssh/server.go | 2 +- vendor/golang.org/x/net/bpf/constants.go | 24 +- vendor/golang.org/x/net/bpf/instructions.go | 194 +++++----- vendor/golang.org/x/net/bpf/vm.go | 10 - .../golang.org/x/net/bpf/vm_instructions.go | 33 +- vendor/golang.org/x/sys/unix/mkerrors.sh | 2 - .../x/sys/unix/mksyscall_solaris.pl | 5 - .../golang.org/x/sys/unix/mksysctl_openbsd.pl | 1 - vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 2 +- vendor/golang.org/x/sys/unix/syscall_linux.go | 26 +- .../x/sys/unix/syscall_linux_amd64.go | 13 - .../x/sys/unix/syscall_linux_ppc64x.go | 13 - .../x/sys/unix/syscall_linux_s390x.go | 13 - .../golang.org/x/sys/unix/syscall_netbsd.go | 6 +- .../golang.org/x/sys/unix/syscall_openbsd.go | 17 - vendor/golang.org/x/sys/unix/syscall_unix.go | 8 +- vendor/golang.org/x/sys/unix/types_aix.go | 12 +- vendor/golang.org/x/sys/unix/types_darwin.go | 12 +- .../golang.org/x/sys/unix/types_dragonfly.go | 12 +- vendor/golang.org/x/sys/unix/types_freebsd.go | 12 +- vendor/golang.org/x/sys/unix/types_netbsd.go | 12 +- vendor/golang.org/x/sys/unix/types_openbsd.go | 19 +- vendor/golang.org/x/sys/unix/types_solaris.go | 12 +- .../x/sys/unix/zerrors_linux_386.go | 20 - .../x/sys/unix/zerrors_linux_amd64.go | 20 - .../x/sys/unix/zerrors_linux_arm.go | 20 - .../x/sys/unix/zerrors_linux_arm64.go | 20 - .../x/sys/unix/zerrors_linux_mips.go | 20 - .../x/sys/unix/zerrors_linux_mips64.go | 20 - .../x/sys/unix/zerrors_linux_mips64le.go | 20 - .../x/sys/unix/zerrors_linux_mipsle.go | 20 - .../x/sys/unix/zerrors_linux_ppc64.go | 20 - .../x/sys/unix/zerrors_linux_ppc64le.go | 20 - .../x/sys/unix/zerrors_linux_riscv64.go | 20 - .../x/sys/unix/zerrors_linux_s390x.go | 20 - .../x/sys/unix/zerrors_linux_sparc64.go | 350 +++++++++--------- .../x/sys/unix/zerrors_openbsd_amd64.go | 4 - .../x/sys/unix/zsyscall_linux_amd64.go | 15 - .../x/sys/unix/zsyscall_linux_ppc64.go | 15 - .../x/sys/unix/zsyscall_linux_ppc64le.go | 15 - .../x/sys/unix/zsyscall_linux_s390x.go | 15 - .../x/sys/unix/zsyscall_solaris_amd64.go | 256 ------------- .../x/sys/unix/zsysctl_openbsd_amd64.go | 13 - .../golang.org/x/sys/unix/ztypes_aix_ppc.go | 10 +- .../golang.org/x/sys/unix/ztypes_aix_ppc64.go | 10 +- .../x/sys/unix/ztypes_darwin_386.go | 10 +- .../x/sys/unix/ztypes_darwin_amd64.go | 10 +- .../x/sys/unix/ztypes_darwin_arm.go | 10 +- .../x/sys/unix/ztypes_darwin_arm64.go | 10 +- .../x/sys/unix/ztypes_dragonfly_amd64.go | 10 +- .../x/sys/unix/ztypes_freebsd_386.go | 10 +- .../x/sys/unix/ztypes_freebsd_amd64.go | 10 +- .../x/sys/unix/ztypes_freebsd_arm.go | 10 +- .../golang.org/x/sys/unix/ztypes_linux_386.go | 38 +- .../x/sys/unix/ztypes_linux_amd64.go | 38 +- .../golang.org/x/sys/unix/ztypes_linux_arm.go | 38 +- .../x/sys/unix/ztypes_linux_arm64.go | 38 +- .../x/sys/unix/ztypes_linux_mips.go | 38 +- .../x/sys/unix/ztypes_linux_mips64.go | 38 +- .../x/sys/unix/ztypes_linux_mips64le.go | 38 +- .../x/sys/unix/ztypes_linux_mipsle.go | 38 +- .../x/sys/unix/ztypes_linux_ppc64.go | 38 +- .../x/sys/unix/ztypes_linux_ppc64le.go | 38 +- .../x/sys/unix/ztypes_linux_riscv64.go | 38 +- .../x/sys/unix/ztypes_linux_s390x.go | 38 +- .../x/sys/unix/ztypes_linux_sparc64.go | 10 +- .../x/sys/unix/ztypes_netbsd_386.go | 10 +- .../x/sys/unix/ztypes_netbsd_amd64.go | 10 +- .../x/sys/unix/ztypes_netbsd_arm.go | 10 +- .../x/sys/unix/ztypes_openbsd_386.go | 101 +---- .../x/sys/unix/ztypes_openbsd_amd64.go | 101 +---- .../x/sys/unix/ztypes_openbsd_arm.go | 101 +---- .../x/sys/unix/ztypes_solaris_amd64.go | 10 +- vendor/yunion.io/x/jsonutils/yamlutils.go | 1 + 157 files changed, 3603 insertions(+), 2848 deletions(-) create mode 100644 pkg/compute/hostdrivers/qcloud.go create mode 100644 vendor/github.com/forhappy/cos-go-sdk/LICENSE create mode 100644 vendor/github.com/forhappy/cos-go-sdk/auth/auth.go create mode 100644 vendor/github.com/forhappy/cos-go-sdk/http/LICENSE delete mode 100644 vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod delete mode 100644 vendor/github.com/miekg/dns/serve_mux.go delete mode 100644 vendor/github.com/miekg/dns/udp_windows.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/auth.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/bucket.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/client.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conf.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conn.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/option.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/requests.go create mode 100644 vendor/github.com/nelsonken/cos-go-sdk-v5/cos/response.go create mode 100644 vendor/github.com/prometheus/procfs/.travis.yml delete mode 100644 vendor/github.com/prometheus/procfs/internal/util/sysreadfile_linux.go create mode 100644 vendor/github.com/sirupsen/logrus/terminal_appengine.go create mode 100644 vendor/github.com/sirupsen/logrus/terminal_bsd.go create mode 100644 vendor/github.com/sirupsen/logrus/terminal_linux.go delete mode 100644 vendor/github.com/sirupsen/logrus/terminal_notwindows.go delete mode 100644 vendor/github.com/spf13/pflag/string_to_int.go delete mode 100644 vendor/github.com/spf13/pflag/string_to_string.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/LICENSE create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/client.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/credentials.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors/errors.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/response.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/client_profile.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/http_profile.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/sign.go create mode 100644 vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/types.go diff --git a/Gopkg.toml b/Gopkg.toml index 3d859a94b9..b7e4b146fe 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -112,11 +112,11 @@ [[constraint]] name = "github.com/tencentcloud/tencentcloud-sdk-go" - version = "=v3.0.0" + version = "=v3.0.28" [[constraint]] + branch = "master" name = "github.com/nelsonken/cos-go-sdk-v5" - version = "=v1.2.0" [[constraint]] branch = "master" @@ -125,3 +125,7 @@ [[constraint]] branch = "master" name = "golang.org/x/crypto" + +[[constraint]] + branch = "master" + name = "github.com/forhappy/cos-go-sdk" diff --git a/cmd/qcloudcli/main.go b/cmd/qcloudcli/main.go index 7e22889f2e..6764f03e00 100644 --- a/cmd/qcloudcli/main.go +++ b/cmd/qcloudcli/main.go @@ -17,7 +17,7 @@ type BaseOptions struct { AppID string `help:"AppID" default:"$QCLOUD_APPID"` SecretID string `help:"Secret" default:"$QCLOUD_SECRET_ID"` SecretKey string `help:"Access key" default:"$QCLOUD_SECRET_KEY"` - RegionId string `help:"RegionId" default:"$QCLOUD_REGION_ID"` + RegionId string `help:"RegionId" default:"$QCLOUD_REGION"` SUBCOMMAND string `help:"azurecli subcommand" subcommand:"true"` } diff --git a/pkg/compute/guestdrivers/qcloud.go b/pkg/compute/guestdrivers/qcloud.go index b9d0cc8dff..9229ab1fe3 100644 --- a/pkg/compute/guestdrivers/qcloud.go +++ b/pkg/compute/guestdrivers/qcloud.go @@ -37,7 +37,7 @@ func (self *SQcloudGuestDriver) ChooseHostStorage(host *models.SHost, backend st return &storages[i] } } - for _, stype := range []string{"local_basic", "local_ssd", "cloud_basic", "cloud_ssd", "cloud_premium"} { + for _, stype := range []string{"cloud_basic", "cloud_premium", "cloud_ssd", "local_basic", "local_ssd"} { for i := 0; i < len(storages); i++ { if storages[i].StorageType == stype { return &storages[i] @@ -128,8 +128,8 @@ func (self *SQcloudGuestDriver) RequestDeployGuestOnHost(ctx context.Context, gu if err != nil { return nil, err } - log.Debugf("VMcreated %s, wait status ready ...", iVM.GetGlobalId()) - err = cloudprovider.WaitStatus(iVM, models.VM_READY, time.Second*5, time.Second*1800) + log.Debugf("VMcreated %s, wait status running ...", iVM.GetGlobalId()) + err = cloudprovider.WaitStatus(iVM, models.VM_RUNNING, time.Second*5, time.Second*1800) if err != nil { return nil, err } @@ -159,12 +159,13 @@ func (self *SQcloudGuestDriver) RequestDeployGuestOnHost(ctx context.Context, gu deleteKeypair := jsonutils.QueryBoolean(params, "__delete_keypair__", false) taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { - if len(userData) > 0 { - err := iVM.UpdateUserData(userData) - if err != nil { - log.Errorf("update userdata fail %s", err) - } - } + //腾讯云暂不支持更新自定义用户数据 + // if len(userData) > 0 { + // err := iVM.UpdateUserData(userData) + // if err != nil { + // log.Errorf("update userdata fail %s", err) + // } + // } err := iVM.DeployVM(name, passwd, publicKey, deleteKeypair, description) if err != nil { @@ -183,12 +184,13 @@ func (self *SQcloudGuestDriver) RequestDeployGuestOnHost(ctx context.Context, gu } taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { - if len(userData) > 0 { - err := iVM.UpdateUserData(userData) - if err != nil { - log.Errorf("update userdata fail %s", err) - } - } + //腾讯云暂不支持更新自定义用户数据 + // if len(userData) > 0 { + // err := iVM.UpdateUserData(userData) + // if err != nil { + // log.Errorf("update userdata fail %s", err) + // } + // } diskId, err := iVM.RebuildRoot(desc.ExternalImageId, passwd, publicKey, desc.SysDiskSize) if err != nil { @@ -267,7 +269,7 @@ func (self *SQcloudGuestDriver) OnGuestDeployTaskDataReceived(ctx context.Contex disk.Status = models.DISK_READY disk.BillingType = diskInfo[i].BillingType disk.FsFormat = diskInfo[i].FsFromat - disk.AutoDelete = diskInfo[i].AutoDelete + disk.AutoDelete = true disk.TemplateId = diskInfo[i].TemplateId disk.DiskFormat = diskInfo[i].DiskFormat disk.ExpiredAt = diskInfo[i].ExpiredAt diff --git a/pkg/compute/hostdrivers/qcloud.go b/pkg/compute/hostdrivers/qcloud.go new file mode 100644 index 0000000000..536c620c64 --- /dev/null +++ b/pkg/compute/hostdrivers/qcloud.go @@ -0,0 +1,209 @@ +package hostdrivers + +import ( + "context" + "fmt" + "os" + + "yunion.io/x/jsonutils" + "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" + "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/onecloud/pkg/compute/options" + "yunion.io/x/onecloud/pkg/httperrors" +) + +type SQcloudHostDriver struct { + SBaseHostDriver +} + +func init() { + driver := SQcloudHostDriver{} + models.RegisterHostDriver(&driver) +} + +func (self *SQcloudHostDriver) GetHostType() string { + return models.HOST_TYPE_QCLOUD +} + +func (self *SQcloudHostDriver) CheckAndSetCacheImage(ctx context.Context, host *models.SHost, storageCache *models.SStoragecache, task taskman.ITask) error { + params := task.GetParams() + imageId, err := params.GetString("image_id") + if err != nil { + return err + } + + osArch, _ := params.GetString("os_arch") + osType, _ := params.GetString("os_type") + osDist, _ := params.GetString("os_distribution") + + isForce := jsonutils.QueryBoolean(params, "is_force", false) + userCred := task.GetUserCred() + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + lockman.LockRawObject(ctx, "cachedimages", fmt.Sprintf("%s-%s", storageCache.Id, imageId)) + defer lockman.ReleaseRawObject(ctx, "cachedimages", fmt.Sprintf("%s-%s", storageCache.Id, imageId)) + + scimg := models.StoragecachedimageManager.Register(ctx, task.GetUserCred(), storageCache.Id, imageId) + iStorageCache, err := storageCache.GetIStorageCache() + if err != nil { + return nil, err + } + + extImgId, err := iStorageCache.UploadImage(userCred, imageId, osArch, osType, osDist, scimg.ExternalId, isForce) + if err != nil { + return nil, err + } + scimg.SetExternalId(extImgId) + + ret := jsonutils.NewDict() + ret.Add(jsonutils.NewString(extImgId), "image_id") + return ret, nil + }) + return nil +} + +func (self *SQcloudHostDriver) RequestAllocateDiskOnStorage(ctx context.Context, host *models.SHost, storage *models.SStorage, disk *models.SDisk, task taskman.ITask, content *jsonutils.JSONDict) error { + iCloudStorage, err := storage.GetIStorage() + if err != nil { + return err + } + size, err := content.Int("size") + if err != nil { + return err + } + size = size >> 10 + iDisk, err := iCloudStorage.CreateIDisk(disk.GetName(), int(size), "") + if err != nil { + return err + } + _, err = disk.GetModelManager().TableSpec().Update(disk, func() error { + disk.ExternalId = iDisk.GetGlobalId() + + if metaData := iDisk.GetMetadata(); metaData != nil { + meta := make(map[string]string) + if err := metaData.Unmarshal(meta); err != nil { + log.Errorf("Get disk %s Metadata error: %v", disk.Name, err) + } else { + for key, value := range meta { + if err := disk.SetMetadata(ctx, key, value, task.GetUserCred()); err != nil { + log.Errorf("set disk %s mata %s => %s error: %v", disk.Name, key, value, err) + } + } + } + } + + return nil + }) + if err != nil { + log.Errorf("Update disk externalId err: %v", err) + return err + } + data := jsonutils.NewDict() + data.Add(jsonutils.NewInt(int64(iDisk.GetDiskSizeMB())), "disk_size") + data.Add(jsonutils.NewString(iDisk.GetDiskFormat()), "disk_format") + task.ScheduleRun(data) + return nil +} + +func (self *SQcloudHostDriver) RequestDeallocateDiskOnHost(host *models.SHost, storage *models.SStorage, disk *models.SDisk, task taskman.ITask) error { + data := jsonutils.NewDict() + if iCloudStorage, err := storage.GetIStorage(); err != nil { + return err + } else if iDisk, err := iCloudStorage.GetIDisk(disk.GetExternalId()); err != nil { + if err == cloudprovider.ErrNotFound { + task.ScheduleRun(data) + return nil + } + return err + } else if err := iDisk.Delete(); err != nil { + return err + } + task.ScheduleRun(data) + return nil +} + +func (self *SQcloudHostDriver) RequestResizeDiskOnHostOnline(host *models.SHost, storage *models.SStorage, disk *models.SDisk, size int64, task taskman.ITask) error { + return self.RequestResizeDiskOnHost(host, storage, disk, size, task) +} + +func (self *SQcloudHostDriver) RequestResizeDiskOnHost(host *models.SHost, storage *models.SStorage, disk *models.SDisk, size int64, task taskman.ITask) error { + iCloudStorage, err := storage.GetIStorage() + if err != nil { + return err + } + iDisk, err := iCloudStorage.GetIDisk(disk.GetExternalId()) + if err != nil { + return err + } + err = iDisk.Resize(size >> 10) + if err != nil { + return err + } + task.ScheduleRun(jsonutils.Marshal(map[string]int64{"disk_size": size})) + return nil +} + +func (self *SQcloudHostDriver) RequestPrepareSaveDiskOnHost(ctx context.Context, host *models.SHost, disk *models.SDisk, imageId string, task taskman.ITask) error { + task.ScheduleRun(nil) + return nil +} + +func (self *SQcloudHostDriver) RequestSaveUploadImageOnHost(ctx context.Context, host *models.SHost, disk *models.SDisk, imageId string, task taskman.ITask, data jsonutils.JSONObject) error { + iDisk, err := disk.GetIDisk() + if err != nil { + return err + } + iStorage, err := disk.GetIStorage() + if err != nil { + return err + } + iStoragecache := iStorage.GetIStoragecache() + if iStoragecache == nil { + return httperrors.NewResourceNotFoundError("fail to find iStoragecache for storage: %s", iStorage.GetName()) + } + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + snapshot, err := iDisk.CreateISnapshot(fmt.Sprintf("Snapshot-%s", imageId), "PrepareSaveImage") + if err != nil { + return nil, err + } + params := task.GetParams() + osType, _ := params.GetString("properties", "os_type") + + scimg := models.StoragecachedimageManager.Register(ctx, task.GetUserCred(), iStoragecache.GetId(), imageId) + if scimg.Status != models.CACHED_IMAGE_STATUS_READY { + scimg.SetStatus(task.GetUserCred(), models.CACHED_IMAGE_STATUS_CACHING, "request_prepare_save_disk_on_host") + } + iImage, err := iStoragecache.CreateIImage(snapshot.GetId(), fmt.Sprintf("Image-%s", imageId), osType, "") + if err != nil { + log.Errorf("fail to create iImage: %v", err) + scimg.SetStatus(task.GetUserCred(), models.CACHED_IMAGE_STATUS_CACHE_FAILED, err.Error()) + return nil, err + } + scimg.SetExternalId(iImage.GetId()) + if _, err := os.Stat(options.Options.TempPath); os.IsNotExist(err) { + if err = os.MkdirAll(options.Options.TempPath, 0755); err != nil { + return nil, err + } + } + result, err := iStoragecache.DownloadImage(task.GetUserCred(), imageId, iImage.GetId(), options.Options.TempPath) + if err != nil { + scimg.SetStatus(task.GetUserCred(), models.CACHED_IMAGE_STATUS_CACHE_FAILED, err.Error()) + return nil, err + } + if err := iImage.Delete(); err != nil { + log.Errorf("Delete iImage %s failed: %v", iImage.GetId(), err) + } + if err := snapshot.Delete(); err != nil { + log.Errorf("Delete snapshot %s failed: %v", snapshot.GetId(), err) + } + scimg.SetStatus(task.GetUserCred(), models.CACHED_IMAGE_STATUS_READY, "") + return result, nil + }) + return nil +} + +func (self *SQcloudHostDriver) RequestDeleteSnapshotWithStorage(ctx context.Context, host *models.SHost, snapshot *models.SSnapshot, task taskman.ITask) error { + return httperrors.NewNotImplementedError("not implement") +} diff --git a/pkg/mcclient/options/servers.go b/pkg/mcclient/options/servers.go index 30c9f17c76..69793506e6 100644 --- a/pkg/mcclient/options/servers.go +++ b/pkg/mcclient/options/servers.go @@ -115,7 +115,7 @@ type ServerCreateOptions struct { Project string `help:"'Owner project ID or Name" json:"tenant"` User string `help:"Owner user ID or Name"` System *bool `help:"Create a system VM, sysadmin ONLY option" json:"is_system"` - Hypervisor string `help:"Hypervisor type" choices:"kvm|esxi|baremetal|container|aliyun|azure"` + Hypervisor string `help:"Hypervisor type" choices:"kvm|esxi|baremetal|container|aliyun|azure|qcloud"` TaskNotify *bool `help:"Setup task notify" json:"-"` Count *int `help:"Create multiple simultaneously" default:"1" json:"-"` DryRun *bool `help:"Dry run to test scheduler" json:"-"` diff --git a/pkg/scheduler/api/types.go b/pkg/scheduler/api/types.go index 8ad5257f97..9123041abd 100644 --- a/pkg/scheduler/api/types.go +++ b/pkg/scheduler/api/types.go @@ -18,6 +18,7 @@ const ( HostHypervisorForKvm = "hypervisor" HostTypeAliyun = "aliyun" HostTypeAzure = "azure" + HostTypeQcloud = "qcloud" HostTypeKubelet = "kubelet" AggregateStrategyRequire = "require" @@ -50,6 +51,7 @@ var ( PublicCloudProviders = sets.NewString( HostTypeAliyun, HostTypeAzure, + HostTypeQcloud, ) ValidGpuTypes = sets.NewString( diff --git a/pkg/util/aliyun/instance.go b/pkg/util/aliyun/instance.go index 31e7c1b1b2..9d9aab6ccf 100644 --- a/pkg/util/aliyun/instance.go +++ b/pkg/util/aliyun/instance.go @@ -118,8 +118,13 @@ type SInstance struct { // {"AutoReleaseTime":"","ClusterId":"","Cpu":1,"CreationTime":"2018-05-23T07:58Z","DedicatedHostAttribute":{"DedicatedHostId":"","DedicatedHostName":""},"Description":"","DeviceAvailable":true,"EipAddress":{"AllocationId":"","InternetChargeType":"","IpAddress":""},"ExpiredTime":"2018-05-30T16:00Z","GPUAmount":0,"GPUSpec":"","HostName":"iZ2ze57isp1ali72tzkjowZ","ImageId":"centos_7_04_64_20G_alibase_201701015.vhd","InnerIpAddress":{"IpAddress":[]},"InstanceChargeType":"PrePaid","InstanceId":"i-2ze57isp1ali72tzkjow","InstanceName":"gaoxianqi-test-7days","InstanceNetworkType":"vpc","InstanceType":"ecs.t5-lc2m1.nano","InstanceTypeFamily":"ecs.t5","InternetChargeType":"PayByBandwidth","InternetMaxBandwidthIn":-1,"InternetMaxBandwidthOut":0,"IoOptimized":true,"Memory":512,"NetworkInterfaces":{"NetworkInterface":[{"MacAddress":"00:16:3e:10:f0:c9","NetworkInterfaceId":"eni-2zecqsagtpztl6x5hu2r","PrimaryIpAddress":"192.168.220.214"}]},"OSName":"CentOS 7.4 64位","OSType":"linux","OperationLocks":{"LockReason":[]},"PublicIpAddress":{"IpAddress":[]},"Recyclable":false,"RegionId":"cn-beijing","ResourceGroupId":"","SaleCycle":"Week","SecurityGroupIds":{"SecurityGroupId":["sg-2zecqsagtpztl6x9zynl"]},"SerialNumber":"df05d9b4-df3d-4400-88d1-5f843f0dd088","SpotPriceLimit":0.000000,"SpotStrategy":"NoSpot","StartTime":"2018-05-23T07:58Z","Status":"Running","StoppedMode":"Not-applicable","VlanId":"","VpcAttributes":{"NatIpAddress":"","PrivateIpAddress":{"IpAddress":["192.168.220.214"]},"VSwitchId":"vsw-2ze9cqwza4upoyujq1thd","VpcId":"vpc-2zer4jy8ix3i8f0coc5uw"},"ZoneId":"cn-beijing-f"} func (self *SRegion) GetInstances(zoneId string, ids []string, offset int, limit int) ([]SInstance, int, error) { + if limit > 50 || limit <= 0 { + limit = 50 + } params := make(map[string]string) params["RegionId"] = self.RegionId + params["PageSize"] = fmt.Sprintf("%d", limit) + params["PageNumber"] = fmt.Sprintf("%d", (offset/limit)+1) if len(zoneId) > 0 { params["ZoneId"] = zoneId diff --git a/pkg/util/aliyun/shell/image.go b/pkg/util/aliyun/shell/image.go index e73a758878..b02ff69774 100644 --- a/pkg/util/aliyun/shell/image.go +++ b/pkg/util/aliyun/shell/image.go @@ -1,6 +1,8 @@ package shell import ( + "fmt" + "yunion.io/x/onecloud/pkg/util/aliyun" "yunion.io/x/onecloud/pkg/util/shellutils" ) @@ -29,4 +31,47 @@ func init() { shellutils.R(&ImageDeleteOptions{}, "image-delete", "Delete image", func(cli *aliyun.SRegion, args *ImageDeleteOptions) error { return cli.DeleteImage(args.ID) }) + + type ImageCreateOptions struct { + SNAPSHOT string `help:"Snapshot id"` + NAME string `help:"Image name"` + Desc string `help:"Image desc"` + } + shellutils.R(&ImageCreateOptions{}, "image-create", "Create image", func(cli *aliyun.SRegion, args *ImageCreateOptions) error { + imageId, err := cli.CreateImage(args.SNAPSHOT, args.NAME, args.Desc) + if err != nil { + return err + } + fmt.Println(imageId) + return nil + }) + + type ImageExportOptions struct { + ID string `help:"ID or Name to export"` + BUCKET string `help:"Bucket name"` + } + + shellutils.R(&ImageExportOptions{}, "image-export", "Export image", func(cli *aliyun.SRegion, args *ImageExportOptions) error { + oss, err := cli.GetOssClient() + if err != nil { + return err + } + exist, err := oss.IsBucketExist(args.BUCKET) + if err != nil { + return err + } + if !exist { + return fmt.Errorf("not exist bucket %s", args.BUCKET) + } + bucket, err := oss.Bucket(args.BUCKET) + if err != nil { + return err + } + task, err := cli.ExportImage(args.ID, bucket) + if err != nil { + return err + } + printObject(task) + return nil + }) } diff --git a/pkg/util/aliyun/shell/snapshot.go b/pkg/util/aliyun/shell/snapshot.go index 5bfe219871..f1ca285ade 100644 --- a/pkg/util/aliyun/shell/snapshot.go +++ b/pkg/util/aliyun/shell/snapshot.go @@ -1,6 +1,8 @@ package shell import ( + "fmt" + "yunion.io/x/onecloud/pkg/util/aliyun" "yunion.io/x/onecloud/pkg/util/shellutils" ) @@ -38,8 +40,12 @@ func init() { } shellutils.R(&SnapshotCreateOptions{}, "snapshot-create", "Create snapshot", func(cli *aliyun.SRegion, args *SnapshotCreateOptions) error { - _, err := cli.CreateSnapshot(args.DiskId, args.Name, args.Desc) - return err + snapshotId, err := cli.CreateSnapshot(args.DiskId, args.Name, args.Desc) + if err != nil { + return err + } + fmt.Println(snapshotId) + return nil }) } diff --git a/pkg/util/aliyun/storagecache.go b/pkg/util/aliyun/storagecache.go index 960e9cab88..231d5d3623 100644 --- a/pkg/util/aliyun/storagecache.go +++ b/pkg/util/aliyun/storagecache.go @@ -245,6 +245,10 @@ func (self *SRegion) checkBucket(bucketName string) (*oss.Bucket, error) { } } +func (self *SRegion) CreateImage(snapshoutId, imageName, imageDesc string) (string, error) { + return self.createIImage(snapshoutId, imageName, imageDesc) +} + func (self *SRegion) createIImage(snapshoutId, imageName, imageDesc string) (string, error) { params := make(map[string]string) params["RegionId"] = self.RegionId diff --git a/pkg/util/qcloud/disk.go b/pkg/util/qcloud/disk.go index 7a77a638f6..61377bc936 100644 --- a/pkg/util/qcloud/disk.go +++ b/pkg/util/qcloud/disk.go @@ -3,6 +3,7 @@ package qcloud import ( "fmt" "sort" + "strings" "time" "yunion.io/x/jsonutils" @@ -157,13 +158,21 @@ func (self *SRegion) ResizeDisk(diskId string, sizeGb int64) error { params := make(map[string]string) params["DiskId"] = diskId params["DiskSize"] = fmt.Sprintf("%d", sizeGb) - - _, err := self.cbsRequest("ResizeDisk", params) - if err != nil { - log.Errorf("ResizeDisk %s to %s GiB fail %s", diskId, sizeGb, err) + startTime := time.Now() + for { + _, err := self.cbsRequest("ResizeDisk", params) + if err != nil { + if strings.Index(err.Error(), "Code=InvalidDisk.Busy") > 0 { + log.Infof("The disk is busy, try later ...") + time.Sleep(10 * time.Second) + if time.Now().Sub(startTime) > time.Minute*20 { + return cloudprovider.ErrTimeout + } + continue + } + } return err } - return nil } func (self *SDisk) Resize(size int64) error { @@ -354,12 +363,13 @@ func (self *SRegion) CreateDisk(zoneId string, category string, name string, siz if err != nil { return "", err } - diskIdSet, err := body.GetArray("DiskIdSet") + diskIDSet := []string{} + err = body.Unmarshal(&diskIDSet, "DiskIdSet") if err != nil { return "", err } - if len(diskIdSet) < 1 { + if len(diskIDSet) < 1 { return "", fmt.Errorf("Create Disk error") } - return diskIdSet[0].String(), nil + return diskIDSet[0], nil } diff --git a/pkg/util/qcloud/host.go b/pkg/util/qcloud/host.go index 9b84e4f524..67f362deb4 100644 --- a/pkg/util/qcloud/host.go +++ b/pkg/util/qcloud/host.go @@ -2,6 +2,7 @@ package qcloud import ( "fmt" + "strings" "yunion.io/x/jsonutils" "yunion.io/x/log" @@ -69,7 +70,7 @@ func (self *SHost) _createVM(name string, imgId string, sysDiskSize int, cpu int return "", fmt.Errorf("network's wire's vpc is empty") } - // var err error + var err error // if len(secgroupId) == 0 { // secgroups, err := net.wire.vpc.GetISecurityGroups() @@ -90,12 +91,12 @@ func (self *SHost) _createVM(name string, imgId string, sysDiskSize int, cpu int // } keypair := "" - // if len(publicKey) > 0 { - // keypair, err = self.zone.region.syncKeypair(publicKey) - // if err != nil { - // return "", err - // } - // } + if len(publicKey) > 0 { + keypair, err = self.zone.region.syncKeypair(publicKey) + if err != nil { + return "", err + } + } img, err := self.zone.region.GetImage(imgId) if err != nil { @@ -107,7 +108,7 @@ func (self *SHost) _createVM(name string, imgId string, sysDiskSize int, cpu int return "", fmt.Errorf("image not ready") } - _, err = self.zone.getStorageByCategory(storageType) + err = self.zone.validateStorageType(storageType) if err != nil { return "", fmt.Errorf("Storage %s not avaiable: %s", storageType, err) } @@ -117,11 +118,14 @@ func (self *SHost) _createVM(name string, imgId string, sysDiskSize int, cpu int if sysDiskSize > 0 && sysDiskSize > img.ImageSize { disks[0].DiskSize = sysDiskSize } - disks[0].DiskType = storageType + if disks[0].DiskSize < 50 { + disks[0].DiskSize = 50 + } + disks[0].DiskType = strings.ToUpper(storageType) for i, sz := range diskSizes { disks[i+1].DiskSize = sz - disks[i+1].DiskType = storageType + disks[i+1].DiskType = strings.ToUpper(storageType) } instanceTypes, err := self.zone.region.GetMatchInstanceTypes(cpu, memMB, 0, self.zone.Zone) @@ -135,7 +139,7 @@ func (self *SHost) _createVM(name string, imgId string, sysDiskSize int, cpu int for _, instType := range instanceTypes { instanceTypeId := instType.InstanceType log.Debugf("Try instancetype : %s", instanceTypeId) - vmId, err := self.zone.region.CreateInstance(name, imgId, instanceTypeId, secgroupId, self.zone.Zone, desc, passwd, disks, networkId, ipAddr, keypair) + vmId, err := self.zone.region.CreateInstance(name, imgId, instanceTypeId, secgroupId, self.zone.Zone, desc, passwd, disks, networkId, ipAddr, keypair, userData) if err != nil { log.Errorf("Failed for %s: %s", instanceTypeId, err) } else { diff --git a/pkg/util/qcloud/image.go b/pkg/util/qcloud/image.go index 0fe586200a..2d481ab146 100644 --- a/pkg/util/qcloud/image.go +++ b/pkg/util/qcloud/image.go @@ -70,14 +70,19 @@ func (self *SRegion) GetImages(status string, owner string, imageIds []string, n } images := make([]SImage, 0) - if body, err := self.cvmRequest("DescribeImages", params); err != nil { + body, err := self.cvmRequest("DescribeImages", params) + if err != nil { return nil, 0, err - } else if err := body.Unmarshal(&images, "ImageSet"); err != nil { - return nil, 0, err - } else { - total, _ := body.Int("TotalCount") - return images, int(total), nil } + err = body.Unmarshal(&images, "ImageSet") + if err != nil { + return nil, 0, err + } + for i := 0; i < len(images); i++ { + images[i].storageCache = self.getStoragecache() + } + total, _ := body.Int("TotalCount") + return images, int(total), nil } func (self *SImage) GetMetadata() *jsonutils.JSONDict { return nil @@ -164,7 +169,13 @@ func (self *SRegion) ImportImage(name string, osArch string, osType string, osVe osVersion = "-" } params["OsVersion"] = osVersion // "6|7|8|-" - params["OsType"] = osType // "CentOS|Ubuntu|Debian|OpenSUSE|SUSE|CoreOS|FreeBSD|Other Linux|Windows Server 2008|Windows Server 2012|Windows Server 2016" + if len(osType) == 0 || osType == "linux" { + osType = "Other Linux" + } + params["OsType"] = osType // "CentOS|Ubuntu|Debian|OpenSUSE|SUSE|CoreOS|FreeBSD|Other Linux|Windows Server 2008|Windows Server 2012|Windows Server 2016" + if len(osArch) == 0 { + osArch = "x86_64" + } params["Architecture"] = osArch // "x86_64|i386" params["ImageUrl"] = imageUrl params["Force"] = "true" @@ -173,14 +184,13 @@ func (self *SRegion) ImportImage(name string, osArch string, osType string, osVe if _, err := self.cvmRequest("ImportImage", params); err != nil { return nil, err - } else { - for i := 0; i < 3; i++ { - image, err := self.GetImageByName(name) - if err == nil { - return image, nil - } - time.Sleep(time.Minute * time.Duration(i)) - } - return nil, cloudprovider.ErrNotFound } + for i := 0; i < 8; i++ { + image, err := self.GetImageByName(name) + if err == nil { + return image, nil + } + time.Sleep(time.Minute * time.Duration(i)) + } + return nil, cloudprovider.ErrNotFound } diff --git a/pkg/util/qcloud/instance.go b/pkg/util/qcloud/instance.go index 9981d6671a..aa51d86820 100644 --- a/pkg/util/qcloud/instance.go +++ b/pkg/util/qcloud/instance.go @@ -99,6 +99,10 @@ type SInstance struct { func (self *SRegion) GetInstances(zoneId string, ids []string, offset int, limit int) ([]SInstance, int, error) { params := make(map[string]string) + if limit < 1 || limit > 50 { + limit = 50 + } + params["Limit"] = fmt.Sprintf("%d", limit) params["Offset"] = fmt.Sprintf("%d", offset) instances := make([]SInstance, 0) @@ -363,32 +367,40 @@ func (self *SInstance) UpdateVM(name string) error { func (self *SInstance) DeployVM(name string, password string, publicKey string, deleteKeypair bool, description string) error { var keypairName string - // if len(publicKey) > 0 { - // var err error - // keypairName, err = self.host.zone.region.syncKeypair(publicKey) - // if err != nil { - // return err - // } - // } + if len(publicKey) > 0 { + var err error + keypairName, err = self.host.zone.region.syncKeypair(publicKey) + if err != nil { + return err + } + } return self.host.zone.region.DeployVM(self.InstanceId, name, password, keypairName, deleteKeypair, description) } func (self *SInstance) RebuildRoot(imageId string, passwd string, publicKey string, sysSizeGB int) (string, error) { keypair := "" - // if len(publicKey) > 0 { - // var err error - // keypair, err = self.host.zone.region.syncKeypair(publicKey) - // if err != nil { - // return "", err - // } - // } - return self.host.zone.region.ReplaceSystemDisk(self.InstanceId, imageId, passwd, keypair, sysSizeGB) + if len(publicKey) > 0 { + var err error + keypair, err = self.host.zone.region.syncKeypair(publicKey) + if err != nil { + return "", err + } + } + err := self.host.zone.region.ReplaceSystemDisk(self.InstanceId, imageId, passwd, keypair, sysSizeGB) + if err != nil { + return "", err + } + self.StopVM(true) + instance, err := self.host.zone.region.GetInstance(self.InstanceId) + if err != nil { + return "", err + } + return instance.SystemDisk.DiskId, nil } func (self *SInstance) ChangeConfig(instanceId string, ncpu int, vmem int) error { - return nil - //return self.host.zone.region.ChangeVMConfig(self.ZoneId, self.InstanceId, ncpu, vmem, nil) + return self.host.zone.region.ChangeVMConfig(self.Placement.Zone, self.InstanceId, ncpu, vmem, nil) } func (self *SInstance) AttachDisk(diskId string) error { @@ -412,7 +424,7 @@ func (self *SRegion) GetInstance(instanceId string) (*SInstance, error) { func (self *SRegion) CreateInstance(name string, imageId string, instanceType string, securityGroupId string, zoneId string, desc string, passwd string, disks []SDisk, networkId string, ipAddr string, - keypair string) (string, error) { + keypair string, userData string) (string, error) { params := make(map[string]string) params["Region"] = self.Region params["ImageId"] = imageId @@ -423,12 +435,18 @@ func (self *SRegion) CreateInstance(name string, imageId string, instanceType st params["Description"] = desc params["InstanceChargeType"] = "POSTPAID_BY_HOUR" params["InternetAccessible.InternetMaxBandwidthOut"] = "100" + params["InternetAccessible.PublicIpAssigned"] = "FALSE" params["HostName"] = name if len(passwd) > 0 { params["LoginSettings.Password"] = passwd } else { - params["PasswordInherit"] = "True" + params["LoginSettings.KeepImageLogin"] = "TRUE" } + + if len(userData) > 0 { + params["UserData"] = userData + } + //params["IoOptimized"] = "optimized" for i, d := range disks { if i == 0 { @@ -504,9 +522,8 @@ func (self *SRegion) StopVM(instanceId string, isForce bool) error { log.Errorf("Fail to get instance status on StopVM: %s", err) return err } - if status != InstanceStatusRunning { - log.Errorf("StopVM: vm status is %s expect %s", status, InstanceStatusRunning) - return cloudprovider.ErrInvalidStatus + if status == InstanceStatusStopped { + return nil } return self.doStopVM(instanceId, isForce) } @@ -530,45 +547,39 @@ func (self *SRegion) DeployVM(instanceId string, name string, password string, k return err } - // // 修改密钥时直接返回 - // if deleteKeypair { - // err = self.DetachKeyPair(instanceId, instance.KeyPairName) - // if err != nil { - // return err - // } - // } + // 修改密钥时直接返回 + if deleteKeypair { + for i := 0; i < len(instance.LoginSettings.KeyIds); i++ { + err = self.DetachKeyPair(instanceId, instance.LoginSettings.KeyIds[i]) + if err != nil { + return err + } + } + } - // if len(keypairName) > 0 { - // err = self.AttachKeypair(instanceId, keypairName) - // if err != nil { - // return err - // } - // } + if len(keypairName) > 0 { + err = self.AttachKeypair(instanceId, keypairName) + if err != nil { + return err + } + } params := make(map[string]string) - // if resetPassword { - // params["Password"] = seclib2.RandomPassword2(12) - // } - // 指定密码的情况下,使用指定的密码 - if len(password) > 0 { - params["Password"] = password - } - if len(name) > 0 && instance.InstanceName != name { params["InstanceName"] = name - params["HostName"] = name } - // if len(description) > 0 && instance.Description != description { - // params["Description"] = description - // } - if len(params) > 0 { - return self.modifyInstanceAttribute(instanceId, params) - } else { - return nil + err := self.modifyInstanceAttribute(instanceId, params) + if err != nil { + return err + } } + if len(password) > 0 { + return self.instanceOperation(instanceId, "ResetInstancesPassword", map[string]string{"Password": password}) + } + return nil } func (self *SInstance) DeleteVM() error { @@ -595,50 +606,46 @@ func (self *SRegion) UpdateVM(instanceId string, hostname string) error { } func (self *SRegion) modifyInstanceAttribute(instanceId string, params map[string]string) error { - return self.instanceOperation(instanceId, "ModifyInstanceAttribute", params) + return self.instanceOperation(instanceId, "ModifyInstancesAttribute", params) } -func (self *SRegion) ReplaceSystemDisk(instanceId string, imageId string, passwd string, keypairName string, sysDiskSizeGB int) (string, error) { +func (self *SRegion) ReplaceSystemDisk(instanceId string, imageId string, passwd string, keypairName string, sysDiskSizeGB int) error { params := make(map[string]string) - params["RegionId"] = self.Region params["InstanceId"] = instanceId params["ImageId"] = imageId + params["EnhancedService.SecurityService.Enabled"] = "TRUE" + params["EnhancedService.MonitorService.Enabled"] = "TRUE" if len(passwd) > 0 { - params["Password"] = passwd + params["LoginSettings.Password"] = passwd } else { - params["PasswordInherit"] = "True" + params["LoginSettings.KeepImageLogin"] = "TRUE" } if len(keypairName) > 0 { - params["KeyPairName"] = keypairName + params["LoginSettings.KeyIds.0"] = keypairName } if sysDiskSizeGB > 0 { - params["SystemDisk.Size"] = fmt.Sprintf("%d", sysDiskSizeGB) + params["SystemDisk.DiskSize"] = fmt.Sprintf("%d", sysDiskSizeGB) } - body, err := self.cvmRequest("ReplaceSystemDisk", params) - if err != nil { - return "", err - } - // log.Debugf("%s", body.String()) - return body.GetString("DiskId") + _, err := self.cvmRequest("ResetInstance", params) + return err } func (self *SRegion) ChangeVMConfig(zoneId string, instanceId string, ncpu int, vmem int, disks []*SDisk) error { // todo: support change disk config? - // params := make(map[string]string) - // instanceTypes, e := self.GetMatchInstanceTypes(ncpu, vmem, 0, zoneId) - // if e != nil { - // return e - // } + params := make(map[string]string) + instanceTypes, e := self.GetMatchInstanceTypes(ncpu, vmem, 0, zoneId) + if e != nil { + return e + } - // for _, instancetype := range instanceTypes { - // params["InstanceType"] = instancetype.InstanceTypeId - // params["ClientToken"] = utils.GenRequestId(20) - // if err := self.instanceOperation(instanceId, "ModifyInstanceSpec", params); err != nil { - // log.Errorf("Failed for %s: %s", instancetype.InstanceTypeId, err) - // } else { - // return nil - // } - // } + for _, instancetype := range instanceTypes { + params["InstanceType"] = instancetype.InstanceType + err := self.instanceOperation(instanceId, "ResetInstancesType", params) + if err != nil { + log.Errorf("Failed for %s: %s", instancetype.InstanceType, err) + } + return nil + } return fmt.Errorf("Failed to change vm config, specification not supported") } @@ -660,13 +667,12 @@ func (self *SRegion) DetachDisk(instanceId string, diskId string) error { func (self *SRegion) AttachDisk(instanceId string, diskId string) error { params := make(map[string]string) params["InstanceId"] = instanceId - params["DiskId"] = diskId - _, err := self.cvmRequest("AttachDisk", params) + params["DiskIds.0"] = diskId + _, err := self.cbsRequest("AttachDisks", params) if err != nil { - log.Errorf("AttachDisk %s to %s fail %s", diskId, instanceId, err) + log.Errorf("AttachDisks %s to %s fail %s", diskId, instanceId, err) return err } - return nil } @@ -726,5 +732,5 @@ func (self *SInstance) GetExpiredAt() time.Time { } func (self *SInstance) UpdateUserData(userData string) error { - return cloudprovider.ErrNotImplemented + return cloudprovider.ErrNotSupported } diff --git a/pkg/util/qcloud/provider/provider.go b/pkg/util/qcloud/provider/provider.go index b378439509..206fb909bf 100644 --- a/pkg/util/qcloud/provider/provider.go +++ b/pkg/util/qcloud/provider/provider.go @@ -6,44 +6,44 @@ import ( "yunion.io/x/onecloud/pkg/util/qcloud" ) -type STencentProviderFactory struct { - // providerTable map[string]*SAliyunProvider +type SQcloudProviderFactory struct { + // providerTable map[string]*SQcloudProvider } -func (self *STencentProviderFactory) GetId() string { +func (self *SQcloudProviderFactory) GetId() string { return qcloud.CLOUD_PROVIDER_QCLOUD } -func (self *STencentProviderFactory) GetProvider(providerId, providerName, url, account, secret string) (cloudprovider.ICloudProvider, error) { +func (self *SQcloudProviderFactory) GetProvider(providerId, providerName, url, account, secret string) (cloudprovider.ICloudProvider, error) { client, err := qcloud.NewQcloudClient(providerId, providerName, account, secret) if err != nil { return nil, err } - return &STencentProvider{client: client}, nil + return &SQcloudProvider{client: client}, nil } func init() { - factory := STencentProviderFactory{} + factory := SQcloudProviderFactory{} cloudprovider.RegisterFactory(&factory) } -type STencentProvider struct { +type SQcloudProvider struct { client *qcloud.SQcloudClient } -func (self *STencentProvider) IsPublicCloud() bool { +func (self *SQcloudProvider) IsPublicCloud() bool { return true } -func (self *STencentProvider) GetId() string { +func (self *SQcloudProvider) GetId() string { return qcloud.CLOUD_PROVIDER_QCLOUD } -func (self *STencentProvider) GetName() string { +func (self *SQcloudProvider) GetName() string { return qcloud.CLOUD_PROVIDER_QCLOUD_CN } -func (self *STencentProvider) GetSysInfo() (jsonutils.JSONObject, error) { +func (self *SQcloudProvider) GetSysInfo() (jsonutils.JSONObject, error) { regions := self.client.GetIRegions() info := jsonutils.NewDict() info.Add(jsonutils.NewInt(int64(len(regions))), "region_count") @@ -51,34 +51,34 @@ func (self *STencentProvider) GetSysInfo() (jsonutils.JSONObject, error) { return info, nil } -func (self *STencentProvider) GetSubAccounts() ([]cloudprovider.SSubAccount, error) { +func (self *SQcloudProvider) GetSubAccounts() ([]cloudprovider.SSubAccount, error) { return self.client.GetSubAccounts() } -func (self *STencentProvider) GetIRegions() []cloudprovider.ICloudRegion { +func (self *SQcloudProvider) GetIRegions() []cloudprovider.ICloudRegion { return self.client.GetIRegions() } -func (self *STencentProvider) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) { +func (self *SQcloudProvider) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) { return self.client.GetIRegionById(id) } -func (self *STencentProvider) GetIHostById(id string) (cloudprovider.ICloudHost, error) { +func (self *SQcloudProvider) GetIHostById(id string) (cloudprovider.ICloudHost, error) { return self.client.GetIHostById(id) } -func (self *STencentProvider) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) { +func (self *SQcloudProvider) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) { return self.client.GetIVpcById(id) } -func (self *STencentProvider) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) { +func (self *SQcloudProvider) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) { return self.client.GetIStorageById(id) } -func (self *STencentProvider) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) { +func (self *SQcloudProvider) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) { return self.client.GetIStoragecacheById(id) } -func (self *STencentProvider) GetBalance() (float64, error) { +func (self *SQcloudProvider) GetBalance() (float64, error) { return 0.0, nil } diff --git a/pkg/util/qcloud/qcloud.go b/pkg/util/qcloud/qcloud.go index 7dca5b987e..898087ef40 100644 --- a/pkg/util/qcloud/qcloud.go +++ b/pkg/util/qcloud/qcloud.go @@ -1,6 +1,7 @@ package qcloud import ( + "fmt" "strings" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" @@ -53,9 +54,9 @@ func jsonRequest(client *common.Client, apiName string, params map[string]string func vpcRequest(client *common.Client, apiName string, params map[string]string) (jsonutils.JSONObject, error) { domain := "vpc.tencentcloudapi.com" - if region, ok := params["Region"]; ok && strings.HasSuffix(region, "-fsi") { - domain = "vpc." + region + ".tencentcloudapi.com" - } + // if region, ok := params["Region"]; ok && strings.HasSuffix(region, "-fsi") { + // domain = "vpc." + region + ".tencentcloudapi.com" + // } return _jsonRequest(client, domain, QCLOUD_API_VERSION, apiName, params) } @@ -90,12 +91,9 @@ func _jsonRequest(client *common.Client, domain string, version string, apiName } err := client.Send(req, resp) if err != nil { - log.Errorf("request error %s", err) + log.Errorf("request url: %s\nparams: %s\nerror: %v", req.GetDomain(), jsonutils.Marshal(req.GetParams()).PrettyString(), err) return nil, err } - - //log.Debugf(jsonutils.Marshal(resp.Response).PrettyString()) - return jsonutils.Marshal(resp.Response), nil } @@ -164,7 +162,10 @@ func (client *SQcloudClient) GetSubAccounts() ([]cloudprovider.SSubAccount, erro } subAccount := cloudprovider.SSubAccount{} subAccount.Name = client.providerName - subAccount.Account = client.SecretKey + subAccount.Account = client.SecretID + if len(client.AppID) > 0 { + subAccount.Account = fmt.Sprintf("%s/%s", client.SecretID, client.AppID) + } return []cloudprovider.SSubAccount{subAccount}, nil } diff --git a/pkg/util/qcloud/region.go b/pkg/util/qcloud/region.go index 3516c436b2..2c74f880b5 100644 --- a/pkg/util/qcloud/region.go +++ b/pkg/util/qcloud/region.go @@ -225,7 +225,16 @@ func (self *SRegion) GetIVpcs() ([]cloudprovider.ICloudVpc, error) { } func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) { - return nil, nil + izones, err := self.GetIZones() + if err != nil { + return nil, err + } + for i := 0; i < len(izones); i += 1 { + if izones[i].GetGlobalId() == id { + return izones[i], nil + } + } + return nil, cloudprovider.ErrNotFound } func (self *SRegion) GetIZones() ([]cloudprovider.ICloudZone, error) { @@ -241,9 +250,8 @@ func (self *SRegion) GetIZones() ([]cloudprovider.ICloudZone, error) { func (self *SRegion) _fetchZones() error { params := make(map[string]string) - params["Region"] = self.Region zones := make([]SZone, 0) - body, err := self.client.jsonRequest("DescribeZones", params) + body, err := self.cvmRequest("DescribeZones", params) if err != nil { return err } @@ -293,7 +301,10 @@ func (self *SRegion) getVpc(vpcId string) (*SVpc, error) { if err != nil { return nil, err } - if total != 1 { + if total > 1 { + return nil, cloudprovider.ErrDuplicateId + } + if total == 0 { return nil, cloudprovider.ErrNotFound } vpcs[0].region = self @@ -498,7 +509,6 @@ func (self *SRegion) CreateInstanceSimple(name string, imgId string, cpu int, me func (self *SRegion) instanceOperation(instanceId string, opname string, extra map[string]string) error { params := make(map[string]string) - params["Region"] = self.Region params["InstanceIds.0"] = instanceId if extra != nil && len(extra) > 0 { for k, v := range extra { diff --git a/pkg/util/qcloud/storage.go b/pkg/util/qcloud/storage.go index 1f3ddfbb80..a9ebca1bc4 100644 --- a/pkg/util/qcloud/storage.go +++ b/pkg/util/qcloud/storage.go @@ -3,6 +3,7 @@ package qcloud import ( "fmt" "strings" + "time" "yunion.io/x/jsonutils" "yunion.io/x/log" @@ -107,13 +108,17 @@ func (self *SStorage) CreateIDisk(name string, sizeGb int, desc string) (cloudpr log.Errorf("createDisk fail %s", err) return nil, err } - disk, err := self.zone.region.GetDisk(diskId) - if err != nil { - log.Errorf("getDisk fail %s", err) - return nil, err + //腾讯刚创建完成的磁盘,需要稍微等待才能查询 + for i := 0; i < 3; i++ { + disk, err := self.zone.region.GetDisk(diskId) + if err == nil { + disk.storage = self + return disk, nil + } + time.Sleep(time.Second * 3) } - disk.storage = self - return disk, nil + log.Errorf("getDisk fail %s id %s", err, diskId) + return nil, cloudprovider.ErrNotFound } func (self *SStorage) GetIDisk(idStr string) (cloudprovider.ICloudDisk, error) { diff --git a/pkg/util/qcloud/storagecache.go b/pkg/util/qcloud/storagecache.go index 8630752591..f51281d605 100644 --- a/pkg/util/qcloud/storagecache.go +++ b/pkg/util/qcloud/storagecache.go @@ -3,6 +3,8 @@ package qcloud import ( "context" "fmt" + "io" + "os" "strings" "time" @@ -125,7 +127,8 @@ func (self *SStoragecache) UploadImage(userCred mcclient.TokenCredential, imageI } func (self *SRegion) getCosUrl(bucket, object string) string { - return fmt.Sprintf("http://%s-%s.cosd.myqcloud.com/%s", bucket, self.client.AppID, object) + //signature := cosauth.NewSignature(self.client.AppID, bucket, self.client.SecretID, time.Now().Add(time.Minute*30).String(), time.Now().String(), "yunion", object).SignOnce(self.client.SecretKey) + return fmt.Sprintf("http://%s-%s.cos.%s.myqcloud.com/%s", bucket, self.client.AppID, self.Region, object) } func (self *SStoragecache) uploadImage(userCred mcclient.TokenCredential, imageId string, osArch, osType, osDist string, isForce bool) (string, error) { @@ -136,16 +139,30 @@ func (self *SStoragecache) uploadImage(userCred mcclient.TokenCredential, imageI if err != nil { return "", err } + + tmpFile := fmt.Sprintf("%s/%s", options.Options.TempPath, imageId) + defer os.Remove(tmpFile) + f, err := os.Create(tmpFile) + if err != nil { + return "", err + } + defer f.Close() + if _, err := io.Copy(f, reader); err != nil { + return "", err + } + log.Infof("meta data %s", meta) cos, err := self.region.GetCosClient() if err != nil { log.Errorf("GetOssClient err %s", err) return "", err } - bucketName := strings.ToLower(fmt.Sprintf("imgcache-%s-%s", self.region.GetId(), self.region.client.providerId)) - if err := cos.BucketExists(context.Background(), bucketName); err != nil { + bucketName := strings.ToLower(fmt.Sprintf("imgcache-%s", self.region.GetId())) + err = cos.BucketExists(context.Background(), bucketName) + if err != nil { log.Debugf("Bucket %s not exists, to create ...", bucketName) - if err := cos.CreateBucket(context.Background(), bucketName, &coslib.AccessControl{ACL: "public-read"}); err != nil { + err := cos.CreateBucket(context.Background(), bucketName, &coslib.AccessControl{ACL: "public-read"}) + if err != nil { log.Errorf("Create bucket error %s", err) return "", err } @@ -153,13 +170,15 @@ func (self *SStoragecache) uploadImage(userCred mcclient.TokenCredential, imageI log.Debugf("Bucket %s exists", bucketName) } log.Debugf("To upload image to bucket %s ...", bucketName) - if err := cos.Bucket(bucketName).UploadObject(context.Background(), imageId, reader, &coslib.AccessControl{}); err != nil { + err = cos.Bucket(bucketName).UploadObjectBySlice(context.Background(), imageId, tmpFile, 3, map[string]string{}) + if err != nil { log.Errorf("UploadObject error %s %s", imageId, err) return "", err } - imageBaseName := imageId + // 腾讯云镜像名称需要小于20个字符 + imageBaseName := imageId[:10] if imageBaseName[0] >= '0' && imageBaseName[0] <= '9' { - imageBaseName = fmt.Sprintf("img%s", imageId) + imageBaseName = fmt.Sprintf("img%s", imageId[:10]) } imageName := imageBaseName nameIdx := 1 diff --git a/pkg/util/qcloud/zone.go b/pkg/util/qcloud/zone.go index b4eb50f024..95474fbde2 100644 --- a/pkg/util/qcloud/zone.go +++ b/pkg/util/qcloud/zone.go @@ -2,6 +2,7 @@ package qcloud import ( "fmt" + "strings" "time" "yunion.io/x/jsonutils" @@ -114,7 +115,17 @@ func (self *SZone) GetIStorages() ([]cloudprovider.ICloudStorage, error) { } func (self *SZone) getLocalStorageByCategory(category string) (*SLocalStorage, error) { - return &SLocalStorage{zone: self, storageType: category}, nil + if utils.IsInStringArray(strings.ToLower(category), []string{"local_basic", "local_ssd"}) { + return &SLocalStorage{zone: self, storageType: strings.ToUpper(category)}, nil + } + return nil, fmt.Errorf("No such storage %s", category) +} + +func (self *SZone) validateStorageType(category string) error { + if utils.IsInStringArray(strings.ToLower(category), []string{"local_basic", "local_ssd", "cloud_basic", "cloud_ssd", "cloud_permium"}) { + return nil + } + return fmt.Errorf("No such storage %s", category) } func (self *SZone) getStorageByCategory(category string) (*SStorage, error) { @@ -125,6 +136,7 @@ func (self *SZone) getStorageByCategory(category string) (*SStorage, error) { for i := 0; i < len(storages); i++ { if utils.IsInStringArray(storages[i].GetStorageType(), []string{"local_basic", "local_ssd"}) { continue + //return &SStorage{zone: self, storageType: strings.ToUpper(storages[i].GetStorageType())}, nil } storage := storages[i].(*SStorage) if storage.storageType == category { diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go index a7f553d38f..803bc57d5a 100644 --- a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go @@ -57,7 +57,7 @@ func (resolver *LocationResolver) TryResolve(param *ResolveParam) (endpoint stri getEndpointRequest.Product = "Location" getEndpointRequest.Version = "2015-06-12" getEndpointRequest.ApiName = "DescribeEndpoints" - getEndpointRequest.Domain = "location-readonly.aliyuncs.com" + getEndpointRequest.Domain = "location.aliyuncs.com" getEndpointRequest.Method = "GET" getEndpointRequest.Scheme = requests.HTTPS diff --git a/vendor/github.com/forhappy/cos-go-sdk/LICENSE b/vendor/github.com/forhappy/cos-go-sdk/LICENSE new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/vendor/github.com/forhappy/cos-go-sdk/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/forhappy/cos-go-sdk/auth/auth.go b/vendor/github.com/forhappy/cos-go-sdk/auth/auth.go new file mode 100644 index 0000000000..397e087015 --- /dev/null +++ b/vendor/github.com/forhappy/cos-go-sdk/auth/auth.go @@ -0,0 +1,99 @@ +package auth + +import ( + "crypto/hmac" + "crypto/sha1" + "encoding/base64" + "fmt" +) + +type Signer interface { + Sign(secretKey string) (string, error) + SignOnce(secretKey string) (string, error) +} + +// 生成签名, 腾讯移动服务通过签名来验证请求的合法性, +// 开发者通过将签名授权给客户端, 使其具备上传下载及管理指定资源的能力, +// 签名分为多次有效签名和单次有效签名. +// 生成签名所需信息包括项目 ID(AppId),空间名称(Bucket,文件资源的组织管理单元),项目的 Secret ID 和 Secret Key, +// 获取这些信息的方法如下: +// 1) 登录 云对象存储, 进入云对象存储空间; +// 2) 如开发者未创建空间,可添加空间,空间名称(Bucket)由用户自行输入 +// 3) 点击“获取secretKey”,获取 Appid,Secret ID 和 Secret Key +type Signature struct { + AppId string + Bucket string + SecretId string + ExpiredTime string + CurrentTime string + Rand string + FileId string +} + +// 构造签名类, 可使用该类的 Sign 和 SignOnce 接口分别进行多次有效签名和单次有效签名 +func NewSignature(appId, bucket, secretId, expiredTime, currentTime, rand, fileId string) *Signature { + return &Signature{ + AppId: appId, + Bucket: bucket, + SecretId: secretId, + ExpiredTime: expiredTime, + CurrentTime: currentTime, + Rand: rand, + FileId: fileId, + } +} + +// 多次有效签名, secretKey 为项目的 Secret Key +func (s *Signature) Sign(secretKey string) string { + stringToSign := fmt.Sprintf("a=%s&k=%s&e=%s&t=%s&r=%s&f=%s&b=%s", + s.AppId, + s.SecretId, + s.ExpiredTime, + s.CurrentTime, + s.Rand, + "", + s.Bucket, + ) + + hmacSha1 := hmac.New(sha1.New, []byte(secretKey)) + hmacSha1.Write([]byte(stringToSign)) + bytesSign := hmacSha1.Sum(nil) + bytesSign = append(bytesSign, []byte(stringToSign)...) + signature := base64.StdEncoding.EncodeToString(bytesSign) + return signature +} + +// 单次有效签名, secretKey 为项目的 Secret Key +func (s *Signature) SignOnce(secretKey string) string { + stringToSign := fmt.Sprintf("a=%s&k=%s&e=%s&t=%s&r=%s&f=%s&b=%s", + s.AppId, + s.SecretId, + "0", + s.CurrentTime, + s.Rand, + s.FileId, + s.Bucket, + ) + + hmacSha1 := hmac.New(sha1.New, []byte(secretKey)) + hmacSha1.Write([]byte(stringToSign)) + bytesSign := hmacSha1.Sum(nil) + bytesSign = append(bytesSign, []byte(stringToSign)...) + signature := base64.StdEncoding.EncodeToString(bytesSign) + return signature +} + +// 字符串签名类 +func (s *Signature) String() string { + str := fmt.Sprintf("a=%s&b=%s&k=%s&e=%s&t=%s&r=%s&f=%s", + s.AppId, + s.SecretId, + s.ExpiredTime, + s.CurrentTime, + s.Rand, + s.FileId, + s.Bucket, + ) + + return str +} diff --git a/vendor/github.com/forhappy/cos-go-sdk/http/LICENSE b/vendor/github.com/forhappy/cos-go-sdk/http/LICENSE new file mode 100644 index 0000000000..b940dd44c9 --- /dev/null +++ b/vendor/github.com/forhappy/cos-go-sdk/http/LICENSE @@ -0,0 +1,24 @@ +The MIT License (MIT) + +Copyright (c) 2013 Jonathan Leibiusky and Marcos Lilljedahl +https://github.com/franela/goreq + +Copyright (c) 2016 Haiping Fu +https://github.com/forhappy/goreq + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod deleted file mode 100644 index 716c613125..0000000000 --- a/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/konsorten/go-windows-terminal-sequences diff --git a/vendor/github.com/miekg/dns/.travis.yml b/vendor/github.com/miekg/dns/.travis.yml index 18259374e5..13e312b4f3 100644 --- a/vendor/github.com/miekg/dns/.travis.yml +++ b/vendor/github.com/miekg/dns/.travis.yml @@ -1,18 +1,21 @@ language: go sudo: false - go: - 1.10.x - 1.11.x - tip +env: + - TESTS="-race -v -bench=. -coverprofile=coverage.txt -covermode=atomic" + - TESTS="-race -v ./..." + before_install: # don't use the miekg/dns when testing forks - mkdir -p $GOPATH/src/github.com/miekg - ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/miekg/ || true script: - - go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./... + - go test $TESTS after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/miekg/dns/Gopkg.lock b/vendor/github.com/miekg/dns/Gopkg.lock index 686632207a..4455c9836f 100644 --- a/vendor/github.com/miekg/dns/Gopkg.lock +++ b/vendor/github.com/miekg/dns/Gopkg.lock @@ -3,55 +3,19 @@ [[projects]] branch = "master" - digest = "1:6914c49eed986dfb8dffb33516fa129c49929d4d873f41e073c83c11c372b870" name = "golang.org/x/crypto" - packages = [ - "ed25519", - "ed25519/internal/edwards25519", - ] - pruneopts = "" - revision = "e3636079e1a4c1f337f212cc5cd2aca108f6c900" + packages = ["ed25519","ed25519/internal/edwards25519"] + revision = "b47b1587369238182299fe4dad77d05b8b461e06" [[projects]] branch = "master" - digest = "1:08e41d63f8dac84d83797368b56cf0b339e42d0224e5e56668963c28aec95685" name = "golang.org/x/net" - packages = [ - "bpf", - "context", - "internal/iana", - "internal/socket", - "ipv4", - "ipv6", - ] - pruneopts = "" - revision = "4dfa2610cdf3b287375bbba5b8f2a14d3b01d8de" - -[[projects]] - branch = "master" - digest = "1:b2ea75de0ccb2db2ac79356407f8a4cd8f798fe15d41b381c00abf3ae8e55ed1" - name = "golang.org/x/sync" - packages = ["errgroup"] - pruneopts = "" - revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca" - -[[projects]] - branch = "master" - digest = "1:149a432fabebb8221a80f77731b1cd63597197ded4f14af606ebe3a0959004ec" - name = "golang.org/x/sys" - packages = ["unix"] - pruneopts = "" - revision = "e4b3c5e9061176387e7cea65e4dc5853801f3fb7" + packages = ["bpf","internal/iana","internal/socket","ipv4","ipv6"] + revision = "1e491301e022f8f977054da4c2d852decd59571f" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - input-imports = [ - "golang.org/x/crypto/ed25519", - "golang.org/x/net/ipv4", - "golang.org/x/net/ipv6", - "golang.org/x/sync/errgroup", - "golang.org/x/sys/unix", - ] + inputs-digest = "c4abc38abaeeeeb9be92455c9c02cae32841122b8982aaa067ef25bb8e86ff9d" solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/miekg/dns/Gopkg.toml b/vendor/github.com/miekg/dns/Gopkg.toml index 85e6ff31b2..2f655b2c7b 100644 --- a/vendor/github.com/miekg/dns/Gopkg.toml +++ b/vendor/github.com/miekg/dns/Gopkg.toml @@ -24,15 +24,3 @@ [[constraint]] branch = "master" name = "golang.org/x/crypto" - -[[constraint]] - branch = "master" - name = "golang.org/x/net" - -[[constraint]] - branch = "master" - name = "golang.org/x/sys" - -[[constraint]] - branch = "master" - name = "golang.org/x/sync" diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go index 63ced2bd06..7a319b02c3 100644 --- a/vendor/github.com/miekg/dns/client.go +++ b/vendor/github.com/miekg/dns/client.go @@ -567,7 +567,7 @@ func (c *Client) ExchangeContext(ctx context.Context, m *Msg, a string) (r *Msg, if deadline, ok := ctx.Deadline(); !ok { timeout = 0 } else { - timeout = time.Until(deadline) + timeout = deadline.Sub(time.Now()) } // not passing the context to the underlying calls, as the API does not support // context. For timeouts you should set up Client.Dialer and call Client.Exchange. diff --git a/vendor/github.com/miekg/dns/generate.go b/vendor/github.com/miekg/dns/generate.go index 91d928c834..3a559793ff 100644 --- a/vendor/github.com/miekg/dns/generate.go +++ b/vendor/github.com/miekg/dns/generate.go @@ -107,8 +107,6 @@ BuildRR: mod, offset, err = modToPrintf(s[j+2 : j+2+sep]) if err != nil { return err.Error() - } else if start + offset < 0 || end + offset > 1<<31-1 { - return "bad offset in $GENERATE" } j += 2 + sep // Jump to it } @@ -154,7 +152,7 @@ func modToPrintf(s string) (string, int, error) { return "", 0, errors.New("bad base in $GENERATE") } offset, err := strconv.Atoi(xs[0]) - if err != nil { + if err != nil || offset > 255 { return "", 0, errors.New("bad offset in $GENERATE") } width, err := strconv.Atoi(xs[1]) diff --git a/vendor/github.com/miekg/dns/listen_go111.go b/vendor/github.com/miekg/dns/listen_go111.go index fad195cfeb..bd024c8938 100644 --- a/vendor/github.com/miekg/dns/listen_go111.go +++ b/vendor/github.com/miekg/dns/listen_go111.go @@ -1,5 +1,4 @@ -// +build go1.11 -// +build aix darwin dragonfly freebsd linux netbsd openbsd +// +build go1.11,!windows package dns diff --git a/vendor/github.com/miekg/dns/listen_go_not111.go b/vendor/github.com/miekg/dns/listen_go_not111.go index b9201417ab..f1fc652c4d 100644 --- a/vendor/github.com/miekg/dns/listen_go_not111.go +++ b/vendor/github.com/miekg/dns/listen_go_not111.go @@ -1,4 +1,4 @@ -// +build !go1.11 !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd +// +build !go1.11 windows package dns diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go index 47ac6cf281..f8b847650f 100644 --- a/vendor/github.com/miekg/dns/msg.go +++ b/vendor/github.com/miekg/dns/msg.go @@ -302,12 +302,6 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c } // If we did compression and we find something add the pointer here if pointer != -1 { - // Clear the msg buffer after the pointer location, otherwise - // packDataNsec writes the wrong data to msg. - tainted := msg[nameoffset:off] - for i := range tainted { - tainted[i] = 0 - } // We have two bytes (14 bits) to put the pointer in // if msg == nil, we will never do compression binary.BigEndian.PutUint16(msg[nameoffset:], uint16(pointer^0xC000)) @@ -373,10 +367,12 @@ Loop: var buf [3]byte bufs := strconv.AppendInt(buf[:0], int64(b), 10) s = append(s, '\\') - for i := len(bufs); i < 3; i++ { + for i := 0; i < 3-len(bufs); i++ { s = append(s, '0') } - s = append(s, bufs...) + for _, r := range bufs { + s = append(s, r) + } // presentation-format \DDD escapes add 3 extra bytes maxLen += 3 } else { @@ -516,7 +512,7 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) { off = off0 var s string for off < len(msg) && err == nil { - s, off, err = unpackString(msg, off) + s, off, err = unpackTxtString(msg, off) if err == nil { ss = append(ss, s) } @@ -524,6 +520,39 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) { return } +func unpackTxtString(msg []byte, offset int) (string, int, error) { + if offset+1 > len(msg) { + return "", offset, &Error{err: "overflow unpacking txt"} + } + l := int(msg[offset]) + if offset+l+1 > len(msg) { + return "", offset, &Error{err: "overflow unpacking txt"} + } + s := make([]byte, 0, l) + for _, b := range msg[offset+1 : offset+1+l] { + switch b { + case '"', '\\': + s = append(s, '\\', b) + default: + if b < 32 || b > 127 { // unprintable + var buf [3]byte + bufs := strconv.AppendInt(buf[:0], int64(b), 10) + s = append(s, '\\') + for i := 0; i < 3-len(bufs); i++ { + s = append(s, '0') + } + for _, r := range bufs { + s = append(s, r) + } + } else { + s = append(s, b) + } + } + } + offset += 1 + l + return string(s), offset, nil +} + // Helpers for dealing with escaped bytes func isDigit(b byte) bool { return b >= '0' && b <= '9' } @@ -531,10 +560,6 @@ func dddToByte(s []byte) byte { return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0')) } -func dddStringToByte(s string) byte { - return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0')) -} - // Helper function for packing and unpacking func intToBytes(i *big.Int, length int) []byte { buf := i.Bytes() diff --git a/vendor/github.com/miekg/dns/msg_helpers.go b/vendor/github.com/miekg/dns/msg_helpers.go index 81fc2b1be3..ec8cd9a851 100644 --- a/vendor/github.com/miekg/dns/msg_helpers.go +++ b/vendor/github.com/miekg/dns/msg_helpers.go @@ -6,7 +6,7 @@ import ( "encoding/binary" "encoding/hex" "net" - "strings" + "strconv" ) // helper functions called from the generated zmsg.go @@ -267,21 +267,29 @@ func unpackString(msg []byte, off int) (string, int, error) { if off+l+1 > len(msg) { return "", off, &Error{err: "overflow unpacking txt"} } - var s strings.Builder - s.Grow(l) + s := make([]byte, 0, l) for _, b := range msg[off+1 : off+1+l] { - switch { - case b == '"' || b == '\\': - s.WriteByte('\\') - s.WriteByte(b) - case b < ' ' || b > '~': // unprintable - writeEscapedByte(&s, b) + switch b { + case '"', '\\': + s = append(s, '\\', b) default: - s.WriteByte(b) + if b < 32 || b > 127 { // unprintable + var buf [3]byte + bufs := strconv.AppendInt(buf[:0], int64(b), 10) + s = append(s, '\\') + for i := 0; i < 3-len(bufs); i++ { + s = append(s, '0') + } + for _, r := range bufs { + s = append(s, r) + } + } else { + s = append(s, b) + } } } off += 1 + l - return s.String(), off, nil + return string(s), off, nil } func packString(s string, msg []byte, off int) (int, error) { diff --git a/vendor/github.com/miekg/dns/privaterr.go b/vendor/github.com/miekg/dns/privaterr.go index d931da7efb..41989e7aee 100644 --- a/vendor/github.com/miekg/dns/privaterr.go +++ b/vendor/github.com/miekg/dns/privaterr.go @@ -134,7 +134,7 @@ func PrivateHandle(rtypestr string, rtype uint16, generator func() PrivateRdata) typeToparserFunc[rtype] = parserFunc{setPrivateRR, true} } -// PrivateHandleRemove removes definitions required to support private RR type. +// PrivateHandleRemove removes defenitions required to support private RR type. func PrivateHandleRemove(rtype uint16) { rtypestr, ok := TypeToString[rtype] if ok { @@ -144,4 +144,5 @@ func PrivateHandleRemove(rtype uint16) { delete(StringToType, rtypestr) delete(typeToUnpack, rtype) } + return } diff --git a/vendor/github.com/miekg/dns/scan.go b/vendor/github.com/miekg/dns/scan.go index a752dbd018..f9cd47401d 100644 --- a/vendor/github.com/miekg/dns/scan.go +++ b/vendor/github.com/miekg/dns/scan.go @@ -10,6 +10,7 @@ import ( ) const maxTok = 2048 // Largest token we can return. +const maxUint16 = 1<<16 - 1 // Tokinize a RFC 1035 zone file. The tokenizer will normalize it: // * Add ownernames if they are left blank; @@ -79,9 +80,9 @@ type lex struct { length int // length of the token err bool // when true, token text has lexer error value uint8 // value: zString, _BLANK, etc. - torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar line int // line in the file column int // column in the file + torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar comment string // any comment text seen } @@ -208,9 +209,10 @@ func parseZone(r io.Reader, origin, f string, defttl *ttlState, t chan *Token, i var prevName string for l := range c { // Lexer spotted an error already - if l.err { + if l.err == true { t <- &Token{Error: &ParseError{f, l.token, l}} return + } switch st { case zExpectOwnerDir: @@ -637,6 +639,7 @@ func zlexer(s *scan, c chan lex) { if quote { str[stri] = x stri++ + break } // discard if outside of quotes case '\n': diff --git a/vendor/github.com/miekg/dns/scanner.go b/vendor/github.com/miekg/dns/scanner.go index 5b124ec595..424e5af9f5 100644 --- a/vendor/github.com/miekg/dns/scanner.go +++ b/vendor/github.com/miekg/dns/scanner.go @@ -42,7 +42,7 @@ func (s *scan) tokenText() (byte, error) { // delay the newline handling until the next token is delivered, // fixes off-by-one errors when reporting a parse error. - if s.eof { + if s.eof == true { s.position.Line++ s.position.Column = 0 s.eof = false diff --git a/vendor/github.com/miekg/dns/serve_mux.go b/vendor/github.com/miekg/dns/serve_mux.go deleted file mode 100644 index ae304db530..0000000000 --- a/vendor/github.com/miekg/dns/serve_mux.go +++ /dev/null @@ -1,147 +0,0 @@ -package dns - -import ( - "strings" - "sync" -) - -// ServeMux is an DNS request multiplexer. It matches the zone name of -// each incoming request against a list of registered patterns add calls -// the handler for the pattern that most closely matches the zone name. -// -// ServeMux is DNSSEC aware, meaning that queries for the DS record are -// redirected to the parent zone (if that is also registered), otherwise -// the child gets the query. -// -// ServeMux is also safe for concurrent access from multiple goroutines. -// -// The zero ServeMux is empty and ready for use. -type ServeMux struct { - z map[string]Handler - m sync.RWMutex -} - -// NewServeMux allocates and returns a new ServeMux. -func NewServeMux() *ServeMux { - return new(ServeMux) -} - -// DefaultServeMux is the default ServeMux used by Serve. -var DefaultServeMux = NewServeMux() - -func (mux *ServeMux) match(q string, t uint16) Handler { - mux.m.RLock() - defer mux.m.RUnlock() - if mux.z == nil { - return nil - } - - var handler Handler - - // TODO(tmthrgd): Once https://go-review.googlesource.com/c/go/+/137575 - // lands in a go release, replace the following with strings.ToLower. - var sb strings.Builder - for i := 0; i < len(q); i++ { - c := q[i] - if !(c >= 'A' && c <= 'Z') { - continue - } - - sb.Grow(len(q)) - sb.WriteString(q[:i]) - - for ; i < len(q); i++ { - c := q[i] - if c >= 'A' && c <= 'Z' { - c += 'a' - 'A' - } - - sb.WriteByte(c) - } - - q = sb.String() - break - } - - for off, end := 0, false; !end; off, end = NextLabel(q, off) { - if h, ok := mux.z[q[off:]]; ok { - if t != TypeDS { - return h - } - // Continue for DS to see if we have a parent too, if so delegate to the parent - handler = h - } - } - - // Wildcard match, if we have found nothing try the root zone as a last resort. - if h, ok := mux.z["."]; ok { - return h - } - - return handler -} - -// Handle adds a handler to the ServeMux for pattern. -func (mux *ServeMux) Handle(pattern string, handler Handler) { - if pattern == "" { - panic("dns: invalid pattern " + pattern) - } - mux.m.Lock() - if mux.z == nil { - mux.z = make(map[string]Handler) - } - mux.z[Fqdn(pattern)] = handler - mux.m.Unlock() -} - -// HandleFunc adds a handler function to the ServeMux for pattern. -func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { - mux.Handle(pattern, HandlerFunc(handler)) -} - -// HandleRemove deregisters the handler specific for pattern from the ServeMux. -func (mux *ServeMux) HandleRemove(pattern string) { - if pattern == "" { - panic("dns: invalid pattern " + pattern) - } - mux.m.Lock() - delete(mux.z, Fqdn(pattern)) - mux.m.Unlock() -} - -// ServeDNS dispatches the request to the handler whose pattern most -// closely matches the request message. -// -// ServeDNS is DNSSEC aware, meaning that queries for the DS record -// are redirected to the parent zone (if that is also registered), -// otherwise the child gets the query. -// -// If no handler is found, or there is no question, a standard SERVFAIL -// message is returned -func (mux *ServeMux) ServeDNS(w ResponseWriter, req *Msg) { - var h Handler - if len(req.Question) >= 1 { // allow more than one question - h = mux.match(req.Question[0].Name, req.Question[0].Qtype) - } - - if h != nil { - h.ServeDNS(w, req) - } else { - HandleFailed(w, req) - } -} - -// Handle registers the handler with the given pattern -// in the DefaultServeMux. The documentation for -// ServeMux explains how patterns are matched. -func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) } - -// HandleRemove deregisters the handle with the given pattern -// in the DefaultServeMux. -func HandleRemove(pattern string) { DefaultServeMux.HandleRemove(pattern) } - -// HandleFunc registers the handler function with the given pattern -// in the DefaultServeMux. -func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { - DefaultServeMux.HandleFunc(pattern, handler) -} diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go index 4b4ec33c8d..2901f8724c 100644 --- a/vendor/github.com/miekg/dns/server.go +++ b/vendor/github.com/miekg/dns/server.go @@ -41,17 +41,6 @@ type Handler interface { ServeDNS(w ResponseWriter, r *Msg) } -// The HandlerFunc type is an adapter to allow the use of -// ordinary functions as DNS handlers. If f is a function -// with the appropriate signature, HandlerFunc(f) is a -// Handler object that calls f. -type HandlerFunc func(ResponseWriter, *Msg) - -// ServeDNS calls f(w, r). -func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) { - f(w, r) -} - // A ResponseWriter interface is used by an DNS handler to // construct an DNS response. type ResponseWriter interface { @@ -83,8 +72,8 @@ type ConnectionStater interface { type response struct { msg []byte hijacked bool // connection has been hijacked by handler - tsigTimersOnly bool tsigStatus error + tsigTimersOnly bool tsigRequestMAC string tsigSecret map[string]string // the tsig secrets udp *net.UDPConn // i/o connection if UDP was used @@ -94,6 +83,35 @@ type response struct { wg *sync.WaitGroup // for gracefull shutdown } +// ServeMux is an DNS request multiplexer. It matches the +// zone name of each incoming request against a list of +// registered patterns add calls the handler for the pattern +// that most closely matches the zone name. ServeMux is DNSSEC aware, meaning +// that queries for the DS record are redirected to the parent zone (if that +// is also registered), otherwise the child gets the query. +// ServeMux is also safe for concurrent access from multiple goroutines. +type ServeMux struct { + z map[string]Handler + m *sync.RWMutex +} + +// NewServeMux allocates and returns a new ServeMux. +func NewServeMux() *ServeMux { return &ServeMux{z: make(map[string]Handler), m: new(sync.RWMutex)} } + +// DefaultServeMux is the default ServeMux used by Serve. +var DefaultServeMux = NewServeMux() + +// The HandlerFunc type is an adapter to allow the use of +// ordinary functions as DNS handlers. If f is a function +// with the appropriate signature, HandlerFunc(f) is a +// Handler object that calls f. +type HandlerFunc func(ResponseWriter, *Msg) + +// ServeDNS calls f(w, r). +func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) { + f(w, r) +} + // HandleFailed returns a HandlerFunc that returns SERVFAIL for every request it gets. func HandleFailed(w ResponseWriter, r *Msg) { m := new(Msg) @@ -102,6 +120,8 @@ func HandleFailed(w ResponseWriter, r *Msg) { w.WriteMsg(m) } +func failedHandler() Handler { return HandlerFunc(HandleFailed) } + // ListenAndServe Starts a server on address and network specified Invoke handler // for incoming queries. func ListenAndServe(addr string, network string, handler Handler) error { @@ -140,6 +160,99 @@ func ActivateAndServe(l net.Listener, p net.PacketConn, handler Handler) error { return server.ActivateAndServe() } +func (mux *ServeMux) match(q string, t uint16) Handler { + mux.m.RLock() + defer mux.m.RUnlock() + var handler Handler + b := make([]byte, len(q)) // worst case, one label of length q + off := 0 + end := false + for { + l := len(q[off:]) + for i := 0; i < l; i++ { + b[i] = q[off+i] + if b[i] >= 'A' && b[i] <= 'Z' { + b[i] |= 'a' - 'A' + } + } + if h, ok := mux.z[string(b[:l])]; ok { // causes garbage, might want to change the map key + if t != TypeDS { + return h + } + // Continue for DS to see if we have a parent too, if so delegeate to the parent + handler = h + } + off, end = NextLabel(q, off) + if end { + break + } + } + // Wildcard match, if we have found nothing try the root zone as a last resort. + if h, ok := mux.z["."]; ok { + return h + } + return handler +} + +// Handle adds a handler to the ServeMux for pattern. +func (mux *ServeMux) Handle(pattern string, handler Handler) { + if pattern == "" { + panic("dns: invalid pattern " + pattern) + } + mux.m.Lock() + mux.z[Fqdn(pattern)] = handler + mux.m.Unlock() +} + +// HandleFunc adds a handler function to the ServeMux for pattern. +func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { + mux.Handle(pattern, HandlerFunc(handler)) +} + +// HandleRemove deregistrars the handler specific for pattern from the ServeMux. +func (mux *ServeMux) HandleRemove(pattern string) { + if pattern == "" { + panic("dns: invalid pattern " + pattern) + } + mux.m.Lock() + delete(mux.z, Fqdn(pattern)) + mux.m.Unlock() +} + +// ServeDNS dispatches the request to the handler whose +// pattern most closely matches the request message. If DefaultServeMux +// is used the correct thing for DS queries is done: a possible parent +// is sought. +// If no handler is found a standard SERVFAIL message is returned +// If the request message does not have exactly one question in the +// question section a SERVFAIL is returned, unlesss Unsafe is true. +func (mux *ServeMux) ServeDNS(w ResponseWriter, request *Msg) { + var h Handler + if len(request.Question) < 1 { // allow more than one question + h = failedHandler() + } else { + if h = mux.match(request.Question[0].Name, request.Question[0].Qtype); h == nil { + h = failedHandler() + } + } + h.ServeDNS(w, request) +} + +// Handle registers the handler with the given pattern +// in the DefaultServeMux. The documentation for +// ServeMux explains how patterns are matched. +func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) } + +// HandleRemove deregisters the handle with the given pattern +// in the DefaultServeMux. +func HandleRemove(pattern string) { DefaultServeMux.HandleRemove(pattern) } + +// HandleFunc registers the handler function with the given pattern +// in the DefaultServeMux. +func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { + DefaultServeMux.HandleFunc(pattern, handler) +} + // Writer writes raw DNS messages; each call to Write should send an entire message. type Writer interface { io.Writer @@ -416,13 +529,14 @@ func (srv *Server) Shutdown() error { // to terminate. func (srv *Server) ShutdownContext(ctx context.Context) error { srv.lock.Lock() - if !srv.started { - srv.lock.Unlock() + started := srv.started + srv.started = false + srv.lock.Unlock() + + if !started { return &Error{err: "server not started"} } - srv.started = false - if srv.PacketConn != nil { srv.PacketConn.SetReadDeadline(aLongTimeAgo) // Unblock reads } @@ -431,10 +545,10 @@ func (srv *Server) ShutdownContext(ctx context.Context) error { srv.Listener.Close() } + srv.lock.Lock() for rw := range srv.conns { rw.SetReadDeadline(aLongTimeAgo) // Unblock reads } - srv.lock.Unlock() if testShutdownNotify != nil { @@ -621,23 +735,20 @@ func (srv *Server) serve(w *response) { } } -func (srv *Server) disposeBuffer(w *response) { +func (srv *Server) serveDNS(w *response) { + req := new(Msg) + err := req.Unpack(w.msg) if w.udp != nil && cap(w.msg) == srv.UDPSize { srv.udpPool.Put(w.msg[:srv.UDPSize]) } w.msg = nil -} - -func (srv *Server) serveDNS(w *response) { - req := new(Msg) - err := req.Unpack(w.msg) if err != nil { // Send a FormatError back x := new(Msg) x.SetRcodeFormatError(req) w.WriteMsg(x) + return } - if err != nil || !srv.Unsafe && req.Response { - srv.disposeBuffer(w) + if !srv.Unsafe && req.Response { return } @@ -654,8 +765,6 @@ func (srv *Server) serveDNS(w *response) { } } - srv.disposeBuffer(w) - handler := srv.Handler if handler == nil { handler = DefaultServeMux @@ -665,16 +774,7 @@ func (srv *Server) serveDNS(w *response) { } func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error) { - // If we race with ShutdownContext, the read deadline may - // have been set in the distant past to unblock the read - // below. We must not override it, otherwise we may block - // ShutdownContext. - srv.lock.RLock() - if srv.started { - conn.SetReadDeadline(time.Now().Add(timeout)) - } - srv.lock.RUnlock() - + conn.SetReadDeadline(time.Now().Add(timeout)) l := make([]byte, 2) n, err := conn.Read(l) if err != nil || n != 2 { @@ -709,13 +809,7 @@ func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error) } func (srv *Server) readUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error) { - srv.lock.RLock() - if srv.started { - // See the comment in readTCP above. - conn.SetReadDeadline(time.Now().Add(timeout)) - } - srv.lock.RUnlock() - + conn.SetReadDeadline(time.Now().Add(timeout)) m := srv.udpPool.Get().([]byte) n, s, err := ReadFromSessionUDP(conn, m) if err != nil { @@ -767,33 +861,24 @@ func (w *response) Write(m []byte) (int, error) { n, err := io.Copy(w.tcp, bytes.NewReader(m)) return int(n), err - default: - panic("dns: Write called after Close") } + panic("not reached") } // LocalAddr implements the ResponseWriter.LocalAddr method. func (w *response) LocalAddr() net.Addr { - switch { - case w.udp != nil: - return w.udp.LocalAddr() - case w.tcp != nil: + if w.tcp != nil { return w.tcp.LocalAddr() - default: - panic("dns: LocalAddr called after Close") } + return w.udp.LocalAddr() } // RemoteAddr implements the ResponseWriter.RemoteAddr method. func (w *response) RemoteAddr() net.Addr { - switch { - case w.udpSession != nil: - return w.udpSession.RemoteAddr() - case w.tcp != nil: + if w.tcp != nil { return w.tcp.RemoteAddr() - default: - panic("dns: RemoteAddr called after Close") } + return w.udpSession.RemoteAddr() } // TsigStatus implements the ResponseWriter.TsigStatus method. diff --git a/vendor/github.com/miekg/dns/sig0.go b/vendor/github.com/miekg/dns/sig0.go index 07c2acb196..f31e9e6843 100644 --- a/vendor/github.com/miekg/dns/sig0.go +++ b/vendor/github.com/miekg/dns/sig0.go @@ -127,7 +127,8 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error { if offset+1 >= buflen { continue } - rdlen := binary.BigEndian.Uint16(buf[offset:]) + var rdlen uint16 + rdlen = binary.BigEndian.Uint16(buf[offset:]) offset += 2 offset += int(rdlen) } diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go index 115f2c7bd0..a64f4d7d83 100644 --- a/vendor/github.com/miekg/dns/types.go +++ b/vendor/github.com/miekg/dns/types.go @@ -419,130 +419,128 @@ type TXT struct { func (rr *TXT) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } func sprintName(s string) string { - var dst strings.Builder - dst.Grow(len(s)) - for i := 0; i < len(s); { - if i+1 < len(s) && s[i] == '\\' && s[i+1] == '.' { - dst.WriteString(s[i : i+2]) + src := []byte(s) + dst := make([]byte, 0, len(src)) + for i := 0; i < len(src); { + if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' { + dst = append(dst, src[i:i+2]...) i += 2 - continue + } else { + b, n := nextByte(src, i) + if n == 0 { + i++ // dangling back slash + } else if b == '.' { + dst = append(dst, b) + } else { + dst = appendDomainNameByte(dst, b) + } + i += n } - - b, n := nextByte(s, i) - switch { - case n == 0: - i++ // dangling back slash - case b == '.': - dst.WriteByte('.') - default: - writeDomainNameByte(&dst, b) - } - i += n } - return dst.String() + return string(dst) } func sprintTxtOctet(s string) string { - var dst strings.Builder - dst.Grow(2 + len(s)) - dst.WriteByte('"') - for i := 0; i < len(s); { - if i+1 < len(s) && s[i] == '\\' && s[i+1] == '.' { - dst.WriteString(s[i : i+2]) + src := []byte(s) + dst := make([]byte, 0, len(src)) + dst = append(dst, '"') + for i := 0; i < len(src); { + if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' { + dst = append(dst, src[i:i+2]...) i += 2 - continue + } else { + b, n := nextByte(src, i) + if n == 0 { + i++ // dangling back slash + } else if b == '.' { + dst = append(dst, b) + } else { + if b < ' ' || b > '~' { + dst = appendByte(dst, b) + } else { + dst = append(dst, b) + } + } + i += n } - - b, n := nextByte(s, i) - switch { - case n == 0: - i++ // dangling back slash - case b == '.': - dst.WriteByte('.') - case b < ' ' || b > '~': - writeEscapedByte(&dst, b) - default: - dst.WriteByte(b) - } - i += n } - dst.WriteByte('"') - return dst.String() + dst = append(dst, '"') + return string(dst) } func sprintTxt(txt []string) string { - var out strings.Builder + var out []byte for i, s := range txt { - out.Grow(3 + len(s)) if i > 0 { - out.WriteString(` "`) + out = append(out, ` "`...) } else { - out.WriteByte('"') + out = append(out, '"') } - for j := 0; j < len(s); { - b, n := nextByte(s, j) + bs := []byte(s) + for j := 0; j < len(bs); { + b, n := nextByte(bs, j) if n == 0 { break } - writeTXTStringByte(&out, b) + out = appendTXTStringByte(out, b) j += n } - out.WriteByte('"') + out = append(out, '"') } - return out.String() + return string(out) } -func writeDomainNameByte(s *strings.Builder, b byte) { +func appendDomainNameByte(s []byte, b byte) []byte { switch b { case '.', ' ', '\'', '@', ';', '(', ')': // additional chars to escape - s.WriteByte('\\') - s.WriteByte(b) - default: - writeTXTStringByte(s, b) + return append(s, '\\', b) } + return appendTXTStringByte(s, b) } -func writeTXTStringByte(s *strings.Builder, b byte) { - switch { - case b == '"' || b == '\\': - s.WriteByte('\\') - s.WriteByte(b) - case b < ' ' || b > '~': - writeEscapedByte(s, b) - default: - s.WriteByte(b) +func appendTXTStringByte(s []byte, b byte) []byte { + switch b { + case '"', '\\': + return append(s, '\\', b) } + if b < ' ' || b > '~' { + return appendByte(s, b) + } + return append(s, b) } -func writeEscapedByte(s *strings.Builder, b byte) { +func appendByte(s []byte, b byte) []byte { var buf [3]byte bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s.WriteByte('\\') - for i := len(bufs); i < 3; i++ { - s.WriteByte('0') + s = append(s, '\\') + for i := 0; i < 3-len(bufs); i++ { + s = append(s, '0') } - s.Write(bufs) + for _, r := range bufs { + s = append(s, r) + } + return s } -func nextByte(s string, offset int) (byte, int) { - if offset >= len(s) { +func nextByte(b []byte, offset int) (byte, int) { + if offset >= len(b) { return 0, 0 } - if s[offset] != '\\' { + if b[offset] != '\\' { // not an escape sequence - return s[offset], 1 + return b[offset], 1 } - switch len(s) - offset { + switch len(b) - offset { case 1: // dangling escape return 0, 0 case 2, 3: // too short to be \ddd default: // maybe \ddd - if isDigit(s[offset+1]) && isDigit(s[offset+2]) && isDigit(s[offset+3]) { - return dddStringToByte(s[offset+1:]), 4 + if isDigit(b[offset+1]) && isDigit(b[offset+2]) && isDigit(b[offset+3]) { + return dddToByte(b[offset+1:]), 4 } } // not \ddd, just an RFC 1035 "quoted" character - return s[offset+1], 2 + return b[offset+1], 2 } // SPF RR. See RFC 4408, Section 3.1.1. diff --git a/vendor/github.com/miekg/dns/udp.go b/vendor/github.com/miekg/dns/udp.go index a4826ee2ff..82ead69399 100644 --- a/vendor/github.com/miekg/dns/udp.go +++ b/vendor/github.com/miekg/dns/udp.go @@ -1,5 +1,3 @@ -// +build !windows - package dns import ( diff --git a/vendor/github.com/miekg/dns/udp_windows.go b/vendor/github.com/miekg/dns/udp_windows.go deleted file mode 100644 index 6778c3c6cf..0000000000 --- a/vendor/github.com/miekg/dns/udp_windows.go +++ /dev/null @@ -1,37 +0,0 @@ -// +build windows - -package dns - -import "net" - -// SessionUDP holds the remote address -type SessionUDP struct { - raddr *net.UDPAddr -} - -// RemoteAddr returns the remote network address. -func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr } - -// ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a -// net.UDPAddr. -// TODO(fastest963): Once go1.10 is released, use ReadMsgUDP. -func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) { - n, raddr, err := conn.ReadFrom(b) - if err != nil { - return n, nil, err - } - session := &SessionUDP{raddr.(*net.UDPAddr)} - return n, session, err -} - -// WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr. -// TODO(fastest963): Once go1.10 is released, use WriteMsgUDP. -func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) { - n, err := conn.WriteTo(b, session.raddr) - return n, err -} - -// TODO(fastest963): Once go1.10 is released and we can use *MsgUDP methods -// use the standard method in udp.go for these. -func setUDPSocketOptions(*net.UDPConn) error { return nil } -func parseDstFromOOB([]byte, net.IP) net.IP { return nil } diff --git a/vendor/github.com/miekg/dns/version.go b/vendor/github.com/miekg/dns/version.go index 403b9ef978..ade7586dc1 100644 --- a/vendor/github.com/miekg/dns/version.go +++ b/vendor/github.com/miekg/dns/version.go @@ -3,7 +3,7 @@ package dns import "fmt" // Version is current version of this library. -var Version = V{1, 0, 13} +var Version = V{1, 0, 10} // V holds the version of this library. type V struct { diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/auth.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/auth.go new file mode 100644 index 0000000000..c560caa2c6 --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/auth.go @@ -0,0 +1,128 @@ +package cos + +import ( + "crypto/hmac" + "crypto/sha1" + "encoding/hex" + "fmt" + "net/http" + "sort" + "strconv" + "strings" + "time" +) + +func (conn *Conn) signHeader(req *http.Request, params map[string]interface{}, headers map[string]string) { + signTime := getSignTime() + signature := conn.getSignature(req, params, headers, signTime) + authStr := fmt.Sprintf("q-sign-algorithm=sha1&q-ak=%s&q-sign-time=%s&q-key-time=%s&q-header-list=%s&q-url-param-list=%s&q-signature=%s", + conn.conf.SecretID, signTime, signTime, getHeadKeys(headers), getParamKeys(params), signature) + + req.Header.Set("Authorization", authStr) +} + +func getSignTime() string { + now := time.Now() + expired := now.Add(time.Second * 1800) + return fmt.Sprintf("%d;%d", now.Unix(), expired.Unix()) +} + +func getHeadKeys(headers map[string]string) string { + if headers == nil || len(headers) == 0 { + return "" + } + + tmp := []string{} + for k := range headers { + tmp = append(tmp, strings.ToLower(k)) + } + sort.Strings(tmp) + + return strings.Join(tmp, ";") +} + +func getParamKeys(params map[string]interface{}) string { + if params == nil || len(params) == 0 { + return "" + } + + tmp := []string{} + for k := range params { + tmp = append(tmp, strings.ToLower(k)) + } + sort.Strings(tmp) + + return strings.Join(tmp, ";") +} + +func (conn *Conn) getSignature(req *http.Request, params map[string]interface{}, headers map[string]string, signTime string) string { + httpString := fmt.Sprintf("%s\n%s\n%s\n%s\n", strings.ToLower(req.Method), + req.URL.Path, getParamStr(params), getHeadStr(headers)) + + httpString = sha(httpString) + signKey := hmacSha(conn.conf.SecretKey, signTime) + signStr := fmt.Sprintf("sha1\n%s\n%s\n", signTime, httpString) + + return hmacSha(signKey, signStr) +} + +func interfaceToString(i interface{}) string { + switch x := i.(type) { + case string: + return x + case int: + return strconv.Itoa(x) + case int64: + return strconv.FormatInt(x, 10) + case uint64: + return strconv.FormatUint(x, 10) + default: + return "" + } +} + +func getParamStr(params map[string]interface{}) string { + if params == nil || len(params) == 0 { + return "" + } + + tmp := []string{} + for k, v := range params { + str := strings.ToLower(fmt.Sprintf("%s=%s", k, interfaceToString(v))) + tmp = append(tmp, str) + } + sort.Strings(tmp) + + return strings.Join(tmp, "&") +} + +func getHeadStr(headers map[string]string) string { + if headers == nil || len(headers) == 0 { + return "" + } + + tmp := []string{} + for k, v := range headers { + str := fmt.Sprintf("%s=%s", strings.ToLower(k), escape(v)) + tmp = append(tmp, str) + } + sort.Strings(tmp) + + return strings.Join(tmp, "&") +} + +func sha(s string) string { + sha := sha1.New() + sha.Write([]byte(s)) + b := sha.Sum(nil) + + return hex.EncodeToString(b) +} + +func hmacSha(k, s string) string { + enc := hmac.New(sha1.New, []byte(k)) + enc.Write([]byte(s)) + b := enc.Sum(nil) + + return hex.EncodeToString(b) +} diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/bucket.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/bucket.go new file mode 100644 index 0000000000..3458f2fb30 --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/bucket.go @@ -0,0 +1,315 @@ +package cos + +import ( + "bytes" + "context" + "crypto/md5" + "encoding/hex" + "encoding/xml" + "fmt" + "io" + "net/http" + "os" + "strings" +) + +// Bucket bucket +type Bucket struct { + Name string + conn *Conn +} + +// ObjectSlice object slice +type ObjectSlice struct { + UploadID string + Size int64 + Offset int64 + Number int + MD5 string + Dst string + Result bool +} + +// 获得云存储上文件信息 +func (b *Bucket) HeadObject(ctx context.Context, object string) error { + resq, err := b.conn.Do(ctx, http.MethodHead, b.Name, object, nil, nil, nil) + if err == nil { + defer resq.Body.Close() + } else { + for k, v := range resq.Header { + value := fmt.Sprintf("%s", v) + fmt.Printf("%-18s: %s\n", k, strings.Replace(strings.Replace(value, "[", "", -1), "]", "", -1)) + } + } + + return err +} + +func (b *Bucket) UploadObject(ctx context.Context, object string, content io.Reader, acl *AccessControl) error { + res, err := b.conn.Do(ctx, http.MethodPut, b.Name, object, nil, acl.GenHead(), content) + if err == nil { + defer res.Body.Close() + } + + return err +} + +func (b *Bucket) CopyObject(ctx context.Context, src, dst string, acl *AccessControl) error { + srcURL := fmt.Sprintf("%s-%s.cos.%s.%s/%s", b.Name, b.conn.conf.AppID, b.conn.conf.Region, b.conn.conf.Domain, dst) + header := map[string]string{ + "x-cos-source-url": srcURL, + } + + res, err := b.conn.Do(ctx, http.MethodPut, b.Name, dst, nil, header, nil) + if err == nil { + defer res.Body.Close() + } + + return err +} + +func (b *Bucket) DeleteObject(ctx context.Context, obj string) error { + res, err := b.conn.Do(ctx, http.MethodDelete, b.Name, obj, nil, nil, nil) + if err == nil { + defer res.Body.Close() + } + + return err +} + +func (b *Bucket) DownloadObject(ctx context.Context, object string, w io.Writer) error { + res, err := b.conn.Do(ctx, http.MethodGet, b.Name, object, nil, nil, nil) + if err != nil { + return err + } + + _, err = io.Copy(w, res.Body) + + return err +} + +// UploadObjectBySlice upload by slice +func (b *Bucket) UploadObjectBySlice(ctx context.Context, dst, src string, taskNum int, headers map[string]string) error { + if taskNum < 1 { + return ParamError{"taskNum 必须大于1"} + } + + uploadID, err := b.InitSliceUpload(ctx, dst, headers) + if err != nil { + return err + } + + fd, err := os.Open(src) + if err != nil { + return err + } + defer fd.Close() + + slices, err := b.PerformSliceUpload(ctx, dst, uploadID, fd, taskNum) + if err != nil { + return err + } + + err = b.CompleteSliceUpload(ctx, dst, uploadID, fd, slices) + + return err +} + +// InitSliceUpload init upload by slice +func (b *Bucket) InitSliceUpload(ctx context.Context, obj string, headers map[string]string) (string, error) { + param := map[string]interface{}{ + "uploads": "", + } + res, err := b.conn.Do(ctx, http.MethodPost, b.Name, obj, param, headers, nil) + if err != nil { + return "", err + } + defer res.Body.Close() + + imur := &InitiateMultipartUploadResult{} + err = XMLDecode(res.Body, imur) + if err != nil { + return "", err + } + + return imur.UploadID, nil +} + +// CompleteSliceUpload finish slice Upload +func (b *Bucket) CompleteSliceUpload(ctx context.Context, dst, uploadID string, fd *os.File, slice []*ObjectSlice) error { + cmu := &CompleteMultipartUpload{} + cmu.Part = []struct { + PartNumber int + ETag string + }{} + + for _, osl := range slice { + cmu.Part = append(cmu.Part, struct { + PartNumber int + ETag string + }{PartNumber: osl.Number, ETag: osl.MD5}) + } + + cmuXML, err := xml.Marshal(cmu) + if err != nil { + return err + } + param := map[string]interface{}{ + "uploadId": uploadID, + } + res, err := b.conn.Do(ctx, http.MethodPost, b.Name, dst, param, nil, bytes.NewReader(cmuXML)) + if err == nil { + defer res.Body.Close() + } + + return err +} + +// PerformSliceUpload perform slice upload +func (b *Bucket) PerformSliceUpload(ctx context.Context, dst, uploadID string, fd *os.File, taskNum int) ([]*ObjectSlice, error) { + oss, err := b.getFileSlices(fd, uploadID, dst) + if err != nil { + return nil, err + } + + jobNum := len(oss) + jobs := make(chan *ObjectSlice, jobNum) + result := make(chan *ObjectSlice, jobNum) + + for i := 0; i < taskNum; i++ { + go b.Worker(ctx, fd, jobs, result) + } + + for _, osl := range oss { + jobs <- osl + } + close(jobs) + + for i := 0; i < jobNum; i++ { + res := <-result + if !res.Result { + return nil, SliceError{fmt.Sprintf("part info : num:%d, md5:%s", res.Number, res.MD5)} + } + } + + return oss, nil +} + +// Worker woker for slice upload +func (b *Bucket) Worker(ctx context.Context, fd *os.File, jobs <-chan *ObjectSlice, result chan<- *ObjectSlice) { + for job := range jobs { + content, err := getFilePartContent(fd, job.Offset, job.Size) + if err != nil { + continue + } + + err = b.UploadSlice(ctx, job.UploadID, job.Dst, job.Number, job.MD5, content) + if err == nil { + job.Result = true + } else { + job.Result = false + } + + result <- job + } +} + +// UploadSlice upload one slice +func (b *Bucket) UploadSlice(ctx context.Context, uploadID, dst string, number int, etag string, content io.Reader) error { + param := map[string]interface{}{ + "PartNumber": number, + "uploadId": uploadID, + } + res, err := b.conn.Do(ctx, http.MethodPut, b.Name, dst, param, nil, content) + + if err != nil { + return FileError{"PUT数据错误:" + err.Error()} + } + defer res.Body.Close() + + if strings.Trim(res.Header.Get("Etag"), "\"") != etag { + return FileError{"cos-etag与文件MD5不匹配"} + } + + return err +} + +func (b *Bucket) getFileSlices(fd *os.File, uploadID, dst string) ([]*ObjectSlice, error) { + sliceSize := b.conn.conf.PartSize + fi, err := fd.Stat() + if err != nil { + return nil, err + } + + fileSize := fi.Size() + oss := []*ObjectSlice{} + var i int + var offset int64 + for fileSize > 0 { + var size int64 + if fileSize > sliceSize { + size = sliceSize + } else { + size = fileSize + } + i++ + md5, err := getFileMD5(fd, offset, size) + if err != nil { + return nil, err + } + + osl := &ObjectSlice{} + osl.Size = size + osl.Number = i + osl.Offset = offset + osl.UploadID = uploadID + osl.MD5 = md5 + osl.Dst = dst + oss = append(oss, osl) + + fileSize -= sliceSize + offset += sliceSize + } + + return oss, nil +} + +func getFileMD5(fd *os.File, offset, size int64) (string, error) { + buf := make([]byte, size) + _, err := fd.ReadAt(buf, offset) + if err != nil { + return "", err + } + + encoder := md5.New() + encoder.Write(buf) + b := encoder.Sum(nil) + + return hex.EncodeToString(b), nil +} + +func getFilePartContent(fd *os.File, offset, size int64) (io.Reader, error) { + buf := make([]byte, size) + _, err := fd.ReadAt(buf, offset) + if err != nil { + return nil, err + } + + return bytes.NewReader(buf), nil +} + +func (b *Bucket) AbortUpload(ctx context.Context, obj, uploadID string) error { + param := map[string]interface{}{ + "uploadId": uploadID, + } + _, err := b.conn.Do(ctx, http.MethodDelete, b.Name, obj, param, nil, nil) + + return err +} + +// ObjectExists object exists +func (b *Bucket) ObjectExists(ctx context.Context, obj string) error { + _, err := b.conn.Do(ctx, http.MethodHead, b.Name, obj, nil, nil, nil) + + return err +} diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/client.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/client.go new file mode 100644 index 0000000000..18beb021b5 --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/client.go @@ -0,0 +1,164 @@ +package cos + +import ( + "context" + "net/http" + "time" +) + +// Client 客户端, cos的句柄 +type Client struct { + conn *Conn +} + +// New cos包的入口 +func New(o *Option) *Client { + client := Client{} + conf := getDefaultConf() + conf.AppID = o.AppID + conf.SecretID = o.SecretID + conf.SecretKey = o.SecretKey + conf.Region = o.Region + + if o.Domain != "" { + conf.Domain = o.Domain + } + + conn := Conn{&http.Client{}, conf} + client.conn = &conn + + return &client +} + +// GetTimeoutCtx 获取一个带超时的context +func GetTimeoutCtx(timeout time.Duration) context.Context { + ctx, _ := context.WithTimeout(context.Background(), timeout) + + return ctx +} + +// Bucket get bucket +func (c *Client) Bucket(name string) *Bucket { + return &Bucket{name, c.conn} +} + +// GetBucketList 获取bucketlist +func (c *Client) GetBucketList(ctx context.Context) (*ListAllMyBucketsResult, error) { + req, err := http.NewRequest(http.MethodGet, "http://service.cos.myqcloud.com/", nil) + if err != nil { + return nil, err + } + + req = req.WithContext(ctx) + c.conn.signHeader(req, nil, nil) + res, err := c.conn.c.Do(req) + if err != nil { + return nil, err + } + defer res.Body.Close() + + res, err = checkHTTPErr(res) + if err != nil { + return nil, err + } + + labr := &ListAllMyBucketsResult{} + err = XMLDecode(res.Body, labr) + if err != nil { + return nil, err + } + + return labr, err +} + +// CreateBucket 建立bucket +func (c *Client) CreateBucket(ctx context.Context, name string, acl *AccessControl) error { + res, err := c.conn.Do(ctx, http.MethodPut, name, "", nil, acl.GenHead(), nil) + if err == nil { + defer res.Body.Close() + } + + return err +} + +// DeleteBucket delete a bucket +func (c *Client) DeleteBucket(ctx context.Context, name string) error { + _, err := c.conn.Do(ctx, http.MethodDelete, name, "", nil, nil, nil) + + return err +} + +// GetBucketACL get bucket's acl +func (c *Client) GetBucketACL(ctx context.Context, name string) (*AccessControlPolicy, error) { + params := map[string]interface{}{"acl": ""} + res, err := c.conn.Do(ctx, http.MethodGet, name, "", params, nil, nil) + + if err != nil { + return nil, err + } + defer res.Body.Close() + + aclp := &AccessControlPolicy{} + + err = XMLDecode(res.Body, aclp) + if err != nil { + return nil, err + } + + return aclp, nil +} + +// SetBucketACL set bucket's acl +func (c *Client) SetBucketACL(ctx context.Context, name string, acl *AccessControl) error { + params := map[string]interface{}{"acl": ""} + res, err := c.conn.Do(ctx, http.MethodPut, name, "", params, acl.GenHead(), nil) + if err == nil { + defer res.Body.Close() + } + + return err +} + +// BucketExists bucket exists? +func (c *Client) BucketExists(ctx context.Context, name string) error { + res, err := c.conn.Do(ctx, http.MethodHead, name, "", nil, nil, nil) + if err == nil { + defer res.Body.Close() + } + + return err +} + +// ListBucketContents list +func (c *Client) ListBucketContents(ctx context.Context, name string, qc *QueryCondition) (*ListBucketResult, error) { + resp, err := c.conn.Do(ctx, http.MethodGet, name, "", qc.GenParams(), nil, nil) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + lbr := &ListBucketResult{} + err = XMLDecode(resp.Body, lbr) + if err != nil { + return nil, err + } + + return lbr, nil +} + +// ListUploading list uploading task +func (c *Client) ListUploading(ctx context.Context, bucket string, lu *ListUploadParam) (*ListMultipartUploadsResult, error) { + res, err := c.conn.Do(ctx, http.MethodGet, bucket, "", lu.GenParams(), nil, nil) + if err != nil { + return nil, err + } + defer res.Body.Close() + + lmur := &ListMultipartUploadsResult{} + err = XMLDecode(res.Body, lmur) + if err != nil { + return nil, err + } + + return lmur, nil +} diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conf.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conf.go new file mode 100644 index 0000000000..516c013164 --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conf.go @@ -0,0 +1,31 @@ +package cos + +const ( + defaultPartSize = 80 * 1024 * 1024 + defaultRetryTimes = 3 + defaultUA = "cos-go-sdk-v5.2.9" + defaultDomain = "myqcloud.com" +) + +// Conf config struct +type Conf struct { + AppID string + SecretID string + SecretKey string + Region string + PartSize int64 + RetryTimes int + UA string + Domain string + Bucket string +} + +func getDefaultConf() *Conf { + conf := Conf{} + conf.PartSize = defaultPartSize + conf.RetryTimes = defaultRetryTimes + conf.UA = defaultUA + conf.Domain = defaultDomain + + return &conf +} diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conn.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conn.go new file mode 100644 index 0000000000..bf6380ac0e --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/conn.go @@ -0,0 +1,141 @@ +package cos + +import ( + "bytes" + "context" + "encoding/xml" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + +// Conn http 请求类 +type Conn struct { + c *http.Client + conf *Conf +} + +func (conn *Conn) Do(ctx context.Context, method, bucket, object string, params map[string]interface{}, headers map[string]string, body io.Reader) (*http.Response, error) { + queryStr := getQueryStr(params) + url := conn.buildURL(bucket, object, queryStr) + + switch body.(type) { + case *bytes.Buffer, *bytes.Reader, *strings.Reader: + default: + if body != nil { + b, err := ioutil.ReadAll(body) + if err != nil { + return nil, err + } + body = bytes.NewReader(b) + } + } + + req, err := http.NewRequest(method, url, body) + if err != nil { + return nil, err + } + + conn.signHeader(req, params, headers) + req.Header.Set("User-Agent", conn.conf.UA) + setHeader(req, headers) + + res, err := conn.c.Do(req) + + if err != nil { + return nil, err + } + + if res.StatusCode < 200 || res.StatusCode >= 300 { + defer res.Body.Close() + return checkHTTPErr(res) + } + + return res, nil +} + +func getQueryStr(params map[string]interface{}) string { + if params == nil || len(params) == 0 { + return "" + } + + buf := new(bytes.Buffer) + buf.WriteString("?") + for k, v := range params { + buf.WriteString(k) + vs := interfaceToString(v) + if vs == "" { + buf.WriteString("&") + continue + } + buf.WriteString("=") + buf.WriteString(vs) + buf.WriteString("&") + } + + return strings.Trim(buf.String(), "&") +} + +func (conn *Conn) buildURL(bucket, object, queryStr string) string { + domain := fmt.Sprintf("%s-%s.cos.%s.%s", bucket, conn.conf.AppID, conn.conf.Region, conn.conf.Domain) + url := fmt.Sprintf("http://%s/%s%s", domain, escape(object), queryStr) + + return url +} + +func escape(str string) string { + //go语言中将空格编码为+,需要改为%20 + return strings.Replace(url.QueryEscape(str), "+", "%20", -1) +} + +func setHeader(req *http.Request, headers map[string]string) { + if headers == nil { + return + } + + for k, v := range headers { + req.Header.Set(k, v) + } +} + +func checkHTTPErr(res *http.Response) (*http.Response, error) { + if res.StatusCode >= 200 && res.StatusCode < 300 { + return res, nil + } + + err := HTTPError{} + err.Code = res.StatusCode + if res.StatusCode >= 300 && res.StatusCode < 400 { + err.Message = "资源被重定向" + } + + if res.StatusCode >= 400 && res.StatusCode < 500 { + err.Message = "请求被拒绝" + } + + if res.StatusCode >= 500 { + err.Message = "cos服务器错误" + } + + if res.ContentLength > 0 { + resErr := &Error{} + e := XMLDecode(res.Body, resErr) + if e != nil { + return nil, err + } + err.Message += resErr.Message + } + + return res, err +} + +// XMLDecode xml解析方法 +func XMLDecode(r io.Reader, i interface{}) error { + jd := xml.NewDecoder(r) + err := jd.Decode(i) + + return err +} diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/option.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/option.go new file mode 100644 index 0000000000..d6bc8af99b --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/option.go @@ -0,0 +1,10 @@ +package cos + +type Option struct { + AppID string `mapstructure:"app_id" json:"app_id"` + SecretID string `mapstructure:"secret_id" json:"secret_id"` + SecretKey string `mapstructure:"secret_key" json:"secret_key"` + Region string `mapstructure:"region" json:"region"` + Domain string `mapstructure:"domain" json:"domain"` + Bucket string `mapstructure:"bucket" json:"bucket"` +} diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/requests.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/requests.go new file mode 100644 index 0000000000..e26c6757e9 --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/requests.go @@ -0,0 +1,102 @@ +package cos + +// AccessControl privilige +type AccessControl struct { + ACL string + GrantRead string + GrantWrite string + FullControl string +} + +// GenHead 生成http head +func (acl *AccessControl) GenHead() map[string]string { + header := map[string]string{ + "x-cos-acl": acl.ACL, + "x-cos-grant-read": acl.GrantRead, + "x-cos-grant-write": acl.GrantWrite, + "x-cos-grant-full-control": acl.FullControl, + } + + for k, v := range header { + if v == "" { + delete(header, k) + } + } + + return header +} + +// QueryCondition query condition +type QueryCondition struct { + Prefix string + Delimiter string + EncodingType string + Marker string + MaxKeys int +} + +// GenParams generate params:map[string]interface{} +func (qc *QueryCondition) GenParams() map[string]interface{} { + params := map[string]interface{}{ + "prefix": qc.Prefix, + "delimiter": qc.Delimiter, + "encoding-type": qc.EncodingType, + "marker": qc.Marker, + "max-keys": qc.MaxKeys, + } + + for k, v := range params { + if v == "" { + delete(params, k) + } + if v == 0 { + delete(params, k) + } + } + + return params +} + +// ListUploadParam list upload param +type ListUploadParam struct { + Prefix string + Delimiter string + EncodingType string + MaxUploads int + KeyMarker string + UploadIDMarker string +} + +// GenParams generate params for request +func (lup *ListUploadParam) GenParams() map[string]interface{} { + params := map[string]interface{}{ + "prefix": lup.Prefix, + "delimiter": lup.Delimiter, + "encoding-type": lup.EncodingType, + "max-uploads": lup.MaxUploads, + "key-marker": lup.KeyMarker, + "upload-id-marker": lup.UploadIDMarker, + } + + for k, v := range params { + if v == "" { + delete(params, k) + } + + if v == 0 { + delete(params, k) + } + } + params["uploads"] = "" + + return params + +} + +// CompleteMultipartUpload compelete slice upload +type CompleteMultipartUpload struct { + Part []struct { + PartNumber int + ETag string + } +} diff --git a/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/response.go b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/response.go new file mode 100644 index 0000000000..8c69ab30cd --- /dev/null +++ b/vendor/github.com/nelsonken/cos-go-sdk-v5/cos/response.go @@ -0,0 +1,156 @@ +package cos + +import ( + "fmt" +) + +// ListAllMyBucketsResult 获取bucket列表的结果 +type ListAllMyBucketsResult struct { + Owner struct { + ID string + DisplayName string + } + + Buckets struct { + Bucket []struct { + Name string + Location string + CreateDate string + } + } +} + +// Error 错误消息 +type Error struct { + Code string + Message string + Resource string + RequestID string `xml:"RequestId"` + TraceID string `xml:"TaceId"` +} + +// HTTPError http error struct +type HTTPError struct { + Code int + Message string +} + +// Error error interface +func (he HTTPError) Error() string { + return fmt.Sprintf("%d:%s", he.Code, he.Message) +} + +// AccessControlPolicy acl return +type AccessControlPolicy struct { + Owner struct { + ID string + DisplayName string + } + AccessControlList struct { + Grant []struct { + Grantee struct { + ID string + DisplayName string + } + Permission string + } + } +} + +// ListBucketResult list bucket contents result +type ListBucketResult struct { + Name string + EncodingType string `xml:"Encoding-Type"` + Prefix string + Marker string + MaxKeys int + IsTruncated bool + NextMarker string + Contents []struct { + Key string + LastModified string + ETag string + Size int64 + Owner struct { + ID string + } + StorageClass string + } + CommonPrefixes []struct { + Prefix string + } +} + +// ListMultipartUploadsResult list uploading task +type ListMultipartUploadsResult struct { + Bucket string + EncodingType string `xml:"Encoding-Type"` + KeyMarker string + UploadIDMarker string `xml:"UploadIdMarker"` + NextKeyMarker string + NextUploadIDMarker string `xml:"NextUploadIdMarker"` + MaxUploads int + IsTruncated bool + Prefix string + Delimiter string + Upload []struct { + Key string + UploadID string + StorageClass string + Initiator struct { + UIN string + } + Owner struct { + UID string + } + Initiated string + } + CommonPrefixes []struct { + Prefix string + } +} + +// InitiateMultipartUploadResult init slice upload +type InitiateMultipartUploadResult struct { + Bucket string + Key string + UploadID string `xml:"UploadId"` +} + +// CompleteMultipartUploadResult compeleted slice upload +type CompleteMultipartUploadResult struct { + Location string + Bucket string + Key string + ETag string +} + +// SliceError slice upload err +type SliceError struct { + Message string +} + +// Error implements error +func (se SliceError) Error() string { + return fmt.Sprintf("上传分片失败:%s", se.Message) +} + +// ParamError slice upload err +type ParamError struct { + Message string +} + +// Error implements error +func (pe ParamError) Error() string { + return fmt.Sprintf("参数错误:%s", pe.Message) +} + +// FileError slice upload err +type FileError struct { + Message string +} + +// Error implements error +func (fe FileError) Error() string { + return fmt.Sprintf("文件错误:%s", fe.Message) +} diff --git a/vendor/github.com/pierrec/lz4/block.go b/vendor/github.com/pierrec/lz4/block.go index 00b1111b92..ef24f17e57 100644 --- a/vendor/github.com/pierrec/lz4/block.go +++ b/vendor/github.com/pierrec/lz4/block.go @@ -286,7 +286,7 @@ func CompressBlockHC(src, dst []byte, depth int) (di int, err error) { for ml < sn-si && src[next+ml] == src[si+ml] { ml++ } - if ml < minMatch || ml <= mLen { + if ml+1 < minMatch || ml <= mLen { // Match too small ( 0 && first[0] == '-' { + if first[0] == '-' { //--unknown --next-flag ... return args } //--unknown arg ... (args will be arg ...) - if len(args) > 1 { - return args[1:] - } - return nil + return args[1:] } func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []string, err error) { diff --git a/vendor/github.com/spf13/pflag/string_to_int.go b/vendor/github.com/spf13/pflag/string_to_int.go deleted file mode 100644 index 5ceda3965d..0000000000 --- a/vendor/github.com/spf13/pflag/string_to_int.go +++ /dev/null @@ -1,149 +0,0 @@ -package pflag - -import ( - "bytes" - "fmt" - "strconv" - "strings" -) - -// -- stringToInt Value -type stringToIntValue struct { - value *map[string]int - changed bool -} - -func newStringToIntValue(val map[string]int, p *map[string]int) *stringToIntValue { - ssv := new(stringToIntValue) - ssv.value = p - *ssv.value = val - return ssv -} - -// Format: a=1,b=2 -func (s *stringToIntValue) Set(val string) error { - ss := strings.Split(val, ",") - out := make(map[string]int, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return fmt.Errorf("%s must be formatted as key=value", pair) - } - var err error - out[kv[0]], err = strconv.Atoi(kv[1]) - if err != nil { - return err - } - } - if !s.changed { - *s.value = out - } else { - for k, v := range out { - (*s.value)[k] = v - } - } - s.changed = true - return nil -} - -func (s *stringToIntValue) Type() string { - return "stringToInt" -} - -func (s *stringToIntValue) String() string { - var buf bytes.Buffer - i := 0 - for k, v := range *s.value { - if i > 0 { - buf.WriteRune(',') - } - buf.WriteString(k) - buf.WriteRune('=') - buf.WriteString(strconv.Itoa(v)) - i++ - } - return "[" + buf.String() + "]" -} - -func stringToIntConv(val string) (interface{}, error) { - val = strings.Trim(val, "[]") - // An empty string would cause an empty map - if len(val) == 0 { - return map[string]int{}, nil - } - ss := strings.Split(val, ",") - out := make(map[string]int, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return nil, fmt.Errorf("%s must be formatted as key=value", pair) - } - var err error - out[kv[0]], err = strconv.Atoi(kv[1]) - if err != nil { - return nil, err - } - } - return out, nil -} - -// GetStringToInt return the map[string]int value of a flag with the given name -func (f *FlagSet) GetStringToInt(name string) (map[string]int, error) { - val, err := f.getFlagType(name, "stringToInt", stringToIntConv) - if err != nil { - return map[string]int{}, err - } - return val.(map[string]int), nil -} - -// StringToIntVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]int variable in which to store the values of the multiple flags. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) { - f.VarP(newStringToIntValue(value, p), name, "", usage) -} - -// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) { - f.VarP(newStringToIntValue(value, p), name, shorthand, usage) -} - -// StringToIntVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]int variable in which to store the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToIntVar(p *map[string]int, name string, value map[string]int, usage string) { - CommandLine.VarP(newStringToIntValue(value, p), name, "", usage) -} - -// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash. -func StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string) { - CommandLine.VarP(newStringToIntValue(value, p), name, shorthand, usage) -} - -// StringToInt defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]int variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToInt(name string, value map[string]int, usage string) *map[string]int { - p := map[string]int{} - f.StringToIntVarP(&p, name, "", value, usage) - return &p -} - -// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int { - p := map[string]int{} - f.StringToIntVarP(&p, name, shorthand, value, usage) - return &p -} - -// StringToInt defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]int variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToInt(name string, value map[string]int, usage string) *map[string]int { - return CommandLine.StringToIntP(name, "", value, usage) -} - -// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash. -func StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int { - return CommandLine.StringToIntP(name, shorthand, value, usage) -} diff --git a/vendor/github.com/spf13/pflag/string_to_string.go b/vendor/github.com/spf13/pflag/string_to_string.go deleted file mode 100644 index 890a01afc0..0000000000 --- a/vendor/github.com/spf13/pflag/string_to_string.go +++ /dev/null @@ -1,160 +0,0 @@ -package pflag - -import ( - "bytes" - "encoding/csv" - "fmt" - "strings" -) - -// -- stringToString Value -type stringToStringValue struct { - value *map[string]string - changed bool -} - -func newStringToStringValue(val map[string]string, p *map[string]string) *stringToStringValue { - ssv := new(stringToStringValue) - ssv.value = p - *ssv.value = val - return ssv -} - -// Format: a=1,b=2 -func (s *stringToStringValue) Set(val string) error { - var ss []string - n := strings.Count(val, "=") - switch n { - case 0: - return fmt.Errorf("%s must be formatted as key=value", val) - case 1: - ss = append(ss, strings.Trim(val, `"`)) - default: - r := csv.NewReader(strings.NewReader(val)) - var err error - ss, err = r.Read() - if err != nil { - return err - } - } - - out := make(map[string]string, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return fmt.Errorf("%s must be formatted as key=value", pair) - } - out[kv[0]] = kv[1] - } - if !s.changed { - *s.value = out - } else { - for k, v := range out { - (*s.value)[k] = v - } - } - s.changed = true - return nil -} - -func (s *stringToStringValue) Type() string { - return "stringToString" -} - -func (s *stringToStringValue) String() string { - records := make([]string, 0, len(*s.value)>>1) - for k, v := range *s.value { - records = append(records, k+"="+v) - } - - var buf bytes.Buffer - w := csv.NewWriter(&buf) - if err := w.Write(records); err != nil { - panic(err) - } - w.Flush() - return "[" + strings.TrimSpace(buf.String()) + "]" -} - -func stringToStringConv(val string) (interface{}, error) { - val = strings.Trim(val, "[]") - // An empty string would cause an empty map - if len(val) == 0 { - return map[string]string{}, nil - } - r := csv.NewReader(strings.NewReader(val)) - ss, err := r.Read() - if err != nil { - return nil, err - } - out := make(map[string]string, len(ss)) - for _, pair := range ss { - kv := strings.SplitN(pair, "=", 2) - if len(kv) != 2 { - return nil, fmt.Errorf("%s must be formatted as key=value", pair) - } - out[kv[0]] = kv[1] - } - return out, nil -} - -// GetStringToString return the map[string]string value of a flag with the given name -func (f *FlagSet) GetStringToString(name string) (map[string]string, error) { - val, err := f.getFlagType(name, "stringToString", stringToStringConv) - if err != nil { - return map[string]string{}, err - } - return val.(map[string]string), nil -} - -// StringToStringVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]string variable in which to store the values of the multiple flags. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) { - f.VarP(newStringToStringValue(value, p), name, "", usage) -} - -// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) { - f.VarP(newStringToStringValue(value, p), name, shorthand, usage) -} - -// StringToStringVar defines a string flag with specified name, default value, and usage string. -// The argument p points to a map[string]string variable in which to store the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToStringVar(p *map[string]string, name string, value map[string]string, usage string) { - CommandLine.VarP(newStringToStringValue(value, p), name, "", usage) -} - -// StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash. -func StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string) { - CommandLine.VarP(newStringToStringValue(value, p), name, shorthand, usage) -} - -// StringToString defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]string variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func (f *FlagSet) StringToString(name string, value map[string]string, usage string) *map[string]string { - p := map[string]string{} - f.StringToStringVarP(&p, name, "", value, usage) - return &p -} - -// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash. -func (f *FlagSet) StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string { - p := map[string]string{} - f.StringToStringVarP(&p, name, shorthand, value, usage) - return &p -} - -// StringToString defines a string flag with specified name, default value, and usage string. -// The return value is the address of a map[string]string variable that stores the value of the flag. -// The value of each argument will not try to be separated by comma -func StringToString(name string, value map[string]string, usage string) *map[string]string { - return CommandLine.StringToStringP(name, "", value, usage) -} - -// StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash. -func StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string { - return CommandLine.StringToStringP(name, shorthand, value, usage) -} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/LICENSE b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/LICENSE new file mode 100644 index 0000000000..efc75a2253 --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2017-2018 Tencent Ltd. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/client.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/client.go new file mode 100644 index 0000000000..78f3ce7c72 --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/client.go @@ -0,0 +1,88 @@ +package common + +import ( + "log" + "net/http" + "time" + + tchttp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" +) + +type Client struct { + region string + httpClient *http.Client + httpProfile *profile.HttpProfile + credential *Credential + signMethod string + debug bool +} + +func (c *Client) Send(request tchttp.Request, response tchttp.Response) (err error) { + if request.GetDomain() == "" { + domain := c.httpProfile.Endpoint + if domain == "" { + domain = tchttp.GetServiceDomain(request.GetService()) + } + request.SetDomain(domain) + } + err = tchttp.ConstructParams(request) + if err != nil { + return + } + tchttp.CompleteCommonParams(request, c.GetRegion()) + err = signRequest(request, c.credential, c.signMethod) + if err != nil { + return + } + httpRequest, err := http.NewRequest(request.GetHttpMethod(), request.GetUrl(), request.GetBodyReader()) + if err != nil { + return + } + if request.GetHttpMethod() == "POST" { + httpRequest.Header["Content-Type"] = []string{"application/x-www-form-urlencoded"} + } + //log.Printf("[DEBUG] http request=%v", httpRequest) + httpResponse, err := c.httpClient.Do(httpRequest) + if err != nil { + return err + } + err = tchttp.ParseFromHttpResponse(httpResponse, response) + return +} + +func (c *Client) GetRegion() string { + return c.region +} + +func (c *Client) Init(region string) *Client { + c.httpClient = &http.Client{} + c.region = region + c.signMethod = "HmacSHA256" + c.debug = false + log.SetFlags(log.LstdFlags | log.Lshortfile) + return c +} + +func (c *Client) WithSecretId(secretId, secretKey string) *Client { + c.credential = NewCredential(secretId, secretKey) + return c +} + +func (c *Client) WithProfile(clientProfile *profile.ClientProfile) *Client { + c.signMethod = clientProfile.SignMethod + c.httpProfile = clientProfile.HttpProfile + c.httpClient.Timeout = time.Duration(c.httpProfile.ReqTimeout) * time.Second + return c +} + +func (c *Client) WithSignatureMethod(method string) *Client { + c.signMethod = method + return c +} + +func NewClientWithSecretId(secretId, secretKey, region string) (client *Client, err error) { + client = &Client{} + client.Init(region).WithSecretId(secretId, secretKey) + return +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/credentials.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/credentials.go new file mode 100644 index 0000000000..19f0722de8 --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/credentials.go @@ -0,0 +1,40 @@ +package common + +type Credential struct { + SecretId string + SecretKey string +} + +func NewCredential(secretId, secretKey string) *Credential { + return &Credential{ + SecretId: secretId, + SecretKey: secretKey, + } +} + +func (c *Credential) GetCredentialParams() map[string]string { + return map[string]string{ + "SecretId": c.SecretId, + } +} + +type TokenCredential struct { + SecretId string + SecretKey string + Token string +} + +func NewTokenCredential(secretId, secretKey, token string) *TokenCredential { + return &TokenCredential{ + SecretId: secretId, + SecretKey: secretKey, + Token: token, + } +} + +func (c *TokenCredential) GetCredentialParams() map[string]string { + return map[string]string{ + "SecretId": c.SecretId, + "Token": c.Token, + } +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors/errors.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors/errors.go new file mode 100644 index 0000000000..27589e59a1 --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors/errors.go @@ -0,0 +1,35 @@ +package errors + +import ( + "fmt" +) + +type TencentCloudSDKError struct { + Code string + Message string + RequestId string +} + +func (e *TencentCloudSDKError) Error() string { + return fmt.Sprintf("[TencentCloudSDKError] Code=%s, Message=%s, RequestId=%s", e.Code, e.Message, e.RequestId) +} + +func NewTencentCloudSDKError(code, message, requestId string) error { + return &TencentCloudSDKError{ + Code: code, + Message: message, + RequestId: requestId, + } +} + +func (e *TencentCloudSDKError) GetCode() string { + return e.Code +} + +func (e *TencentCloudSDKError) GetMessage() string { + return e.Message +} + +func (e *TencentCloudSDKError) GetRequestId() string { + return e.RequestId +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go new file mode 100644 index 0000000000..c7a068556a --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go @@ -0,0 +1,231 @@ +package common + +import ( + "io" + //"log" + "math/rand" + "net/url" + "reflect" + "strconv" + "strings" + "time" +) + +const ( + POST = "POST" + GET = "GET" + + RootDomain = "tencentcloudapi.com" + Path = "/" +) + +type Request interface { + GetAction() string + GetBodyReader() io.Reader + GetDomain() string + GetHttpMethod() string + GetParams() map[string]string + GetPath() string + GetService() string + GetUrl() string + GetVersion() string + SetDomain(string) + SetHttpMethod(string) +} + +type BaseRequest struct { + httpMethod string + domain string + path string + params map[string]string + formParams map[string]string + + service string + version string + action string +} + +func (r *BaseRequest) GetAction() string { + return r.action +} + +func (r *BaseRequest) GetHttpMethod() string { + return r.httpMethod +} + +func (r *BaseRequest) GetParams() map[string]string { + return r.params +} + +func (r *BaseRequest) GetPath() string { + return r.path +} + +func (r *BaseRequest) GetDomain() string { + return r.domain +} + +func (r *BaseRequest) SetDomain(domain string) { + r.domain = domain +} + +func (r *BaseRequest) SetHttpMethod(method string) { + switch strings.ToUpper(method) { + case POST: + { + r.httpMethod = POST + } + case GET: + { + r.httpMethod = GET + } + default: + { + r.httpMethod = GET + } + } +} + +func (r *BaseRequest) GetService() string { + return r.service +} + +func (r *BaseRequest) GetUrl() string { + if r.httpMethod == GET { + return "https://" + r.domain + r.path + "?" + getUrlQueriesEncoded(r.params) + } else if r.httpMethod == POST { + return "https://" + r.domain + r.path + } else { + return "" + } +} + +func (r *BaseRequest) GetVersion() string { + return r.version +} + +func getUrlQueriesEncoded(params map[string]string) string { + values := url.Values{} + for key, value := range params { + if value != "" { + values.Add(key, value) + } + } + return values.Encode() +} + +func (r *BaseRequest) GetBodyReader() io.Reader { + if r.httpMethod == POST { + s := getUrlQueriesEncoded(r.params) + //log.Printf("[DEBUG] body: %s", s) + return strings.NewReader(s) + } else { + return strings.NewReader("") + } +} + +func (r *BaseRequest) Init() *BaseRequest { + r.httpMethod = GET + r.domain = "" + r.path = Path + r.params = make(map[string]string) + r.formParams = make(map[string]string) + return r +} + +func (r *BaseRequest) WithApiInfo(service, version, action string) *BaseRequest { + r.service = service + r.version = version + r.action = action + return r +} + +func GetServiceDomain(service string) (domain string) { + domain = service + "." + RootDomain + return +} + +func CompleteCommonParams(request Request, region string) { + params := request.GetParams() + params["Region"] = region + if request.GetVersion() != "" { + params["Version"] = request.GetVersion() + } + params["Action"] = request.GetAction() + params["Timestamp"] = strconv.FormatInt(time.Now().Unix(), 10) + params["Nonce"] = strconv.Itoa(rand.Int()) + params["RequestClient"] = "SDK_GO_3.0.28" +} + +func ConstructParams(req Request) (err error) { + value := reflect.ValueOf(req).Elem() + err = flatStructure(value, req, "") + //log.Printf("[DEBUG] params=%s", req.GetParams()) + return +} + +func flatStructure(value reflect.Value, request Request, prefix string) (err error) { + //log.Printf("[DEBUG] reflect value: %v", value.Type()) + valueType := value.Type() + for i := 0; i < valueType.NumField(); i++ { + tag := valueType.Field(i).Tag + nameTag, hasNameTag := tag.Lookup("name") + if !hasNameTag { + continue + } + field := value.Field(i) + kind := field.Kind() + if kind == reflect.Ptr && field.IsNil() { + continue + } + if kind == reflect.Ptr { + field = field.Elem() + kind = field.Kind() + } + key := prefix + nameTag + if kind == reflect.String { + s := field.String() + if s != "" { + request.GetParams()[key] = s + } + } else if kind == reflect.Bool { + request.GetParams()[key] = strconv.FormatBool(field.Bool()) + } else if kind == reflect.Int || kind == reflect.Int64 { + request.GetParams()[key] = strconv.FormatInt(field.Int(), 10) + } else if kind == reflect.Uint || kind == reflect.Uint64 { + request.GetParams()[key] = strconv.FormatUint(field.Uint(), 10) + } else if kind == reflect.Float64 { + request.GetParams()[key] = strconv.FormatFloat(field.Float(), 'f', -1, 64) + } else if kind == reflect.Slice { + list := value.Field(i) + for j := 0; j < list.Len(); j++ { + vj := list.Index(j) + key := prefix + nameTag + "." + strconv.Itoa(j) + kind = vj.Kind() + if kind == reflect.Ptr && vj.IsNil() { + continue + } + if kind == reflect.Ptr { + vj = vj.Elem() + kind = vj.Kind() + } + if kind == reflect.String { + request.GetParams()[key] = vj.String() + } else if kind == reflect.Bool { + request.GetParams()[key] = strconv.FormatBool(vj.Bool()) + } else if kind == reflect.Int || kind == reflect.Int64 { + request.GetParams()[key] = strconv.FormatInt(vj.Int(), 10) + } else if kind == reflect.Uint || kind == reflect.Uint64 { + request.GetParams()[key] = strconv.FormatUint(vj.Uint(), 10) + } else if kind == reflect.Float64 { + request.GetParams()[key] = strconv.FormatFloat(vj.Float(), 'f', -1, 64) + } else { + flatStructure(vj, request, key+".") + } + } + } else { + flatStructure(reflect.ValueOf(field.Interface()), request, prefix+nameTag+".") + } + } + return +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/response.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/response.go new file mode 100644 index 0000000000..100fca1102 --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/response.go @@ -0,0 +1,69 @@ +package common + +import ( + "encoding/json" + "io/ioutil" + // "log" + "net/http" + + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" +) + +type Response interface { + ParseErrorFromHTTPResponse(body []byte) error +} + +type BaseResponse struct { +} + +type ErrorResponse struct { + Response struct { + Error struct { + Code string `json:"Code"` + Message string `json:"Message"` + } `json:"Error" omitempty` + RequestId string `json:"RequestId"` + } `json:"Response"` +} + +type DeprecatedAPIErrorResponse struct { + Code int `json:"code"` + Message string `json:"message"` + CodeDesc string `json:"codeDesc"` +} + +func (r *BaseResponse) ParseErrorFromHTTPResponse(body []byte) (err error) { + resp := &ErrorResponse{} + err = json.Unmarshal(body, resp) + if err != nil { + return + } + if resp.Response.Error.Code != "" { + return errors.NewTencentCloudSDKError(resp.Response.Error.Code, resp.Response.Error.Message, resp.Response.RequestId) + } + + deprecated := &DeprecatedAPIErrorResponse{} + err = json.Unmarshal(body, deprecated) + if err != nil { + return + } + if deprecated.Code != 0 { + return errors.NewTencentCloudSDKError(deprecated.CodeDesc, deprecated.Message, "") + } + return nil +} + +func ParseFromHttpResponse(hr *http.Response, response Response) (err error) { + defer hr.Body.Close() + body, err := ioutil.ReadAll(hr.Body) + if err != nil { + return + } + //log.Printf("[DEBUG] Response Body=%s", body) + err = response.ParseErrorFromHTTPResponse(body) + if err != nil { + return + } + err = json.Unmarshal(body, &response) + return +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/client_profile.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/client_profile.go new file mode 100644 index 0000000000..94c63b2f03 --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/client_profile.go @@ -0,0 +1,13 @@ +package profile + +type ClientProfile struct { + HttpProfile *HttpProfile + SignMethod string +} + +func NewClientProfile() *ClientProfile { + return &ClientProfile{ + HttpProfile: NewHttpProfile(), + SignMethod: "HmacSHA256", + } +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/http_profile.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/http_profile.go new file mode 100644 index 0000000000..8d4bf8f57b --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile/http_profile.go @@ -0,0 +1,17 @@ +package profile + +type HttpProfile struct { + ReqMethod string + ReqTimeout int + Endpoint string + Protocol string +} + +func NewHttpProfile() *HttpProfile { + return &HttpProfile{ + ReqMethod: "POST", + ReqTimeout: 60, + Endpoint: "", + Protocol: "HTTPS", + } +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/sign.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/sign.go new file mode 100644 index 0000000000..450fe2ccde --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/sign.go @@ -0,0 +1,75 @@ +package common + +import ( + "crypto/hmac" + "crypto/sha1" + "crypto/sha256" + "encoding/base64" + "fmt" + "sort" + "strings" + + tchttp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http" +) + +const ( + SHA256 = "HmacSHA256" + SHA1 = "HmacSHA1" +) + +func Sign(s, secretKey, method string) string { + hashed := hmac.New(sha1.New, []byte(secretKey)) + if method == SHA256 { + hashed = hmac.New(sha256.New, []byte(secretKey)) + } + hashed.Write([]byte(s)) + + return base64.StdEncoding.EncodeToString(hashed.Sum(nil)) +} + +func signRequest(request tchttp.Request, credential *Credential, method string) (err error) { + if method != SHA256 { + method = SHA1 + } + checkAuthParams(request, credential, method) + s := getStringToSign(request) + signature := Sign(s, credential.SecretKey, method) + request.GetParams()["Signature"] = signature + return +} + +func checkAuthParams(request tchttp.Request, credential *Credential, method string) { + params := request.GetParams() + credentialParams := credential.GetCredentialParams() + for key, value := range credentialParams { + params[key] = value + } + params["SignatureMethod"] = method + delete(params, "Signature") +} + +func getStringToSign(request tchttp.Request) string { + method := request.GetHttpMethod() + domain := request.GetDomain() + path := request.GetPath() + + text := method + domain + path + "?" + + params := request.GetParams() + // sort params + keys := make([]string, 0, len(params)) + for k, _ := range params { + keys = append(keys, k) + } + sort.Strings(keys) + + for i := range keys { + k := keys[i] + if params[k] == "" { + continue + } + text += fmt.Sprintf("%v=%v&", strings.Replace(k, "_", ".", -1), params[k]) + } + text = text[:len(text)-1] + return text +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/types.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/types.go new file mode 100644 index 0000000000..ec2c786dbf --- /dev/null +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/types.go @@ -0,0 +1,47 @@ +package common + +func IntPtr(v int) *int { + return &v +} + +func Int64Ptr(v int64) *int64 { + return &v +} + +func UintPtr(v uint) *uint { + return &v +} + +func Uint64Ptr(v uint64) *uint64 { + return &v +} + +func Float64Ptr(v float64) *float64 { + return &v +} + +func StringPtr(v string) *string { + return &v +} + +func StringValues(ptrs []*string) []string { + values := make([]string, len(ptrs)) + for i := 0; i < len(ptrs); i++ { + if ptrs[i] != nil { + values[i] = *ptrs[i] + } + } + return values +} + +func StringPtrs(vals []string) []*string { + ptrs := make([]*string, len(vals)) + for i := 0; i < len(vals); i++ { + ptrs[i] = &vals[i] + } + return ptrs +} + +func BoolPtr(v bool) *bool { + return &v +} diff --git a/vendor/github.com/vmware/govmomi/.mailmap b/vendor/github.com/vmware/govmomi/.mailmap index d3fcbc5bfe..704c5b736c 100644 --- a/vendor/github.com/vmware/govmomi/.mailmap +++ b/vendor/github.com/vmware/govmomi/.mailmap @@ -19,6 +19,3 @@ Anfernee Yongkun Gui Anfernee Yongkun Gui Yongkun Anfernee Gui Zach Tucker Zee Yang -Jiatong Wang jiatongw -Uwe Bessle Uwe Bessle -Uwe Bessle Uwe Bessle diff --git a/vendor/github.com/vmware/govmomi/CHANGELOG.md b/vendor/github.com/vmware/govmomi/CHANGELOG.md index aef1957569..c8afb958f4 100644 --- a/vendor/github.com/vmware/govmomi/CHANGELOG.md +++ b/vendor/github.com/vmware/govmomi/CHANGELOG.md @@ -1,12 +1,6 @@ # changelog -### 0.19.0 (2018-09-30) - -* New vapi/rest and and vapi/tags packages - -* Allowing the use of STS for exchanging tokens - -* Add object.VirtualMachine.UUID method +### unreleased * SetRootCAs on the soap.Client returns an error for invalid certificates diff --git a/vendor/github.com/vmware/govmomi/CONTRIBUTORS b/vendor/github.com/vmware/govmomi/CONTRIBUTORS index d2a9a7aaa9..1fd37b609d 100644 --- a/vendor/github.com/vmware/govmomi/CONTRIBUTORS +++ b/vendor/github.com/vmware/govmomi/CONTRIBUTORS @@ -29,7 +29,6 @@ Cédric Blomart Chris Marchesi Christian Höltje Clint Greenwood -CuiHaozhi Danny Lockard Dave Tucker Davide Agnello @@ -43,7 +42,6 @@ Erik Hollensbe Fabio Rapposelli Faiyaz Ahmed forkbomber -freebsdly Gavin Gray Gavrie Philipson George Hicken @@ -56,27 +54,17 @@ Ivan Porto Carrero Jason Kincl Jeremy Canady jeremy-clerc -Jiatong Wang João Pereira Jorge Sevilla -kayrus -Kevin George leslie-qiwa Louie Jiang Marc Carmier -Maria Ntalla -Marin Atanasov Nikolov Matthew Cosgrove -Matt Moriarity Mevan Samaratunga -Michal Jankowski -mingwei Nicolas Lamirault Omar Kohl Parham Alvani Pieter Noordhuis -prydin -Rowan Jacobs runner.mei S.Çağlar Onur Sergey Ignatov @@ -86,7 +74,6 @@ tanishi Ted Zlatanov Thibaut Ackermann Trevor Dawe -Uwe Bessle Vadim Egorov Volodymyr Bobyr Witold Krecicki diff --git a/vendor/github.com/vmware/govmomi/README.md b/vendor/github.com/vmware/govmomi/README.md index da5d426ea2..5cd8c5adf6 100644 --- a/vendor/github.com/vmware/govmomi/README.md +++ b/vendor/github.com/vmware/govmomi/README.md @@ -75,8 +75,6 @@ Refer to the [CHANGELOG](CHANGELOG.md) for version to version changes. * [Libretto](https://github.com/apcera/libretto/tree/master/virtualmachine/vsphere) -* [Telegraf](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/vsphere) - ## Related projects * [rbvmomi](https://github.com/vmware/rbvmomi) diff --git a/vendor/github.com/vmware/govmomi/session/keep_alive.go b/vendor/github.com/vmware/govmomi/session/keep_alive.go index 3b44f5ffb6..a9d4c141c9 100644 --- a/vendor/github.com/vmware/govmomi/session/keep_alive.go +++ b/vendor/github.com/vmware/govmomi/session/keep_alive.go @@ -114,9 +114,10 @@ func (k *keepAlive) RoundTrip(ctx context.Context, req, res soap.HasFault) error if err != nil { return err } + // Start ticker on login, stop ticker on logout. switch req.(type) { - case *methods.LoginBody, *methods.LoginExtensionByCertificateBody, *methods.LoginByTokenBody: + case *methods.LoginBody, *methods.LoginExtensionByCertificateBody: k.start() case *methods.LogoutBody: k.stop() diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go index 122c03e70a..d0f4825319 100644 --- a/vendor/golang.org/x/crypto/ssh/server.go +++ b/vendor/golang.org/x/crypto/ssh/server.go @@ -404,7 +404,7 @@ userAuthLoop: perms, authErr = config.PasswordCallback(s, password) case "keyboard-interactive": if config.KeyboardInteractiveCallback == nil { - authErr = errors.New("ssh: keyboard-interactive auth not configured") + authErr = errors.New("ssh: keyboard-interactive auth not configubred") break } diff --git a/vendor/golang.org/x/net/bpf/constants.go b/vendor/golang.org/x/net/bpf/constants.go index 12f3ee835a..b89ca35239 100644 --- a/vendor/golang.org/x/net/bpf/constants.go +++ b/vendor/golang.org/x/net/bpf/constants.go @@ -38,7 +38,6 @@ const ( type JumpTest uint16 // Supported operators for conditional jumps. -// K can be RegX for JumpIfX const ( // K == A JumpEqual JumpTest = iota @@ -135,9 +134,12 @@ const ( opMaskLoadDest = 0x01 opMaskLoadWidth = 0x18 opMaskLoadMode = 0xe0 - // opClsALU & opClsJump - opMaskOperand = 0x08 - opMaskOperator = 0xf0 + // opClsALU + opMaskOperandSrc = 0x08 + opMaskOperator = 0xf0 + // opClsJump + opMaskJumpConst = 0x0f + opMaskJumpCond = 0xf0 ) const ( @@ -190,21 +192,15 @@ const ( opLoadWidth1 ) -// Operand for ALU and Jump instructions -type opOperand uint16 +// Operator defined by ALUOp* -// Supported operand sources. const ( - opOperandConstant opOperand = iota << 3 - opOperandX + opALUSrcConstant uint16 = iota << 3 + opALUSrcX ) -// An jumpOp is a conditional jump condition. -type jumpOp uint16 - -// Supported jump conditions. const ( - opJumpAlways jumpOp = iota << 4 + opJumpAlways = iota << 4 opJumpEqual opJumpGT opJumpGE diff --git a/vendor/golang.org/x/net/bpf/instructions.go b/vendor/golang.org/x/net/bpf/instructions.go index 3cffcaa014..f9dc0e8ee7 100644 --- a/vendor/golang.org/x/net/bpf/instructions.go +++ b/vendor/golang.org/x/net/bpf/instructions.go @@ -89,14 +89,10 @@ func (ri RawInstruction) Disassemble() Instruction { case opClsALU: switch op := ALUOp(ri.Op & opMaskOperator); op { case ALUOpAdd, ALUOpSub, ALUOpMul, ALUOpDiv, ALUOpOr, ALUOpAnd, ALUOpShiftLeft, ALUOpShiftRight, ALUOpMod, ALUOpXor: - switch operand := opOperand(ri.Op & opMaskOperand); operand { - case opOperandX: + if ri.Op&opMaskOperandSrc != 0 { return ALUOpX{Op: op} - case opOperandConstant: - return ALUOpConstant{Op: op, Val: ri.K} - default: - return ri } + return ALUOpConstant{Op: op, Val: ri.K} case aluOpNeg: return NegateA{} default: @@ -104,18 +100,63 @@ func (ri RawInstruction) Disassemble() Instruction { } case opClsJump: - switch op := jumpOp(ri.Op & opMaskOperator); op { + if ri.Op&opMaskJumpConst != opClsJump { + return ri + } + switch ri.Op & opMaskJumpCond { case opJumpAlways: return Jump{Skip: ri.K} - case opJumpEqual, opJumpGT, opJumpGE, opJumpSet: - cond, skipTrue, skipFalse := jumpOpToTest(op, ri.Jt, ri.Jf) - switch operand := opOperand(ri.Op & opMaskOperand); operand { - case opOperandX: - return JumpIfX{Cond: cond, SkipTrue: skipTrue, SkipFalse: skipFalse} - case opOperandConstant: - return JumpIf{Cond: cond, Val: ri.K, SkipTrue: skipTrue, SkipFalse: skipFalse} - default: - return ri + case opJumpEqual: + if ri.Jt == 0 { + return JumpIf{ + Cond: JumpNotEqual, + Val: ri.K, + SkipTrue: ri.Jf, + SkipFalse: 0, + } + } + return JumpIf{ + Cond: JumpEqual, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, + } + case opJumpGT: + if ri.Jt == 0 { + return JumpIf{ + Cond: JumpLessOrEqual, + Val: ri.K, + SkipTrue: ri.Jf, + SkipFalse: 0, + } + } + return JumpIf{ + Cond: JumpGreaterThan, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, + } + case opJumpGE: + if ri.Jt == 0 { + return JumpIf{ + Cond: JumpLessThan, + Val: ri.K, + SkipTrue: ri.Jf, + SkipFalse: 0, + } + } + return JumpIf{ + Cond: JumpGreaterOrEqual, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, + } + case opJumpSet: + return JumpIf{ + Cond: JumpBitsSet, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, } default: return ri @@ -146,41 +187,6 @@ func (ri RawInstruction) Disassemble() Instruction { } } -func jumpOpToTest(op jumpOp, skipTrue uint8, skipFalse uint8) (JumpTest, uint8, uint8) { - var test JumpTest - - // Decode "fake" jump conditions that don't appear in machine code - // Ensures the Assemble -> Disassemble stage recreates the same instructions - // See https://github.com/golang/go/issues/18470 - if skipTrue == 0 { - switch op { - case opJumpEqual: - test = JumpNotEqual - case opJumpGT: - test = JumpLessOrEqual - case opJumpGE: - test = JumpLessThan - case opJumpSet: - test = JumpBitsNotSet - } - - return test, skipFalse, 0 - } - - switch op { - case opJumpEqual: - test = JumpEqual - case opJumpGT: - test = JumpGreaterThan - case opJumpGE: - test = JumpGreaterOrEqual - case opJumpSet: - test = JumpBitsSet - } - - return test, skipTrue, skipFalse -} - // LoadConstant loads Val into register Dst. type LoadConstant struct { Dst Register @@ -407,7 +413,7 @@ type ALUOpConstant struct { // Assemble implements the Instruction Assemble method. func (a ALUOpConstant) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsALU | uint16(opOperandConstant) | uint16(a.Op), + Op: opClsALU | opALUSrcConstant | uint16(a.Op), K: a.Val, }, nil } @@ -448,7 +454,7 @@ type ALUOpX struct { // Assemble implements the Instruction Assemble method. func (a ALUOpX) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsALU | uint16(opOperandX) | uint16(a.Op), + Op: opClsALU | opALUSrcX | uint16(a.Op), }, nil } @@ -503,7 +509,7 @@ type Jump struct { // Assemble implements the Instruction Assemble method. func (a Jump) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsJump | uint16(opJumpAlways), + Op: opClsJump | opJumpAlways, K: a.Skip, }, nil } @@ -524,39 +530,11 @@ type JumpIf struct { // Assemble implements the Instruction Assemble method. func (a JumpIf) Assemble() (RawInstruction, error) { - return jumpToRaw(a.Cond, opOperandConstant, a.Val, a.SkipTrue, a.SkipFalse) -} - -// String returns the instruction in assembler notation. -func (a JumpIf) String() string { - return jumpToString(a.Cond, fmt.Sprintf("#%d", a.Val), a.SkipTrue, a.SkipFalse) -} - -// JumpIfX skips the following Skip instructions in the program if A -// X is true. -type JumpIfX struct { - Cond JumpTest - SkipTrue uint8 - SkipFalse uint8 -} - -// Assemble implements the Instruction Assemble method. -func (a JumpIfX) Assemble() (RawInstruction, error) { - return jumpToRaw(a.Cond, opOperandX, 0, a.SkipTrue, a.SkipFalse) -} - -// String returns the instruction in assembler notation. -func (a JumpIfX) String() string { - return jumpToString(a.Cond, "x", a.SkipTrue, a.SkipFalse) -} - -// jumpToRaw assembles a jump instruction into a RawInstruction -func jumpToRaw(test JumpTest, operand opOperand, k uint32, skipTrue, skipFalse uint8) (RawInstruction, error) { var ( - cond jumpOp + cond uint16 flip bool ) - switch test { + switch a.Cond { case JumpEqual: cond = opJumpEqual case JumpNotEqual: @@ -574,63 +552,63 @@ func jumpToRaw(test JumpTest, operand opOperand, k uint32, skipTrue, skipFalse u case JumpBitsNotSet: cond, flip = opJumpSet, true default: - return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", test) + return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", a.Cond) } - jt, jf := skipTrue, skipFalse + jt, jf := a.SkipTrue, a.SkipFalse if flip { jt, jf = jf, jt } return RawInstruction{ - Op: opClsJump | uint16(cond) | uint16(operand), + Op: opClsJump | cond, Jt: jt, Jf: jf, - K: k, + K: a.Val, }, nil } -// jumpToString converts a jump instruction to assembler notation -func jumpToString(cond JumpTest, operand string, skipTrue, skipFalse uint8) string { - switch cond { +// String returns the instruction in assembler notation. +func (a JumpIf) String() string { + switch a.Cond { // K == A case JumpEqual: - return conditionalJump(operand, skipTrue, skipFalse, "jeq", "jneq") + return conditionalJump(a, "jeq", "jneq") // K != A case JumpNotEqual: - return fmt.Sprintf("jneq %s,%d", operand, skipTrue) + return fmt.Sprintf("jneq #%d,%d", a.Val, a.SkipTrue) // K > A case JumpGreaterThan: - return conditionalJump(operand, skipTrue, skipFalse, "jgt", "jle") + return conditionalJump(a, "jgt", "jle") // K < A case JumpLessThan: - return fmt.Sprintf("jlt %s,%d", operand, skipTrue) + return fmt.Sprintf("jlt #%d,%d", a.Val, a.SkipTrue) // K >= A case JumpGreaterOrEqual: - return conditionalJump(operand, skipTrue, skipFalse, "jge", "jlt") + return conditionalJump(a, "jge", "jlt") // K <= A case JumpLessOrEqual: - return fmt.Sprintf("jle %s,%d", operand, skipTrue) + return fmt.Sprintf("jle #%d,%d", a.Val, a.SkipTrue) // K & A != 0 case JumpBitsSet: - if skipFalse > 0 { - return fmt.Sprintf("jset %s,%d,%d", operand, skipTrue, skipFalse) + if a.SkipFalse > 0 { + return fmt.Sprintf("jset #%d,%d,%d", a.Val, a.SkipTrue, a.SkipFalse) } - return fmt.Sprintf("jset %s,%d", operand, skipTrue) + return fmt.Sprintf("jset #%d,%d", a.Val, a.SkipTrue) // K & A == 0, there is no assembler instruction for JumpBitNotSet, use JumpBitSet and invert skips case JumpBitsNotSet: - return jumpToString(JumpBitsSet, operand, skipFalse, skipTrue) + return JumpIf{Cond: JumpBitsSet, SkipTrue: a.SkipFalse, SkipFalse: a.SkipTrue, Val: a.Val}.String() default: - return fmt.Sprintf("unknown JumpTest %#v", cond) + return fmt.Sprintf("unknown instruction: %#v", a) } } -func conditionalJump(operand string, skipTrue, skipFalse uint8, positiveJump, negativeJump string) string { - if skipTrue > 0 { - if skipFalse > 0 { - return fmt.Sprintf("%s %s,%d,%d", positiveJump, operand, skipTrue, skipFalse) +func conditionalJump(inst JumpIf, positiveJump, negativeJump string) string { + if inst.SkipTrue > 0 { + if inst.SkipFalse > 0 { + return fmt.Sprintf("%s #%d,%d,%d", positiveJump, inst.Val, inst.SkipTrue, inst.SkipFalse) } - return fmt.Sprintf("%s %s,%d", positiveJump, operand, skipTrue) + return fmt.Sprintf("%s #%d,%d", positiveJump, inst.Val, inst.SkipTrue) } - return fmt.Sprintf("%s %s,%d", negativeJump, operand, skipFalse) + return fmt.Sprintf("%s #%d,%d", negativeJump, inst.Val, inst.SkipFalse) } // RetA exits the BPF program, returning the value of register A. diff --git a/vendor/golang.org/x/net/bpf/vm.go b/vendor/golang.org/x/net/bpf/vm.go index 73f57f1f72..4c656f1e12 100644 --- a/vendor/golang.org/x/net/bpf/vm.go +++ b/vendor/golang.org/x/net/bpf/vm.go @@ -35,13 +35,6 @@ func NewVM(filter []Instruction) (*VM, error) { if check <= int(ins.SkipFalse) { return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) } - case JumpIfX: - if check <= int(ins.SkipTrue) { - return nil, fmt.Errorf("cannot jump %d instructions in true case; jumping past program bounds", ins.SkipTrue) - } - if check <= int(ins.SkipFalse) { - return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) - } // Check for division or modulus by zero case ALUOpConstant: if ins.Val != 0 { @@ -116,9 +109,6 @@ func (v *VM) Run(in []byte) (int, error) { case JumpIf: jump := jumpIf(ins, regA) i += jump - case JumpIfX: - jump := jumpIfX(ins, regA, regX) - i += jump case LoadAbsolute: regA, ok = loadAbsolute(ins, in) case LoadConstant: diff --git a/vendor/golang.org/x/net/bpf/vm_instructions.go b/vendor/golang.org/x/net/bpf/vm_instructions.go index f0d2e55bdc..516f9462b9 100644 --- a/vendor/golang.org/x/net/bpf/vm_instructions.go +++ b/vendor/golang.org/x/net/bpf/vm_instructions.go @@ -55,41 +55,34 @@ func aluOpCommon(op ALUOp, regA uint32, value uint32) uint32 { } } -func jumpIf(ins JumpIf, regA uint32) int { - return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, ins.Val) -} - -func jumpIfX(ins JumpIfX, regA uint32, regX uint32) int { - return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, regX) -} - -func jumpIfCommon(cond JumpTest, skipTrue, skipFalse uint8, regA uint32, value uint32) int { +func jumpIf(ins JumpIf, value uint32) int { var ok bool + inV := uint32(ins.Val) - switch cond { + switch ins.Cond { case JumpEqual: - ok = regA == value + ok = value == inV case JumpNotEqual: - ok = regA != value + ok = value != inV case JumpGreaterThan: - ok = regA > value + ok = value > inV case JumpLessThan: - ok = regA < value + ok = value < inV case JumpGreaterOrEqual: - ok = regA >= value + ok = value >= inV case JumpLessOrEqual: - ok = regA <= value + ok = value <= inV case JumpBitsSet: - ok = (regA & value) != 0 + ok = (value & inV) != 0 case JumpBitsNotSet: - ok = (regA & value) == 0 + ok = (value & inV) == 0 } if ok { - return int(skipTrue) + return int(ins.SkipTrue) } - return int(skipFalse) + return int(ins.SkipFalse) } func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) { diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 7943853ff1..ec8e613226 100755 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -193,7 +193,6 @@ struct ltchars { #include #include #include -#include #include #include #include @@ -446,7 +445,6 @@ ccflags="$@" $2 ~ /^(MS|MNT|UMOUNT)_/ || $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || $2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ || - $2 ~ /^KEXEC_/ || $2 ~ /^LINUX_REBOOT_CMD_/ || $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || $2 !~ "NLA_TYPE_MASK" && diff --git a/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl b/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl index a354df5a6b..3e6ed9df8e 100755 --- a/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl +++ b/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl @@ -92,11 +92,6 @@ while(<>) { my @in = parseparamlist($in); my @out = parseparamlist($out); - # Try in vain to keep people from editing this file. - # The theory is that they jump into the middle of the file - # without reading the header. - $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"; - # So file name. if($modname eq "") { $modname = "libc"; diff --git a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl index 20632e1460..49f186f832 100755 --- a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl +++ b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl @@ -32,7 +32,6 @@ my @headers = qw ( sys/sem.h sys/shm.h sys/vmmeter.h - uvm/uvmexp.h uvm/uvm_param.h uvm/uvm_swap_encrypt.h ddb/db_var.h diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index 9dd2f32f50..f153c0673d 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -12,7 +12,7 @@ import "unsafe" // Round the length of a raw sockaddr up to align it properly. func cmsgAlignOf(salen int) int { - salign := SizeofPtr + salign := sizeofPtr // NOTE: It seems like 64-bit Darwin, DragonFly BSD and // Solaris kernels still require 32-bit aligned access to // network subsystem. diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index bfa20a971d..02cf204a12 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1122,7 +1122,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro // The ptrace syscall differs from glibc's ptrace. // Peeks returns the word in *data, not as the return value. - var buf [SizeofPtr]byte + var buf [sizeofPtr]byte // Leading edge. PEEKTEXT/PEEKDATA don't require aligned // access (PEEKUSER warns that it might), but if we don't @@ -1130,12 +1130,12 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro // boundary and not get the bytes leading up to the page // boundary. n := 0 - if addr%SizeofPtr != 0 { - err = ptrace(req, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if addr%sizeofPtr != 0 { + err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return 0, err } - n += copy(out, buf[addr%SizeofPtr:]) + n += copy(out, buf[addr%sizeofPtr:]) out = out[n:] } @@ -1173,15 +1173,15 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c // Leading edge. n := 0 - if addr%SizeofPtr != 0 { - var buf [SizeofPtr]byte - err = ptrace(peekReq, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if addr%sizeofPtr != 0 { + var buf [sizeofPtr]byte + err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return 0, err } - n += copy(buf[addr%SizeofPtr:], data) + n += copy(buf[addr%sizeofPtr:], data) word := *((*uintptr)(unsafe.Pointer(&buf[0]))) - err = ptrace(pokeReq, pid, addr-addr%SizeofPtr, word) + err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word) if err != nil { return 0, err } @@ -1189,19 +1189,19 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c } // Interior. - for len(data) > SizeofPtr { + for len(data) > sizeofPtr { word := *((*uintptr)(unsafe.Pointer(&data[0]))) err = ptrace(pokeReq, pid, addr+uintptr(n), word) if err != nil { return n, err } - n += SizeofPtr - data = data[SizeofPtr:] + n += sizeofPtr + data = data[sizeofPtr:] } // Trailing edge. if len(data) > 0 { - var buf [SizeofPtr]byte + var buf [sizeofPtr]byte err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return n, err diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 5247d9f908..5f9b2454ad 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -160,16 +160,3 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { } return poll(&fds[0], len(fds), timeout) } - -//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) - -func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { - cmdlineLen := len(cmdline) - if cmdlineLen > 0 { - // Account for the additional NULL byte added by - // BytePtrFromString in kexecFileLoad. The kexec_file_load - // syscall expects a NULL-terminated string. - cmdlineLen++ - } - return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) -} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 41451854bc..6a38dfd5b1 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -136,16 +136,3 @@ func SyncFileRange(fd int, off int64, n int64, flags int) error { // order of their arguments. return syncFileRange2(fd, flags, off, n) } - -//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) - -func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { - cmdlineLen := len(cmdline) - if cmdlineLen > 0 { - // Account for the additional NULL byte added by - // BytePtrFromString in kexecFileLoad. The kexec_file_load - // syscall expects a NULL-terminated string. - cmdlineLen++ - } - return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) -} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index f52f148f9f..6e4ee0cf2a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -322,16 +322,3 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { } return poll(&fds[0], len(fds), timeout) } - -//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) - -func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { - cmdlineLen := len(cmdline) - if cmdlineLen > 0 { - // Account for the additional NULL byte added by - // BytePtrFromString in kexecFileLoad. The kexec_file_load - // syscall expects a NULL-terminated string. - cmdlineLen++ - } - return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) -} diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 206ce2af80..639bcdef74 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -100,14 +100,14 @@ func SysctlClockinfo(name string) (*Clockinfo, error) { } n := uintptr(SizeofClockinfo) - var ci Clockinfo - if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil { + buf := make([]byte, SizeofClockinfo) + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { return nil, err } if n != SizeofClockinfo { return nil, EIO } - return &ci, nil + return (*Clockinfo)(unsafe.Pointer(&buf[0])), nil } //sysnb pipe() (fd1 int, fd2 int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 2c674a5c8a..07e6669cab 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -43,23 +43,6 @@ func nametomib(name string) (mib []_C_int, err error) { return nil, EINVAL } -func SysctlUvmexp(name string) (*Uvmexp, error) { - mib, err := sysctlmib(name) - if err != nil { - return nil, err - } - - n := uintptr(SizeofUvmexp) - var u Uvmexp - if err := sysctl(mib, (*byte)(unsafe.Pointer(&u)), &n, nil, 0); err != nil { - return nil, err - } - if n != SizeofUvmexp { - return nil, EIO - } - return &u, nil -} - //sysnb pipe(p *[2]_C_int) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 64fcda4aef..13956b7954 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -22,10 +22,10 @@ var ( ) const ( - darwin64Bit = runtime.GOOS == "darwin" && SizeofPtr == 8 - dragonfly64Bit = runtime.GOOS == "dragonfly" && SizeofPtr == 8 - netbsd32Bit = runtime.GOOS == "netbsd" && SizeofPtr == 4 - solaris64Bit = runtime.GOOS == "solaris" && SizeofPtr == 8 + darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 + dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 + netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4 + solaris64Bit = runtime.GOOS == "solaris" && sizeofPtr == 8 ) // Do the interface allocations only once for common diff --git a/vendor/golang.org/x/sys/unix/types_aix.go b/vendor/golang.org/x/sys/unix/types_aix.go index 25e834940d..18fbddd52c 100644 --- a/vendor/golang.org/x/sys/unix/types_aix.go +++ b/vendor/golang.org/x/sys/unix/types_aix.go @@ -59,14 +59,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics +// Machine characteristics; for internal use. const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong PathMax = C.PATH_MAX ) diff --git a/vendor/golang.org/x/sys/unix/types_darwin.go b/vendor/golang.org/x/sys/unix/types_darwin.go index 9fd2aaa6a2..46b9908e03 100644 --- a/vendor/golang.org/x/sys/unix/types_darwin.go +++ b/vendor/golang.org/x/sys/unix/types_darwin.go @@ -70,14 +70,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics +// Machine characteristics; for internal use. const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_dragonfly.go b/vendor/golang.org/x/sys/unix/types_dragonfly.go index 3365dd79d0..386d5f89ff 100644 --- a/vendor/golang.org/x/sys/unix/types_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/types_dragonfly.go @@ -65,14 +65,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics +// Machine characteristics; for internal use. const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_freebsd.go b/vendor/golang.org/x/sys/unix/types_freebsd.go index a0a5843b92..e84a892d63 100644 --- a/vendor/golang.org/x/sys/unix/types_freebsd.go +++ b/vendor/golang.org/x/sys/unix/types_freebsd.go @@ -154,14 +154,14 @@ struct if_msghdr8 { */ import "C" -// Machine characteristics +// Machine characteristics; for internal use. const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_netbsd.go b/vendor/golang.org/x/sys/unix/types_netbsd.go index 1edbf1ba71..c49621ce52 100644 --- a/vendor/golang.org/x/sys/unix/types_netbsd.go +++ b/vendor/golang.org/x/sys/unix/types_netbsd.go @@ -67,14 +67,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics +// Machine characteristics; for internal use. const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_openbsd.go b/vendor/golang.org/x/sys/unix/types_openbsd.go index 297e40d37e..8f2fe704c8 100644 --- a/vendor/golang.org/x/sys/unix/types_openbsd.go +++ b/vendor/golang.org/x/sys/unix/types_openbsd.go @@ -38,7 +38,6 @@ package unix #include #include #include -#include #include #include #include @@ -67,14 +66,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics +// Machine characteristics; for internal use. const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong ) // Basic types @@ -264,9 +263,3 @@ const ( // Uname type Utsname C.struct_utsname - -// Uvmexp - -const SizeofUvmexp = C.sizeof_struct_uvmexp - -type Uvmexp C.struct_uvmexp diff --git a/vendor/golang.org/x/sys/unix/types_solaris.go b/vendor/golang.org/x/sys/unix/types_solaris.go index 2b716f9348..8cef71bd45 100644 --- a/vendor/golang.org/x/sys/unix/types_solaris.go +++ b/vendor/golang.org/x/sys/unix/types_solaris.go @@ -75,14 +75,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics +// Machine characteristics; for internal use. const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong PathMax = C.PATH_MAX MaxHostNameLen = C.MAXHOSTNAMELEN ) diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 86b980a5aa..fe564160bf 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -879,26 +879,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 286311572e..dcfa667495 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -879,26 +879,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 1b58da1e78..c2ef50c658 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 08377eb4fb..1a820d668f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -881,26 +881,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index 5de2c7aa40..b515b2a63f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 51015f354e..29a88f0e5e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index fdd388debd..0767ac1b0d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 2d15046129..269b813182 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index cd8fcd35ce..eb52e9689f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x400 IXON = 0x200 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index cdb6088760..0563d34b31 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x400 IXON = 0x200 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 9e9472bec5..e95e3f6778 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index f33d031add..bad17418e8 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -878,26 +878,6 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 - KEXEC_ARCH_386 = 0x30000 - KEXEC_ARCH_68K = 0x40000 - KEXEC_ARCH_AARCH64 = 0xb70000 - KEXEC_ARCH_ARM = 0x280000 - KEXEC_ARCH_DEFAULT = 0x0 - KEXEC_ARCH_IA_64 = 0x320000 - KEXEC_ARCH_MASK = 0xffff0000 - KEXEC_ARCH_MIPS = 0x80000 - KEXEC_ARCH_MIPS_LE = 0xa0000 - KEXEC_ARCH_PPC = 0x140000 - KEXEC_ARCH_PPC64 = 0x150000 - KEXEC_ARCH_S390 = 0x160000 - KEXEC_ARCH_SH = 0x2a0000 - KEXEC_ARCH_X86_64 = 0x3e0000 - KEXEC_FILE_NO_INITRAMFS = 0x4 - KEXEC_FILE_ON_CRASH = 0x2 - KEXEC_FILE_UNLOAD = 0x1 - KEXEC_ON_CRASH = 0x1 - KEXEC_PRESERVE_CONTEXT = 0x2 - KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index ba93f3e53c..7fdc85b172 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -1,10 +1,10 @@ -// mkerrors.sh -Wall -Werror -static -I/tmp/include -// Code generated by the command above; see README.md. DO NOT EDIT. +// mkerrors.sh -m64 +// Code generated by the command above; DO NOT EDIT. // +build sparc64,linux -// Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go package unix @@ -1969,182 +1969,174 @@ const ( ) // Error table -var errorList = [...]struct { - num syscall.Errno - name string - desc string -}{ - {1, "EPERM", "operation not permitted"}, - {2, "ENOENT", "no such file or directory"}, - {3, "ESRCH", "no such process"}, - {4, "EINTR", "interrupted system call"}, - {5, "EIO", "input/output error"}, - {6, "ENXIO", "no such device or address"}, - {7, "E2BIG", "argument list too long"}, - {8, "ENOEXEC", "exec format error"}, - {9, "EBADF", "bad file descriptor"}, - {10, "ECHILD", "no child processes"}, - {11, "EAGAIN", "resource temporarily unavailable"}, - {12, "ENOMEM", "cannot allocate memory"}, - {13, "EACCES", "permission denied"}, - {14, "EFAULT", "bad address"}, - {15, "ENOTBLK", "block device required"}, - {16, "EBUSY", "device or resource busy"}, - {17, "EEXIST", "file exists"}, - {18, "EXDEV", "invalid cross-device link"}, - {19, "ENODEV", "no such device"}, - {20, "ENOTDIR", "not a directory"}, - {21, "EISDIR", "is a directory"}, - {22, "EINVAL", "invalid argument"}, - {23, "ENFILE", "too many open files in system"}, - {24, "EMFILE", "too many open files"}, - {25, "ENOTTY", "inappropriate ioctl for device"}, - {26, "ETXTBSY", "text file busy"}, - {27, "EFBIG", "file too large"}, - {28, "ENOSPC", "no space left on device"}, - {29, "ESPIPE", "illegal seek"}, - {30, "EROFS", "read-only file system"}, - {31, "EMLINK", "too many links"}, - {32, "EPIPE", "broken pipe"}, - {33, "EDOM", "numerical argument out of domain"}, - {34, "ERANGE", "numerical result out of range"}, - {36, "EINPROGRESS", "operation now in progress"}, - {37, "EALREADY", "operation already in progress"}, - {38, "ENOTSOCK", "socket operation on non-socket"}, - {39, "EDESTADDRREQ", "destination address required"}, - {40, "EMSGSIZE", "message too long"}, - {41, "EPROTOTYPE", "protocol wrong type for socket"}, - {42, "ENOPROTOOPT", "protocol not available"}, - {43, "EPROTONOSUPPORT", "protocol not supported"}, - {44, "ESOCKTNOSUPPORT", "socket type not supported"}, - {45, "ENOTSUP", "operation not supported"}, - {46, "EPFNOSUPPORT", "protocol family not supported"}, - {47, "EAFNOSUPPORT", "address family not supported by protocol"}, - {48, "EADDRINUSE", "address already in use"}, - {49, "EADDRNOTAVAIL", "cannot assign requested address"}, - {50, "ENETDOWN", "network is down"}, - {51, "ENETUNREACH", "network is unreachable"}, - {52, "ENETRESET", "network dropped connection on reset"}, - {53, "ECONNABORTED", "software caused connection abort"}, - {54, "ECONNRESET", "connection reset by peer"}, - {55, "ENOBUFS", "no buffer space available"}, - {56, "EISCONN", "transport endpoint is already connected"}, - {57, "ENOTCONN", "transport endpoint is not connected"}, - {58, "ESHUTDOWN", "cannot send after transport endpoint shutdown"}, - {59, "ETOOMANYREFS", "too many references: cannot splice"}, - {60, "ETIMEDOUT", "connection timed out"}, - {61, "ECONNREFUSED", "connection refused"}, - {62, "ELOOP", "too many levels of symbolic links"}, - {63, "ENAMETOOLONG", "file name too long"}, - {64, "EHOSTDOWN", "host is down"}, - {65, "EHOSTUNREACH", "no route to host"}, - {66, "ENOTEMPTY", "directory not empty"}, - {67, "EPROCLIM", "too many processes"}, - {68, "EUSERS", "too many users"}, - {69, "EDQUOT", "disk quota exceeded"}, - {70, "ESTALE", "stale file handle"}, - {71, "EREMOTE", "object is remote"}, - {72, "ENOSTR", "device not a stream"}, - {73, "ETIME", "timer expired"}, - {74, "ENOSR", "out of streams resources"}, - {75, "ENOMSG", "no message of desired type"}, - {76, "EBADMSG", "bad message"}, - {77, "EIDRM", "identifier removed"}, - {78, "EDEADLK", "resource deadlock avoided"}, - {79, "ENOLCK", "no locks available"}, - {80, "ENONET", "machine is not on the network"}, - {81, "ERREMOTE", "unknown error 81"}, - {82, "ENOLINK", "link has been severed"}, - {83, "EADV", "advertise error"}, - {84, "ESRMNT", "srmount error"}, - {85, "ECOMM", "communication error on send"}, - {86, "EPROTO", "protocol error"}, - {87, "EMULTIHOP", "multihop attempted"}, - {88, "EDOTDOT", "RFS specific error"}, - {89, "EREMCHG", "remote address changed"}, - {90, "ENOSYS", "function not implemented"}, - {91, "ESTRPIPE", "streams pipe error"}, - {92, "EOVERFLOW", "value too large for defined data type"}, - {93, "EBADFD", "file descriptor in bad state"}, - {94, "ECHRNG", "channel number out of range"}, - {95, "EL2NSYNC", "level 2 not synchronized"}, - {96, "EL3HLT", "level 3 halted"}, - {97, "EL3RST", "level 3 reset"}, - {98, "ELNRNG", "link number out of range"}, - {99, "EUNATCH", "protocol driver not attached"}, - {100, "ENOCSI", "no CSI structure available"}, - {101, "EL2HLT", "level 2 halted"}, - {102, "EBADE", "invalid exchange"}, - {103, "EBADR", "invalid request descriptor"}, - {104, "EXFULL", "exchange full"}, - {105, "ENOANO", "no anode"}, - {106, "EBADRQC", "invalid request code"}, - {107, "EBADSLT", "invalid slot"}, - {108, "EDEADLOCK", "file locking deadlock error"}, - {109, "EBFONT", "bad font file format"}, - {110, "ELIBEXEC", "cannot exec a shared library directly"}, - {111, "ENODATA", "no data available"}, - {112, "ELIBBAD", "accessing a corrupted shared library"}, - {113, "ENOPKG", "package not installed"}, - {114, "ELIBACC", "can not access a needed shared library"}, - {115, "ENOTUNIQ", "name not unique on network"}, - {116, "ERESTART", "interrupted system call should be restarted"}, - {117, "EUCLEAN", "structure needs cleaning"}, - {118, "ENOTNAM", "not a XENIX named type file"}, - {119, "ENAVAIL", "no XENIX semaphores available"}, - {120, "EISNAM", "is a named type file"}, - {121, "EREMOTEIO", "remote I/O error"}, - {122, "EILSEQ", "invalid or incomplete multibyte or wide character"}, - {123, "ELIBMAX", "attempting to link in too many shared libraries"}, - {124, "ELIBSCN", ".lib section in a.out corrupted"}, - {125, "ENOMEDIUM", "no medium found"}, - {126, "EMEDIUMTYPE", "wrong medium type"}, - {127, "ECANCELED", "operation canceled"}, - {128, "ENOKEY", "required key not available"}, - {129, "EKEYEXPIRED", "key has expired"}, - {130, "EKEYREVOKED", "key has been revoked"}, - {131, "EKEYREJECTED", "key was rejected by service"}, - {132, "EOWNERDEAD", "owner died"}, - {133, "ENOTRECOVERABLE", "state not recoverable"}, - {134, "ERFKILL", "operation not possible due to RF-kill"}, - {135, "EHWPOISON", "memory page has hardware error"}, +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol", + 48: "address already in use", + 49: "cannot assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "transport endpoint is already connected", + 57: "transport endpoint is not connected", + 58: "cannot send after transport endpoint shutdown", + 59: "too many references: cannot splice", + 60: "connection timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disk quota exceeded", + 70: "stale file handle", + 71: "object is remote", + 72: "device not a stream", + 73: "timer expired", + 74: "out of streams resources", + 75: "no message of desired type", + 76: "bad message", + 77: "identifier removed", + 78: "resource deadlock avoided", + 79: "no locks available", + 80: "machine is not on the network", + 81: "unknown error 81", + 82: "link has been severed", + 83: "advertise error", + 84: "srmount error", + 85: "communication error on send", + 86: "protocol error", + 87: "multihop attempted", + 88: "RFS specific error", + 89: "remote address changed", + 90: "function not implemented", + 91: "streams pipe error", + 92: "value too large for defined data type", + 93: "file descriptor in bad state", + 94: "channel number out of range", + 95: "level 2 not synchronized", + 96: "level 3 halted", + 97: "level 3 reset", + 98: "link number out of range", + 99: "protocol driver not attached", + 100: "no CSI structure available", + 101: "level 2 halted", + 102: "invalid exchange", + 103: "invalid request descriptor", + 104: "exchange full", + 105: "no anode", + 106: "invalid request code", + 107: "invalid slot", + 108: "file locking deadlock error", + 109: "bad font file format", + 110: "cannot exec a shared library directly", + 111: "no data available", + 112: "accessing a corrupted shared library", + 113: "package not installed", + 114: "can not access a needed shared library", + 115: "name not unique on network", + 116: "interrupted system call should be restarted", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "invalid or incomplete multibyte or wide character", + 123: "attempting to link in too many shared libraries", + 124: ".lib section in a.out corrupted", + 125: "no medium found", + 126: "wrong medium type", + 127: "operation canceled", + 128: "required key not available", + 129: "key has expired", + 130: "key has been revoked", + 131: "key was rejected by service", + 132: "owner died", + 133: "state not recoverable", + 134: "operation not possible due to RF-kill", + 135: "memory page has hardware error", } // Signal table -var signalList = [...]struct { - num syscall.Signal - name string - desc string -}{ - {1, "SIGHUP", "hangup"}, - {2, "SIGINT", "interrupt"}, - {3, "SIGQUIT", "quit"}, - {4, "SIGILL", "illegal instruction"}, - {5, "SIGTRAP", "trace/breakpoint trap"}, - {6, "SIGABRT", "aborted"}, - {7, "SIGEMT", "EMT trap"}, - {8, "SIGFPE", "floating point exception"}, - {9, "SIGKILL", "killed"}, - {10, "SIGBUS", "bus error"}, - {11, "SIGSEGV", "segmentation fault"}, - {12, "SIGSYS", "bad system call"}, - {13, "SIGPIPE", "broken pipe"}, - {14, "SIGALRM", "alarm clock"}, - {15, "SIGTERM", "terminated"}, - {16, "SIGURG", "urgent I/O condition"}, - {17, "SIGSTOP", "stopped (signal)"}, - {18, "SIGTSTP", "stopped"}, - {19, "SIGCONT", "continued"}, - {20, "SIGCHLD", "child exited"}, - {21, "SIGTTIN", "stopped (tty input)"}, - {22, "SIGTTOU", "stopped (tty output)"}, - {23, "SIGIO", "I/O possible"}, - {24, "SIGXCPU", "CPU time limit exceeded"}, - {25, "SIGXFSZ", "file size limit exceeded"}, - {26, "SIGVTALRM", "virtual timer expired"}, - {27, "SIGPROF", "profiling timer expired"}, - {28, "SIGWINCH", "window changed"}, - {29, "SIGLOST", "power failure"}, - {30, "SIGUSR1", "user defined signal 1"}, - {31, "SIGUSR2", "user defined signal 2"}, +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "stopped (signal)", + 18: "stopped", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "resource lost", + 30: "user defined signal 1", + 31: "user defined signal 2", } diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go index 1f9e8a29ea..12261a562f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go @@ -952,7 +952,6 @@ const ( MNT_NOATIME = 0x8000 MNT_NODEV = 0x10 MNT_NOEXEC = 0x4 - MNT_NOPERM = 0x20 MNT_NOSUID = 0x8 MNT_NOWAIT = 0x2 MNT_QUOTA = 0x2000 @@ -960,7 +959,6 @@ const ( MNT_RELOAD = 0x40000 MNT_ROOTFS = 0x4000 MNT_SOFTDEP = 0x4000000 - MNT_STALLED = 0x100000 MNT_SYNCHRONOUS = 0x2 MNT_UPDATE = 0x10000 MNT_VISFLAGMASK = 0x400ffff @@ -1443,8 +1441,6 @@ const ( TIOCUCNTL_CBRK = 0x7a TIOCUCNTL_SBRK = 0x7b TOSTOP = 0x400000 - UTIME_NOW = -0x2 - UTIME_OMIT = -0x1 VDISCARD = 0xf VDSUSP = 0xb VEOF = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 46e9ddfb52..11a30786cf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -2296,18 +2296,3 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(cmdline) - if err != nil { - return - } - _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index c8ca4279e4..8300814d2c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -2343,18 +2343,3 @@ func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(cmdline) - if err != nil { - return - } - _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 870c8f6db6..002b4e175a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -2343,18 +2343,3 @@ func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(cmdline) - if err != nil { - return - } - _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 55e79d6407..1a9ba99925 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -2113,18 +2113,3 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(cmdline) - if err != nil { - return - } - _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index 97b22a499e..e2e5fc5e0a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -399,8 +399,6 @@ var ( procrecvfrom syscallFunc ) -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe(p *[2]_C_int) (n int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe)), 1, uintptr(unsafe.Pointer(p)), 0, 0, 0, 0, 0) n = int(r0) @@ -410,8 +408,6 @@ func pipe(p *[2]_C_int) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) if e1 != 0 { @@ -420,8 +416,6 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getcwd(buf []byte) (n int, err error) { var _p0 *byte if len(buf) > 0 { @@ -435,8 +429,6 @@ func Getcwd(buf []byte) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func getgroups(ngid int, gid *_Gid_t) (n int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) n = int(r0) @@ -446,8 +438,6 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func setgroups(ngid int, gid *_Gid_t) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) if e1 != 0 { @@ -456,8 +446,6 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func wait4(pid int32, statusp *_C_int, options int, rusage *Rusage) (wpid int32, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwait4)), 4, uintptr(pid), uintptr(unsafe.Pointer(statusp)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) wpid = int32(r0) @@ -467,8 +455,6 @@ func wait4(pid int32, statusp *_C_int, options int, rusage *Rusage) (wpid int32, return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func gethostname(buf []byte) (n int, err error) { var _p0 *byte if len(buf) > 0 { @@ -482,8 +468,6 @@ func gethostname(buf []byte) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func utimes(path string, times *[2]Timeval) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -497,8 +481,6 @@ func utimes(path string, times *[2]Timeval) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -512,8 +494,6 @@ func utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func fcntl(fd int, cmd int, arg int) (val int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) val = int(r0) @@ -523,8 +503,6 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func futimesat(fildes int, path *byte, times *[2]Timeval) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfutimesat)), 3, uintptr(fildes), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)), 0, 0, 0) if e1 != 0 { @@ -533,8 +511,6 @@ func futimesat(fildes int, path *byte, times *[2]Timeval) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procaccept)), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) fd = int(r0) @@ -544,8 +520,6 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_recvmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) n = int(r0) @@ -555,8 +529,6 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_sendmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) n = int(r0) @@ -566,8 +538,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func acct(path *byte) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procacct)), 1, uintptr(unsafe.Pointer(path)), 0, 0, 0, 0, 0) if e1 != 0 { @@ -576,32 +546,24 @@ func acct(path *byte) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func __makedev(version int, major uint, minor uint) (val uint64) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&proc__makedev)), 3, uintptr(version), uintptr(major), uintptr(minor), 0, 0, 0) val = uint64(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func __major(version int, dev uint64) (val uint) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&proc__major)), 2, uintptr(version), uintptr(dev), 0, 0, 0, 0) val = uint(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func __minor(version int, dev uint64) (val uint) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&proc__minor)), 2, uintptr(version), uintptr(dev), 0, 0, 0, 0) val = uint(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) if e1 != 0 { @@ -610,8 +572,6 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procpoll)), 3, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout), 0, 0, 0) n = int(r0) @@ -621,8 +581,6 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -636,8 +594,6 @@ func Access(path string, mode uint32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAdjtime)), 2, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0, 0, 0, 0) if e1 != 0 { @@ -646,8 +602,6 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Chdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -661,8 +615,6 @@ func Chdir(path string) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Chmod(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -676,8 +628,6 @@ func Chmod(path string, mode uint32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Chown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -691,8 +641,6 @@ func Chown(path string, uid int, gid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Chroot(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -706,8 +654,6 @@ func Chroot(path string) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Close(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procClose)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -716,8 +662,6 @@ func Close(fd int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Creat(path string, mode uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -732,8 +676,6 @@ func Creat(path string, mode uint32) (fd int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup(fd int) (nfd int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup)), 1, uintptr(fd), 0, 0, 0, 0, 0) nfd = int(r0) @@ -743,8 +685,6 @@ func Dup(fd int) (nfd int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup2(oldfd int, newfd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup2)), 2, uintptr(oldfd), uintptr(newfd), 0, 0, 0, 0) if e1 != 0 { @@ -753,15 +693,11 @@ func Dup2(oldfd int, newfd int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Exit(code int) { sysvicall6(uintptr(unsafe.Pointer(&procExit)), 1, uintptr(code), 0, 0, 0, 0, 0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -775,8 +711,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchdir(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchdir)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -785,8 +719,6 @@ func Fchdir(fd int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchmod(fd int, mode uint32) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmod)), 2, uintptr(fd), uintptr(mode), 0, 0, 0, 0) if e1 != 0 { @@ -795,8 +727,6 @@ func Fchmod(fd int, mode uint32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -810,8 +740,6 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchown)), 3, uintptr(fd), uintptr(uid), uintptr(gid), 0, 0, 0) if e1 != 0 { @@ -820,8 +748,6 @@ func Fchown(fd int, uid int, gid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -835,8 +761,6 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fdatasync(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFdatasync)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -845,8 +769,6 @@ func Fdatasync(fd int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Flock(fd int, how int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0) if e1 != 0 { @@ -855,8 +777,6 @@ func Flock(fd int, how int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fpathconf(fd int, name int) (val int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFpathconf)), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0) val = int(r0) @@ -866,8 +786,6 @@ func Fpathconf(fd int, name int) (val int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fstat(fd int, stat *Stat_t) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstat)), 2, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) if e1 != 0 { @@ -876,8 +794,6 @@ func Fstat(fd int, stat *Stat_t) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -891,8 +807,6 @@ func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstatvfs)), 2, uintptr(fd), uintptr(unsafe.Pointer(vfsstat)), 0, 0, 0, 0) if e1 != 0 { @@ -901,8 +815,6 @@ func Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { var _p0 *byte if len(buf) > 0 { @@ -916,24 +828,18 @@ func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getgid() (gid int) { r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetgid)), 0, 0, 0, 0, 0, 0, 0) gid = int(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpid() (pid int) { r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpid)), 0, 0, 0, 0, 0, 0, 0) pid = int(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpgid(pid int) (pgid int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) pgid = int(r0) @@ -943,8 +849,6 @@ func Getpgid(pid int) (pgid int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpgrp() (pgid int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgrp)), 0, 0, 0, 0, 0, 0, 0) pgid = int(r0) @@ -954,32 +858,24 @@ func Getpgrp() (pgid int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Geteuid() (euid int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGeteuid)), 0, 0, 0, 0, 0, 0, 0) euid = int(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getegid() (egid int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetegid)), 0, 0, 0, 0, 0, 0, 0) egid = int(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getppid() (ppid int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetppid)), 0, 0, 0, 0, 0, 0, 0) ppid = int(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpriority(which int, who int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetpriority)), 2, uintptr(which), uintptr(who), 0, 0, 0, 0) n = int(r0) @@ -989,8 +885,6 @@ func Getpriority(which int, who int) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) if e1 != 0 { @@ -999,8 +893,6 @@ func Getrlimit(which int, lim *Rlimit) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getrusage(who int, rusage *Rusage) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0) if e1 != 0 { @@ -1009,8 +901,6 @@ func Getrusage(who int, rusage *Rusage) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Gettimeofday(tv *Timeval) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGettimeofday)), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1019,16 +909,12 @@ func Gettimeofday(tv *Timeval) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getuid() (uid int) { r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetuid)), 0, 0, 0, 0, 0, 0, 0) uid = int(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Kill(pid int, signum syscall.Signal) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procKill)), 2, uintptr(pid), uintptr(signum), 0, 0, 0, 0) if e1 != 0 { @@ -1037,8 +923,6 @@ func Kill(pid int, signum syscall.Signal) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1052,8 +936,6 @@ func Lchown(path string, uid int, gid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Link(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1072,8 +954,6 @@ func Link(path string, link string) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Listen(s int, backlog int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_llisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) if e1 != 0 { @@ -1082,8 +962,6 @@ func Listen(s int, backlog int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Lstat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1097,8 +975,6 @@ func Lstat(path string, stat *Stat_t) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Madvise(b []byte, advice int) (err error) { var _p0 *byte if len(b) > 0 { @@ -1111,8 +987,6 @@ func Madvise(b []byte, advice int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mkdir(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1126,8 +1000,6 @@ func Mkdir(path string, mode uint32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1141,8 +1013,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1156,8 +1026,6 @@ func Mkfifo(path string, mode uint32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mkfifoat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1171,8 +1039,6 @@ func Mkfifoat(dirfd int, path string, mode uint32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mknod(path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1186,8 +1052,6 @@ func Mknod(path string, mode uint32, dev int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1201,8 +1065,6 @@ func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mlock(b []byte) (err error) { var _p0 *byte if len(b) > 0 { @@ -1215,8 +1077,6 @@ func Mlock(b []byte) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mlockall(flags int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlockall)), 1, uintptr(flags), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1225,8 +1085,6 @@ func Mlockall(flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mprotect(b []byte, prot int) (err error) { var _p0 *byte if len(b) > 0 { @@ -1239,8 +1097,6 @@ func Mprotect(b []byte, prot int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Msync(b []byte, flags int) (err error) { var _p0 *byte if len(b) > 0 { @@ -1253,8 +1109,6 @@ func Msync(b []byte, flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Munlock(b []byte) (err error) { var _p0 *byte if len(b) > 0 { @@ -1267,8 +1121,6 @@ func Munlock(b []byte) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Munlockall() (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlockall)), 0, 0, 0, 0, 0, 0, 0) if e1 != 0 { @@ -1277,8 +1129,6 @@ func Munlockall() (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procNanosleep)), 2, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0, 0, 0, 0) if e1 != 0 { @@ -1287,8 +1137,6 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Open(path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1303,8 +1151,6 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1319,8 +1165,6 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Pathconf(path string, name int) (val int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1335,8 +1179,6 @@ func Pathconf(path string, name int) (val int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Pause() (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPause)), 0, 0, 0, 0, 0, 0, 0) if e1 != 0 { @@ -1345,8 +1187,6 @@ func Pause() (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1360,8 +1200,6 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1375,8 +1213,6 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func read(fd int, p []byte) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1390,8 +1226,6 @@ func read(fd int, p []byte) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Readlink(path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1410,8 +1244,6 @@ func Readlink(path string, buf []byte) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) @@ -1430,8 +1262,6 @@ func Rename(from string, to string) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) @@ -1450,8 +1280,6 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Rmdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1465,8 +1293,6 @@ func Rmdir(path string) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclseek)), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0) newoffset = int64(r0) @@ -1476,8 +1302,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSelect)), 5, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) if e1 != 0 { @@ -1486,8 +1310,6 @@ func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setegid(egid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetegid)), 1, uintptr(egid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1496,8 +1318,6 @@ func Setegid(egid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Seteuid(euid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSeteuid)), 1, uintptr(euid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1506,8 +1326,6 @@ func Seteuid(euid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setgid(gid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetgid)), 1, uintptr(gid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1516,8 +1334,6 @@ func Setgid(gid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Sethostname(p []byte) (err error) { var _p0 *byte if len(p) > 0 { @@ -1530,8 +1346,6 @@ func Sethostname(p []byte) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setpgid(pid int, pgid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetpgid)), 2, uintptr(pid), uintptr(pgid), 0, 0, 0, 0) if e1 != 0 { @@ -1540,8 +1354,6 @@ func Setpgid(pid int, pgid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setpriority(which int, who int, prio int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSetpriority)), 3, uintptr(which), uintptr(who), uintptr(prio), 0, 0, 0) if e1 != 0 { @@ -1550,8 +1362,6 @@ func Setpriority(which int, who int, prio int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setregid(rgid int, egid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetregid)), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0) if e1 != 0 { @@ -1560,8 +1370,6 @@ func Setregid(rgid int, egid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setreuid(ruid int, euid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetreuid)), 2, uintptr(ruid), uintptr(euid), 0, 0, 0, 0) if e1 != 0 { @@ -1570,8 +1378,6 @@ func Setreuid(ruid int, euid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) if e1 != 0 { @@ -1580,8 +1386,6 @@ func Setrlimit(which int, lim *Rlimit) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetsid)), 0, 0, 0, 0, 0, 0, 0) pid = int(r0) @@ -1591,8 +1395,6 @@ func Setsid() (pid int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setuid(uid int) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetuid)), 1, uintptr(uid), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1601,8 +1403,6 @@ func Setuid(uid int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(s int, how int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procshutdown)), 2, uintptr(s), uintptr(how), 0, 0, 0, 0) if e1 != 0 { @@ -1611,8 +1411,6 @@ func Shutdown(s int, how int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Stat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1626,8 +1424,6 @@ func Stat(path string, stat *Stat_t) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Statvfs(path string, vfsstat *Statvfs_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1641,8 +1437,6 @@ func Statvfs(path string, vfsstat *Statvfs_t) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Symlink(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1661,8 +1455,6 @@ func Symlink(path string, link string) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Sync() (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSync)), 0, 0, 0, 0, 0, 0, 0) if e1 != 0 { @@ -1671,8 +1463,6 @@ func Sync() (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Times(tms *Tms) (ticks uintptr, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procTimes)), 1, uintptr(unsafe.Pointer(tms)), 0, 0, 0, 0, 0) ticks = uintptr(r0) @@ -1682,8 +1472,6 @@ func Times(tms *Tms) (ticks uintptr, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Truncate(path string, length int64) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1697,8 +1485,6 @@ func Truncate(path string, length int64) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fsync(fd int) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFsync)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1707,8 +1493,6 @@ func Fsync(fd int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ftruncate(fd int, length int64) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFtruncate)), 2, uintptr(fd), uintptr(length), 0, 0, 0, 0) if e1 != 0 { @@ -1717,16 +1501,12 @@ func Ftruncate(fd int, length int64) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Umask(mask int) (oldmask int) { r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procUmask)), 1, uintptr(mask), 0, 0, 0, 0, 0) oldmask = int(r0) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Uname(buf *Utsname) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procUname)), 1, uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0, 0) if e1 != 0 { @@ -1735,8 +1515,6 @@ func Uname(buf *Utsname) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Unmount(target string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(target) @@ -1750,8 +1528,6 @@ func Unmount(target string, flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Unlink(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1765,8 +1541,6 @@ func Unlink(path string) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Unlinkat(dirfd int, path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1780,8 +1554,6 @@ func Unlinkat(dirfd int, path string, flags int) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ustat(dev int, ubuf *Ustat_t) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUstat)), 2, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0, 0, 0, 0) if e1 != 0 { @@ -1790,8 +1562,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Utime(path string, buf *Utimbuf) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1805,8 +1575,6 @@ func Utime(path string, buf *Utimbuf) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_bind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { @@ -1815,8 +1583,6 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_connect)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { @@ -1825,8 +1591,6 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmmap)), 6, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) ret = uintptr(r0) @@ -1836,8 +1600,6 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func munmap(addr uintptr, length uintptr) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmunmap)), 2, uintptr(addr), uintptr(length), 0, 0, 0, 0) if e1 != 0 { @@ -1846,8 +1608,6 @@ func munmap(addr uintptr, length uintptr) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendfile)), 4, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) written = int(r0) @@ -1857,8 +1617,6 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { var _p0 *byte if len(buf) > 0 { @@ -1871,8 +1629,6 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func socket(domain int, typ int, proto int) (fd int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_socket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) fd = int(r0) @@ -1882,8 +1638,6 @@ func socket(domain int, typ int, proto int) (fd int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&proc__xnet_socketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) if e1 != 0 { @@ -1892,8 +1646,6 @@ func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func write(fd int, p []byte) (n int, err error) { var _p0 *byte if len(p) > 0 { @@ -1907,8 +1659,6 @@ func write(fd int, p []byte) (n int, err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_getsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) if e1 != 0 { @@ -1917,8 +1667,6 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetpeername)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) if e1 != 0 { @@ -1927,8 +1675,6 @@ func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) if e1 != 0 { @@ -1937,8 +1683,6 @@ func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) return } -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { var _p0 *byte if len(p) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go index d014451c9d..90c95c2c75 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go @@ -254,17 +254,4 @@ var sysctlMib = []mibentry{ {"net.mpls.ttl", []_C_int{4, 33, 2}}, {"net.pflow.stats", []_C_int{4, 34, 1}}, {"net.pipex.enable", []_C_int{4, 35, 1}}, - {"vm.anonmin", []_C_int{2, 7}}, - {"vm.loadavg", []_C_int{2, 2}}, - {"vm.maxslp", []_C_int{2, 10}}, - {"vm.nkmempages", []_C_int{2, 6}}, - {"vm.psstrings", []_C_int{2, 3}}, - {"vm.swapencrypt.enable", []_C_int{2, 5, 0}}, - {"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}}, - {"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}}, - {"vm.uspace", []_C_int{2, 11}}, - {"vm.uvmexp", []_C_int{2, 4}}, - {"vm.vmmeter", []_C_int{2, 1}}, - {"vm.vnodemin", []_C_int{2, 9}}, - {"vm.vtextmin", []_C_int{2, 8}}, } diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go index cedc9b0f26..f1cfe7db15 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 PathMax = 0x3ff ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go index f46482d272..95581a3bc3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x3ff ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go index 2aeb52a886..327af5fba1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 0d0d9f2ccb..116e6e0757 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go index 04e344b78d..2750ad7607 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -7,11 +7,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 9fec185c18..8cead0996c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index 7b34e2e2c6..c01ae67016 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 11380294ac..8006c5638e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index a6fc127180..716774ded0 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index 6b3006d6b3..92e07b00f5 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 3879002a9c..793b3fdd21 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1937,31 +1937,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index cbc2c7d073..c3548848a4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1959,31 +1959,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index 6ed804fa3c..c7b6994329 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1927,31 +1927,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index b5fe7ddf76..2339b21298 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1938,31 +1938,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 7379ad2d81..013462ba5d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1932,31 +1932,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 0b131a24e1..86f0ab5520 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1940,31 +1940,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 9191020cc8..007537b4d3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1940,31 +1940,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index 8fcad32bfc..fc4a159124 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1932,31 +1932,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index a9d1b6c9ff..377e9efdfc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1948,31 +1948,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index f0f5214a53..595ba63030 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1948,31 +1948,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 09c905866f..0ccf5bc3e1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1965,31 +1965,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 5e86e496cd..06b07852d1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -1965,31 +1965,3 @@ type XDPDesc struct { Len uint32 Options uint32 } - -const ( - NCSI_CMD_UNSPEC = 0x0 - NCSI_CMD_PKG_INFO = 0x1 - NCSI_CMD_SET_INTERFACE = 0x2 - NCSI_CMD_CLEAR_INTERFACE = 0x3 - NCSI_ATTR_UNSPEC = 0x0 - NCSI_ATTR_IFINDEX = 0x1 - NCSI_ATTR_PACKAGE_LIST = 0x2 - NCSI_ATTR_PACKAGE_ID = 0x3 - NCSI_ATTR_CHANNEL_ID = 0x4 - NCSI_PKG_ATTR_UNSPEC = 0x0 - NCSI_PKG_ATTR = 0x1 - NCSI_PKG_ATTR_ID = 0x2 - NCSI_PKG_ATTR_FORCED = 0x3 - NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 - NCSI_CHANNEL_ATTR_UNSPEC = 0x0 - NCSI_CHANNEL_ATTR = 0x1 - NCSI_CHANNEL_ATTR_ID = 0x2 - NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 - NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 - NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 - NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 - NCSI_CHANNEL_ATTR_ACTIVE = 0x7 - NCSI_CHANNEL_ATTR_FORCED = 0x8 - NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 - NCSI_CHANNEL_ATTR_VLAN_ID = 0xa -) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 1fc7f7dea9..8e7384b89c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -5,11 +5,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x1000 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go index 1fdc5fd211..9e9088de11 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go index 711f780675..ed3f17366a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go index fa1a16bae1..d263b61476 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index c8509bf0e4..231f4e8ef3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( @@ -465,94 +465,3 @@ type Utsname struct { Version [256]byte Machine [256]byte } - -const SizeofUvmexp = 0x158 - -type Uvmexp struct { - Pagesize int32 - Pagemask int32 - Pageshift int32 - Npages int32 - Free int32 - Active int32 - Inactive int32 - Paging int32 - Wired int32 - Zeropages int32 - Reserve_pagedaemon int32 - Reserve_kernel int32 - Anonpages int32 - Vnodepages int32 - Vtextpages int32 - Freemin int32 - Freetarg int32 - Inactarg int32 - Wiredmax int32 - Anonmin int32 - Vtextmin int32 - Vnodemin int32 - Anonminpct int32 - Vtextminpct int32 - Vnodeminpct int32 - Nswapdev int32 - Swpages int32 - Swpginuse int32 - Swpgonly int32 - Nswget int32 - Nanon int32 - Nanonneeded int32 - Nfreeanon int32 - Faults int32 - Traps int32 - Intrs int32 - Swtch int32 - Softs int32 - Syscalls int32 - Pageins int32 - Obsolete_swapins int32 - Obsolete_swapouts int32 - Pgswapin int32 - Pgswapout int32 - Forks int32 - Forks_ppwait int32 - Forks_sharevm int32 - Pga_zerohit int32 - Pga_zeromiss int32 - Zeroaborts int32 - Fltnoram int32 - Fltnoanon int32 - Fltnoamap int32 - Fltpgwait int32 - Fltpgrele int32 - Fltrelck int32 - Fltrelckok int32 - Fltanget int32 - Fltanretry int32 - Fltamcopy int32 - Fltnamap int32 - Fltnomap int32 - Fltlget int32 - Fltget int32 - Flt_anon int32 - Flt_acow int32 - Flt_obj int32 - Flt_prcopy int32 - Flt_przero int32 - Pdwoke int32 - Pdrevs int32 - Pdswout int32 - Pdfreed int32 - Pdscans int32 - Pdanscan int32 - Pdobscan int32 - Pdreact int32 - Pdbusy int32 - Pdpageouts int32 - Pdpending int32 - Pddeact int32 - Pdreanon int32 - Pdrevnode int32 - Pdrevtext int32 - Fpswtch int32 - Kmapent int32 -} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index 200575d941..bb2c44886e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 ) type ( @@ -465,94 +465,3 @@ type Utsname struct { Version [256]byte Machine [256]byte } - -const SizeofUvmexp = 0x158 - -type Uvmexp struct { - Pagesize int32 - Pagemask int32 - Pageshift int32 - Npages int32 - Free int32 - Active int32 - Inactive int32 - Paging int32 - Wired int32 - Zeropages int32 - Reserve_pagedaemon int32 - Reserve_kernel int32 - Anonpages int32 - Vnodepages int32 - Vtextpages int32 - Freemin int32 - Freetarg int32 - Inactarg int32 - Wiredmax int32 - Anonmin int32 - Vtextmin int32 - Vnodemin int32 - Anonminpct int32 - Vtextminpct int32 - Vnodeminpct int32 - Nswapdev int32 - Swpages int32 - Swpginuse int32 - Swpgonly int32 - Nswget int32 - Nanon int32 - Nanonneeded int32 - Nfreeanon int32 - Faults int32 - Traps int32 - Intrs int32 - Swtch int32 - Softs int32 - Syscalls int32 - Pageins int32 - Obsolete_swapins int32 - Obsolete_swapouts int32 - Pgswapin int32 - Pgswapout int32 - Forks int32 - Forks_ppwait int32 - Forks_sharevm int32 - Pga_zerohit int32 - Pga_zeromiss int32 - Zeroaborts int32 - Fltnoram int32 - Fltnoanon int32 - Fltnoamap int32 - Fltpgwait int32 - Fltpgrele int32 - Fltrelck int32 - Fltrelckok int32 - Fltanget int32 - Fltanretry int32 - Fltamcopy int32 - Fltnamap int32 - Fltnomap int32 - Fltlget int32 - Fltget int32 - Flt_anon int32 - Flt_acow int32 - Flt_obj int32 - Flt_prcopy int32 - Flt_przero int32 - Pdwoke int32 - Pdrevs int32 - Pdswout int32 - Pdfreed int32 - Pdscans int32 - Pdanscan int32 - Pdobscan int32 - Pdreact int32 - Pdbusy int32 - Pdpageouts int32 - Pdpending int32 - Pddeact int32 - Pdreanon int32 - Pdrevnode int32 - Pdrevtext int32 - Fpswtch int32 - Kmapent int32 -} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go index 3e20cdf092..941367cab8 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x4 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x4 - SizeofLongLong = 0x8 + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 ) type ( @@ -458,94 +458,3 @@ type Utsname struct { Version [256]byte Machine [256]byte } - -const SizeofUvmexp = 0x158 - -type Uvmexp struct { - Pagesize int32 - Pagemask int32 - Pageshift int32 - Npages int32 - Free int32 - Active int32 - Inactive int32 - Paging int32 - Wired int32 - Zeropages int32 - Reserve_pagedaemon int32 - Reserve_kernel int32 - Anonpages int32 - Vnodepages int32 - Vtextpages int32 - Freemin int32 - Freetarg int32 - Inactarg int32 - Wiredmax int32 - Anonmin int32 - Vtextmin int32 - Vnodemin int32 - Anonminpct int32 - Vtextminpct int32 - Vnodeminpct int32 - Nswapdev int32 - Swpages int32 - Swpginuse int32 - Swpgonly int32 - Nswget int32 - Nanon int32 - Nanonneeded int32 - Nfreeanon int32 - Faults int32 - Traps int32 - Intrs int32 - Swtch int32 - Softs int32 - Syscalls int32 - Pageins int32 - Obsolete_swapins int32 - Obsolete_swapouts int32 - Pgswapin int32 - Pgswapout int32 - Forks int32 - Forks_ppwait int32 - Forks_sharevm int32 - Pga_zerohit int32 - Pga_zeromiss int32 - Zeroaborts int32 - Fltnoram int32 - Fltnoanon int32 - Fltnoamap int32 - Fltpgwait int32 - Fltpgrele int32 - Fltrelck int32 - Fltrelckok int32 - Fltanget int32 - Fltanretry int32 - Fltamcopy int32 - Fltnamap int32 - Fltnomap int32 - Fltlget int32 - Fltget int32 - Flt_anon int32 - Flt_acow int32 - Flt_obj int32 - Flt_prcopy int32 - Flt_przero int32 - Pdwoke int32 - Pdrevs int32 - Pdswout int32 - Pdfreed int32 - Pdscans int32 - Pdanscan int32 - Pdobscan int32 - Pdreact int32 - Pdbusy int32 - Pdpageouts int32 - Pdpending int32 - Pddeact int32 - Pdreanon int32 - Pdrevnode int32 - Pdrevtext int32 - Fpswtch int32 - Kmapent int32 -} diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go index 8531a190f2..0543e1a49a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -6,11 +6,11 @@ package unix const ( - SizeofPtr = 0x8 - SizeofShort = 0x2 - SizeofInt = 0x4 - SizeofLong = 0x8 - SizeofLongLong = 0x8 + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 PathMax = 0x400 MaxHostNameLen = 0x100 ) diff --git a/vendor/yunion.io/x/jsonutils/yamlutils.go b/vendor/yunion.io/x/jsonutils/yamlutils.go index de45df9211..fd2b978882 100644 --- a/vendor/yunion.io/x/jsonutils/yamlutils.go +++ b/vendor/yunion.io/x/jsonutils/yamlutils.go @@ -61,6 +61,7 @@ func parseYAMLDict(lines []string) (map[string]JSONObject, error) { } else { key := lines[i][0:keypos] val := strings.Trim(lines[i][keypos+1:], " ") + if len(val) > 0 && val != "|" { dict[key] = NewString(val) i++