utils

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2021 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//list of supported services types
	ServiceTypeSpark      string = "spark"
	ServiceTypeIgnite     string = "ignite"
	ServiceTypeCassandra  string = "cassandra"
	ServiceTypeJupyter    string = "jupyter"
	ServiceTypeJupyterhub string = "jupyterhub"
	ServiceTypeElastic    string = "elastic"
	ServiceTypeNFS        string = "nfs-server"
	ServiceTypeNextCloud  string = "nextcloud"

	//supported spark configurations
	SparkUseYarn         string = "use-yarn"
	SparkHadoopVersion   string = "hadoop-version"
	SparkWorkerMemMb     string = "worker-mem-mb"
	SparkYarnMasterMemMb string = "yarn-master-mem-mb"

	//supported jupyter configurations
	JupyterToreeVersion string = "toree-version"

	//supported ignite configurations
	IgniteMemory string = "ignite-memory"

	//supported elastic configurations
	ElasticHeapSize string = "es-heap-size"

	//supported cassandra configurations
	CassandraDefaultVersion string = "3.11.4"

	//statuses for ansible runner
	AnsibleOk   string = "OK"
	AnsibleFail string = "FAIL"

	//supported actions for ansible
	AnsibleLaunch  = "launch"
	AnsibleDestroy = "destroy"

	//ansible-playbook command
	AnsiblePlaybookCmd = "ansible-playbook"

	//path for ansible.cfg
	AnsibleConfigVar  = "ANSIBLE_CONFIG"
	AnsibleConfigPath = "ansible/ansible.cfg"

	//base path
	BasePath = "michman"
	//ansible main role path
	AnsibleMainRole = "ansible/main.yml"
	//ansible get master ip role path
	AnsibleMasterIpRole = "ansible/get_master.yml"
	//ansible get ip of any instance with role
	AnsibleIpRole = "ansible/get_ip.yml"

	//openstack secrets keys
	OsAuthUrl            = "OS_AUTH_URL"
	OsPassword           = "OS_PASSWORD"
	OsProjectName        = "OS_PROJECT_NAME"
	OsProjectID          = "OS_PROJECT_ID"
	OsProjectDomainID    = "OS_PROJECT_DOMAIN_ID"
	OsInterface          = "OS_INTERFACE"
	OsRegionName         = "OS_REGION_NAME"
	OsTenantId           = "OS_TENANT_ID"
	OsTenantName         = "OS_TENANT_NAME"
	OsUsername           = "OS_USERNAME"
	OsSwiftUsername      = "OS_SWIFT_USERNAME"
	OsSwiftPassword      = "OS_SWIFT_PASSWORD"
	OsComputeApiVersion  = "COMPUTE_API_VERSION"
	OsNovaVersion        = "NOVA_VERSION"
	OsAuthType           = "OS_AUTH_TYPE"
	OsCloudname          = "OS_CLOUDNAME"
	OsIdentityApiVersion = "OS_IDENTITY_API_VERSION"
	OsImageApiVersion    = "OS_IMAGE_API_VERSION"
	OsNoCache            = "OS_NO_CACHE"
	OsProjectDomainName  = "OS_PROJECT_DOMAIN_NAME"
	OsUserDomainName     = "OS_USER_DOMAIN_NAME"
	OsVolumeApiVersion   = "OS_VOLUME_API_VERSION"
	OsPythonwarnings     = "PYTHONWARNINGS"
	OsNoProxy            = "no_proxy"

	// Docker login secrets keys
	DockerLoginUlr      = "url"
	DockerLoginUser     = "user"
	DockerLoginPassword = "password"

	//Couchbase secret keys
	CouchbasePath     = "path"
	CouchbaseUsername = "username"
	CouchbasePassword = "password"

	//Hydra secret keys
	HydraRedirectUri  = "redirect_uri"
	HydraClientId     = "client_id"
	HydraClientSecret = "client_secret"

	//ssh secrets keys
	VaultSshKey = "key_bgt"

	//Entity statuses
	StatusInited   = "INITED"
	StatusActive   = "ACTIVE"
	StatusFailed   = "FAILED"
	StatusStopping = "STOPPING"
	StatusMissing  = "MISSING"

	//default IDs
	CommonProjectID string = "None"

	//Openstack stein version
	OsSteinVersion   string = "stein"
	OsLibertyVersion string = "liberty"
	OsUssuriVersion  string = "ussuri"

	//Supported classes for service types
	ClassStorage     string = "storage"
	ClassMasterSlave string = "master-slave"
	ClassStandAlone  string = "stand-alone"

	//Authorization models
	OAuth2Mode   = "oauth2"
	NoneAuthMode = "none"
	KeystoneMode = "keystone"

	//sessions keys
	GroupKey       = "groups"
	AccessTokenKey = "AccessToken"

	//cluster logs outputs
	LogsFileOutput     = "file"
	LogsLogstashOutput = "logstash"

	//ansible actions
	ActionCreate = "create"
	ActionUpdate = "update"
	ActionDelete = "delete"
)

Variables

View Source
var (
	SshKeyPath  = os.Getenv("PWD") + "/ansible/files/ssh_key"
	ConfigPath  = "configs/config.yaml"
	UseBasePath = true
)

Functions

func DownloadFile

func DownloadFile(filepath string, url string) (err error)

