예제 #1
0
        protected override void ProcessRecord()
        {
            Types.returnServerTemplatePublish result = new Types.returnServerTemplatePublish();

            List <string> lstAcctGrps   = new List <string>();
            List <string> lstCategories = new List <string>();

            if (!string.IsNullOrEmpty(accountGroupIDs))
            {
                lstAcctGrps = new List <string>(accountGroupIDs.Split(','));
            }
            if (!string.IsNullOrEmpty(categories))
            {
                lstCategories = new List <string>(categories.Split(','));
            }

            base.ProcessRecord();

            try
            {
                string rsServerTemplateCommitID = RightScale.netClient.ServerTemplate.publish(serverTemplateID, lstAcctGrps, allowComments, longDescription, descriptionNotes, shortDescription, emailComments, lstCategories);

                if (!string.IsNullOrEmpty(rsServerTemplateCommitID))
                {
                    result.ServerTemplateID = serverTemplateID;
                    result.Message          = "ServerTemplate Published";
                    result.Result           = true;

                    WriteObject(result);
                }
                else
                {
                    result.ServerTemplateID = serverTemplateID;
                    result.Message          = "Error Publishing ServerTemplate";
                    result.Details          = rsServerTemplateCommitID;
                    result.Result           = false;

                    WriteObject(result);
                }
            }
            catch (RightScaleAPIException rex)
            {
                result.ServerTemplateID = serverTemplateID;
                result.Result           = false;
                result.Message          = rex.Message;
                result.Description      = rex.InnerException.Message;;
                result.APIHref          = rex.APIHref;

                WriteObject(result);
            }
        }
        protected override void ProcessRecord()
        {
            Types.returnServerTemplatePublish result = new Types.returnServerTemplatePublish();

            List<string> lstAcctGrps = new List<string>();
            List<string> lstCategories = new List<string>();

            if (!string.IsNullOrEmpty(accountGroupIDs)) {lstAcctGrps = new List<string>(accountGroupIDs.Split(','));}
            if (!string.IsNullOrEmpty(categories)){lstCategories = new List<string>(categories.Split(','));}

            base.ProcessRecord();

            try
            {
                string rsServerTemplateCommitID = RightScale.netClient.ServerTemplate.publish(serverTemplateID,lstAcctGrps,allowComments,longDescription,descriptionNotes,shortDescription,emailComments,lstCategories);

                if (!string.IsNullOrEmpty(rsServerTemplateCommitID))
                {
                    result.ServerTemplateID = serverTemplateID;
                    result.Message = "ServerTemplate Published";
                    result.Result = true;

                    WriteObject(result);
                }
                else
                {
                    result.ServerTemplateID = serverTemplateID;
                    result.Message = "Error Publishing ServerTemplate";
                    result.Details = rsServerTemplateCommitID;
                    result.Result = false;

                    WriteObject(result);
                }
            }
            catch (RightScaleAPIException rex)
            {
                result.ServerTemplateID = serverTemplateID;
                result.Result = false;
                result.Message = rex.Message;
                result.Description = rex.InnerException.Message; ;
                result.APIHref = rex.APIHref;

                WriteObject(result);
            }
        }