 < ? x m l   v e r s i o n = ' 1 . 0 '   e n c o d i n g = ' U T F - 8 ' ? > 
 < d u n e s - s c r i p t - m o d u l e   n a m e = " u p d a t e C l o u d A c c o u n t V s p h e r e C e r t i f i c a t e "   r e s u l t - t y p e = " s t r i n g "   a p i - v e r s i o n = " 6 . 0 . 0 "   i d = " 3 a 2 3 9 3 0 4 - 6 c 7 5 - 4 5 2 f - 9 2 0 2 - c 2 f d 0 0 6 0 d a 4 5 "   v e r s i o n = " 0 . 0 . 1 "   a l l o w e d - o p e r a t i o n s = " v f e " > 
     < p a r a m   n = " v r a H o s t "   t = " V R A : H o s t " > < ! [ C D A T A [ ] ] > < / p a r a m > 
     < p a r a m   n = " c l o u d A c c o u n t I d "   t = " s t r i n g " > < ! [ C D A T A [ ] ] > < / p a r a m > 
     < p a r a m   n = " v s p h e r e A d m i n U s e r "   t = " s t r i n g " > < ! [ C D A T A [ ] ] > < / p a r a m > 
     < p a r a m   n = " v s p h e r e A d m i n U s e r P a s s w o r d "   t = " S e c u r e S t r i n g " > < ! [ C D A T A [ ] ] > < / p a r a m > 
     < p a r a m   n = " c e r t i f i c a t e "   t = " s t r i n g " > < ! [ C D A T A [ ] ] > < / p a r a m > 
     < s c r i p t   e n c o d e d = " f a l s e " > < ! [ C D A T A [ v a r   u r l   =   " / i a a s / a p i / c l o u d - a c c o u n t s / "   +   c l o u d A c c o u n t I d   +   " ? a p i V e r s i o n = 2 0 2 1 - 0 7 - 1 5 " ; 
 v a r   d a t a   =   { 
         " p r i v a t e K e y I d " :   v s p h e r e A d m i n U s e r , 
         " p r i v a t e K e y " :   v s p h e r e A d m i n U s e r P a s s w o r d , 
         " c e r t i f i c a t e I n f o " :   { 
                 " c e r t i f i c a t e " :   c e r t i f i c a t e 
         } 
 } 
 
 v a r   c o n t e n t   =   J S O N . s t r i n g i f y ( d a t a ) ; 
 S y s t e m . d e b u g ( c o n t e n t ) ; 
 v a r   o p e r a t i o n   =   " P A T C H " ; 
 
 t r y   { 
         v a r   c o n t e n t A s S t r i n g   =   S y s t e m . g e t M o d u l e ( " c o m . v m w a r e . v r a . e x t e n s i b i l i t y . p l u g i n . r e s t " ) . i n v o k e R e s t O p e r a t i o n ( v r a H o s t ,   o p e r a t i o n ,   u r l ,   c o n t e n t ) ; 
 }   c a t c h   ( e )   { 
         t h r o w   " P A T C H   "   +   u r l   +   " F a i l e d "   + 
         " \ n   E r r o r   :   "   +   e ; 
 } 
 v a r   r e q u e t T r a c k e r   =   J S O N . p a r s e ( c o n t e n t A s S t r i n g ) ; 
 v a r   r e q u e s t I d   =   r e q u e t T r a c k e r [ " i d " ] 
 
 w a i t R e q u e s t T o C o m p l e t e ( v r a H o s t ,   r e q u e s t I d ,   1 2 0 ) 
 v a r   r e q u e s t   =   g e t R e q u e s t ( v r a H o s t ,   r e q u e s t I d ) 
 
 
 i f   ( r e q u e s t [ " s t a t u s " ]   = =   " F A I L E D " )   { 
         t h r o w   ( " U p d a t e   c e r t i f i c a t e   r e q u e s t   f o r   c l o u d   a c c o u n t   w i t h   i d   "   +   c l o u d A c c o u n t I d   +   "   f a i l e d .   E r r o r   :   "   +   r e q u e s t [ " m e s s a g e " ] ) ; 
 } 
 
 
 
 f u n c t i o n   w a i t R e q u e s t T o C o m p l e t e ( v r a H o s t ,   r e q u e s t I d ,   t i m e o u t I n S e c )   { 
         c u r r e n t T i m e   =   0 
         s l e e p T i m e   =   5   *   1 0 0 0   / /   5   s e c . 
         t i m e o u t   =   t i m e o u t I n S e c   *   1 0 0 0 
         w h i l e   ( t r u e )   { 
                 c u r r e n t S t a t u s   =   g e t R e q u e s t ( v r a H o s t ,   r e q u e s t I d ) [ " s t a t u s " ] 
                 i f   ( [ " F I N I S H E D " ,   " F A I L E D " ] . i n d e x O f ( c u r r e n t S t a t u s ) = = - 1 )   { 
                         S y s t e m . s l e e p ( s l e e p T i m e ) 
                         c u r r e n t T i m e   + =   s l e e p T i m e ; 
                 }   e l s e   { 
                         b r e a k ; 
                 } 
 
                 i f   ( c u r r e n t T i m e   > =   t i m e o u t )   { 
                         t h r o w   ( " R e q u e s t   w i t h   i d   "   +   r e q u e s t I d   +   "   d i d   n o t   f i n i s h   f o r   "   +   t i m e o u t I n S e c   +   "   s e c . " ) 
                 } 
         } 
 } 
 
 f u n c t i o n   g e t R e q u e s t ( v r a H o s t ,   r e q u e s t I d )   { 
         o p e r a t i o n   =   " G E T " 
         u r l   =   " / i a a s / a p i / r e q u e s t - t r a c k e r / "   +   r e q u e s t I d   +   " ? a p i V e r s i o n = 2 0 1 9 - 0 5 - 1 5 " 
         v a r   c o n t e n t A s S t r i n g   =   S y s t e m . g e t M o d u l e ( " c o m . v m w a r e . v r a . e x t e n s i b i l i t y . p l u g i n . r e s t " ) . i n v o k e R e s t O p e r a t i o n ( v r a H o s t ,   o p e r a t i o n ,   u r l ) 
         r e s u l t   =   J S O N . p a r s e ( c o n t e n t A s S t r i n g ) 
         r e t u r n   r e s u l t 
 } ] ] > < / s c r i p t > 
 < / d u n e s - s c r i p t - m o d u l e >