package pkg import ( "regexp" "github.rackspace.com/gorax/tools/util" ) type ( MasterKey struct { Enabled string `json:"enabled"` Unit1Key string `json:"unit1_key"` Unit2Key string `json:"unit2_key"` PeerKey string `json:"peer_key"` StoreHash string `json:"store_hash"` } ) func (mk *MasterKey) Parse(c string) { mk.Enabled = util.RegexpString(regexp.MustCompile(`(?i)show\s+sys\s+master-key\n+Sys::Master\s+Key\n+\s+Enabled\s+:\s+(\S+)`), c) mk.Unit1Key = util.RegexpString(regexp.MustCompile(`(?i)\s+Unit1\s+Key\s+:\s+(\S+)`), c) mk.Unit2Key = util.RegexpString(regexp.MustCompile(`(?i)\s+Unit2\s+Key\s+:\s+(\S+)`), c) mk.PeerKey = util.RegexpString(regexp.MustCompile(`(?i)\s+Peer\s+Key\s+:\s+(\S+)`), c) mk.StoreHash = util.RegexpString(regexp.MustCompile(`(?i)\s+Store-Hash\s*:\s+(\S+)`), c) } func ParseMasterKey(c string) (*MasterKey, error) { mk := new(MasterKey) mk.Parse(c) return mk, nil }