예제 #1
0
// Run changes the juju-managed firewall to hide any
// ports that were also explicitly marked by units as closed.
func (c *UnexposeCommand) Run(_ *cmd.Context) error {
	conn, err := juju.NewConnFromName(c.EnvName)
	if err != nil {
		return err
	}
	defer conn.Close()
	params := params.ServiceUnexpose{ServiceName: c.ServiceName}
	return statecmd.ServiceUnexpose(conn.State, params)
}
예제 #2
0
func (s *UnexposeSuite) TestServiceUnexpose(c *C) {
	charm := s.AddTestingCharm(c, "dummy")
	for i, t := range serviceUnexposeTests {
		c.Logf("test %d. %s", i, t.about)
		svc, err := s.State.AddService("dummy-service", charm)
		c.Assert(err, IsNil)
		if t.initial {
			svc.SetExposed()
		}
		c.Assert(svc.IsExposed(), Equals, t.initial)
		params := params.ServiceUnexpose{ServiceName: t.service}
		err = statecmd.ServiceUnexpose(s.State, params)
		if t.err == "" {
			c.Assert(err, IsNil)
			svc.Refresh()
			c.Assert(svc.IsExposed(), Equals, t.expected)
		} else {
			c.Assert(err, ErrorMatches, t.err)
		}
		err = svc.Destroy()
		c.Assert(err, IsNil)
	}
}
예제 #3
0
// ServiceUnexpose changes the juju-managed firewall to unexpose any ports that
// were also explicitly marked by units as open.
func (c *Client) ServiceUnexpose(args params.ServiceUnexpose) error {
	return statecmd.ServiceUnexpose(c.api.state, args)
}