Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: copyedit

Powershell PowerShell can be used to write + and query objects on swarm clusters using the InvokeWebRequest method and InvokeRestMethod.

Powershell PowerShell should be installed on all windows server Windows Server distributions since Windows Server 2008 r2R2.

Table of Contents

Head a

...

domain

The basic command is below but as you can see the response is a little garbled.

Code Block
languagepowershell
Invoke-WebRequest -Uri http://tony.demo.sales.local -Credential csadmin -Method Head

...



PS C:\Users\Administrator> Invoke-WebRequest -Uri http://tony.demo.sales.local -Credential csadmin -Method Head

...



StatusCode        : 200

...


StatusDescription : OK

...


Content           :

...

 
RawContent        : HTTP/1.1 200 OK

...


                   Gateway-Request-Id: EDEA5D325623D3EC

...


                   Gateway-Protocol: scsp

...


                   Age: 0

...


                   Allow: HEAD, HOLD, GET, SEND, PUT, RELEASE, POST, COPY, GEN, APPEND, DELETE

...


                   Castor-System-TotalGBAvailable: 7316...

...


Forms             : {}

...


Headers           : {[Gateway-Request-Id, EDEA5D325623D3EC], [Gateway-Protocol, scsp], [Age, 0], [Allow, HEAD, HOLD, GET, SEND, PUT, RELEASE, POST, COPY, GEN, APPEND,

...

 
                   DELETE]...}

...


Images            : {}

...


InputFields       : {}

...


Links             : {}

...


ParsedHtml        : System.__ComObject

...


RawContentLength  : 0

Here’s how we get the raw content of the head. The main change is to put the actual web request in brackets and add the .RawContent property.

