diff --git a/pkg/apis/compute/storage_const.go b/pkg/apis/compute/storage_const.go index e040022b51..d2724f92a9 100644 --- a/pkg/apis/compute/storage_const.go +++ b/pkg/apis/compute/storage_const.go @@ -39,9 +39,11 @@ const ( STORAGE_EPHEMERAL_SSD = "ephemeral_ssd" //单块本地SSD盘, 容量最大不能超过800 GiB //Azure hdd and ssd storagetype - STORAGE_STANDARD_LRS = "standard_lrs" - STORAGE_STANDARDSSD_LRS = "standardssd_lrs" - STORAGE_PREMIUM_LRS = "premium_lrs" + STORAGE_STANDARD_LRS = "standard_lrs" + STORAGE_STANDARDSSD_LRS = "standardssd_lrs" + STORAGE_PREMIUM_LRS = "premium_lrs" + STORAGE_AZURE_BASIC = "basic_storage" + STORAGE_AZURE_GENERAL_PURPOSE = "general_purpose_storage" // aws storage type STORAGE_GP2_SSD = "gp2" // aws general purpose ssd diff --git a/pkg/multicloud/azure/azure.go b/pkg/multicloud/azure/azure.go index cfcc7995cc..fee6333289 100644 --- a/pkg/multicloud/azure/azure.go +++ b/pkg/multicloud/azure/azure.go @@ -397,6 +397,21 @@ func (self *SAzureClient) _apiVersion(resource string, params url.Values) string return version } info := strings.Split(strings.ToLower(resource), "/") + if utils.IsInStringArray("microsoft.dbformariadb", info) { + return "2018-06-01-preview" + } + if utils.IsInStringArray("microsoft.dbformysql", info) { + if utils.IsInStringArray("flexibleservers", info) { + return "2020-07-01-privatepreview" + } + return "2017-12-01" + } + if utils.IsInStringArray("microsoft.dbforpostgresql", info) { + if utils.IsInStringArray("flexibleservers", info) { + return "2020-02-14-preview" + } + return "2017-12-01" + } if utils.IsInStringArray("microsoft.compute", info) { if utils.IsInStringArray("tags", info) { return "2020-06-01" @@ -928,7 +943,7 @@ func (self *SAzureClient) GetCapabilities() []string { cloudprovider.CLOUD_CAPABILITY_NETWORK, // cloudprovider.CLOUD_CAPABILITY_LOADBALANCER, cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE, - // cloudprovider.CLOUD_CAPABILITY_RDS, + cloudprovider.CLOUD_CAPABILITY_RDS, // cloudprovider.CLOUD_CAPABILITY_CACHE, cloudprovider.CLOUD_CAPABILITY_EVENT, cloudprovider.CLOUD_CAPABILITY_CLOUDID, diff --git a/pkg/multicloud/azure/dbinstance.go b/pkg/multicloud/azure/dbinstance.go new file mode 100644 index 0000000000..dda365e4e7 --- /dev/null +++ b/pkg/multicloud/azure/dbinstance.go @@ -0,0 +1,385 @@ +// Copyright 2019 Yunion +// +// 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. + +package azure + +import ( + "fmt" + "net/url" + "strings" + "time" + + "yunion.io/x/jsonutils" + "yunion.io/x/pkg/errors" + + api "yunion.io/x/onecloud/pkg/apis/compute" + "yunion.io/x/onecloud/pkg/cloudprovider" + "yunion.io/x/onecloud/pkg/multicloud" +) + +type SDBInstanceVirtualNetworkRule struct { + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Properties SDBInstanceVirtualNetworkRuleProperties `json:"properties"` +} + +type SDBInstanceVirtualNetworkRuleProperties struct { + IgnoreMissingVnetServiceEndpoint bool `json:"ignoreMissingVnetServiceEndpoint"` + State string `json:"state"` + VirtualNetworkSubnetID string `json:"virtualNetworkSubnetId"` +} + +type SDBInstanceSku struct { + Name string `json:"name"` + Tier string `json:"tier"` + Family string `json:"family"` + Capacity int `json:"capacity"` +} + +type SDBInstanceStorageProfile struct { + StorageMB int `json:"storageMB"` + BackupRetentionDays int `json:"backupRetentionDays"` + StorageIops int `json:"storageIops"` + GeoRedundantBackup string `json:"geoRedundantBackup"` +} + +type SDBInstanceDelegatedSubnetArguments struct { + SubnetArmResourceId string `json:"subnetArmResourceId"` +} + +type SDBInstanceProperties struct { + AdministratorLogin string `json:"administratorLogin"` + StorageProfile SDBInstanceStorageProfile `json:"storageProfile"` + Version string `json:"version"` + SslEnforcement string `json:"sslEnforcement"` + UserVisibleState string `json:"userVisibleState"` + FullyQualifiedDomainName string `json:"fullyQualifiedDomainName"` + EarliestRestoreDate time.Time `json:"earliestRestoreDate"` + + ReplicationRole string `json:"replicationRole"` + MasterServerId string `json:"masterServerId"` + ReplicaCapacity int `json:"replicaCapacity"` + DelegatedSubnetArguments SDBInstanceDelegatedSubnetArguments `json:"delegatedSubnetArguments"` +} + +type SDBInstance struct { + region *SRegion + multicloud.SDBInstanceBase + Sku SDBInstanceSku `json:"sku"` + Properties SDBInstanceProperties `json:"properties"` + Location string `json:"location"` + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Tags map[string]string `json:"tags"` +} + +func (self *SRegion) GetIDBInstances() ([]cloudprovider.ICloudDBInstance, error) { + instanceTypes := []string{ + "Microsoft.DBForMariaDB/servers", + "Microsoft.DBforMySQL/servers", + "Microsoft.DBforMySQL/flexibleServers", + "Microsoft.DBforPostgreSQL/servers", + "Microsoft.DBforPostgreSQL/flexibleServers", + } + DBInstances := []SDBInstance{} + for i := range instanceTypes { + instances, err := self.ListDBInstance(instanceTypes[i]) + if err != nil { + if errors.Cause(err) != cloudprovider.ErrNotFound { + return nil, errors.Wrap(err, "self.ListDBInstance()") + } + } + DBInstances = append(DBInstances, instances...) + } + result := []cloudprovider.ICloudDBInstance{} + for i := range DBInstances { + result = append(result, &DBInstances[i]) + } + return result, nil +} + +func (self *SRegion) GetIDBInstanceById(instanceId string) (cloudprovider.ICloudDBInstance, error) { + rds, err := self.GetDBInstanceById(instanceId) + if err != nil { + return nil, errors.Wrapf(err, "self.get(%s, url.Values{}, &newrds)", instanceId) + } + return rds, nil +} + +func (self *SRegion) GetDBInstanceById(instanceId string) (*SDBInstance, error) { + rds := SDBInstance{} + err := self.get(instanceId, url.Values{}, &rds) + if err != nil { + return nil, errors.Wrapf(err, "self.get(%s, url.Values{}, &newrds)", instanceId) + } + rds.region = self + return &rds, nil +} + +func (self *SRegion) ListDBInstance(instanceType string) ([]SDBInstance, error) { + result := []SDBInstance{} + err := self.list(instanceType, url.Values{}, &result) + if err != nil { + return nil, errors.Wrapf(err, "list(%s)", instanceType) + } + for i := range result { + result[i].region = self + } + return result, nil +} + +func (self *SRegion) ListDBInstanceReplica(Id string) ([]SDBInstance, error) { + type replicas struct { + Value []SDBInstance + } + result := replicas{} + err := self.get(fmt.Sprintf("%s/replicas", Id), url.Values{}, &result) + if err != nil { + return nil, errors.Wrapf(err, "get(%s)", Id) + } + for i := range result.Value { + result.Value[i].region = self + } + return result.Value, nil +} + +func (self *SRegion) ListDBInstanceVirtualNetworkRule(Id string) ([]SDBInstanceVirtualNetworkRule, error) { + type networksRules struct { + Value []SDBInstanceVirtualNetworkRule + } + result := networksRules{} + err := self.get(fmt.Sprintf("%s/virtualNetworkRules", Id), url.Values{}, &result) + if err != nil { + return nil, errors.Wrapf(err, "get(%s)", Id) + } + return result.Value, nil +} + +func (rds *SDBInstance) GetName() string { + return rds.Name +} + +func (rds *SDBInstance) GetId() string { + return strings.ToLower(rds.ID) +} + +func (rds *SDBInstance) GetGlobalId() string { + return rds.GetId() +} + +func (rds *SDBInstance) GetStatus() string { + return api.DBINSTANCE_RUNNING +} + +func (self *SDBInstance) GetProjectId() string { + return getResourceGroup(self.ID) +} + +func (rds *SDBInstance) GetExpiredAt() time.Time { + return time.Time{} +} + +func (rds *SDBInstance) GetStorageType() string { + switch rds.Sku.Tier { + case "Basic": + return api.STORAGE_AZURE_BASIC + case "General Purpose": + return api.STORAGE_AZURE_GENERAL_PURPOSE + case "Memory Optimized": + return api.STORAGE_AZURE_GENERAL_PURPOSE + default: + return api.STORAGE_AZURE_BASIC + } +} + +func (rds *SDBInstance) Refresh() error { + newrds := SDBInstance{} + err := rds.region.get(rds.ID, url.Values{}, &newrds) + if err != nil { + return errors.Wrapf(err, "rds.region.get(%s, url.Values{}, &newdb)", rds.ID) + } + + err = jsonutils.Update(rds, newrds) + if err != nil { + return err + } + rds.Tags = newrds.Tags + return nil +} + +func (rds *SDBInstance) GetMasterInstanceId() string { + if len(rds.Properties.MasterServerId) > 0 { + return strings.ToLower(rds.Properties.MasterServerId) + } + return "" +} + +func (rds *SDBInstance) GetPort() int { + switch rds.GetEngine() { + case api.DBINSTANCE_TYPE_POSTGRESQL: + return 5432 + case api.DBINSTANCE_TYPE_MYSQL: + return 3306 + case api.DBINSTANCE_TYPE_MARIADB: + return 3306 + default: + return 0 + } +} + +func (rds *SDBInstance) GetEngine() string { + databaseType := strings.Split(rds.Type, "/") + switch databaseType[0] { + case "Microsoft.DBforPostgreSQL": + return api.DBINSTANCE_TYPE_POSTGRESQL + case "Microsoft.DBforMySQL": + return api.DBINSTANCE_TYPE_MYSQL + case "Microsoft.DBforMariaDB": + return api.DBINSTANCE_TYPE_MARIADB + default: + return "" + } +} + +func (rds *SDBInstance) GetEngineVersion() string { + return rds.Properties.Version +} + +func (rds *SDBInstance) GetInstanceType() string { + return rds.Sku.Name +} + +func (rds *SDBInstance) GetVcpuCount() int { + return rds.Sku.Capacity +} + +func (rds *SDBInstance) GetVmemSizeMB() int { + if strings.Contains(rds.Type, "server") { + switch rds.Sku.Tier { + case "Basic": + return rds.Sku.Capacity * 2 * 1024 + case "General Purpose": + return rds.Sku.Capacity * 5 * 1024 + case "Memory Optimized": + return rds.Sku.Capacity * 10 * 1024 + default: + return 0 + } + } + return 0 +} + +func (rds *SDBInstance) GetDiskSizeGB() int { + return rds.Properties.StorageProfile.StorageMB / 1024 +} + +func (rds *SDBInstance) GetCategory() string { + return rds.Sku.Tier +} + +func (rds *SDBInstance) GetMaintainTime() string { + return "" +} + +func (rds *SDBInstance) GetConnectionStr() string { + return rds.Properties.FullyQualifiedDomainName +} + +// func (rds *SDBInstance) GetInternalConnectionStr() string + +func (rds *SDBInstance) GetIVpcId() string { + splited := strings.Split(rds.Properties.DelegatedSubnetArguments.SubnetArmResourceId, "/subnets") + return splited[0] +} + +func (rds *SDBInstance) GetDBNetworks() ([]cloudprovider.SDBInstanceNetwork, error) { + result := []cloudprovider.SDBInstanceNetwork{} + delegateNet := cloudprovider.SDBInstanceNetwork{NetworkId: rds.Properties.DelegatedSubnetArguments.SubnetArmResourceId} + result = append(result, delegateNet) + return result, nil +} + +func (rds *SDBInstance) GetZone1Id() string { + return "" +} + +func (rds *SDBInstance) GetZone2Id() string { + return "" +} + +func (rds *SDBInstance) GetZone3Id() string { + return "" +} + +func (rds *SDBInstance) GetIDBInstanceParameters() ([]cloudprovider.ICloudDBInstanceParameter, error) { + configs, err := rds.region.ListDBInstanceConfiguration(rds.ID) + if err != nil { + return nil, errors.Wrapf(err, "rds.region.ListDBInstanceConfiguration(%s)", rds.ID) + } + result := []cloudprovider.ICloudDBInstanceParameter{} + for i := range configs { + result = append(result, &configs[i]) + } + return result, nil +} + +func (rds *SDBInstance) GetIDBInstanceDatabases() ([]cloudprovider.ICloudDBInstanceDatabase, error) { + db, err := rds.region.ListSDBInstanceDatabase(rds.ID) + if err != nil { + return nil, errors.Wrapf(err, "rds.region.ListSDBInstanceDatabase(%s)", rds.ID) + } + result := []cloudprovider.ICloudDBInstanceDatabase{} + for i := range db { + result = append(result, &db[i]) + } + return result, nil +} + +func (rds *SDBInstance) GetIDBInstanceAccounts() ([]cloudprovider.ICloudDBInstanceAccount, error) { + accounts := []cloudprovider.ICloudDBInstanceAccount{} + if len(rds.Properties.AdministratorLogin) > 0 { + account := &SDBInstanceAccount{instance: rds, AccountName: rds.Properties.AdministratorLogin} + accounts = append(accounts, account) + } + return accounts, nil +} + +func (rds *SDBInstance) GetIDBInstanceBackups() ([]cloudprovider.ICloudDBInstanceBackup, error) { + return []cloudprovider.ICloudDBInstanceBackup{}, nil +} + +func (rds *SDBInstance) Delete() error { + return cloudprovider.ErrNotImplemented +} + +func (self *SDBInstance) GetTags() (map[string]string, error) { + return self.Tags, nil +} + +func (self *SDBInstance) SetTags(tags map[string]string, replace bool) error { + if !replace { + for k, v := range self.Tags { + if _, ok := tags[k]; !ok { + tags[k] = v + } + } + } + _, err := self.region.client.SetTags(self.ID, tags) + if err != nil { + return errors.Wrapf(err, "self.region.client.SetTags(%s,%s)", self.ID, jsonutils.Marshal(tags).String()) + } + return nil +} diff --git a/pkg/multicloud/azure/dbinstance_account.go b/pkg/multicloud/azure/dbinstance_account.go new file mode 100644 index 0000000000..ed7b7d9d0f --- /dev/null +++ b/pkg/multicloud/azure/dbinstance_account.go @@ -0,0 +1,28 @@ +// Copyright 2019 Yunion +// +// 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. + +package azure + +import "yunion.io/x/onecloud/pkg/multicloud" + +type SDBInstanceAccount struct { + multicloud.SDBInstanceAccountBase + instance *SDBInstance + + AccountName string +} + +func (account *SDBInstanceAccount) GetName() string { + return account.AccountName + "@" + account.instance.Name +} diff --git a/pkg/multicloud/azure/dbinstance_configuration.go b/pkg/multicloud/azure/dbinstance_configuration.go new file mode 100644 index 0000000000..8eeee876c8 --- /dev/null +++ b/pkg/multicloud/azure/dbinstance_configuration.go @@ -0,0 +1,67 @@ +// Copyright 2019 Yunion +// +// 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. + +package azure + +import ( + "fmt" + "net/url" + "strings" + + "yunion.io/x/pkg/errors" +) + +type SDBInstanceConfiguration struct { + Properties SDBInstanceConfigurationProperties `json:"properties"` + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` +} + +type SDBInstanceConfigurationProperties struct { + Value string `json:"value"` + Description string `json:"description"` + DefaultValue string `json:"defaultValue"` + DataType string `json:"dataType"` + AllowedValues string `json:"allowedValues"` + Source string `json:"source"` +} + +func (self *SRegion) ListDBInstanceConfiguration(Id string) ([]SDBInstanceConfiguration, error) { + type configs struct { + Value []SDBInstanceConfiguration + } + result := configs{} + err := self.get(fmt.Sprintf("%s/configurations", Id), url.Values{}, &result) + if err != nil { + return nil, errors.Wrapf(err, "get(%s/configurations)", Id) + } + return result.Value, nil +} + +func (param *SDBInstanceConfiguration) GetGlobalId() string { + return strings.ToLower(param.ID) +} + +func (param *SDBInstanceConfiguration) GetKey() string { + return strings.ToLower(param.Name) +} + +func (param *SDBInstanceConfiguration) GetValue() string { + return param.Properties.Value +} + +func (param *SDBInstanceConfiguration) GetDescription() string { + return param.Properties.Description +} diff --git a/pkg/multicloud/azure/dbinstance_database.go b/pkg/multicloud/azure/dbinstance_database.go new file mode 100644 index 0000000000..fbff92e35f --- /dev/null +++ b/pkg/multicloud/azure/dbinstance_database.go @@ -0,0 +1,88 @@ +// Copyright 2019 Yunion +// +// 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. + +package azure + +import ( + "fmt" + "net/url" + "strings" + + "yunion.io/x/jsonutils" + "yunion.io/x/pkg/errors" + + api "yunion.io/x/onecloud/pkg/apis/compute" + "yunion.io/x/onecloud/pkg/multicloud" +) + +type SDBInstanceDatabase struct { + region *SRegion + multicloud.SDBInstanceDatabaseBase + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Properties SDBInstanceDatabaseProperties `json:"properties"` +} + +type SDBInstanceDatabaseProperties struct { + Charset string `json:"charset"` + Collation string `json:"collation"` +} + +func (self *SRegion) ListSDBInstanceDatabase(Id string) ([]SDBInstanceDatabase, error) { + type databases struct { + Value []SDBInstanceDatabase `json:"collation"` + } + + result := databases{} + err := self.get(fmt.Sprintf("%s/databases", Id), url.Values{}, &result) + if err != nil { + return nil, errors.Wrapf(err, "get(%s/databases)", Id) + } + return result.Value, nil +} + +func (database *SDBInstanceDatabase) GetCharacterSet() string { + return database.Properties.Charset +} + +func (database *SDBInstanceDatabase) GetName() string { + return database.Name +} + +func (database *SDBInstanceDatabase) GetGlobalId() string { + return strings.ToLower(database.ID) +} + +func (database *SDBInstanceDatabase) GetId() string { + return strings.ToLower(database.ID) +} + +func (database *SDBInstanceDatabase) IsEmulated() bool { + return false +} + +func (database *SDBInstanceDatabase) Refresh() error { + newdb := SDBInstanceDatabase{} + err := database.region.get(database.ID, url.Values{}, &newdb) + if err != nil { + return errors.Wrapf(err, "database.region.get(%s, url.Values{}, &newdb)", database.ID) + } + + return jsonutils.Update(database, newdb) +} + +func (database *SDBInstanceDatabase) GetStatus() string { + return api.DBINSTANCE_DATABASE_RUNNING +} diff --git a/pkg/multicloud/azure/region.go b/pkg/multicloud/azure/region.go index 27f38c0682..a209d5db82 100644 --- a/pkg/multicloud/azure/region.go +++ b/pkg/multicloud/azure/region.go @@ -617,7 +617,7 @@ func (self *SRegion) list(resource string, params url.Values, retVal interface{} ret := []jsonutils.JSONObject{} for i := range result { location, _ := result[i].GetString("location") - if len(location) == 0 || strings.ToLower(self.Name) == strings.ToLower(location) { + if len(location) == 0 || strings.ToLower(self.Name) == strings.ToLower(strings.Replace(location, " ", "", -1)) { ret = append(ret, result[i]) } } diff --git a/pkg/multicloud/azure/shell/dbinstance.go b/pkg/multicloud/azure/shell/dbinstance.go new file mode 100644 index 0000000000..087e3050fe --- /dev/null +++ b/pkg/multicloud/azure/shell/dbinstance.go @@ -0,0 +1,48 @@ +// Copyright 2019 Yunion +// +// 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. + +package shell + +import ( + "yunion.io/x/onecloud/pkg/multicloud/azure" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type DBInstanceListOptions struct { + Type string `help:"dbinstance type" choices:"Microsoft.DBForMariaDB/servers|Microsoft.DBforMySQL/servers|Microsoft.DBforMySQL/flexibleServers|Microsoft.DBforPostgreSQL/servers|Microsoft.DBforPostgreSQL/flexibleServers"` + } + shellutils.R(&DBInstanceListOptions{}, "dbinstance-list", "List rds intances", func(cli *azure.SRegion, args *DBInstanceListOptions) error { + instances, err := cli.ListDBInstance(args.Type) + if err != nil { + return err + } + printList(instances, 0, 0, len(instances), []string{}) + return nil + }) + + type DBInstanceIdOptions struct { + ID string + } + + shellutils.R(&DBInstanceIdOptions{}, "dbinstance-show", "Show rds intance", func(cli *azure.SRegion, args *DBInstanceIdOptions) error { + instance, err := cli.GetDBInstanceById(args.ID) + if err != nil { + return err + } + printObject(instance) + return nil + }) + +} diff --git a/pkg/multicloud/azure/shell/dbinstance_databases.go b/pkg/multicloud/azure/shell/dbinstance_databases.go new file mode 100644 index 0000000000..420892bd27 --- /dev/null +++ b/pkg/multicloud/azure/shell/dbinstance_databases.go @@ -0,0 +1,36 @@ +// Copyright 2019 Yunion +// +// 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. + +package shell + +import ( + "yunion.io/x/onecloud/pkg/multicloud/azure" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type DBInstanceDatabasesOptions struct { + ID string + } + + shellutils.R(&DBInstanceDatabasesOptions{}, "dbinstance-database-show", "Show rds intance database", func(cli *azure.SRegion, args *DBInstanceDatabasesOptions) error { + databases, err := cli.ListSDBInstanceDatabase(args.ID) + if err != nil { + return err + } + printList(databases, 0, 0, 0, []string{}) + return nil + }) + +} diff --git a/pkg/multicloud/azure/shell/dbinstance_networkRules.go b/pkg/multicloud/azure/shell/dbinstance_networkRules.go new file mode 100644 index 0000000000..3158952d46 --- /dev/null +++ b/pkg/multicloud/azure/shell/dbinstance_networkRules.go @@ -0,0 +1,36 @@ +// Copyright 2019 Yunion +// +// 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. + +package shell + +import ( + "yunion.io/x/onecloud/pkg/multicloud/azure" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type DBInstanceNetworkOptions struct { + ID string + } + + shellutils.R(&DBInstanceNetworkOptions{}, "dbinstance-network-show", "Show rds intance networks", func(cli *azure.SRegion, args *DBInstanceNetworkOptions) error { + networks, err := cli.ListDBInstanceVirtualNetworkRule(args.ID) + if err != nil { + return err + } + printList(networks, 0, 0, 0, []string{}) + return nil + }) + +} diff --git a/pkg/multicloud/azure/shell/dbinstance_paraments.go b/pkg/multicloud/azure/shell/dbinstance_paraments.go new file mode 100644 index 0000000000..cd5446861f --- /dev/null +++ b/pkg/multicloud/azure/shell/dbinstance_paraments.go @@ -0,0 +1,36 @@ +// Copyright 2019 Yunion +// +// 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. + +package shell + +import ( + "yunion.io/x/onecloud/pkg/multicloud/azure" + "yunion.io/x/onecloud/pkg/util/shellutils" +) + +func init() { + type DBInstanceParameterOptions struct { + ID string + } + + shellutils.R(&DBInstanceParameterOptions{}, "dbinstance-parameter-show", "Show rds intance parameter", func(cli *azure.SRegion, args *DBInstanceParameterOptions) error { + parameters, err := cli.ListDBInstanceConfiguration(args.ID) + if err != nil { + return err + } + printList(parameters, 0, 0, 0, []string{}) + return nil + }) + +}