func ItemExists

func ItemExists(slice interface{}, item interface{}) bool

func SetConfigPath

func SetConfigPath(configPath string)

func Unzip

func Unzip(src string, dest string) ([]string, error)

Types

type CbCredentials

type CbCredentials struct {
	Address  string `yaml:"cb_address"`
	Username string `yaml:"cb_username"`
	Password string `yaml:"cb_password"`
}

type Config

type Config struct {
	// Openstack
	Key            string `yaml:"os_key_name"`
	VirtualNetwork string `yaml:"virtual_network"`
	OsImage        string `yaml:"os_image"`
	FloatingIP     string `yaml:"floating_ip_pool"`
	MasterFlavor   string `yaml:"master_flavor"`
	SlavesFlavor   string `yaml:"slaves_flavor"`
	StorageFlavor  string `yaml:"storage_flavor"`
	OsVersion      string `yaml:"os_version"` //Now are supported only 'stein', 'ussuri' and 'liberty' versions

	// Vault
	Token       string `yaml:"token"`
	VaultAddr   string `yaml:"vault_addr"`
	OsKey       string `yaml:"os_key"`
	SshKey      string `yaml:"ssh_key"`
	CbKey       string `yaml:"cb_key"`
	RegistryKey string `yaml:"registry_key"`
	HydraKey    string `yaml:"hydra_key"`

	// Mirror
	UsePackageMirror string `yaml:"use_package_mirror,omitempty"`
	UsePipMirror     string `yaml:"use_pip_mirror,omitempty"`
	YumMirrorAddress string `yaml:"yum_mirror_address,omitempty"`
	AptMirrorAddress string `yaml:"apt_mirror_address,omitempty"`
	PipMirrorAddress string `yaml:"pip_mirror_address,omitempty"`
	PipTrustedHost   string `yaml:"pip_trusted_host,omitempty"`

	// Registry
	SelfignedRegistry bool `yaml:"docker_selfsigned_registry,omitempty"`
	InsecureRegistry  bool `yaml:"docker_insecure_registry,omitempty"`
	GitlabRegistry    bool `yaml:"gitlab_registry,omitempty"`

	SelfsignedRegistryIp string `yaml:"docker_selfsigned_registry_ip,omitempty"`
	InsecureRegistryIp   string `yaml:"docker_insecure_registry_ip,omitempty"`

	SelfignedRegistryUrl  string `yaml:"docker_selfsigned_registry_url,omitempty"`
	SelfignedRegistryCert string `yaml:"docker_cert_path,omitempty"`

	//Authentication
	UseAuth            bool   `yaml:"use_auth"`
	AuthorizationModel string `yaml:"authorization_model,omitempty"`   //Now are supported only 'oauth2', 'none' or 'keystone' values
	AdminGroup         string `yaml:"admin_group,omitempty"`           //name of the Admin user group
	SessionIdleTimeout int    `yaml:"session_idle_timeout,omitempty"'` //time in minutes, controls the maximum length of time a session can be inactive before it expires
	SessionLifetime    int    `yaml:"session_lifetime,omitempty"`      //time in minutes, controls the maximum length of time that a session is valid for before it expires
	HydraAdmin         string `yaml:"hydra_admin,omitempty"`           //hydra admin address
	HydraClient        string `yaml:"hydra_client,omitempty"`          //hydra client address
	KeystoneAddr       string `yaml:"keystone_addr,omitempty"`         //keystone service address

	//Cluster logs
	LogsOutput   string `yaml:"logs_output"`              //file or logstash
	LogsFilePath string `yaml:"logs_file_path,omitempty"` //path to directory with cluster logs if file output is used
	LogstashAddr string `yaml:"logstash_addr,omitempty"`  //logstash address if logstash output is used
	ElasticAddr  string `yaml:"elastic_addr,omitempty"`   //elastic address if logstash output is used
}

func (*Config) MakeCfg

func (Cfg *Config) MakeCfg() error

type DockerCredentials

type DockerCredentials struct {
	Url      string
	User     string
	Password string
}

type HydraCredentials

type HydraCredentials struct {
	RedirectUri  string
	ClientId     string
	ClientSecret string
}

type OsCredentials

type OsCredentials struct {
	OsAuthUrl            string
	OsPassword           string
	OsProjectID          string
	OsProjectName        string
	OsProjectDomainID    string
	OsInterface          string
	OsRegionName         string
	OsTenantId           string
	OsTenantName         string
	OsUserName           string
	OsSwiftUserName      string
	OsSwiftPassword      string
	OsComputeApiVersion  string
	OsNovaVersion        string
	OsAuthType           string
	OsCloudname          string
	OsIdentityApiVersion string
	OsImageApiVersion    string
	OsNoCache            string
	OsProjectDomainName  string
	OsUserDomainName     string
	OsVolumeApiVersion   string
	OsPythonwarnings     string
	OsNoProxy            string
}

type SecretStorage

type SecretStorage interface {
	ConnectVault() (*vaultapi.Client, *Config)
}

type VaultCommunicator

type VaultCommunicator struct {
	// contains filtered or unexported fields
}

func (*VaultCommunicator) ConnectVault

func (vc *VaultCommunicator) ConnectVault() (*vaultapi.Client, *Config)

func (*VaultCommunicator) Init

func (vc *VaultCommunicator) Init() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL