cm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveCMRegistry

func ActiveCMRegistry(id string)

ActiveCMRegistry turn on active status on selected CM registry

func CreateCMRegistryDb

func CreateCMRegistryDb()

CreateCMRegistryDb initialize cmctl database

func DeRegisterCMEntry

func DeRegisterCMEntry(id string)

DeRegisterCMEntry remove an CM server enrty by id

func DeRegisterConnectionProfile

func DeRegisterConnectionProfile(id string)

DeRegisterConnectionProfile remove a connection profile by id

func DeactiveAllCMRegistry

func DeactiveAllCMRegistry()

DeactiveAllCMRegistry turn off active status on all CM registries

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile download a file from an url to the local filesystem

func DownloadViaScp

func DownloadViaScp(sshConfig *easyssh.MakeConfig, source string, dest string, skipJump bool) error

DownloadViaScp downloads file from remote to local

func DropCMRegistryRecords

func DropCMRegistryRecords()

DropCMRegistryRecords drop all CM server entries from cmctl database

func DropConnectionProfileRecords

func DropConnectionProfileRecords()

DropConnectionProfileRecords drop all connection profile from cmctl database

func EvaluateBoolValueFromString

func EvaluateBoolValueFromString(answer string) bool

EvaluateBoolValueFromString get a string boolean answer and evaluate as a boolean value

func FormatJson

func FormatJson(b []byte) *bytes.Buffer

FormatJson format json file

func GetCMEntryId

func GetCMEntryId(id string) string

GetCMEntryId get CM server entry id if the id exists

func GetConnectionProfileEntryId

func GetConnectionProfileEntryId(id string) string

GetConnectionProfileEntryId get connection profile entry id if the id exists

func GetHttpClient

func GetHttpClient() *http.Client

GetHttpClient create HTTP client instance for CM Server

func GetPassword

func GetPassword(flagValue string, text string) string

GetPassword trying to read a password flag value, if it does not exists ask an input from the user

func GetStringFlag

func GetStringFlag(flagValue string, defaultValue string, text string) string

GetStringFlag trying to read a flag value, if it does not exists ask an input from the user

func ProcessAsMap

func ProcessAsMap(request *http.Request) map[string]interface{}

ProcessAsMap get map format response

func ProcessAsMapFromBytes

func ProcessAsMapFromBytes(bodyBytes []byte) map[string]interface{}

ProcessAsMapFromBytes get JSON map from bytes

func ProcessAsMapFromSSHResponse

func ProcessAsMapFromSSHResponse(sshResponse RemoteResponse) map[string]interface{}

ProcessAsMapFromSSHResponse get JSON map from CM gateway SSH response

func ProcessRequest

func ProcessRequest(request *http.Request) []byte

ProcessRequest get a simple response from a REST call

func RegisterNewCMEntry

func RegisterNewCMEntry(id string, hostname string, port int, protocol string, username string, password string, useGateway bool, apiVersion int)

RegisterNewCMEntry create new CM server registry entry in cmctl database

func RegisterNewConnectionProfile

func RegisterNewConnectionProfile(id string, keyPath string, port int, username string)

RegisterNewConnectionProfile create new connection profile entry in cmctl database

func RunLocalCommand

func RunLocalCommand(command string, arg ...string) (string, string, error)

RunLocalCommand run local system command

func SetProfileIdForCMEntry

func SetProfileIdForCMEntry(cmEntryId string, profileId string)

SetProfileIdForCMEntry attach a connection profile to a specific CM server entry

func UpdateCMEntry

func UpdateCMEntry(id string, hostname string, port int, protocol string, username string, password string, useGateway bool, apiVersion int, connectionProfile string)

UpdateCMEntry update CM server registry entry in cmctl database

func WriteCMServerEntries

func WriteCMServerEntries(cmServers []CMServer)

WriteCMServerEntries write CM server entries to the CM server registry json file

func WriteConnectionProfileEntries

func WriteConnectionProfileEntries(connectionProfiles []ConnectionProfile)

WriteConnectionProfileEntries write connection profile entries to the connection profile registry json file

Types

type CMItems

type CMItems struct {
	Href  string `json:"href"`
	Items []Item `json:"items"`
}

CMItems global items from CM Server rest API response

func ProcessCMItems

func ProcessCMItems(request *http.Request) CMItems

ProcessCMItems get "items" from CM server response

func ProcessCMItemsFromBytes

func ProcessCMItemsFromBytes(bodyBytes []byte) CMItems

ProcessCMItemsFromBytes get "items" from bytes

func ProcessCMItemsFromSSHResponse

func ProcessCMItemsFromSSHResponse(sshResponse RemoteResponse) CMItems

ProcessCMItemsFromSSHResponse get "items" from CM gateway SSH response

func (CMItems) ConvertClustersResponse

func (c CMItems) ConvertClustersResponse() []Cluster

ConvertClustersResponse convert items response to Clusters response

func (CMItems) ConvertHostsResponse

func (c CMItems) ConvertHostsResponse() []Host

ConvertHostsResponse convert items response to Hosts response

func (CMItems) ConvertRolesResponse

func (c CMItems) ConvertRolesResponse(cluster string, service string) []Role

ConvertRolesResponse convert items response to Roles response

func (CMItems) ConvertServicesResponse

func (c CMItems) ConvertServicesResponse(cluster string) []Service

ConvertServicesResponse convert items response to Services response

func (CMItems) ConvertUsersResponse

func (c CMItems) ConvertUsersResponse() []User

ConvertUsersResponse convert items response to Users response

type CMServer

type CMServer struct {
	Name              string `json:"name"`
	Hostname          string `json:"hostname"`
	Port              int    `json:"port"`
	Username          string `json:"username"`
	Password          string `json:"password"`
	Protocol          string `json:"protocol"`
	Active            bool   `json:"active"`
	ConnectionProfile string `json:"profile"`
	UseGateway        bool   `json:"gateway"`
	ApiVersion        int    `json:"version"`
}

CMServer represents registered CM server entry details

func GetActiveCM

func GetActiveCM() CMServer

GetActiveCM get the active CM server registry from cmctl database (should be only one)

func GetCMById

func GetCMById(searchId string) CMServer

GetCMById get the CM server registry from cmctl database by id

func ListCMRegistryEntries

func ListCMRegistryEntries() []CMServer

ListCMRegistryEntries get all CM server registries from cmctl database

func (CMServer) CreateGatewayCurlGetCommand

func (c CMServer) CreateGatewayCurlGetCommand(uri string) string

func (CMServer) CreateGatewayCurlPostCommand

func (c CMServer) CreateGatewayCurlPostCommand(uri string) string

func (CMServer) CreateGetRequest

func (c CMServer) CreateGetRequest(urlSuffix string) *http.Request

CreateGetRequest creates an CM Server GET request

func (CMServer) CreatePostRequest

func (c CMServer) CreatePostRequest(body bytes.Buffer, urlSuffix string) *http.Request

CreatePostRequest creates an CM Server POST request with body

func (CMServer) CreatePutRequest

func (c CMServer) CreatePutRequest(body bytes.Buffer, urlSuffix string) *http.Request

CreatePutRequest creates an CM Server PUT request with body

func (CMServer) ExecuteSaltCommand

func (c CMServer) ExecuteSaltCommand(command string, saltBinaryPathPrefix string, saltBinary string)

ExecuteSaltCommand execute a command on all minions

func (CMServer) ExportClusterTemplate

func (c CMServer) ExportClusterTemplate(cluster string) []byte

ExportClusterTemplate exporting template for a specific cluster

func (CMServer) GetCMUri

func (c CMServer) GetCMUri(uriSuffix string) string

GetCMUri creates the CM uri with /api/vx/ suffix (+ /api/vx/clusters/<cluster> suffix is useCluster is enabled)

func (CMServer) GetDeployment

func (c CMServer) GetDeployment() Deployment

GetDeployment get full deployement data for CM server

func (CMServer) GetFilteredHosts

func (c CMServer) GetFilteredHosts(filter Filter) map[string]bool

GetFilteredHosts obtain specific hosts based on different filters

func (CMServer) GetUsers

func (c CMServer) GetUsers() []User

GetUsers returns a list of the user names configured in the system.

func (CMServer) ListClusters

func (c CMServer) ListClusters() []Cluster

ListClusters get all the registered clusters

func (CMServer) ListHosts

func (c CMServer) ListHosts() []Host

ListHosts get all the registered hosts

func (CMServer) ListServices

func (c CMServer) ListServices(cluster string) []Service

ListServices get all the registered services per cluster

func (CMServer) RunGatewayCMCommand

func (c CMServer) RunGatewayCMCommand(command string, printStdOut bool) RemoteResponse

func (CMServer) RunRemoteHostCommand

func (c CMServer) RunRemoteHostCommand(command string, filteredHosts map[string]bool, skipJump bool) map[string]RemoteResponse

RunRemoteHostCommand executes bash commands on CM hosts

type Cluster

type Cluster struct {
	UUID        string `json:"uuid,omitempty"`
	Name        string `json:"name,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
	Version     string `json:"fullVersion,omitempty"`
	Type        string `json:"clusterType,omitempty"`
}

Cluster holds installed CM cluster details

type ConnectionProfile

type ConnectionProfile struct {
	Name     string `json:"name"`
	KeyPath  string `json:"key_path"`
	Port     int    `json:"port"`
	Username string `json:"username"`
}

ConnectionProfile represents ssh/connection descriptions which is used to communicate with CM server and agents

func GetConnectionProfileById

func GetConnectionProfileById(searchId string) ConnectionProfile

GetConnectionProfileById get the connection profile from cmctl database by id

func ListConnectionProfileEntries

func ListConnectionProfileEntries() []ConnectionProfile

ListConnectionProfileEntries get all CM server registries from cmctl database

type Deployment

type Deployment struct {
	Clusters              []Cluster
	Services              []Service
	Hosts                 []Host
	ClusterServiceRoleMap map[string]ServiceRolesMap
}

Deployment hold full CM server deployment data

func ConvertDeploymentResponse

func ConvertDeploymentResponse(responseMap map[string]interface{}) Deployment

ConvertDeploymentResponse convert map to Deployment response

type Filter

type Filter struct {
	Hosts    []string
	Clusters []string
	Services []string
	Server   bool
}

Filter represents filter on agent hosts (by component / service / hosts)

func CreateFilter

func CreateFilter(clusterFilter string, serviceFilter string, hostFilter string, cmServer bool) Filter

CreateFilter will make a Filter object from filter strings (hosts)

type Host

type Host struct {
	HostID             string `json:"hostId,omitempty"`
	IPAddress          string `json:"ipAddress,omitempty"`
	HostName           string `json:"hostName,omitempty"`
	CommissionState    string `json:"commissionState,omitempty"`
	RackID             string `json:"rackId,omitempty"`
	ClusterName        string `json:"clusterName,omitempty"`
	ClusterDisplayName string `json:"clusterDisplayName,omitempty"`
}

Host holds host details

type Item

type Item map[string]interface{}

Item dynamic map - cast contents to specific types

type RemoteResponse

type RemoteResponse struct {
	StdOut string
	StdErr string
	Done   bool
}

RemoteResponse represents an ssh command output

type Role

type Role struct {
	Name           string `json:"name,omitempty"`
	Type           string `json:"type,omitempty"`
	HostName       string `json:"hostName,omitempty"`
	ConfigGroup    string `json:"configGroup,omitempty"`
	State          string `json:"roleState,omitempty"`
	StaleConfig    string `json:"configStalenessStatus,omitempty"`
	ComissionState string `json:"commissionState,omitempty"`
	ClusterName    string `json:"clusterName,omitempty"`
	ServiceName    string `json:"serviceName,omitempty"`
}

Role holds role details

type Service

type Service struct {
	Name        string `json:"name,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
	Type        string `json:"type,omitempty"`
	State       string `json:"serviceState,omitempty"`
	ClusterName string `json:"clusterName,omitempty"`
	StaleConfig string `json:"configStalenessStatus,omitempty"`
}

Service holds service details

type ServiceRolesMap

type ServiceRolesMap struct {
	RolesMap map[string][]Role
}

ServiceRolesMap holds service - roles map

type User

type User struct {
	Name      string         `json:"name,omitempty"`
	AuthRoles []UserAuthRole `json:"authRoles,omitempty"`
}

User holds user details

type UserAuthRole

type UserAuthRole struct {
	Name string `json:"name,omitempty"`
}

UserAuthRole holds user auth role details

Jump to

Keyboard shortcuts

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