Code Block
languagepowershell
PS C:\Users\Administrator> (Invoke-WebRequest -Uri http://tony.demo.sales.local -Credential csadmin -Method Head).RawContent

...


HTTP/1.1 200 OK

...


Gateway-Request-Id: F25E93AD9740303A

...


Gateway-Protocol: scsp

...


Age: 0

...


Allow: HEAD, HOLD, GET, SEND, PUT, RELEASE, POST, COPY, GEN, APPEND, DELETE

...


Castor-System-TotalGBAvailable: 7316

...


Castor-System-TotalGBCapacity: 11637

...


Castor-System-Cluster: demo.sales.local

...


Castor-System-EnforceTenancy: True

...


Policy-Versioning-Evaluated: enabled

...


Policy-Versioning-Evaluated-Constrained: no

...


Policy-ECMinStreamSize-Evaluated: 1000000

...


Policy-ECMinStreamSize-Evaluated-Constrained: no

...


Policy-ECEncoding-Evaluated: 4:2

...


Policy-ECEncoding-Evaluated-Constrained: no

...


Policy-Replicas-Evaluated: min:2 max:16 default:2

...


Policy-Replicas-Evaluated-Constrained: no

...


Castor-System-LicenseSerialNumber: 20150901073350-27708

...


Castor-System-LicenseCapacityTB: 20.0

...


Castor-System-LicenseLogicalObjects: 0

...


Castor-System-LicenseHealthReportingRequired: False

...


Node-State: ok

...


Content-Length: 2277

...


Cache-Control: no-cache

...


Content-Type: text/html;charset=UTF-8

...


Date: Tue, 07 Nov 2017 11:21:39 GMT

...


Expires: Mon, 06 Nov 2017 07:34:59 GMT

...


ETag: "a5aebae0e6524edcc9807d690e423cf2"

...


Server: CAStor Cluster/9.3.2

...


Via: 1.1 tony.demo.sales.local (Cloud Gateway SCSP/5.2.2)

...



PS C:\Users\Administrator>


Writing a file to a named object in a bucket

Code Block
languagepowershell
PS C:\Users\Administrator> Invoke-WebRequest -Uri http://tony.demo.sales.local/emptybucket/test.txt -Credential csadmin -InFile C:\Users\Administrator\Desktop\results.txt -Method Post

...



StatusCode        : 201

...


StatusDescription : Created

...


Content           : <html><body>New stream created</body></html>

...


                   

...


RawContent        : HTTP/1.1 201 Created

...


                   Gateway-Request-Id: 1FD002262BA6F902

...


                   Gateway-Protocol: scsp

...


                   Content-MD5: QxBqF/BQrSn7HncxXmOfAw==

...


                   Volume: 26fb3fcef16bb0e8b6d7979b149900b0,d5644e8ab59653c676d9653ccf6fe813

...


                   En...

...


Forms             : {}

...


Headers           : {[Gateway-Request-Id, 1FD002262BA6F902], [Gateway-Protocol, scsp], [Content-MD5, QxBqF/BQrSn7HncxXmOfAw==], [Volume,

...

 
                   26fb3fcef16bb0e8b6d7979b149900b0,d5644e8ab59653c676d9653ccf6fe813]...}

...


Images            : {}

...


InputFields       : {}

...


Links             : {}

...


ParsedHtml        : System.__ComObject

...


RawContentLength  : 46

Heading the file to get the properties


Code Block
languagepowershell
PS C:\Users\Administrator> (Invoke-WebRequest -Uri http://tony.demo.sales.local/emptybucket/test.txt -Credential csadmin -Method Head).RawContent

...



HTTP/1.1 200 OK

...



Gateway-Request-Id: 72633F2886C7EB4F

...


Gateway-Protocol: scsp

...


Castor-System-CID: d735b15cc012fd455b361bbd0b9cd865

...


Castor-System-Cluster: demo.sales.local

...


Castor-System-Created: Tue, 07 Nov 2017 11:08:26 GMT

...


Castor-System-Name: test.txt

...


Castor-System-Version: 1510052906.155

...


X-Last-Modified-By-Meta: csadmin@

...


X-Owner-Meta: csadmin

...


Castor-System-Path: /tony.demo.sales.local/emptybucket/test.txt

...


Castor-System-Domain: tony.demo.sales.local

...


Volume: d5644e8ab59653c676d9653ccf6fe813

...


Content-MD5: QxBqF/BQrSn7HncxXmOfAw==

...


Content-Length: 12248

...


Content-Type: application/x-www-form-urlencoded

...


Date: Tue, 07 Nov 2017 11:32:40 GMT

...


ETag: "af6b99f9b97fefdd791ec48c1b795f69"

...


Last-Modified: Tue, 07 Nov 2017 11:08:26 GMT

...


Server: CAStor Cluster/9.3.2

...


Via: 1.1 tony.demo.sales.local (Cloud Gateway SCSP/5.2.2)



Write a file with custom metadata header info

...

Code Block
languagepowershell
PS C:\Users\Administrator> Invoke-WebRequest -Uri http://tony.demo.sales.local/emptybucket/test2.txt -Credential csadmin -Headers @{"x-color-meta"="blue, green"} -InFile C:\Users\Administrator\Desktop\results.txt -Method Post

...

StatusCode        : 201

StatusDescription : Created

Content           : <html><body>New stream created</body></html>

                 

...



StatusCode        : 201

StatusDescription : Created
Content           : <html><body>New stream created</body></html>                 

RawContent        : HTTP/1.1 201

...

 Created
                   Gateway-Request-Id:

...

 395B45C356E83051
                   Gateway-Protocol:

...

 scsp
                   Content-MD5: QxBqF/BQrSn7HncxXmOfAw==

...


                   Volume: fab7f8e5f10012f788f6cecb9f0a7212,c7be8d4e94b0572e91527f603a957ba3

...


                   En...

...


Forms             : {}

...


Headers           : {[Gateway-Request-Id, 395B45C356E83051], [Gateway-Protocol, scsp], [Content-MD5, QxBqF/BQrSn7HncxXmOfAw==], [Volume,

...


                   fab7f8e5f10012f788f6cecb9f0a7212,c7be8d4e94b0572e91527f603a957ba3]...}

...


Images            : {}

...


InputFields       : {}

...


Links             : {}

...


ParsedHtml        : System.__ComObject

...


RawContentLength  : 46


Head to see our color metadata

Code Block
languagepowershell
PS C:\Users\Administrator> (Invoke-WebRequest -Uri http://tony.demo.sales.local/emptybucket/test2.txt -Credential csadmin -Method Head).RawContent

...



HTTP/1.1 200 OK

...



Gateway-Request-Id: DBC621E4EA2CC9C7

...


Gateway-Protocol: scsp

...


Castor-System-CID: d735b15cc012fd455b361bbd0b9cd865

...


Castor-System-Cluster: demo.sales.local

...


Castor-System-Created: Tue, 07 Nov 2017 11:59:31 GMT

...


Castor-System-Name: test2.txt

...


Castor-System-Version: 1510055971.106

...


X-Last-Modified-By-Meta: csadmin@

...


X-Owner-Meta: csadmin

...


x-color-meta: blue, green

...


Castor-System-Path: /tony.demo.sales.local/emptybucket/test2.txt

...


Castor-System-Domain: tony.demo.sales.local

...


Volume: c7be8d4e94b0572e91527f603a957ba3

...


Content-MD5: QxBqF/BQrSn7HncxXmOfAw==

...


Content-Length: 12248

...


Content-Type: application/x-www-form-urlencoded

...


Date: Tue, 07 Nov 2017 12:00:25 GMT

...


ETag: "57e6fcb1e02245365f8b66796f8233f1"

...


Last-Modified: Tue, 07 Nov 2017 11:59:31 GMT

...


Server: CAStor Cluster/9.3.2

...


Via: 1.1 tony.demo.sales.local (Cloud Gateway SCSP/5.2.2)


Create a

...

domain

Code Block
languagepowershell
PS C:\Users\Administrator> Invoke-WebRequest -Uri http://172.30.2.246/?domain=newdomain.example.com -Credential csadmin -ContentType application/castorcontext -Method Post

...

StatusCode        : 201

StatusDescription : Created

...



StatusCode        : 201
StatusDescription : Created
Content           : <html><body>New stream created</body></html>

...

                 

...



RawContent        : HTTP/1.1 201

...

 Created
                   Gateway-Request-Id:

...

 009BE8ED1E9C3FE9
                   Gateway-Protocol:

...

 scsp
                   Content-MD5: 1B2M2Y8AsgTpgAmY7PhCfg==

...


                   Volume: fab7f8e5f10012f788f6cecb9f0a7212,44f685261e7c738e47d0286c600f6aa4

...


                   En...

...


Forms             : {}

...


Headers           : {[Gateway-Request-Id, 009BE8ED1E9C3FE9], [Gateway-Protocol, scsp], [Content-MD5, 1B2M2Y8AsgTpgAmY7PhCfg==], [Volume,

...


                   fab7f8e5f10012f788f6cecb9f0a7212,44f685261e7c738e47d0286c600f6aa4]...}

...


Images            : {}

...


InputFields       : {}

...


Links             : {}

...


ParsedHtml        : System.__ComObject

...


RawContentLength  : 46


Create a bucket

Code Block
languagepowershell
PS C:\Users\Administrator> Invoke-WebRequest -Uri http://172.30.2.246/newbucket?domain=newdomain.example.com -Credential csadmin -ContentType application/castorcontext -Method Post

...

StatusCode        : 201

StatusDescription : Created

Content           : <html><body>New stream created</body></html>

                 

...



StatusCode        : 201
StatusDescription : Created
Content           : <html><body>New stream created</body></html>                 

RawContent        : HTTP/1.1 201

...

 Created
                   Gateway-Request-Id:

...

 289B9614BC6E650A
                   Gateway-Protocol:

...

 scsp
                   Content-MD5: 1B2M2Y8AsgTpgAmY7PhCfg==

...


                   Volume: 239ce9da91a90f77f5b8a7a838523945,c71439cffe50256aebea0c7ff0200bd8

...


                   En...

...


Forms             : {}

...


Headers           : {[Gateway-Request-Id, 289B9614BC6E650A], [Gateway-Protocol, scsp], [Content-MD5, 1B2M2Y8AsgTpgAmY7PhCfg==], [Volume,

...


                   239ce9da91a90f77f5b8a7a838523945,c71439cffe50256aebea0c7ff0200bd8]...}

...


Images            : {}

...


InputFields       : {}

...


Links             : {}

...


ParsedHtml        : System.__ComObject

...


RawContentLength  : 46



Search for a bucket in a domain

Code Block
languagepowershell
PS C:\Users\Administrator> Invoke-RestMethod -Uri http://172.30.2.246/?format=json"&"domain=newdomain.example.com -Credential csadmin -Method Get

...



last_modified : 2017-11-07T12:33:07.632400Z

...

hash          : 02616848f4a99f59fbd668068226d867


hash          : 02616848f4a99f59fbd668068226d867
content_type  : application/castorcontext

...

name          : newbucket

...


name          : newbucket
bytes         : 0