Skip to content

Commit

Permalink
feat(cli): add https support
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-howe-1 committed Nov 21, 2024
1 parent b440888 commit 6231ad2
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 223 deletions.
18 changes: 12 additions & 6 deletions cli/pkg/serviceLib/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

package flags

// Constants
const (
PROTOCOL_HTTP = "http"
PROTOCOL_HTTPS = "https"
)

// CLI flag component descriptor
const (
SERVICE string = "serv"
Expand Down Expand Up @@ -40,9 +46,9 @@ const (
SERVICE_NET_PORT string = SERVICE + "-" + NET_PORT
SERVICE_NET_PORT_SH string = "p"
SERVICE_INSECURE string = SERVICE + "-" + INSECURE
SERVICE_INSECURE_SH string = "" //"s"
SERVICE_INSECURE_SH string = "s"
SERVICE_PROTOCOL string = SERVICE + "-" + PROTOCOL
SERVICE_PROTOCOL_SH string = "" //"t"
SERVICE_PROTOCOL_SH string = "t"

APPLIANCE_ID string = APPLIANCE + "-" + ID
APPLIANCE_ID_SH string = "L"
Expand Down Expand Up @@ -92,26 +98,26 @@ const (
SERVICE_NET_IP_DFLT string = "127.0.0.1"
SERVICE_NET_PORT_DFLT uint16 = 8080
SERVICE_INSECURE_DFLT bool = false
SERVICE_PROTOCOL_DFLT string = "http"
SERVICE_PROTOCOL_DFLT string = PROTOCOL_HTTPS

APPLIANCE_NET_IP_DFLT string = "127.0.0.1"
APPLIANCE_NET_PORT_DFLT uint16 = 443
APPLIANCE_INSECURE_DFLT bool = false
APPLIANCE_PROTOCOL_DFLT string = "https"
APPLIANCE_PROTOCOL_DFLT string = PROTOCOL_HTTPS
APPLIANCE_USERNAME_DFLT string = "dummyuser"
APPLIANCE_PASSWORD_DFLT string = "dummypswd"

BLADE_NET_IP_DFLT string = "127.0.0.1"
BLADE_NET_PORT_DFLT uint16 = 443
BLADE_INSECURE_DFLT bool = false
BLADE_PROTOCOL_DFLT string = "https"
BLADE_PROTOCOL_DFLT string = PROTOCOL_HTTPS
BLADE_USERNAME_DFLT string = "root"
BLADE_PASSWORD_DFLT string = "0penBmc"

HOST_NET_IP_DFLT string = "127.0.0.1"
HOST_NET_PORT_DFLT uint16 = 8082
HOST_INSECURE_DFLT bool = false
HOST_PROTOCOL_DFLT string = "http"
HOST_PROTOCOL_DFLT string = PROTOCOL_HTTP
HOST_USERNAME_DFLT string = "admin"
HOST_PASSWORD_DFLT string = "admin12345"

Expand Down
10 changes: 5 additions & 5 deletions cli/pkg/serviceLib/serviceRequests/appliances.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (r *ServiceRequestAddAppliance) Execute() (*service.Appliance, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "AppliancesCred", fmt.Sprintf("%+v", *r.ApplianceCred))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ApplianceTcp", fmt.Sprintf("%+v", *r.ApplianceTcp))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

insecure := r.ApplianceTcp.GetInsecure()
protocol := r.ApplianceTcp.GetProtocol()
Expand Down Expand Up @@ -79,7 +79,7 @@ func (r *ServiceRequestDeleteAppliance) Execute() (*service.Appliance, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ServiceTcp", fmt.Sprintf("%+v", *r.ServiceTcp))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ApplianceId", fmt.Sprintf("%+v", *r.ApplianceId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

deletedAppliance, err := serviceWrap.DeleteApplianceById(serviceClient, r.ApplianceId.GetId())
if err != nil {
Expand All @@ -102,7 +102,7 @@ func NewServiceRequestListAppliances(cmd *cobra.Command) *ServiceRequestListAppl
func (r *ServiceRequestListAppliances) Execute() (*[]*service.Appliance, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ServiceTcp", fmt.Sprintf("%+v", *r.ServiceTcp))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.ip, r.ServiceTcp.port)
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

appliances, err := serviceWrap.GetAllAppliances(serviceClient)
if err != nil {
Expand Down Expand Up @@ -147,7 +147,7 @@ func (r *ServiceRequestRenameAppliance) Execute() (*service.Appliance, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ApplianceId", fmt.Sprintf("%+v", *r.ApplianceId))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "NewApplianceId", fmt.Sprintf("%+v", *r.NewApplianceId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

appliance, err := serviceWrap.RenameApplianceById(serviceClient, r.ApplianceId.GetId(), r.NewApplianceId.GetId())
if err != nil {
Expand All @@ -173,7 +173,7 @@ func (r *ServiceRequestResyncAppliance) Execute() (*service.Appliance, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ServiceTcp", fmt.Sprintf("%+v", *r.ServiceTcp))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ApplianceId", fmt.Sprintf("%+v", *r.ApplianceId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

appliance, err := serviceWrap.ResyncApplianceById(serviceClient, r.ApplianceId.GetId())
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cli/pkg/serviceLib/serviceRequests/blades.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (r *ServiceRequestAddBlade) Execute() (*service.Blade, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "BladeCred", fmt.Sprintf("%+v", *r.BladeCred))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "BladeTcp", fmt.Sprintf("%+v", *r.BladeTcp))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

insecure := r.BladeTcp.GetInsecure()
protocol := r.BladeTcp.GetProtocol()
Expand Down Expand Up @@ -82,7 +82,7 @@ func (r *ServiceRequestDeleteBlade) Execute() (*service.Blade, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ApplianceId", fmt.Sprintf("%+v", *r.ApplianceId))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "BladeId", fmt.Sprintf("%+v", *r.BladeId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

blade, err := serviceWrap.DeleteBladeById(serviceClient, r.ApplianceId.GetId(), r.BladeId.GetId())
if err != nil {
Expand Down Expand Up @@ -123,7 +123,7 @@ func (r *ServiceRequestListBlades) Execute() (*serviceWrap.ApplianceBladeSummary
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ServiceTcp", fmt.Sprintf("%+v", *r.ServiceTcp))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ApplianceId", fmt.Sprintf("%+v", *r.ApplianceId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

if !r.AllAppliances() && !r.AllBlades() {
blade, err := serviceWrap.FindBladeById_SingleAppl(serviceClient, r.ApplianceId.GetId(), r.BladeId.GetId())
Expand Down Expand Up @@ -201,7 +201,7 @@ func (r *ServiceRequestRenameBlade) Execute() (*service.Blade, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "BladeId", fmt.Sprintf("%+v", *r.BladeId))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "NewBladeId", fmt.Sprintf("%+v", *r.NewBladeId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

blade, err := serviceWrap.RenameBladeById(serviceClient, r.ApplianceId.GetId(), r.BladeId.GetId(), r.NewBladeId.GetId())
if err != nil {
Expand Down Expand Up @@ -230,7 +230,7 @@ func (r *ServiceRequestResyncBlade) Execute() (*service.Blade, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ApplianceId", fmt.Sprintf("%+v", *r.ApplianceId))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "BladeId", fmt.Sprintf("%+v", *r.BladeId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

blade, err := serviceWrap.ResyncBladeById(serviceClient, r.ApplianceId.GetId(), r.BladeId.GetId())
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cli/pkg/serviceLib/serviceRequests/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r *ServiceRequestAddHost) Execute() (*service.Host, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "HostCred", fmt.Sprintf("%+v", *r.HostCred))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "HostTcp", fmt.Sprintf("%+v", *r.HostTcp))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

insecure := r.HostTcp.GetInsecure()
protocol := r.HostTcp.GetProtocol()
Expand Down Expand Up @@ -79,7 +79,7 @@ func (r *ServiceRequestDeleteHost) Execute() (*service.Host, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ServiceTcp", fmt.Sprintf("%+v", *r.ServiceTcp))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "HostId", fmt.Sprintf("%+v", *r.HostId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

host, err = serviceWrap.DeleteHostById(serviceClient, r.HostId.GetId())
if err != nil {
Expand All @@ -102,7 +102,7 @@ func NewServiceRequestListHosts(cmd *cobra.Command) *ServiceRequestListHosts {
func (r *ServiceRequestListHosts) Execute() (*[]*service.Host, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ServiceTcp", fmt.Sprintf("%+v", *r.ServiceTcp))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.ip, r.ServiceTcp.port)
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

hosts, err := serviceWrap.GetAllHosts(serviceClient)
if err != nil {
Expand Down Expand Up @@ -147,7 +147,7 @@ func (r *ServiceRequestRenameHost) Execute() (*service.Host, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "HostId", fmt.Sprintf("%+v", *r.HostId))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "NewHostId", fmt.Sprintf("%+v", *r.NewHostId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

host, err := serviceWrap.RenameHostById(serviceClient, r.HostId.GetId(), r.NewHostId.GetId())
if err != nil {
Expand All @@ -173,7 +173,7 @@ func (r *ServiceRequestResyncHost) Execute() (*service.Host, error) {
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "ServiceTcp", fmt.Sprintf("%+v", *r.ServiceTcp))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "HostId", fmt.Sprintf("%+v", *r.HostId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort())
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

host, err := serviceWrap.ResyncHostById(serviceClient, r.HostId.GetId())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/pkg/serviceLib/serviceRequests/memory-devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (r *ServiceRequestListHostMemoryDevices) Execute() (*serviceWrap.HostMemory
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "HostId", fmt.Sprintf("%+v", *r.HostId))
klog.V(4).InfoS(fmt.Sprintf("%T", *r), "MemoryDeviceId", fmt.Sprintf("%+v", *r.MemoryDeviceId))

serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.ip, r.ServiceTcp.port)
serviceClient := serviceWrap.GetServiceClient(r.ServiceTcp.GetIp(), r.ServiceTcp.GetPort(), r.ServiceTcp.GetInsecure(), r.ServiceTcp.GetProtocol())

if r.AllHosts() && r.AllMemoryDevices() {
summary, err = serviceWrap.GetMemoryDevices_AllHosts(serviceClient)
Expand Down
Loading

0 comments on commit 6231ad2

Please sign in to comment.